/** * Adds an assignee with a given role * * @param TBGIdentifiable $assignee The user or team to add * @param integer $role The role to add * * @return null */ public function addAssignee($assignee, $role) { switch (true) { case $assignee instanceof TBGUser: if (!($res = B2DB::getTable('TBGProjectAssigneesTable')->getByProjectAndRoleAndUser($this->getID(), $role, $assignee->getID()))) { B2DB::getTable('TBGProjectAssigneesTable')->addByProjectAndRoleAndUser($this->getID(), $role, $assignee->getID()); } break; case $assignee instanceof TBGTeam: if (!($res = B2DB::getTable('TBGProjectAssigneesTable')->getByProjectAndRoleAndTeam($this->getID(), $role, $assignee->getID()))) { B2DB::getTable('TBGProjectAssigneesTable')->addByProjectAndRoleAndTeam($this->getID(), $role, $assignee->getID()); } break; } $this->applyInitialPermissionSet($assignee, $role); }
public function setAssignee(TBGIdentifiable $assignee) { if ($assignee instanceof TBGTeam) { $this->_addChangedProperty('_assignee_user', null); $this->_addChangedProperty('_assignee_team', $assignee->getID()); } else { $this->_addChangedProperty('_assignee_user', $assignee->getID()); $this->_addChangedProperty('_assignee_team', null); } }
public function applyInitialPermissionSet(TBGIdentifiable $identifiable, $type) { $permission_set = TBGContext::getProjectAssigneeDefaultPermissionSet($this, $type); $uid = $identifiable->getType() == TBGIdentifiableClass::TYPE_USER ? $identifiable->getID() : null; $tid = $identifiable->getType() == TBGIdentifiableClass::TYPE_TEAM ? $identifiable->getID() : null; foreach ($permission_set as $permission) { TBGContext::setPermission($permission, $this->getID(), 'core', $uid, null, $tid, true); } if (!$this instanceof TBGProject) { $extrapermissions = array(); $extrapermissions[] = 'page_project_allpages_access'; $extrapermissions[] = 'canseeproject'; $extrapermissions[] = 'canseeprojecthierarchy'; $extrapermissions[] = 'cancreateandeditissues'; $extrapermissions[] = 'canpostandeditcomments'; $project_id = $this->getProject()->getID(); foreach ($extrapermissions as $permission) { TBGContext::setPermission($permission, $project_id, 'core', $uid, null, $tid, true); } } }
/** * Adds an assignee with a given role * * @param TBGIdentifiable $assignee The user or team to add * @param integer $role The role to add * * @return null */ public function addAssignee($assignee, $role = null) { $user_id = 0; $team_id = 0; if ($assignee instanceof TBGUser) { $user_id = $assignee->getID(); TBGProjectAssignedUsersTable::getTable()->addUserToProject($this->getID(), $user_id, $role->getID()); } elseif ($assignee instanceof TBGTeam) { $team_id = $assignee->getID(); TBGProjectAssignedTeamsTable::getTable()->addTeamToProject($this->getID(), $team_id, $role->getID()); } if ($role instanceof TBGRole) { foreach ($role->getPermissions() as $role_permission) { $target_id = $role_permission->hasTargetID() ? $role_permission->getReplacedTargetID($this) : $this->getID(); TBGContext::setPermission($role_permission->getPermission(), $target_id, $role_permission->getModule(), $user_id, 0, $team_id, true, null, $role->getID()); } } }