예제 #1
0
 public function _defaultAclRole($from, $to, $action)
 {
     switch ($action) {
         case static::ACT_CONVERT_TO_OBJECT:
             /* @var $from TeamEnvs */
             $to->defaultAclRole = ['id' => $from->getTeam()->accountRoleId];
             break;
         case static::ACT_CONVERT_TO_ENTITY:
             /* @var $to TeamEnvs */
             // now its only Team property
             throw new ApiNotImplementedErrorException('Adjustment the default ACL Role for the Environment has not been implemented yet.');
         case static::ACT_GET_FILTER_CRITERIA:
             $aclRoleId = ApiController::getBareId($from, 'defaultAclRole');
             $team = new Team();
             $envTeam = new TeamEnvs();
             return [AbstractEntity::STMT_FROM => "\n                        JOIN {$team->table('t')} ON {$team->columnId('t')} = {$envTeam->columnTeamId()}\n                            AND {$team->columnAccountRoleId('t')} = " . $team->qstr('accountRoleId', $aclRoleId) . "\n                    "];
     }
 }
예제 #2
0
 /**
  * Gets default search criteria according current account
  *
  * @return  array   Returns array of the search criteria
  */
 private function getDefaultCriteria()
 {
     $criteria = [['accountId' => $this->getUser()->getAccountId()]];
     $user = $this->getUser();
     if (!$user->canManageAcl()) {
         $env = new Account\Environment();
         $teamEnv = new Account\TeamEnvs();
         $team = new Account\Team();
         $teamUser = new Account\TeamUser();
         $criteria = array_merge($criteria, [AbstractEntity::STMT_DISTINCT => true, AbstractEntity::STMT_FROM => " {$env->table()}\n                    JOIN  {$teamEnv->table('te')} ON  {$teamEnv->columnEnvId('te')}  =  {$env->columnId()}\n                    JOIN  {$team->table('at')} ON  {$team->columnId('at')}  = {$teamEnv->columnTeamId('te')}\n                    JOIN  {$teamUser->table('tu')}  ON  {$teamUser->columnTeamId('tu')} = {$team->columnId('at')}\n                ", AbstractEntity::STMT_WHERE => "{$teamUser->columnUserId('tu')}  = " . $teamUser->qstr('userId', $user->id) . " AND  {$team->columnAccountId('at')}  = " . $team->qstr('accountId', $user->getAccountId())]);
     }
     return $criteria;
 }