rendered paste bodyclass k4CanDoTag extends FATemplateTag{ function parse(&$context, &$renderer, &$node) { $this->requireAttributes('object', 'perm'); $user = &$context->get('k4_user'); $perm = $this->getAttribute('perm'); $object = $this->getAttribute('object'); $perm_has_and = strpos($perm, ','); $perm_has_or = strpos($perm, '|'); $object_has_and = strpos($object, ','); $object_has_or = strpos($object, '|'); $perms_array = array(); $objects_array = array(); if($perm_has_and !== FALSE || $perm_has_or !== FALSE) { $glue = $perm_has_and !== FALSE ? ',' : '|'; $perms_array = explode($glue, $perm); } else { $perms_array[] = $perm; } if($object_has_and !== FALSE || $object_has_or !== FALSE) { $glue = $object_has_and !== FALSE ? ',' : '|'; $objects_array = explode($glue, $object); $multiobjects = TRUE; } else { $objects_array[] = $object; } $res = FALSE; foreach($objects_array as $object) { $sub_res = FALSE; foreach($perms_array as $perm) { $sub_res = $user->canDo($perm, $object); if($sub_res && !$perm_has_and) { break; } } if($sub_res && !$object_has_and) { $res = TRUE; break; } } if($res) { return $renderer->doNode($node); } }}