Example #1
0
 public function testNonNegativeInt()
 {
     $this->assertEquals(4, non_negative_int(4));
     $this->assertEquals(0, non_negative_int(-4));
     $this->assertEquals(0, non_negative_int(4.1));
     $this->assertEquals(0, non_negative_int(4.9));
     $this->assertEquals(0, non_negative_int(0));
     $this->assertEquals(0, non_negative_int('somestring'));
     $this->assertEquals(0, non_negative_int([]));
 }
 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');
 }
Example #3
0
 $to = in('to');
 // The target of the message, if any were specified.
 $to = $to ? $to : get_setting('last_messaged');
 $to_clan = in('toclan');
 $messenger = in('messenger');
 // naive spam detection attempt
 $message = in('message', null, null);
 // Unfiltered input for this message.
 $target_id = (int) in('target_id') ? (int) in('target_id') : ($to ? get_user_id($to) : null);
 // Id takes precedence
 $ninja = new Player(self_char_id());
 $clan = ClanFactory::clanOfMember($ninja);
 $has_clan = $clan ? true : false;
 $page = in('page', 1, 'non_negative_int');
 $limit = 25;
 $offset = non_negative_int(($page - 1) * $limit);
 $delete = in('delete');
 $informational = in('informational');
 $type = in('type');
 // Clan chat or normal messages.
 $type = restrict_to($type, array(0, 1));
 $message_sent_to = null;
 // Names or name to display.
 $message_to = null;
 // strings clan or individual if sent to those respectively.
 if ($target_id) {
     $to = get_char_name($target_id);
 }
 set_setting('last_messaged', $to);
 switch (true) {
     case $command == 'clan' && $_POST: