コード例 #1
0
ファイル: Permissions.php プロジェクト: founderio/thebuggenie
 public function addRolePermission(\thebuggenie\core\entities\Role $role, \thebuggenie\core\entities\RolePermission $rolepermission)
 {
     $role_id = $role->getID();
     $crit = $this->getCriteria();
     $crit->addWhere(self::ROLE_ID, $role_id);
     $existing_identifiables = array(self::UID => array(), self::TID => array());
     $target_id = $rolepermission->getExpandedTargetID($role);
     if ($res = $this->doSelect($crit)) {
         while ($row = $res->getNextRow()) {
             $key = $row->get(self::UID) ? self::UID : self::TID;
             if (!isset($existing_identifiables[$key][$row->get($key)])) {
                 $existing_identifiables[$key][$row->get($key)] = array('id' => $row->get($key), 'target_id' => $target_id, 'permission_type_module' => array());
             }
             $existing_identifiables[$key][$row->get($key)]['permission_type_module'][] = $row->get(self::PERMISSION_TYPE) . ';' . $row->get(self::MODULE);
         }
     }
     foreach (ProjectAssignedUsers::getTable()->getUsersByRoleID($role_id) as $uid => $assigned_user) {
         if (!isset($existing_identifiables[self::UID][$uid])) {
             $existing_identifiables[self::UID][$uid] = array('id' => $uid, 'target_id' => $target_id, 'permission_type_module' => array());
         }
     }
     foreach (ProjectAssignedTeams::getTable()->getTeamsByRoleID($role_id) as $tid => $assigned_team) {
         if (!isset($existing_identifiables[self::TID][$tid])) {
             $existing_identifiables[self::TID][$tid] = array('id' => $tid, 'target_id' => $target_id, 'permission_type_module' => array());
         }
     }
     foreach ($existing_identifiables as $key => $identifiables) {
         foreach ($identifiables as $identifiable) {
             if (in_array($rolepermission->getPermission() . ';' . $rolepermission->getModule(), $identifiable['permission_type_module'])) {
                 continue;
             }
             $crit = $this->getCriteria();
             $crit->addInsert(self::SCOPE, framework\Context::getScope()->getID());
             $crit->addInsert(self::PERMISSION_TYPE, $rolepermission->getPermission());
             $crit->addInsert(self::TARGET_ID, $identifiable['target_id']);
             $crit->addInsert($key, $identifiable['id']);
             $crit->addInsert(self::ALLOWED, true);
             $crit->addInsert(self::MODULE, $rolepermission->getModule());
             $crit->addInsert(self::ROLE_ID, $role_id);
             $res = $this->doInsert($crit);
         }
     }
 }
コード例 #2
0
ファイル: Role.php プロジェクト: pkdevboxy/thebuggenie
 public function removePermission(\thebuggenie\core\entities\RolePermission $permission)
 {
     $this->_populatePermissions();
     $permission_id = $permission->getID();
     unset($this->_permissions[$permission_id]);
     tables\Permissions::getTable()->deleteRolePermission($this->getID(), $permission->getPermission(), $permission->getExpandedTargetID($this));
     $permission->delete();
 }
コード例 #3
0
ファイル: Permissions.php プロジェクト: RTechSoft/thebuggenie
 public function addRolePermission($role_id, \thebuggenie\core\entities\RolePermission $rolepermission)
 {
     $crit = $this->getCriteria();
     $crit->addWhere(self::ROLE_ID, $role_id);
     $existing_identifiables = array('users' => array(), 'teams' => array());
     if ($res = $this->doSelect($crit)) {
         while ($row = $res->getNextRow()) {
             $key = $row->get(self::UID) ? self::UID : self::TID;
             $existing_identifiables[$key][$row->get($key)] = array('id' => $row->get($key), 'target_id' => $row->get(self::TARGET_ID));
         }
         foreach ($existing_identifiables as $key => $identifiables) {
             foreach ($identifiables as $identifiable) {
                 $crit = $this->getCriteria();
                 $crit->addInsert(self::SCOPE, framework\Context::getScope()->getID());
                 $crit->addInsert(self::PERMISSION_TYPE, $rolepermission->getPermission());
                 $crit->addInsert(self::TARGET_ID, $identifiable['target_id']);
                 $crit->addInsert($key, $identifiable['id']);
                 $crit->addInsert(self::ALLOWED, true);
                 $crit->addInsert(self::MODULE, $rolepermission->getModule());
                 $crit->addInsert(self::ROLE_ID, $role_id);
                 $res = $this->doInsert($crit);
             }
         }
     }
 }