public function xRemoveAction() { if (!$this->user->canManageAcl()) { throw new Scalr_Exception_InsufficientPermissions(); } $team = Scalr_Account_Team::init(); $team->loadById($this->getParam('teamId')); if ($team->accountId != $this->user->getAccountId()) { throw new Scalr_Exception_InsufficientPermissions(); } $team->delete(); $this->response->success('Team successfully removed'); }
public function viewAction() { $users = array(); foreach ($this->env->getTeams() as $teamId) { $team = Scalr_Account_Team::init()->loadById($teamId); foreach ($team->getUsers() as $user) { if (!isset($users[$user['id']])) { $users[$user['id']] = array('id' => $user['id'], 'name' => !empty($user['fullname']) ? $user['fullname'] : $user['email'], 'email' => $user['email'], 'teams' => array()); } $users[$user['id']]['teams'][] = array('id' => $team->id, 'name' => $team->name); } } $this->response->page('ui/account2/environments/accessmap.js', array('definitions' => Acl::getResources(true), 'users' => array_values($users), 'env' => array('id' => $this->env->id, 'name' => $this->env->name))); }
/** * Gets all account teams list * * @return array * @throws Scalr_Exception_InsufficientPermissions */ public function getAccountTeamsList() { $acl = \Scalr::getContainer()->acl; if ($this->user->canManageAcl()) { $teamIds = $this->db->getAll('SELECT id FROM account_teams WHERE account_id = ?', array($this->user->getAccountId())); } else { $teamIds = $this->user->getTeams(); } $result = array(); foreach ($teamIds as &$row) { $team = Scalr_Account_Team::init()->loadById($row['id']); $resultRow = array('id' => $team->id, 'name' => $team->name, 'description' => $team->description, 'account_role_id' => $team->accountRoleId); $users = array_map(function ($arr) { return $arr['id']; }, $team->getUsers()); if (!empty($users)) { foreach ($acl->getUserRoleIdsByTeam($users, $row['id'], $this->user->getAccountId()) as $userId => $roles) { $resultRow['users'][] = array('id' => $userId, 'roles' => $roles); } } $result[] = $resultRow; } return $result; }
/** * Checks wheter this user is considered to be the team owner for the specified team. * * @param int $teamId The identifier of the team. * @return boolean Returns true if the user is considered to be the team owner for the specified team. * @deprecated This function has been deprecated since new ACL */ public function isTeamOwner($teamId = null) { $ret = false; if ($teamId) { try { $team = Scalr_Account_Team::init(); $team->loadById($teamId); $ret = $team->isTeamOwner($this->id); } catch (\Exception $e) { } } else { $ret = $this->canManageAcl(); } return $ret; }
public function addTeam($teamId) { $team = Scalr_Account_Team::init()->loadById($teamId); if ($team->accountId == $this->clientId) { $this->removeTeam($teamId); $this->db->Execute('INSERT INTO `account_team_envs` (team_id, env_id) VALUES(?,?)', array($teamId, $this->id)); } else { throw new Exception('This team doesn\'t belongs to this account'); } }
public function xRemoveAction() { $team = Scalr_Account_Team::init(); $team->loadById($this->getParam('teamId')); if ($this->user->isAccountOwner() && $team->accountId == $this->user->getAccountId()) { $team->delete(); } else { throw new Scalr_Exception_InsufficientPermissions(); } $this->response->success(); }
public function xRemovePermissionGroupAction() { $team = Scalr_Account_Team::init()->loadById($this->getParam(self::CALL_PARAM_NAME)); $this->user->getPermissions()->validate($team); if (!($this->user->getType() == Scalr_Account_User::TYPE_ACCOUNT_OWNER || $team->isTeamOwner($this->user->getId()))) { throw new Scalr_Exception_InsufficientPermissions(); } $group = Scalr_Account_Group::init(); $group->loadById($this->getParam('groupId')); if ($group->teamId != $team->id) { throw new Scalr_Exception_InsufficientPermissions(); } $group->delete(); $this->response->success(); }