Discuz!发送系统通知方法notification_add解析

discuz教程
方法定义位置:

source\function\function_core.php

代码如下:

[php] view plain copy

function notification_add($touid, $type, $note, $notevars = array(), $system = 0) {

return helper_notification::notification_add($touid, $type, $note, $notevars, $system);

}

参数说明:

$touid:接收通知的uid,即发给谁;

$type:通知类型,如system为系统通知,这里$type参数稍微复制一点,下面我们把type参数的各种意义罗列出来供大家参考:

appId(数字) 漫游应用

myapp 应用邀请或请求

credit 积分充值

goods 商品

mod_member 用户审核

system 系统消息

group 群组审核通过

report 举报

verify 认证

manage_ 管理通知

magic 道具

poke 打招呼

friend 好友

task 任务

wall 留言

piccomment 图片评论

blogcomment 日志评论

sharecomment 分享评论

follow 关注

pusearticle 推送

at @功能

pcomment 点评

post 回帖引用

show 排行榜

clickblog 日志顶操作

clickarticle 文章顶操作

clickpic 图片顶操作

doing 记录

pmreport 消息举报

sharenotice 分享通知

group 群组

reward 悬赏

activity 活动

thread 主题

blog 日志

article 文章

$note:通知内容,支持html代码;

$notevars:附加参数,如:actor、from_num、from_id、from_idtype

$system:是否系统通知,默认0,强制转为系统通知;

详细代码逻辑参考helper_notification类代码

helper类所在位置:

\source\class\helper\helper_notification.php

相关代码如下:

  1. [php] view plain copypublic static function notification_add($touid, $type, $note, $notevars = array(), $system = 0, $category = -1) { global $_G; if(!($tospace = getuserbyuid($touid))) { return false; } space_merge($tospace, 'field_home'); $filter = empty($tospace['privacy']['filter_note'])?array():array_keys($tospace['privacy']['filter_note']); if($filter && (in_array($type.'|0', $filter) || in_array($type.'|'.$_G['uid'], $filter))) { return false; } if($category == -1) { $category = 0; $categoryname = ''; if($type == 'follow' || $type == 'follower') { switch ($type) { case 'follow' : $category = 5; break; case 'follower' : $category = 6; break; } $categoryname = $type; } else { foreach($_G['notice_structure'] as $key => $val) { if(in_array($type, $val)) { switch ($key) { case 'mypost' : $category = 1; break; case 'interactive' : $category = 2; break; case 'system' : $category = 3; break; case 'manage'爱站库温馨提示:如果你正在寻找优秀的discuz模板,那你可以到爱站库的 discuz模板 频道看看,相信一定有你喜欢的!

标签: