Example #1
0
 /**
  * Constructor, creating a timestamp type message (whenever any action happens)
  *
  * Make sure that activity column has a number in it!
  *
  * @param integer $roomId Id of the room (optional)
  * @param integer $time UNIX timestamp (optional)
  * @param integer $hide Set to one if you don't want a message to appear in transcript but room is not locked yet
  * @return void
  */
 function __construct($roomId = null, $time = null, $hide = 0)
 {
     // call parent constructor to set db connection
     $this->db = Fari_Db::getConnection();
     parent::__construct($this->db);
     // we don't want to timestamp a room as active if a user is leaving for example...
     if (isset($roomId)) {
         $this->roomId = $roomId;
         $this->timestampRoom($time, $hide);
     }
 }
Example #2
0
 function __construct($time = NULL)
 {
     if (!isset($time)) {
         $time = mktime();
     }
     $this->db = Fari_Db::getConnection();
     parent::__construct($this->db);
     $cutoff = $time - 60 * 10;
     // check if user has a timestamp older than 5 minutes in a room
     $leave = $this->db->select('room_users JOIN users ON room_users.user=users.id', 'user, room, short', "timestamp < {$cutoff}");
     if (!empty($leave)) {
         $message = new MessageSpeak();
         foreach ($leave as $user) {
             // leaving message
             $message->leave($user['room'], $time, $user['short']);
         }
         // clear them out from the room
         $this->db->delete('room_users', "timestamp < {$cutoff}");
     }
 }