Example #1
0
 public function setAssignee(\thebuggenie\core\entities\common\Identifiable $assignee)
 {
     if ($assignee instanceof \thebuggenie\core\entities\Team) {
         $this->_addChangedProperty('_assignee_user', null);
         $this->_addChangedProperty('_assignee_team', $assignee->getID());
     } else {
         $this->_addChangedProperty('_assignee_user', $assignee->getID());
         $this->_addChangedProperty('_assignee_team', null);
     }
 }
Example #2
0
 /**
  * Adds an assignee with a given role
  *
  * @param \thebuggenie\core\entities\common\Identifiable $assignee The user or team to add
  * @param Role $role The role to add
  *
  * @return null
  */
 public function addAssignee($assignee, $role = null)
 {
     $user_id = 0;
     $team_id = 0;
     if ($assignee instanceof \thebuggenie\core\entities\User) {
         $user_id = $assignee->getID();
         if (tables\ProjectAssignedUsers::getTable()->addUserToProject($this->getID(), $user_id, $role->getID()) && is_array($this->_assigned_users)) {
             $this->_assigned_users = array_merge($this->_assigned_users, tables\ProjectAssignedUsers::getTable()->getUserByProjectIDUserIDRoleID($this->getID(), $user_id, $role->getID()));
         }
     } elseif ($assignee instanceof \thebuggenie\core\entities\Team) {
         $team_id = $assignee->getID();
         if (tables\ProjectAssignedTeams::getTable()->addTeamToProject($this->getID(), $team_id, $role->getID()) && is_array($this->_assigned_users)) {
             $this->_assigned_teams = array_merge($this->_assigned_teams, tables\ProjectAssignedTeams::getTable()->getTeamByProjectIDTeamIDRoleID($this->getID(), $team_id, $role->getID()));
         }
     }
     if ($role instanceof \thebuggenie\core\entities\Role) {
         $role_id = $role->getID();
         foreach ($role->getPermissions() as $role_permission) {
             $target_id = strtolower($role_permission->getExpandedTargetID($role));
             tables\Permissions::getTable()->removeSavedPermission($user_id, 0, $team_id, $role_permission->getModule(), $role_permission->getPermission(), $target_id, framework\Context::getScope()->getID(), $role_id);
             framework\Context::setPermission($role_permission->getPermission(), $target_id, $role_permission->getModule(), $user_id, 0, $team_id, true, null, $role_id);
         }
     }
 }
Example #3
0
 /**
  * Adds an assignee with a given role
  *
  * @param \thebuggenie\core\entities\common\Identifiable $assignee The user or team to add
  * @param Role $role The role to add
  *
  * @return null
  */
 public function addAssignee($assignee, $role = null)
 {
     $user_id = 0;
     $team_id = 0;
     if ($assignee instanceof \thebuggenie\core\entities\User) {
         $user_id = $assignee->getID();
         tables\ProjectAssignedUsers::getTable()->addUserToProject($this->getID(), $user_id, $role->getID());
     } elseif ($assignee instanceof \thebuggenie\core\entities\Team) {
         $team_id = $assignee->getID();
         tables\ProjectAssignedTeams::getTable()->addTeamToProject($this->getID(), $team_id, $role->getID());
     }
     if ($role instanceof \thebuggenie\core\entities\Role) {
         foreach ($role->getPermissions() as $role_permission) {
             $target_id = $role_permission->hasTargetID() ? $role_permission->getReplacedTargetID($this) : $this->getID();
             framework\Context::setPermission($role_permission->getPermission(), $target_id, $role_permission->getModule(), $user_id, 0, $team_id, true, null, $role->getID());
         }
     }
 }