Пример #1
0
 function preg()
 {
     $users = list_at_user("hello @spencer and @kfir");
     foreach ($users as $user) {
         $user = $this->Users_Model->get_user($user);
         print_r($user);
         echo "<hr>";
     }
 }
Пример #2
0
 function notify_comment($comment_id, $options = null)
 {
     $this->type = "comment";
     $this->item_id = $comment_id;
     $dreamer = isset($options['dreamer']) ? $options['dreamer'] : true;
     $sibling_comments = isset($options['sibling_comments']) ? $options['sibling_comments'] : false;
     $at_mention = isset($options['at_mention']) ? $options['at_mention'] : true;
     $user_ids = null;
     if ($dreamer) {
         $this->db->select("comments.dream_id, comments.user_id, comments.content, dreams.user_id AS user_id2");
         $this->db->where("comment_id", $comment_id);
         $this->db->join("dreams", "dreams.dream_id = comments.dream_id");
         $this->db->where("comments.user_id != dreams.user_id");
         $this->db->where_not_in("comments.user_id", $user_ids);
         $query = $this->db->get("comments");
         $comment = $query->row();
         $this->user_id = $comment->user_id2;
         $this->_create();
         $user_ids[] = $this->user_id;
     }
     if ($at_mention) {
         $users = list_at_user($comment->content);
         $this->data['at_mention'] = true;
         foreach ($users as $user) {
             $user = $this->Users_Model->get_user($user);
             if ($user && $user->user_id != $comment->user_id && !in_array($user->user_id, $user_ids)) {
                 $this->user_id = $user->user_id;
                 $this->_create();
                 $user_ids[] = $this->user_id;
             }
         }
         $this->data['content'] = null;
     }
     if ($sibling_comments) {
         $this->db->select("comments.user_id");
         $this->db->distinct();
         $this->db->where("dream_id", $comment->dream_id);
         $this->db->where("user_id !=", $comment->user_id);
         $this->db->where("user_id !=", $comment->user_id2);
         $this->db->where_not_in("comments.user_id", $user_ids);
         $query = $this->db->get("comments");
         $comments = $query->result();
         foreach ($comments as $item) {
             $this->user_id = $item->user_id;
             $this->_create();
             $user_ids[] = $this->user_id;
         }
     }
 }