/** * 按用户ID发送私信 * * @param int $uid * @param string $content * @return PwError|boolean */ public function sendMessageByUid($uid, $content, $fromUid = 0) { if (!$uid) { return new PwError('MESSAGE:user.empty'); } $fromUid or $fromUid = $this->_getLoginUserId(); if ($uid == $fromUid) { return new PwError('MESSAGE:send.to.myself'); } Wind::import('LIB:ubb.PwUbbCode'); $content = PwUbbCode::autoUrl($content, true); // 发消息前hook if (($result = $this->_getHook()->runWithVerified('check', $fromUid, $content, $uid)) instanceof PwError) { return $result; } $result = $this->_getWindid()->send($uid, $content, $fromUid); if ($result < 1) { return new PwError('WINDID:code.' . $result); } /* @var $creditBo PwCreditBo */ Wind::import('SRV:credit.bo.PwCreditBo'); $creditBo = PwCreditBo::getInstance(); $creditBo->operate('sendmsg', new PwUserBo($fromUid)); // 发消息扩展 $this->_getHook()->runDo('addMessage', $uid, $fromUid, $content); if ($result) { //发件人通知 $params = array('from_uid' => $uid, 'to_uid' => $fromUid, 'content' => $content, 'is_send' => 1); $this->_getNoticeService()->sendNotice($fromUid, 'message', $uid, $params, false); //收件人通知 $params = array('from_uid' => $fromUid, 'to_uid' => $uid, 'content' => $content); $this->_getNoticeService()->sendNotice($uid, 'message', $fromUid, $params, false); //更新用户表未读数 $this->updateUserMessage($uid); } //记录每天发送数量 $this->_getUserBehaviorDs()->replaceDayBehavior($fromUid, 'message_today', Pw::getTime()); return $result; }
protected function _dateFormat() { if (isset($this->_data['content'])) { $this->_data['content'] = PwUbbCode::autoUrl($this->_data['content'], true); $useubb = 0; if ($this->hide) { $this->_data['content'] = "[post]" . str_replace(array('[post]', '[/post]'), "", $this->_data['content']) . "[/post]"; $useubb = 1; } if ($this->user && preg_match('/\\[sell=(\\d+)(\\,(\\d+))?\\].+?\\[\\/sell\\]/is', $this->_data['content'], $matchs)) { $this->_data['content'] = $this->_formatSell($this->_data['content'], $matchs); $useubb = 1; } if ($this->_data['reminds']) { $useubb = 1; } if (!$useubb) { $useubb = $this->_data['content'] == PwUbbCode::convert($this->_data['content'], new PwUbbCodeConvertThread()) ? 0 : 1; } $this->_setUseubb($useubb); } }