Example #1
0
 /**
  * Checks if the user is a member of the given team
  *
  * @param \thebuggenie\core\entities\Team $team
  *
  * @return boolean
  */
 public function isMemberOfTeam(\thebuggenie\core\entities\Team $team)
 {
     $this->_populateTeams();
     return array_key_exists($team->getID(), $this->_teams['assigned']) || array_key_exists($team->getID(), $this->_teams['ondemand']);
 }
Example #2
0
 public function runAddTeam(framework\Request $request)
 {
     try {
         $mode = $request['mode'];
         if ($team_name = $request['team_name']) {
             if ($mode == 'clone') {
                 try {
                     $old_team = entities\Team::getB2DBTable()->selectById($request['team_id']);
                 } catch (\Exception $e) {
                 }
                 if (!$old_team instanceof entities\Team) {
                     throw new \Exception(framework\Context::getI18n()->__("You cannot clone this team"));
                 }
             }
             if (entities\Team::doesTeamNameExist(trim($team_name))) {
                 throw new \Exception(framework\Context::getI18n()->__("Please enter a team name that doesn't already exist"));
             }
             $team = new entities\Team();
             $team->setName($team_name);
             $team->save();
             if ($mode == 'clone') {
                 if ($request['clone_permissions']) {
                     tables\Permissions::getTable()->cloneTeamPermissions($old_team->getID(), $team->getID());
                 }
                 if ($request['clone_memberships']) {
                     tables\TeamMembers::getTable()->cloneTeamMemberships($old_team->getID(), $team->getID());
                 }
                 $message = framework\Context::getI18n()->__('The team was cloned');
             } else {
                 $message = framework\Context::getI18n()->__('The team was added');
             }
             return $this->renderJSON(array('message' => $message, 'content' => $this->getComponentHTML('configuration/teambox', array('team' => $team)), 'total_count' => entities\Team::countAll(), 'more_available' => framework\Context::getScope()->hasTeamsAvailable()));
         } else {
             throw new \Exception(framework\Context::getI18n()->__('Please enter a team name'));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $e->getMessage()));
     }
 }