Exemplo n.º 1
0
 /**
  * returns all the messages from a parent
  * @param  integer $id_message_thread 
  * @param  Model_User $user    
  * @param integer $status       
  * @return bool / array                    
  */
 public static function status_thread($id_message_thread, $user, $status)
 {
     $msg_thread = new Model_Message();
     $msg_thread->where('id_message', '=', $id_message_thread)->where('id_message_parent', '=', $id_message_thread)->where_open()->where('id_user_from', '=', $user->id_user)->or_where('id_user_to', '=', $user->id_user)->where_close()->find();
     if ($msg_thread->loaded() and is_numeric($status)) {
         //get all the messages where parent = $is_msg order by created asc
         $messages = new Model_Message();
         $messages = $messages->where('id_message_parent', '=', $id_message_thread)->order_by('created', 'asc')->find_all();
         foreach ($messages as $message) {
             $message->status($user, $status);
         }
         return TRUE;
     }
     return FALSE;
 }
Exemplo n.º 2
0
 /**
  * returns all the messages from a parent
  * @param  integer $id_message_thread 
  * @param  integer $id_user           
  * @return bool / array                    
  */
 public static function get_thread($id_message_thread, $id_user)
 {
     $msg_thread = new Model_Message();
     $msg_thread->where('id_message', '=', $id_message_thread)->where('id_message_parent', '=', $id_message_thread)->where_open()->where('id_user_from', '=', $id_user)->or_where('id_user_to', '=', $id_user)->where_close()->where('status', '!=', Model_Message::STATUS_SPAM)->find();
     if ($msg_thread->loaded()) {
         //get all the messages where parent = $is_msg order by created asc
         $messages = new Model_Message();
         $messages = $messages->where('id_message_parent', '=', $id_message_thread)->where('status', '!=', Model_Message::STATUS_SPAM)->order_by('created', 'asc')->find_all();
         foreach ($messages as $message) {
             $m[$message->id_message] = $message->mark_read($id_user);
         }
         return $m;
     }
     return FALSE;
 }