Révision 59e46405
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/entity/modules/callbacks.inc | ||
---|---|---|
29 | 29 |
|
30 | 30 |
case 'book_ancestors': |
31 | 31 |
$ancestors = array(); |
32 |
while (!empty($node->book['plid'])) { |
|
32 |
while (!empty($node->book['plid']) && $node->book['plid'] != -1) {
|
|
33 | 33 |
$link = book_link_load($node->book['plid']); |
34 | 34 |
array_unshift($ancestors, $link['nid']); |
35 | 35 |
$node = node_load($link['nid']); |
... | ... | |
670 | 670 |
function entity_metadata_no_hook_node_access($op, $node = NULL, $account = NULL) { |
671 | 671 |
// First deal with the case where a $node is provided. |
672 | 672 |
if (isset($node)) { |
673 |
if ($op == 'create') { |
|
673 |
if (empty($node->vid) && in_array($op, array('create', 'update'))) { |
|
674 |
// This is a new node or the original node. |
|
674 | 675 |
if (isset($node->type)) { |
675 |
return node_access($op, $node->type, $account); |
|
676 |
$op = !empty($node->is_new) && $node->is_new ? 'create' : 'update'; |
|
677 |
return node_access($op, $op == 'create' ? $node->type : $node, $account); |
|
676 | 678 |
} |
677 | 679 |
else { |
678 | 680 |
throw new EntityMalformedException('Permission to create a node was requested but no node type was given.'); |
... | ... | |
796 | 798 |
* Access callback for the taxonomy entities. |
797 | 799 |
*/ |
798 | 800 |
function entity_metadata_taxonomy_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) { |
799 |
if ($entity_type == 'taxonomy_vocabulary') { |
|
800 |
return user_access('administer taxonomy', $account); |
|
801 |
} |
|
802 |
if (isset($entity) && $op == 'update' && !isset($account) && taxonomy_term_edit_access($entity)) { |
|
801 |
// If user has administer taxonomy permission then no further checks. |
|
802 |
if (user_access('administer taxonomy', $account)) { |
|
803 | 803 |
return TRUE; |
804 | 804 |
} |
805 |
if (user_access('administer taxonomy', $account) || user_access('access content', $account) && $op == 'view') { |
|
806 |
return TRUE; |
|
805 |
switch ($op) { |
|
806 |
case "view": |
|
807 |
if (user_access('access content', $account)) { |
|
808 |
return TRUE; |
|
809 |
} |
|
810 |
break; |
|
811 |
case "update": |
|
812 |
if ($entity_type == 'taxonomy_term') { |
|
813 |
return user_access("edit terms in $entity->vid", $account); |
|
814 |
} |
|
815 |
break; |
|
816 |
case "create": |
|
817 |
if ($entity_type == 'taxonomy_term') { |
|
818 |
// Check for taxonomy_access_fix contrib module which adds additional |
|
819 |
// permissions to create new terms in a given vocabulary. |
|
820 |
if (function_exists('taxonomy_access_fix_access')) { |
|
821 |
return taxonomy_access_fix_access('add terms', $entity->vocabulary_machine_name); |
|
822 |
} |
|
823 |
} |
|
824 |
break; |
|
825 |
case "delete": |
|
826 |
if ($entity_type == 'taxonomy_term') { |
|
827 |
return user_access("delete terms in $entity->vid", $account); |
|
828 |
} |
|
829 |
break; |
|
807 | 830 |
} |
808 | 831 |
return FALSE; |
809 | 832 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules