예제 #1
0
 /**
  * postMessage 
  * 
  * @param array $pParamHash 
  * @access public
  * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
  */
 function postMessage($pParamHash)
 {
     global $gBitSmarty, $gBitUser, $gBitSystem;
     if ($this->verifyMessage($pParamHash)) {
         $this->mDb->associateInsert(BIT_DB_PREFIX . "messages", $pParamHash['message_store']);
         // we need to load the user this message is being sent to that we can check if the user should be notified by email
         $queryUser = new BitUser($pParamHash['userInfo']['user_id']);
         $queryUser->load();
         if ($queryUser->getPreference('messages_min_priority') && $queryUser->getPreference('messages_min_priority') <= $pParamHash['message_store']['priority']) {
             if (!empty($pParamHash['userInfo']['email'])) {
                 $gBitSmarty->assign('msgHash', $pParamHash['message_store']);
                 $gBitSmarty->assign('from', stripslashes($gBitUser->getDisplayName()));
                 @mail($pParamHash['userInfo']['email'], tra('New message arrived from ') . $gBitSystem->getConfig('kernel_server_name', $_SERVER["SERVER_NAME"]), $gBitSmarty->fetch('bitpackage:messages/message_notification.tpl'), "From: " . $gBitSystem->getConfig('site_sender_email') . "\r\nContent-type: text/plain;charset=utf-8\r\n");
             }
         }
     }
     return count($this->mErrors) == 0;
 }