public function viewClan()
 {
     $ninja = new Player(self_char_id());
     $page = in('page', 1, 'non_negative_int');
     $limit = 25;
     $offset = non_negative_int(($page - 1) * $limit);
     $type = 1;
     // Clan chat or normal messages.
     $message_count = Message::countByReceiver($ninja, $type);
     // To count all the messages
     Message::markAsRead($ninja, $type);
     // mark messages as read for next viewing.
     $parts = array_merge($this->configure(), ['messages' => Message::findByReceiver($ninja, $type, $limit, $offset), 'message_count' => $message_count, 'pages' => ceil($message_count / $limit), 'current_page' => $page, 'current_tab' => 'clan', 'has_clan' => (bool) ClanFactory::clanOfMember($ninja)]);
     return $this->render($parts, 'Clan Messages');
 }
示例#2
0
 public function testFindPrivateMessagesForACertainChar()
 {
     $messageCount = 4;
     $this->messageData['send_to'] = $this->char_id;
     $this->messageData['send_from'] = $this->char_id_2;
     for ($count = 0; $count < $messageCount; $count++) {
         $this->messageData['message'] = 'Random phpunit test message' . $count;
         Message::create($this->messageData);
         // Test deletes these
     }
     $char = Player::find($this->char_id);
     $messages = Message::findByReceiver($char)->all();
     $this->assertEquals($messageCount, count($messages));
     Message::deleteByReceiver($char, 0);
     $this->assertEquals(0, Message::countByReceiver($char));
 }
示例#3
0
 /**
  * View clan messages
  *
  * @param Container
  */
 public function viewClan(Container $p_dependencies)
 {
     $ninja = $p_dependencies['current_player'];
     $page = max(1, (int) RequestWrapper::getPostOrGet('page'));
     $limit = 25;
     $offset = ($page - 1) * $limit;
     $type = 1;
     // Clan chat or normal messages.
     $message_count = Message::countByReceiver($ninja, $type);
     // To count all the messages
     Message::markAsRead($ninja, $type);
     // mark messages as read for next viewing.
     $parts = array_merge($this->configure(), ['messages' => Message::findByReceiver($ninja, $type, $limit, $offset), 'message_count' => $message_count, 'pages' => ceil($message_count / $limit), 'current_page' => $page, 'current_tab' => 'clan', 'has_clan' => (bool) Clan::findByMember($ninja)]);
     return $this->render($parts, 'Clan Messages');
 }