Пример #1
0
 /**
  * Sends a user board message to another user.
  * Performs the insertion to user_board table, sends e-mail notification
  * (if appliable), and increases social statistics as appropriate.
  *
  * @param $user_id_from Integer: user ID of the sender
  * @param $user_name_from Mixed: user name of the sender
  * @param $user_id_to Integer: user ID of the reciever
  * @param $user_name_to Mixed: user name of the reciever
  * @param $message Mixed: message text
  * @param $message_type Integer: 0 for public message
  * @return Integer: the inserted value of ub_id row
  */
 public function sendBoardMessage($user_id_from, $user_name_from, $user_id_to, $user_name_to, $message, $message_type = 0)
 {
     // convert '@' to wiki link;
     $message = CommentFunctions::preprocessText($message);
     $dbw = wfGetDB(DB_MASTER);
     $user_name_from = stripslashes($user_name_from);
     $user_name_to = stripslashes($user_name_to);
     $dbw->insert('user_board', array('ub_user_id_from' => $user_id_from, 'ub_user_name_from' => $user_name_from, 'ub_user_id' => $user_id_to, 'ub_user_name' => $user_name_to, 'ub_message' => $message, 'ub_type' => $message_type, 'ub_date' => date('Y-m-d H:i:s')), __METHOD__);
     // Send e-mail notification (if user is not writing on own board)
     if ($user_id_from != $user_id_to) {
         $this->sendBoardNotificationEmail($user_id_to, $user_name_from, $message);
         $this->incNewMessageCount($user_id_to);
     }
     $mentionedUsers = CommentFunctions::getMentionedUsers($message);
     if (count($mentionedUsers) && $message_type == 0) {
         $this->sendMentionedNotification($user_id_from, $user_name_from, $user_id_to, $user_name_to, $message, $mentionedUsers);
     }
     $stats = new UserStatsTrack($user_id_to, $user_name_to);
     if ($message_type == 0) {
         // public message count
         $stats->incStatField('user_board_count');
     } else {
         // private message count
         $stats->incStatField('user_board_count_priv');
     }
     $stats = new UserStatsTrack($user_id_from, $user_name_from);
     $stats->incStatField('user_board_sent');
     return $dbw->insertId();
 }