public function getTemplateParameters() { $count = MessagesDataService::countInboxMessages($this->_websoccer, $this->_db); $eps = $this->_websoccer->getConfig("entries_per_page"); $paginator = new Paginator($count, $eps, $this->_websoccer); if ($count > 0) { $messages = MessagesDataService::getInboxMessages($this->_websoccer, $this->_db, $paginator->getFirstIndex(), $eps); } else { $messages = array(); } return array("messages" => $messages, "paginator" => $paginator); }
public function getTemplateParameters() { $id = $this->_websoccer->getRequestParameter("id"); $message = MessagesDataService::getMessageById($this->_websoccer, $this->_db, $id); // update "seen" state if ($message && !$message["seen"]) { $columns["gelesen"] = "1"; $fromTable = $this->_websoccer->getConfig("db_prefix") . "_briefe"; $whereCondition = "id = %d"; $this->_db->queryUpdate($columns, $fromTable, $whereCondition, $id); } return array("message" => $message); }
public function executeAction($parameters) { $id = $parameters["id"]; $message = MessagesDataService::getMessageById($this->_websoccer, $this->_db, $id); if ($message == null) { throw new Exception($this->_i18n->getMessage("messages_delete_invalidid")); } // delete $fromTable = $this->_websoccer->getConfig("db_prefix") . "_briefe"; $whereCondition = "id = %d"; $this->_db->queryDelete($fromTable, $whereCondition, $id); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("messages_delete_success"), "")); return null; }
/** * (non-PHPdoc) * @see IActionController::executeAction() */ public function executeAction($parameters) { $senderId = $this->_websoccer->getUser()->id; // check if messages is enabled if (!$this->_websoccer->getConfig("messages_enabled")) { throw new Exception($this->_i18n->getMessage("messages_err_messagesdisabled")); } // find user $recipientId = UsersDataService::getUserIdByNick($this->_websoccer, $this->_db, $parameters["nick"]); if ($recipientId < 1) { throw new Exception($this->_i18n->getMessage("messages_send_err_invalidrecipient")); } // cannot send to yourself if ($senderId == $recipientId) { throw new Exception($this->_i18n->getMessage("messages_send_err_sendtoyourself")); } $now = $this->_websoccer->getNowAsTimestamp(); // check when sent last message (needs x minutes break in order to prevent spam) $lastMessage = MessagesDataService::getLastMessageOfUserId($this->_websoccer, $this->_db, $senderId); $timebreakBoundary = $now - $this->_websoccer->getConfig("messages_break_minutes") * 60; if ($lastMessage != null && $lastMessage["date"] >= $timebreakBoundary) { throw new Exception($this->_i18n->getMessage("messages_send_err_timebreak", $this->_websoccer->getConfig("messages_break_minutes"))); } // create message $columns["empfaenger_id"] = $recipientId; $columns["absender_id"] = $senderId; $columns["datum"] = $now; $columns["betreff"] = $parameters["subject"]; $columns["nachricht"] = $parameters["msgcontent"]; $fromTable = $this->_websoccer->getConfig("db_prefix") . "_briefe"; // create message in inbox of recipient $columns["typ"] = "eingang"; $this->_db->queryInsert($columns, $fromTable); // create message in outbox of sender $columns["typ"] = "ausgang"; $this->_db->queryInsert($columns, $fromTable); // success message $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("messages_send_success"), "")); // clear fields $_REQUEST["subject"] = ""; $_REQUEST["msgcontent"] = ""; $_REQUEST["nick"] = ""; return null; }
public function getTemplateParameters() { $fromTable = $this->_websoccer->getConfig("db_prefix") . "_user"; $user = $this->_websoccer->getUser(); // select general information $columns = "fanbeliebtheit AS user_popularity, highscore AS user_highscore"; $whereCondition = "id = %d"; $result = $this->_db->querySelect($columns, $fromTable, $whereCondition, $user->id, 1); $userinfo = $result->fetch_array(); $result->free(); $clubId = $user->getClubId($this->_websoccer, $this->_db); // get team info $team = null; if ($clubId > 0) { $team = TeamsDataService::getTeamSummaryById($this->_websoccer, $this->_db, $clubId); } // unread messages $unseenMessages = MessagesDataService::countUnseenInboxMessages($this->_websoccer, $this->_db); // unseen notifications $unseenNotifications = NotificationsDataService::countUnseenNotifications($this->_websoccer, $this->_db, $user->id, $clubId); return array("profile" => $userinfo, "userteam" => $team, "unseenMessages" => $unseenMessages, "unseenNotifications" => $unseenNotifications); }