切换风格

紫电网站开发随笔

 找回密码
 立即注册

QQ登录

只需一步,快速开始

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 27968|回复: 0

Discuz!信息、提醒和私信发送函数sendpm()解析

[复制链接]

16

主题

20

帖子

1977

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1977
发表于 2018-11-27 15:33:41 | 显示全部楼层 |阅读模式

该函数用于发送短消息(包括私人消息、系统消息、提醒消息等)

函数定义于:\source\function\function_core.php

  1. function sendpm($toid, $subject, $message, $fromid = '', $replypmid = 0, $isusername = 0, $type = 0) {
  2.         return helper_pm::sendpm($toid, $subject, $message, $fromid, $replypmid, $isusername, $type);
  3. }
复制代码

helper_pm::sendpm位于:\source\class\helper\helper_pm.php

  1. class helper_pm {


  2.         public static function sendpm($toid, $subject, $message, $fromid = '', $replypmid = 0, $isusername = 0, $type = 0) {
  3.                 global $_G;
  4.                 if($fromid === '') {
  5.                         $fromid = $_G['uid'];
  6.                 }
  7.                 $author = '';
  8.                 if($fromid) {
  9.                         if($fromid == $_G['uid']) {
  10.                                 $sendpmmaxnum = $_G['group']['allowsendpmmaxnum'];
  11.                                 $author = $_G['username'];
  12.                         } else {
  13.                                 $user = getuserbyuid($fromid);
  14.                                 $author = $user['username'];
  15.                                 loadcache('usergroup_'.$user['groupid']);
  16.                                 $sendpmmaxnum = $_G['cache']['usergroup_'.$user['groupid']]['allowsendpmmaxnum'];
  17.                         }
  18.                         $currentnum = C::t('common_member_action_log')->count_day_hours(getuseraction('pmid'), $fromid);
  19.                         if($sendpmmaxnum && $currentnum >= $sendpmmaxnum) {
  20.                                 return -16;
  21.                         }
  22.                 }

  23.                 loaducenter();
  24.                 $return = uc_pm_send($fromid, $toid, addslashes($subject), addslashes($message), 1, $replypmid, $isusername, $type);
  25.                 if($return > 0 && $fromid) {
  26.                         foreach(explode(',', $fromid) as $v) {
  27.                                 useractionlog($fromid, 'pmid');
  28.                         }
  29.                 }

  30.                 return $return;
  31.         }
  32. }
复制代码

参数含义:

$toid参数是接收短消息的用户UID;

$subject参数是短消息的标题;

$message参数是短消息的正文内容;

$fromid参数是发送短消息的用户UID;

需要注意:当$toid为0时,消息类型为公共消息,$fromid为0时,消息类型为系统消息,$message这个消息内容的参数,不支持HTML,但是支持Discuz!代码。


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

顶部qrcode底部
帅的人都用微信扫了!

QQ|Archiver|手机版|小黑屋|紫电插件 ( 京ICP备16066493号-3 )

GMT+8, 2024-3-28 23:42 , Processed in 0.216766 second(s), 6 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表