protected function deleteTeam() { global $site; 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; } // notify team members using a private message first because later we won't have the membership info $pm = new pm(); $pm->setSubject(\user::getCurrentUser()->getName() . ' deleted ' . $this->team->getName()); $pm->setContent('Player ' . \user::getCurrentUser()->getName() . ' just deleted the team ' . $this->team->getName() . ' you were member of.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addTeamID($this->team->getID()); // send it $pm->send(); // remove the members from team $members = $this->team->getUsers(); foreach ($members as $member) { $member->removeTeamMembership($this->team->getID()); $member->update(); } unset($members); unset($member); // if team never matched deleted it from database, otherwise just mark it as deleted require_once $site->installationPath() . '/CMS/classes/match.php'; $matchCount = \match::getMatchCountForTeamId($this->team->getID()); if ($matchCount > 0 || $matchCount === false) { // set the teams status to deleted $this->team->setStatus('deleted'); $deletionTask = $this->team->update(); } else { // actually delete team $deletionTask = $this->team->delete(); } if (!$deletionTask) { $tmpl->assign('error', 'An unknown error occurred while deleting the team.'); } else { // tell joined user that deletion was successful $tmpl->assign('teamDeleteSuccessful', true); } }