コード例 #1
0
ファイル: Message.php プロジェクト: reillo/ninjawars
 /**
  * Send the message to a group of target ids
  **/
 public static function sendToGroup(Player $sender, array $groupTargets, $message, $type)
 {
     if (!$sender || !$sender->id()) {
         throw new Exception('Error: Message sender not set.');
     }
     $id = $sender->id();
     foreach ($groupTargets as $target_id) {
         Message::create(['message' => $message, 'send_to' => $target_id, 'send_from' => $id, 'type' => $type]);
     }
     return true;
 }
コード例 #2
0
ファイル: MessageTest.php プロジェクト: reillo/ninjawars
 public function testFindPrivateMessagesForACertainChar()
 {
     $i = 4;
     while ($i--) {
         Message::create(['message' => 'Random phpunit test message' . $i, 'send_to' => $this->char_id, 'send_from' => $this->char_id_2, 'unread' => 1]);
     }
     $char = new Player($this->char_id);
     $messages = Message::findByReceiver($char)->all();
     $this->assertEquals(4, count($messages));
     Message::deleteByReceiver($char, $type = 0);
     $this->assertEquals(0, Message::countByReceiver($char));
 }
コード例 #3
0
ファイル: messages.php プロジェクト: reillo/ninjawars
     default:
         $command = 'personal';
         $messages_type = 'personal';
         $current_tab = 'messages';
         $type = 0;
 }
 // Sending mail section.
 if ($message && $messenger) {
     if ($to_clan && $has_clan) {
         $type = 1;
         $target_id_list = $clan->getMemberIds();
         $passfail = Message::sendToGroup($ninja, $target_id_list, $message, $type);
         $message_sent_to = 'your clan';
         $message_to = 'clan';
     } elseif ((bool) $target_id) {
         Message::create(['send_from' => $ninja->id(), 'send_to' => $target_id, 'message' => $message, 'type' => $type]);
         $message_sent_to = $to;
         $message_to = 'individual';
         $type = 0;
     }
 }
 // An illuminate collection object.
 $messages = Message::findByReceiver($ninja, $type, $limit, $offset);
 $message_count = Message::countByReceiver($ninja, $type);
 // To count all the messages
 $pages = ceil($message_count / $limit);
 // Total pages.
 $current_page = $page;
 Message::markAsRead($ninja, $type);
 // mark messages as read for next viewing.
 // TODO: Handle "send" ing to specific, known users.