Beispiel #1
0
 protected function showForm()
 {
     global $site;
     global $tmpl;
     // protected against cross site injection attempts
     $randomKeyName = 'teamReactivate_' . microtime();
     // convert some special chars to underscores
     $randomKeyName = strtr($randomKeyName, array(' ' => '_', '.' => '_'));
     $randomkeyValue = $site->setKey($randomKeyName);
     $tmpl->assign('keyName', $randomKeyName);
     $tmpl->assign('keyValue', htmlent($randomkeyValue));
     // display teams that can be reactivated
     $teamids = \team::getDeletedTeamIds();
     $teamData = array();
     foreach ($teamids as $teamid) {
         $teamData[] = array('id' => $teamid, 'name' => (new team($teamid))->getName());
     }
     $tmpl->assign('teams', $teamData);
     // a team must always have a leader
     // display user choice to admin
     // get all teamless users
     $users = \user::getTeamlessUsers();
     $userData = array();
     foreach ($users as $user) {
         // a team should only be reactivated so it can play...no point of inactive, disabled or banned user
         if ($user->getStatus() === 'active') {
             $userData[] = array('id' => $user->getID(), 'name' => $user->getName());
         }
     }
     $tmpl->assign('users', $userData);
 }
Beispiel #2
0
 public function showTeams()
 {
     global $tmpl;
     global $user;
     global $db;
     // can user create a new team?
     $tmpl->assign('canCreateTeams', \user::getCurrentUserLoggedIn() && \user::getCurrentUser()->getPermission('allow_create_teams') && \user::getCurrentUser()->getIsTeamless());
     // tell template if user can reactivate maintained/deleted teams and there are teams that could be reactivated
     if ($user->getPermission('allow_reactivate_teams')) {
         $tmpl->assign('canReactivateTeams', count(\team::getDeletedTeamIds()) > 0);
     }
     if (!$tmpl->setTemplate('teamSystemList')) {
         $tmpl->noTemplateFound();
         die;
     }
     $tmpl->assign('title', 'Team overview');
     // get list of new, active, inactive and reactivated teams (no deleted and inactive teams)
     $teams = team::getNewTeamIds();
     $teams = array_merge($teams, team::getActiveTeamIds());
     $teams = array_merge($teams, team::getReactivatedTeamIds());
     $teams = team::getTeamsFromIds($teams);
     // sort teams by score, highest score first
     function scoreSort(team $a, team $b)
     {
         if ($a->getScore() === $b->getScore()) {
             return 0;
         }
         return $a->getScore() > $b->getScore() ? -1 : 1;
     }
     usort($teams, 'scoreSort');
     // display all teams that are not deleted or inactive as active
     $activeTeams = array();
     foreach ($teams as $team) {
         $activeTeams[] = $this->addToTeamList($team);
     }
     $teams = team::getTeamsFromIds(team::getInactiveTeamIds());
     usort($teams, 'scoreSort');
     $inactiveTeams = array();
     foreach ($teams as $team) {
         // use a temporary array for better readable (but slower) code
         // append team data
         $inactiveTeams[] = $this->addToTeamList($team);
     }
     $tmpl->assign('activeTeams', $activeTeams);
     $tmpl->assign('inactiveTeams', $inactiveTeams);
 }