/** * True if a lock with given bundle and module are set * @param string $bundle The bundle name * @param string $module The module name * @return boolean Returns true if the lock is set */ private function HasLock($bundle, $module = '') { $sql = Access::SqlBuilder(); $tblModLock = ModuleLock::Schema()->Table(); $where = $sql->Equals($tblModLock->Field('Bundle'), $sql->Value($bundle))->And_($sql->Equals($tblModLock->Field('Module'), $sql->Value($module)))->And_($sql->Equals($tblModLock->Field('UserGroup'), $sql->Value($this->group->GetID()))); return ModuleLock::Schema()->Count(false, $where) > 0; }
static function AddUserGroupOptions(Select $field) { $sql = Access::SqlBuilder(); $tblGroup = Usergroup::Schema()->Table(); $orderBy = $sql->OrderList($sql->OrderAsc($tblGroup->Field('Name'))); $groups = Usergroup::Schema()->Fetch(false, null, $orderBy); foreach ($groups as $group) { $field->AddOption($group->GetID(), $group->GetName()); } }
/** * Saves the group and redirects to the list */ protected function OnSuccess() { $action = $this->group->Exists() ? Action::Update() : Action::Create(); $this->group->SetName($this->Value('Name')); $this->group->SetCreateContainers((bool) $this->Value('CreateContainers')); $this->group->SetCreateLayouts((bool) $this->Value('CreateLayouts')); $this->group->SetCreateContainers((bool) $this->Value('CreateContainers')); $this->group->Save(); $logger = new Logger(self::Guard()->GetUser()); $logger->ReportUserGroupAction($this->group, $action); $target = BackendRouter::ModuleUrl(new UsergroupList()); Response::Redirect($target); }
private function SaveRights() { $groupID = $this->Value('UserGroup'); $userGroup = Usergroup::Schema()->ByID($groupID); $this->site->SetUserGroup($userGroup); if (!$userGroup) { $oldRights = $this->site->GetUserGroupRights(); if ($oldRights) { $oldRights->GetPageRights()->GetContentRights()->Delete(); } $this->site->SetUserGroupRights(null); } else { $this->siteRights->Save(); $this->site->SetUserGroupRights($this->siteRights->Rights()); } $this->site->Save(); }
/** * Calculates the grant result for a group on a content * @param Usergroup $group The evaluated group * @param Usergroup $contentGroup The group of the content * @param BackendContentRights $contentRights The rights of the content * @param BackendAction $action The action that shall be taken for the content * @return GrantResult Returns the calculated result */ private function GrantGroupOnContent(Usergroup $group, Usergroup $contentGroup, BackendContentRights $contentRights, BackendAction $action) { if (!$group->Equals($contentGroup)) { return GrantResult::NoAccess(); } $allowed = false; switch ($action) { case BackendAction::Create(): $allowed = $contentRights->GetCreateIn(); break; case BackendAction::Edit(): $allowed = $contentRights->GetEdit(); break; case BackendAction::Move(): $allowed = $contentRights->GetMove(); break; case BackendAction::Delete(): $allowed = $contentRights->GetRemove(); break; case BackendAction::Read(): $allowed = $this->HasAnyContentRight($contentRights); break; } return $allowed ? GrantResult::Allowed() : GrantResult::NoAccess(); }
/** * Gets the url for the module lock * @param Usergroup $group * @return string */ protected function ModuleLockFormUrl(Usergroup $group) { $args = array('usergroup' => $group->GetID()); return BackendRouter::ModuleUrl(new ModuleLockForm(), $args); }
private function UserGroupWhere(Usergroup $group) { $sql = Access::SqlBuilder(); $tblUug = UserUsergroup::Schema()->Table(); return $sql->Equals($tblUug->Field('User'), $sql->Value($this->user->GetID()))->And_($sql->Equals($tblUug->Field('UserGroup'), $sql->Value($group->GetID()))); }