/** * Removes inactive users. * * @return Bengine_Game_Cronjob_RemoveInactiveUser */ protected function removeInactiveUsers() { $deleteTime = TIME - Core::getConfig()->get("USER_DELETE_TIME") * 86400; $where = Core::getDB()->quoteInto("(u.last < ? OR (u.`delete` < '" . TIME . "' AND u.`delete` > '0')) AND ((u2g.usergroupid != '2' AND u2g.usergroupid != '4') OR u2g.usergroupid IS NULL)", $deleteTime); $result = Core::getQuery()->select("user u", "u.userid", "LEFT JOIN " . PREFIX . "user2group u2g ON (u2g.userid = u.userid)", $where); foreach ($result->fetchAll() as $row) { $userid = $row["userid"]; $_result = Core::getQuery()->select("planet", array("planetid", "ismoon"), "", Core::getDB()->quoteInto("userid = ?", $userid)); foreach ($_result->fetchAll() as $_row) { if (!$_row["ismoon"]) { deletePlanet($_row["planetid"], $userid, false); } } $_result->closeCursor(); $_result = Core::getQuery()->select("alliance", "aid", "", Core::getDB()->quoteInto("founder = ?", $userid)); if ($_row = $_result->fetchRow()) { deleteAlliance($_row["aid"]); } $_result->closeCursor(); Core::getQuery()->delete("user", "userid = ?", null, null, array($userid)); } $result->closeCursor(); return $this; }
/** * Abandons an alliance, if user has permissions. * * @return Bengine_Game_Controller_Alliance */ protected function abandonAlly() { $result = Core::getQuery()->select("alliance", "founder", "", Core::getDB()->quoteInto("aid = ?", Core::getUser()->get("aid"))); if ($row = $result->fetchRow()) { $result->closeCursor(); if ($row["founder"] == Core::getUser()->get("userid")) { Hook::event("AbandonAlliance"); deleteAlliance(Core::getUser()->get("aid")); Core::getUser()->rebuild(); } } $this->redirect("game/" . SID . "/Alliance"); return $this; }