Discuz!信息、提醒和私信发送函数sendpm()解析
该函数用于发送短消息(包括私人消息、系统消息、提醒消息等)函数定义于:\source\function\function_core.phpfunction sendpm($toid, $subject, $message, $fromid = '', $replypmid = 0, $isusername = 0, $type = 0) {return helper_pm::sendpm($toid, $subject, $message, $fromid, $replypmid, $isusername, $type);
}helper_pm::sendpm位于:\source\class\helper\helper_pm.phpclass helper_pm {
public static function sendpm($toid, $subject, $message, $fromid = '', $replypmid = 0, $isusername = 0, $type = 0) {
global $_G;
if($fromid === '') {
$fromid = $_G['uid'];
}
$author = '';
if($fromid) {
if($fromid == $_G['uid']) {
$sendpmmaxnum = $_G['group']['allowsendpmmaxnum'];
$author = $_G['username'];
} else {
$user = getuserbyuid($fromid);
$author = $user['username'];
loadcache('usergroup_'.$user['groupid']);
$sendpmmaxnum = $_G['cache']['usergroup_'.$user['groupid']]['allowsendpmmaxnum'];
}
$currentnum = C::t('common_member_action_log')->count_day_hours(getuseraction('pmid'), $fromid);
if($sendpmmaxnum && $currentnum >= $sendpmmaxnum) {
return -16;
}
}
loaducenter();
$return = uc_pm_send($fromid, $toid, addslashes($subject), addslashes($message), 1, $replypmid, $isusername, $type);
if($return > 0 && $fromid) {
foreach(explode(',', $fromid) as $v) {
useractionlog($fromid, 'pmid');
}
}
return $return;
}
}参数含义:$toid参数是接收短消息的用户UID;$subject参数是短消息的标题;$message参数是短消息的正文内容;$fromid参数是发送短消息的用户UID;需要注意:当$toid为0时,消息类型为公共消息,$fromid为0时,消息类型为系统消息,$message这个消息内容的参数,不支持HTML,但是支持Discuz!代码。
页:
[1]