/** * @throws GraphException */ public function run() { $groupName = strtoupper($this->request->getPar('group')); $tGroupName = $groupName; $retPermissions = array(); do { $top = $tGroupName === Group::$everyoneGroupName; if (!$top) { $tGroup = new Group(); $tGroup->setName($tGroupName); $tGroup = $tGroup->read(); if ($tGroup === null) { if (strcasecmp($groupName, $tGroupName) === 0) { throw new GraphException('group ' . $groupName . ' not found', 400); } else { throw new GraphException('parent group ' . $tGroupName . ' not found', 400); } } } $permissions = new Permission(); $permissions->setGroup($tGroupName); $oPermissions = $permissions->read(true); if ($oPermissions !== null) { foreach ($oPermissions as $permission) { if (array_search($permission->getAction(), $retPermissions, true) === false) { $retPermissions[] = $permission->getAction(); } } } if (!$top) { $tGroupName = $tGroup->getParent(); } } while (!$top); $this->response->setBody(json_encode(array("PermissionSet" => array("group" => $groupName, "permissions" => $retPermissions)), JSON_PRETTY_PRINT)); }
public function run() { $group = new Group(); $groups = $this->resultsToArray($group->read(true, null, 1, 0)); $ret = $this->getGroupTree($groups); $this->response->setBody(json_encode(array("GroupsHierarchy" => $ret), JSON_PRETTY_PRINT)); }
public function run() { $groupName = $this->request->getPar('group'); $group = new Group(); $group->setName($groupName); $group->delete(); $this->sendMessage('group ' . $group->getName() . ' successfully deleted'); }
public function run() { $groupName = $this->request->getPar('group'); $group = new Group(); $group->setName($groupName); $rGroup = $group->read(); $this->sendModel($rGroup); }
public function run() { $groupName = Group::standardizeGroupName($this->request->getPar('group')); $group = new Group(); $group->setName($groupName); $group = $group->read(); if ($group === null) { throw new GraphException('Group ' . $groupName . ' not found'); } $nGroup = Group::getByRequest(); $nGroup->setId($group->getId()); $nGroup->setVersion($group->getVersion()); $this->sendModel($nGroup->update()); }
public function run() { $group = Group::standardizeGroupName($this->request->getPar('group')); $userGroup = new UserGroup(); $userGroup->setGroup($group); $userGroups = $userGroup->read(true); $ret = array(); if ($userGroups !== null) { foreach ($userGroups as $uGroup) { $res = $this->forward('/users/user/' . $uGroup->getUserId()); if ($res->getStatusCode() !== 200) { Log::err('user: '******' not found'); } else { $ret[] = json_decode($res->getBody(), true)['User']['username']; } } } $this->response->setBody(json_encode(array('GroupUsers' => array('group' => $group, 'users' => $ret)), JSON_PRETTY_PRINT)); }
public function onSend() { $this->content['group'] = Group::getGroupName($this->content['group']); }
public function run() { $this->sendModel(Group::getByRequest()->create()); }
public function securityChecks() { $this->standardize(); $parentGroup = self::getGroupName($this->getParent()); if ($this->getName() === Group::$superUserGroupName) { throw new GraphException('cannot use system group name: ' . self::$superUserGroupName . ' for group', 400); } if ($this->getName() === Group::$everyoneGroupName) { throw new GraphException('cannot create system group: ' . Group::$everyoneGroupName . ' for group name', 400); } if ($parentGroup === Group::$superUserGroupName) { throw new GraphException('cannot use system group: ' . Group::$superUserGroupName . ' as parent', 400); } $fGroup = new Group(); $fGroup->setName($this->getName()); if ($fGroup->read() !== null) { throw new GraphException('group ' . $this->getName() . ' already exists', 400); } if ($this->getParent() !== Group::$everyoneGroupName) { $fGroup = new Group(); $fGroup->setName($this->getParent()); if ($fGroup->read() === null) { throw new GraphException('parent group: ' . $this->getParent() . ' does not exists', 400); } } }