protected function reactivateTeam() { global $tmpl; // perform sanity checks if (($result = $this->sanityCheck()) !== true) { $tmpl->assign('error', $result === false ? 'An unknown error occurred while checking your request' : $result); return; } $tmpl->assign('teamName', $this->team->getName()); $tmpl->assign('teamid', $this->team->getID()); $tmpl->assign('userName', $this->user->getName()); $tmpl->assign('userid', $this->user->getID()); // reactivate team with chosen leader // issue an invitation for team leader so he can join $invitation = new invitation(); $invitation->forUserId($this->user->getID()); $invitation->toTeam($this->team->getID()); $invitation->insert(false); // now change team status to reactivate and add the user to team then make the user leader if (!$this->team->setStatus('reactivated') || !$this->team->update() || !$this->user->addTeamMembership($this->team->getID()) || !$this->user->update() || !$this->team->setLeaderId($this->user->getID()) || !$this->team->update()) { /* var_dump($this->user->addTeamMembership($this->team->getID())); */ $tmpl->assign('error', 'An unknown error occurred while reactivating the team.'); } else { // notify team members using a private message $pm = new pm(); $pm->setSubject(\user::getCurrentUser()->getName() . ' reactivated team ' . $this->team->getName()); $pm->setContent('Congratulations: Player ' . \user::getCurrentUser()->getName() . ' reactivated team ' . $this->team->getName() . ' with you as its leader.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addUserID($this->user->getID()); // send it $pm->send(); // tell user that team reactivation was successful $tmpl->assign('teamReactivationSuccessful', true); } }
public static function sendWelcomeMessage($id) { global $config; $subject = $config->getValue('login.welcome.subject') ? $config->getValue('login.welcome.subject') : 'Welcome'; $content = $config->getValue('login.welcome.content') ? $config->getValue('login.welcome.content') : 'Welcome and thanks for registering at this website!' . "\n" . 'In the FAQ you can find the most important informations' . ' about organising and playing matches.' . "\n\n" . 'See you on the battlefield.'; // prepare welcome message $pm = new pm(); $pm->setSubject($subject); $pm->setContent($content); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addUserID($id); // send it $pm->send(); }
protected function leaveTeam() { global $tmpl; // perform sanity checks if (($result = $this->sanityCheck()) !== true) { $tmpl->assign('error', $result === false ? 'An unknown error occurred while checking your request' : $result); } // remove user from team if (!$this->user->removeTeamMembership($this->team->getID()) || !$this->user->update()) { $tmpl->assign('error', 'An unknown error occurred while leaving the team.'); } else { // notify team members using a private message $pm = new pm(); if (\user::getCurrentUserId() === $this->user->getID()) { // notify team members about left member $pm->setSubject($this->user->getName() . ' left your team'); $pm->setContent('Player ' . $this->user->getName() . ' just left your team.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addTeamID($this->team->getID()); // send it $pm->send(); } else { // notify team members of kicked member $pm->setSubject($this->user->getName() . ' got kicked from your team'); $pm->setContent('Player ' . $this->user->getName() . ' got kicked from your team by ' . \user::getCurrentUser()->getName() . '.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addTeamID($this->team->getID()); // send it $pm->send(); // notify kicked member of the kick $pm = new pm(); $pm->setSubject('You got kicked from your team by ' . \user::getCurrentUser()->getName()); $pm->setContent('Player ' . \user::getCurrentUser()->getName() . ' just kicked you from your team.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addUserID($this->user->getID()); // send it $pm->send(); } // tell joined user that join was successful $tmpl->assign('teamLeaveSuccessful', true); } }
public function insert($sendPM = true) { global $db; if (count($this->teamids) > 0) { foreach ($this->teamids as $teamid) { if (count($this->userids) > 0) { $query = $db->prepare('INSERT INTO `invitations` (`userid`, `teamid`, `expiration`) VALUES (:userid, :teamid, :expiration)'); foreach ($this->userids as $userid) { if (!$db->execute($query, array(':userid' => array((int) $userid, PDO::PARAM_INT), ':teamid' => array((int) $teamid, PDO::PARAM_INT), ':expiration' => array(strftime('%Y-%m-%d %H:%M:%S', $this->expiration), PDO::PARAM_STR)))) { return false; } if ($sendPM) { $pm = new pm(); $pm->setSubject(\user::getCurrentUser()->getName() . ' invited you to ' . (new team($teamid))->getName()); $pm->setContent('Congratulations: ' . \user::getCurrentUser()->getName() . ' invited you to ' . (new team($teamid))->getName() . '. The invitation is valid until ' . strftime('%Y-%m-%d %H:%M:%S', $this->expiration) . '.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addUserID($userid); // send it $pm->send(); } } } } } return true; }