Ejemplo n.º 1
0
 public function addComment()
 {
     $config = get_addon_config('LocalComment');
     $can_guest_comment = $config['can_guest_comment'];
     if (!$can_guest_comment) {
         //不允许游客评论
         if (!is_login()) {
             $this->error('请登录后评论。');
         }
     }
     //获取参数
     $app = strval($_REQUEST['app']);
     $mod = strval($_REQUEST['mod']);
     $row_id = intval($_REQUEST['row_id']);
     $content = strval($_REQUEST['content']);
     $uid = intval($_REQUEST['uid']);
     //调用API接口,添加新评论
     $data = array('app' => $app, 'mod' => $mod, 'row_id' => $row_id, 'content' => $content, 'uid' => is_login());
     D($app . '/' . $mod)->where(array('id' => $row_id))->setInc('reply_count');
     $commentModel = D('Addons://LocalComment/LocalComment');
     $data = $commentModel->create($data);
     if (!$data) {
         $this->error('评论失败:' . $commentModel->getError());
     }
     $commentModel->add($data);
     if (!is_login()) {
         if ($uid) {
             $title = '游客' . '评论了您';
             $message = '评论内容:' . $content;
             $url = $_SERVER['HTTP_REFERER'];
             D('Common/Message')->sendMessage($uid, $message, $title, $url, 0, 0, $app);
         }
         //返回结果
         $this->success('评论成功', 'refresh');
     } else {
         //给评论对象发送消息
         if ($uid) {
             $user = D('User/UcenterMember')->find(get_uid());
             $title = $user['username'] . '评论了您';
             $message = '评论内容:' . $content;
             $url = $_SERVER['HTTP_REFERER'];
             D('Common/Message')->sendMessage($uid, $message, $title, $url, get_uid(), 0, $app);
         }
     }
     //通知被@到的人
     $uids = get_at_uids($content);
     $uids = array_unique($uids);
     $uids = array_subtract($uids, array($uid));
     foreach ($uids as $uid) {
         $user = D('User/UcenterMember')->find($uid);
         $title = $user['username'] . '@了您';
         $message = '评论内容:' . $content;
         $url = $_SERVER['HTTP_REFERER'];
         D('Common/Message')->sendMessage($uid, $message, $title, $url, get_uid(), 0, $app);
     }
     //返回结果
     $this->success('评论成功', 'refresh');
 }
Ejemplo n.º 2
0
 public function insert()
 {
     $data['sendtype'] = I('sendtype', 0);
     $data['at'] = I('at', '');
     $data['title'] = I('title', '');
     $data['content'] = I('content', '');
     if ($data['content'] == '') {
         $this->mtReturn(300, '内容为空!');
     }
     if ($data['sendtype'] == 0 && $data['at'] == '') {
         $this->mtReturn(300, '没有@任何人!');
     }
     if ($data['sendtype'] == 0) {
         //通知被@到的人
         $uids = get_at_uids($data['at']);
         $uids = array_unique($uids);
         $count = 0;
         foreach ($uids as $uid) {
             $title = $data['title'];
             $message = $data['content'];
             if ($uid > 0) {
                 sendMessage($uid, 1, $title, $message, 0);
                 $count = $count + 1;
             }
             //
         }
         if ($count == 0) {
             $this->mtReturn(300, '@的人不存在!');
         } elseif ($count < count($uids)) {
             $this->mtReturn(200, '发送消息成功,但@的用户中有' . (count($uids) - $count) . '个不存在!');
         } else {
             $this->mtReturn(200, '发送消息成功!');
         }
     } else {
         $uids = D('member')->where(array('status' => 1))->getField('uid', true);
         $uids = array_subtract($uids, array(1));
         foreach ($uids as $uid) {
             $title = $data['title'];
             $message = $data['content'];
             sendMessage($uid, 1, $title, $message, 0);
         }
     }
     $this->mtReturn(200, '发送消息成功!');
 }
/**
 * send_comment  发布评论
 * @param $weibo_id
 * @param $content
 * @param int $comment_id
 * @return bool
 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com
 */
function send_comment($weibo_id, $content, $comment_id = 0)
{
    $uid = is_login();
    $result = M('WeiboComment')->addComment($uid, $weibo_id, $content, $comment_id);
    //行为日志
    action_log('add_weibo_comment', 'weibo_comment', $result, $uid);
    //通知轻博客作者
    $weibo = M('Weibo')->getWeiboDetail($weibo_id);
    M('Common/Message')->sendMessage($weibo['uid'], '评论消息', "评论内容:{$content}", 'Weibo/Index/weiboDetail', array('id' => $weibo_id), is_login(), 1);
    //通知回复的人
    if ($comment_id) {
        $comment = M('WeiboComment')->getComment($comment_id);
        if ($comment['uid'] != $weibo['uid']) {
            M('Common/Message')->sendMessage($weibo['uid'], '评论消息', "回复内容:{$content}", 'Weibo/Index/weiboDetail', array('id' => $weibo_id), is_login(), 1);
        }
    }
    $uids = get_at_uids($content);
    $uids = array_subtract($uids, array($weibo['uid'], $comment['uid']));
    send_at_message($uids, $weibo_id, $content);
    return $result;
}
Ejemplo n.º 4
0
/**
 * send_comment  发布评论
 * @param $weibo_id
 * @param $content
 * @param int $comment_id
 * @return bool
 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com
 */
function send_comment($weibo_id, $content, $comment_id = 0)
{
    $uid = is_login();
    $result = D('WeiboComment')->addComment($uid, $weibo_id, $content, $comment_id);
    //行为日志
    action_log('add_weibo_comment', 'weibo_comment', $result, $uid);
    //通知微博作者
    $weibo = D('Weibo')->getWeiboDetail($weibo_id);
    send_comment_message($weibo['uid'], $weibo_id, "评论内容:{$content}");
    //通知回复的人
    if ($comment_id) {
        $comment = D('WeiboComment')->getComment($comment_id);
        if ($comment['uid'] != $weibo['uid']) {
            send_comment_message($comment['uid'], $weibo_id, "回复内容:{$content}");
        }
    }
    $uids = get_at_uids($content);
    $uids = array_subtract($uids, array($weibo['uid'], $comment['uid']));
    send_at_message($uids, $weibo_id, $content);
    return $result;
}
Ejemplo n.º 5
0
/**
 * send_comment  发布评论
 * @param $weibo_id
 * @param $content
 * @param int $comment_id
 * @return bool
 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com
 */
function send_comment($weibo_id, $content, $comment_id = 0)
{
    $uid = is_login();
    $result = D('WeiboComment')->addComment($uid, $weibo_id, $content, $comment_id);
    if (!$result) {
        return false;
    }
    //行为日志
    action_log('add_weibo_comment', 'weibo_comment', $result, $uid);
    //通知微博作者
    $weibo = D('Weibo')->getWeiboDetail($weibo_id);
    send_comment_message($weibo['uid'], $weibo_id, L('_COMMENT_CONTENT_') . L('_COLON_') . "{$content}");
    //通知回复的人
    if ($comment_id) {
        $comment = D('WeiboComment')->getComment($comment_id);
        if ($comment['uid'] != $weibo['uid']) {
            send_comment_message($comment['uid'], $weibo_id, L('_REPLY_CONTENT_') . L('_COLON_') . "{$content}");
        }
    }
    $uids = get_at_uids($content);
    $uids = array_subtract($uids, array($weibo['uid'], $comment['uid']));
    send_at_message($uids, $weibo_id, $content);
    return $result;
}
Ejemplo n.º 6
0
 public function sendRepostComment($weibo_id, $content)
 {
     $result = $this->commentModel->addComment(get_uid(), $weibo_id, $content, 0);
     if (!$result) {
         return $this->apiError('评论失败:' . $this->commentModel->getError());
     }
     //写入数据库成功,记录动作,更新最后发送时间
     $increase_score = action_log_and_get_score('add_weibo_comment', 'WeiboComment', $result, is_login());
     $this->updateLastSendTime();
     //通知微博作者
     $weibo = $this->weiboModel->field('uid')->find($weibo_id);
     $this->sendCommentMessage($weibo['uid'], $weibo_id, "评论内容:{$content}");
     //通知被AT的人,除去微博作者、被回复的人,避免通知出现两次。
     $uids = get_at_uids($content);
     $uids = array_subtract($uids, array($weibo['uid']));
     $this->sendAtMessage($uids, $weibo_id, $content);
 }
 public function addComment()
 {
     $aPath = I('post.path', '', 'urldecode');
     $aPath = explode('/', $aPath);
     $aApp = $aPath[0];
     $aMod = $aPath[1];
     $aRowId = $aPath[2];
     $aUrl = I('post.this_url', '', 'text');
     $aExtra = I('post.extra', '', 'text');
     parse_str($aExtra);
     $field = empty($field) ? 'id' : $field;
     $can_guest = modC($aMod . '_LOCAL_COMMENT_CAN_GUEST', 1, $aApp);
     if (!$can_guest) {
         if (!is_login()) {
             $this->error('请登录后评论。');
         }
     }
     $aCountModel = I('get.count_model', '', 'text');
     $aCountField = I('get.count_field', '', 'text');
     $aContent = I('content', '', 'text');
     $aUid = I('get.uid', '', 'intval');
     if (empty($aContent)) {
         $this->error('评论内容不能为空');
     }
     $commentModel = $this->commentModel;
     $lookup = get_ip_lookup();
     $data = array('app' => $aApp, 'mod' => $aMod, 'row_id' => $aRowId, 'content' => $aContent, 'uid' => is_login(), 'ip' => get_client_ip(1), 'area' => $lookup['province'] . $lookup['city']);
     $res = $commentModel->addComment($data);
     if ($res) {
         M($aCountModel)->where(array('id' => $aRowId))->setInc($aCountField);
         $class = get_addon_class('LocalComment');
         $object = new $class();
         $html = $object->getCommentHtml($res);
         if (!is_login()) {
             if ($aUid) {
                 $title = '游客' . '评论了您';
                 $message = '评论内容:' . $aContent;
                 M('Common/Message')->sendMessage($aUid, $title, $message, $aUrl, array($field => $aRowId), 0);
             }
             $result['status'] = 1;
             $result['data'] = $html;
             $result['info'] = '评论成功';
             $this->ajaxReturn($result);
         }
         if ($aUid) {
             $user = query_user(array('nickname', 'uid'), is_login());
             $title = $user['nickname'] . '评论了您';
             $message = '评论内容:' . $aContent;
             M('Common/Message')->sendMessage($aUid, $title, $message, $aUrl, array($field => $aRowId));
         }
         //通知被@到的人
         $uids = get_at_uids($aContent);
         $uids = array_unique($uids);
         $uids = array_subtract($uids, array($aUid));
         foreach ($uids as $uid) {
             $user = query_user(array('nickname', 'uid'), is_login());
             $title = $user['nickname'] . '@了您';
             $message = '评论内容:' . $aContent;
             M('Common/Message')->sendMessage($uid, $title, $message, $aUrl, array($field => $aRowId));
         }
         $result['status'] = 1;
         $result['data'] = $html;
         $result['info'] = '评论成功';
         $this->ajaxReturn($result);
     } else {
         $result['status'] = 0;
         $result['data'] = '';
         $result['info'] = '评论失败';
         $this->ajaxReturn($result);
     }
 }
 public function addLocalComment()
 {
     $aPath = I('post.path', '', 'urldecode');
     $aPath = explode('/', $aPath);
     $aApp = $aPath[0];
     $aMod = $aPath[1];
     $aRowId = $aPath[2];
     $aUrl = I('post.this_url', '', 'text');
     $aExtra = I('post.extra', '', 'text');
     parse_str($aExtra);
     $field = empty($field) ? 'id' : $field;
     if (!is_login()) {
         $this->error('请登录后评论。');
     }
     $aCountModel = I('get.count_model', '', 'text');
     $aCountField = I('get.count_field', '', 'text');
     $aContent = I('content', '', 'text');
     $aUid = I('get.uid', '', 'intval');
     if (empty($aContent)) {
         $this->error('评论内容不能为空');
     }
     $commentModel = M('Addons://LocalComment/LocalComment');
     $data = array('app' => $aApp, 'mod' => $aMod, 'row_id' => $aRowId, 'content' => $aContent, 'uid' => is_login(), 'ip' => get_client_ip(1));
     $res = $commentModel->addComment($data);
     if ($res) {
         M($aCountModel)->where(array('id' => $aRowId))->setInc($aCountField);
         $comment = $commentModel->getComment($res);
         $this->assign('localcomment', $comment);
         $html = $this->fetch('localcomment');
         if ($aUid) {
             $user = query_user(array('nickname', 'uid'), is_login());
             $title = $user['nickname'] . '评论了您';
             $message = '评论内容:' . $aContent;
             M('Common/Message')->sendMessage($aUid, $title, $message, $aUrl, array($field => $aRowId));
         }
         //通知被@到的人
         $uids = get_at_uids($aContent);
         $uids = array_unique($uids);
         $uids = array_subtract($uids, array($aUid));
         foreach ($uids as $uid) {
             $user = query_user(array('nickname', 'uid'), is_login());
             $title = $user['nickname'] . '@了您';
             $message = '评论内容:' . $aContent;
             M('Common/Message')->sendMessage($uid, $title, $message, $aUrl, array($field => $aRowId));
         }
         $result['status'] = 1;
         $result['data'] = $html;
         $result['info'] = '评论成功';
         $this->ajaxReturn($result);
     } else {
         $result['status'] = 0;
         $result['data'] = '';
         $result['info'] = '评论失败';
         $this->ajaxReturn($result);
     }
 }
Ejemplo n.º 9
0
 public function addComment()
 {
     $config = get_addon_config('LocalComment');
     $can_guest_comment = $config['can_guest_comment'];
     if (!$can_guest_comment) {
         //不允许游客评论
         if (!is_login()) {
             $this->error('请登录后评论。');
         }
     }
     //获取参数
     $app = strval($_REQUEST['app']);
     $mod = strval($_REQUEST['con']);
     $row_id = intval($_REQUEST['row_id']);
     $content = strval($_REQUEST['content']);
     $uid = intval($_REQUEST['uid']);
     $pid = intval($_REQUEST['pid']);
     if (M($mod)->where(array('id' => $row_id))->getField('status') != 1) {
         $this->error('该文章尚未审核通过!');
     }
     $data = array('app' => $app, 'con' => $mod, 'row_id' => $row_id, 'content' => $content, 'uid' => is_login(), 'pid' => $pid);
     $commentModel = D('Addons://LocalComment/LocalComment');
     $data = $commentModel->create($data);
     if (!$data) {
         $this->error('评论失败:' . $commentModel->getError());
     } else {
         D($app . '/' . $mod)->where(array('id' => $row_id))->setInc('reply_count');
         $rowinfo = D($app . '/' . $mod)->where(array('id' => $row_id))->find();
         $data['content'] = op_h($data['content'], 'font');
         $commentModel->add($data);
         if (!is_login()) {
             if ($uid) {
                 $title = '游客' . '评论了您';
                 $message = '评论内容:' . $content;
                 $url = $_SERVER['HTTP_REFERER'];
                 if (strtolower($mod) == 'article') {
                     $rowurl = U('Home/Index/artc', array('id' => $row_id));
                 }
                 if (strtolower($mod) == 'music') {
                     $rowurl = U('Home/Index/musicc', array('id' => $row_id));
                 }
                 if (strtolower($mod) == 'group') {
                     $rowurl = U('Home/Index/groupc', array('id' => $row_id));
                 }
                 sendMessage($rowinfo['uid'], '0', $title, $message . ',链接地址:<a href="' . $rowurl . '">' . $rowinfo['title'] . '</a>', 0);
             }
             //返回结果
             $this->success('评论成功', 'refresh');
         } else {
             //给评论对象发送消息
             if ($uid) {
                 $user = D('Member')->find(getnowUid());
                 $title = $user['nickname'] . '评论了您';
                 $message = '评论内容:' . $content;
                 $url = $_SERVER['HTTP_REFERER'];
                 if ($rowinfo['uid'] != getnowUid()) {
                     if (strtolower($mod) == 'article') {
                         $rowurl = U('Home/Index/artc', array('id' => $row_id));
                     }
                     if (strtolower($mod) == 'music') {
                         $rowurl = U('Home/Index/musicc', array('id' => $row_id));
                     }
                     if (strtolower($mod) == 'group') {
                         $rowurl = U('Home/Index/groupc', array('id' => $row_id));
                     }
                     sendMessage($rowinfo['uid'], getnowUid(), $title, $message . ',链接地址:<a href="' . $rowurl . '">' . $rowinfo['title'] . '</a>', 0);
                 }
             }
         }
         //通知被@到的人
         $uids = get_at_uids($content);
         $uids = array_unique($uids);
         $uids = array_subtract($uids, array($uid));
         foreach ($uids as $uid) {
             $user = D('Member')->find(getnowUid());
             $title = $user['nickname'] . '@了您';
             $message = '评论内容:' . $content;
             $url = $_SERVER['HTTP_REFERER'];
             sendMessage($uid, getnowUid(), $title, $message . ',链接地址:<a href="' . U('Index/artc', array('id' => $row_id)) . '">' . $rowinfo['title'] . '</a>', 0);
         }
         //返回结果
         $this->success('评论成功');
     }
 }