Jump to navigation

You are currently browsing all posts tagged with '提醒'

把新短消息加入到discuz的提醒里面

  • Posted on February 28, 2010 at 5:03 pm

discuz 7.2 gbk版

discuz的默认情况:
接收到新短消息之后,会发出声音;有了新的提醒之后,“提醒”二个字前面会出现红色信封。 新短消息和提醒之间没有任何的联系。
如果用户的电脑没有打开声音,就无法知道是否有了新的短消息。因此,需要把新短消息加入到提醒里面。

在forumdata/cache/cache_settings.php中,我们可以看到
632   ‘promptkeys’ =>
633   array (
634     1 => ‘pm’,
635     2 => ‘announcepm’,
636     3 => ‘task’,
637     4 => ‘systempm’,
638     5 => ‘friend’,
639     6 => ‘threads’,
640   ),
641   ‘prompts’ =>
642   array (
643     ‘pm’ =>
644     array (
645       ‘name’ => ‘私人消息’,
646       ‘script’ => ‘pm.php?filter=newpm’,
647       ‘id’ => ’1′,
648       ‘new’ => 0,
649     ),
650     ‘announcepm’ =>
651     array (
652       ‘name’ => ‘公共消息’,
653       ‘script’ => ‘pm.php?filter=announcepm’,
654       ‘id’ => ’2′,
655       ‘new’ => 0,
656     ),
657     ‘task’ =>
658     array (
659       ‘name’ => ‘论坛任务’,
660       ‘script’ => ‘task.php?item=doing’,
661       ‘id’ => ’3′,
662       ‘new’ => 0,
663     ),
664     ‘systempm’ =>
665     array (
666       ‘name’ => ‘系统消息’,
667       ‘script’ => ”,
668       ‘id’ => ’4′,
669       ‘new’ => 0,
670     ),
671     ‘friend’ =>
672     array (
673       ‘name’ => ‘好友消息’,
674       ‘script’ => ”,
675       ‘id’ => ’5′,
676       ‘new’ => 0,
677     ),
678     ‘threads’ =>
679     array (
680       ‘name’ => ‘帖子消息’,
681       ‘script’ => ”,
682       ‘id’ => ’6′,
683       ‘new’ => 0,
684     ),
685   ),

dz已经预留了pm与announcepm 专门给新短消息来用。
我们需要做的就是 在用户发送完短消息后,插入一条提醒就可以了。
修改uc_client/control/pm.php   function onsendpm()
加入一行

require_once $_SERVER['DOCUMENT_ROOT']."/include/global.func.php";

然后在本函数中搜索

$lastpmid = $_ENV['pm']->sendpm(

在这一行之后,加入:

if ($fromuid)
$notice_message = "<div>收到新的短消息  来自:<a target=_blank href=\"{boardurl}space-uid-".$this->user['uid'].".html\">".$this->user['username']."</a><BR>".htmlspecialchars($message)."<BR><a href=\"{boardurl}pm.php?filter=newpm&uid=".$this->user['uid']."#new\" target=_blank>查看消息</a></div>";
else
$notice_message = "<div>收到新的短消息  <BR>".htmlspecialchars($message)."<BR><a href=\"{boardurl}pm.php?filter=newpm\" target=_blank>查看消息</a></div>";
sendnotice($uid, $notice_message, $notice_typeid);

等等,还没完,还有其它文件要改。
修改 /notice.php

$typeadd = $filter ? "AND typeid='".$prompts[$filter]['id']."'" : "AND typeid IN (".implodeids($promptpmids).")";

之前,加一行:

array_push($promptpmids, 1);

从promptkeys数组中可以看到,1对应的是”pm”.

还要改一下模板:
templates/default/notice.htm
在 <!–{loop $prompts $promptkey $promptdata}–> 里面,把下面的if改成:

<!--{if $promptkey!='announcepm'}-->

即可。

Top