让NexusPHP支持@功能

@user文件包下载:点击下载

先下载@user文件包,将里面的三个文件上传至文件夹根目录(当然,js和css样式文件可以传到其它目录,确保路径正确就行了),这里为了省事,我上传的是根文件夹下面

1、修改include文件夹下面的functions.php文件

funtion.php搜索:

1 print("<td align=\"left\"><textarea class=\"bbcode\" cols=\"100\" style=\"width: 650px;\" name=\"".$text."\" id=\"".$text."\" rows=\"20\" onkeydown=\"ctrlenter(event,'compose','qr')\">".$content."</textarea>");

 在下面添加 

1 ?>
2 <link rel="stylesheet" href="userAutoTips.css" type="text/css">
3 <script type="text/javascript" src="userAutoTips.js"></script>
4 <script type="text/javascript">userAutoTips({id:'<?php  echo $text?>'});$(window).bind('scroll resize', function(e){userAutoTips({id:'<?php  echo $text?>'})})</script>

 继续搜索function quickreply($formname, $taname,$submit){

在该方法的最后一行添加 

1 <link rel="stylesheet" href="userAutoTips.css" type="text/css">
2 <script type="text/javascript" src="userAutoTips.js"></script>
3 <script type="text/javascript">userAutoTips({id:'qrbody'});$(window).bind('scroll resize', function(e){userAutoTips({id:'qrbody'})})</script>

 该方法中textarea 添加ID参数(红色部分)

1 print("<textarea id=\"qrbody\" name='".$taname."' cols=\"100\" rows=\"8\" style=\"width: 450px\" onkeydown=\"ctrlenter(event,'compose','qr')\"></textarea>");

 2、种子回复评论页面为comment.php,论坛帖子回复页面为:forums.php

下面以修改forums.php页面为例,(comment.php回复的话系统会自动发送消息的,只不过由于改了functions.php,@还是会显示用户名的,不过不发送系统定义消息)

// ------------- start: functions ------------------//下面添加如下方法

 1 function at_user_message($topicid,$body,$postid){
 2 global $Cache;
 3             $subject="You may be @";
 4            $url=$BASEURL."/forums.php?action=viewtopic&topicid=".$topicid."&page=p".$postid."#pid".($postid);
 5            $address="[url=$url]"."Click here to view the detail"."[/url]";
 6                         preg_match_all( "/\[@([0-9]+?)\]/ei",$body,$useridget);
 7                         $useridget[1] = array_unique($useridget[1]);
 8                         for($i = 0;$i < min(10,count($useridget[1])); $i++){
 9                         sql_query("INSERT INTO messages (sender, receiver, subject, msg, added) VALUES(0, " . $useridget[1][$i] . ",'$subject','$address', ".sqlesc(date("Y-m-d H:i:s")).")");
10                         $Cache->delete_value('user_'.$useridget[1][$i].'_unread_message_count');
11                         $Cache->delete_value('user_'.$useridget[1][$i].'_inbox_count');
12                         }
13 }

搜索$postid = mysql_insert_id()

在这一行下面添加如下部分(调用上面的函数语句) 

1  at_user_message($topicid,$body,$postid);

 后就可以使用功能了,@某一位后,系统会发送短消息的。(comment.php可以根据需求修改at_user_message函数

posted @ 2013-05-21 17:31  茗迹周  阅读(925)  评论(2编辑  收藏  举报