public static function configureFromImport(\SimpleXMLElement $element) { $g = Group::getByName((string) $element['name']); if (!is_object($g)) { $g = Group::add((string) $element['name'], (string) $element['description']); } return static::getOrCreate($g); }
public function groupExists($name, $batch) { $g = Group::getByName($name); if (is_object($g)) { return true; } return false; }
public function getAccessEntity() { $group = $this->group; if (!is_object($group)) { $group = Group::getByName($this->group); if (!is_object($group)) { $group = Group::getByPath($this->group); } } if (is_object($group)) { $entity = GroupAccessEntity::getOrCreate($group); return $entity; } }
public function import(\SimpleXMLElement $sx) { if (isset($sx->permissionkeys)) { foreach ($sx->permissionkeys->permissionkey as $pk) { if (is_object(Key::getByHandle((string) $pk['handle']))) { continue; } $pkc = Category::getByHandle((string) $pk['category']); $c1 = $pkc->getPermissionKeyClass(); $pkx = call_user_func(array($c1, 'import'), $pk); $assignments = array(); if (isset($pk->access)) { foreach ($pk->access->children() as $ch) { if ($ch->getName() == 'group') { /* * Legacy */ $g = Group::getByName($ch['name']); if (!is_object($g)) { $g = Group::add($g['name'], $g['description']); } $pae = GroupEntity::getOrCreate($g); $assignments[] = $pae; } if ($ch->getName() == 'entity') { $type = Type::getByHandle((string) $ch['type']); $class = $type->getAccessEntityTypeClass(); if (method_exists($class, 'configureFromImport')) { $pae = $class::configureFromImport($ch); $assignments[] = $pae; } } } } if (count($assignments)) { $pa = Access::create($pkx); foreach ($assignments as $pae) { $pa->addListItem($pae); } $pt = $pkx->getPermissionAssignmentObject(); $pt->assignPermissionAccess($pa); } } } }
/** * Filters the user list for only users within the provided group. Accepts an instance of a group object or a string group name. * * @param \Group | string $group * @param bool $inGroup */ public function filterByGroup($group = '', $inGroup = true) { if (!$group instanceof \Concrete\Core\User\Group\Group) { $group = \Concrete\Core\User\Group\Group::getByName($group); } $table = 'ug' . $group->getGroupID(); $this->query->leftJoin('u', 'UserGroups', $table, 'u.uID = ' . $table . '.uID AND ' . $table . '.gID = ' . $group->getGroupID()); if ($inGroup) { $this->query->andWhere($table . '.gID = :gID' . $group->getGroupID()); $this->query->setParameter('gID' . $group->getGroupID(), $group->getGroupID()); } else { $this->query->andWhere($table . '.gID is null'); } }
protected function getAssignments(AccessEntity $entity) { $class = $this->getClass($entity); $g = Group::getByName($entity->getGroupName()); return $class::getOrCreate($g); }