Example #1
0
 public function comment()
 {
     $id = intval($this->input['status_id']);
     $content = $this->input['text'];
     $transmit_type = intval($this->input['transmit_type']);
     !$this->input['cid'] && ($cid = 0);
     $result = $this->mComment->comment($id, $content, $cid);
     if ($result && is_array($result)) {
         $result['content'] = hg_verify($result['content']);
         $result['comment_time'] = $result['comment_time'];
         $result['create_at'] = hg_get_date($result['create_at']);
     }
     //同时转发到我的点滴
     if ($transmit_type == 1) {
         $status = new status();
         $status->update($content, '点滴', $id);
     }
     if ($this->user['id'] != $result['status']['user']['id']) {
         include_once ROOT_PATH . 'lib/class/notify.class.php';
         $notify = new notify();
         $content = array('title' => '新评论', 'page_link' => SNS_MBLOG . 'all_comment.php');
         $content = serialize($content);
         $notyfy_arr = $notify->notify_send($result['status']['member_id'], $content, 2);
         //发新评论通知
     }
     $result['text'] = hg_verify($result['text']);
     $result = json_encode($result);
     print_r($result);
 }
Example #2
0
    public function reply()
    {
        include_once ROOT_DIR . 'lib/class/settings.class.php';
        $setting = new settings();
        $result_setttings = $setting->getMark('mblog_comment');
        if (!empty($result_setttings) && $result_setttings['state']) {
            $this->errorOutput('评论回复已关闭');
        }
        $userinfo = $this->mUser->verify_credentials();
        if (!$userinfo['id']) {
            $this->errorOutput(USENAME_NOLOGIN);
        }
        $status_id = intval($this->input['status_id']);
        $cid = intval($this->input['cid']);
        $text = urldecode($this->input['text']);
        (!$status_id || !$text) && $this->errorOutput(OBJECT_NULL);
        //点滴id为空就返回错误
        $time = time();
        $query_info = $this->db->query_first('SELECT member_id FROM ' . DB_PREFIX . 'status_comments WHERE id = ' . $cid);
        !$query_info && $this->errorOutput(OBJECT_NULL);
        $sql = 'INSERT INTO ' . DB_PREFIX . 'status_comments ( status_id , member_id , content , comment_time , reply_comment_id , reply_member_id )
				VALUES(' . $status_id . ', ' . $userinfo['id'] . ', "' . $text . '" , "' . $time . '" , ' . $cid . ',' . $query_info['member_id'] . ')';
        $this->db->query($sql);
        $insert_id = $this->db->insert_id();
        $query_info = $this->db->query_first('SELECT member_id FROM ' . DB_PREFIX . 'status_comments WHERE status_id = ' . $status_id . ' AND id = ' . $cid);
        //将该条点滴的评论次数加1
        $this->db->query('UPDATE ' . DB_PREFIX . 'status_extra SET comment_count = comment_count + 1 WHERE status_id = ' . $status_id);
        $members = $this->mUser->getUserById($userinfo['id']);
        $members = $members[0];
        $status = $this->mStatus->show($status_id);
        $return_array = array('id' => $insert_id, 'text' => $text, 'create_at' => $time, 'reply_member_id' => $query_info['member_id'], 'reply_comment_id' => $cid, 'status' => $status[0], 'user' => $members);
        if ($userinfo['id'] != $query_info['member_id'] && $userinfo['id'] != $status[0]['user']['id']) {
            $notify_userid = $query_info['member_id'] . ',' . $status[0]['user']['id'];
            //加通知
            include_once ROOT_PATH . 'lib/class/notify.class.php';
            $notify = new notify();
            $content = array('title' => '新回复', 'page_link' => SNS_MBLOG . 'all_comment.php');
            $content = serialize($content);
            $notyfy_arr = $notify->notify_send($notify_userid, $content, 2);
            //发新评论通知
        }
        $this->addItem($return_array);
        $this->output();
    }
Example #3
0
 /**
  * 验证text中搜含是否含有话题,用户名
  * @param $text 传入话题
  * @param $id 用户ID
  */
 private function verify($text, $id)
 {
     $pattern = "/@([\\x{4e00}-\\x{9fa5}0-9A-Za-z_-]+)[\\s::,,.。\\'‘’\"“”、!!]/iu";
     //这里牵扯到用户名命名规则问题
     if (preg_match_all($pattern, $text, $username)) {
         foreach ($username[1] as $value) {
             $name[] = $value;
         }
         $screen_name = implode(",", $name);
         $userInfo = $this->member->getMemberByName($screen_name);
         if ($userInfo) {
             include_once ROOT_PATH . 'lib/class/notify.class.php';
             $notify = new notify();
             foreach ($userInfo as $key => $value) {
                 $ids[] = $value['id'];
             }
             $sql = "INSERT IGNORE INTO " . DB_PREFIX . "status_member \r\n\t\t\t\t(status_id,member_id)\r\n\t\t\t\tVALUES";
             foreach ($ids as $value) {
                 $sql .= "(" . $id . ",\r\n\t\t\t\t\t" . $value . "),";
                 $idd .= $value . ",";
             }
             $idd = rtrim($idd, ",");
             $content = array('title' => '提到我的', 'page_link' => SNS_MBLOG . 'atme.php');
             $notyfy_arr = $notify->notify_send($idd, serialize($content), 3);
             //提到我的通知
             $sql = rtrim($sql, ",");
             $this->db->query($sql);
         }
     }
     $pattern = "/#([\\x{4e00}-\\x{9fa5}0-9A-Za-z_-]+)[\\s#]/iu";
     //这里牵扯到话题规则问题
     if (preg_match_all($pattern, $text, $topic)) {
         foreach ($topic[1] as $key => $value) {
             $topics[] = "'" . strtoupper($value) . "'";
             $title[] = $value;
         }
         $topics = implode(",", $topics);
         $sql = "SELECT * FROM " . DB_PREFIX . "topic WHERE title IN(" . $topics . ")";
         $query = $this->db->query($sql);
         while ($array = $this->db->fetch_array($query)) {
             $topicid[] = $array['id'];
             $data[] = $array;
             $topictitle[] = $array['title'];
         }
         if (!count($topictitle)) {
             $newtitle = $title;
         } else {
             if (count($topictitle) <= count($title)) {
                 $newtitle = array_diff($title, $topictitle);
             } else {
                 $newtitle = array_diff($topictitle, $title);
             }
         }
         if ($newtitle) {
             $topicids = array();
             foreach ($newtitle as $value) {
                 $value = str_replace("#", "", trim($value));
                 $sql = "INSERT INTO " . DB_PREFIX . "topic(\r\n\t\t\t\ttitle,\r\n\t\t\t\trelate_count,\r\n\t\t\t\tstatus\r\n\t\t\t\t)\r\n\t\t\t\tVALUES('" . $value . "',1,0)";
                 $this->db->query($sql);
                 $topicids[] = $this->db->insert_id();
             }
             $this->updateStatusTopic($topicids);
         } else {
             foreach ($data as $value) {
                 $relate_count = $value['relate_count'] + 1;
                 $sql = "UPDATE " . DB_PREFIX . "topic \r\n\t\t\t\t\tSET relate_count = " . $relate_count . " \r\n\t\t\t\t\tWHERE id=" . $value['id'];
                 $this->db->query($sql);
             }
             $this->updateStatusTopic($topicid);
         }
     }
     return $text;
 }
Example #4
0
     $result = $this->libactivity->getActivityApply('id,action_id', array('action_id' => $action_id, 'apply_status' => 1, 'state' => 1), 0, -1, '');
     if ($result) {
         $ids = $sp = '';
         foreach ($result as $k => $v) {
             $ids .= $sp . $v['id'];
             $sp = ',';
         }
         //更新待审核为免审核
         if ($this->libactivity->updateActivityApply(array('id' => ids, 'action_id' => action_id, 'apply_status' => 0), true)) {
             //更新申请通过的人数
             $this->libactivity->updateActivity(array('yet_join' => count($result), 'action_id' => action_id), true, true);
         }
     }
     return $result;
 }
 //关闭
 public function delete()
 {
     $data = $this->getData();
     if (!$data['action_id'] || !is_numeric($data['action_id'])) {
         $this->errorOutput("你搜索得活动id参数不合法");
     }
     $rawData = $this->libactivity->get('activity', 'team_id,state', array('action_id' => $data['action_id']), 0, 1, array());
     if (!$rawData['state']) {
         $this->errorOutput("你搜索得活动不存在");
     }
     $state = isset($this->input['state']) ? intval($this->input['state']) : 1;
     //关闭
     $tata['state'] = $state;
     $result = $this->libactivity->update('activity', $tata, array('action_id' => $data['action_id']), array());
     if ($result && $tata['state'] != $rawData['state']) {
         if ($tata['state'] == 2 && $rawData['state'] == 1) {
             //更新对应小组的活动总数
             $this->team->update_total(array('action_num' => -1, 'team_id' => $rawData['team_id']));
             //删除标签
             $this->libmark->delete_source_id_mark(array('source_id' => $data['action_id'], 'source' => 'activity', 'action' => 'keywords', 'parent_id' => $rawData['team_id']));
         } else {
             if ($tata['state'] == 1 && $rawData['state'] == 2) {
                 $this->team->update_total(array('action_num' => 1, 'team_id' => $rawData['team_id']));
             } else {
                 if ($tata['state'] == 0) {
                     if ($rawData['state'] == 1) {
                         //更新对应小组的活动总数
                         $this->team->update_total(array('action_num' => -1, 'team_id' => $rawData['team_id']));
                         //删除标签
                         $this->libmark->delete_source_id_mark(array('source_id' => $data['action_id'], 'source' => 'activity', 'action' => 'keywords', 'parent_id' => $rawData['team_id']));
                     }
                     //nothing todo
                 } else {
                     $this->errorOutput("你更新的活动已经被删除,不可以回复");
                 }
             }
         }
     }
     if ($result) {
         //获取参与行动的用户信息
         $member_info = $this->libactivity->get('activity_apply', 'user_id', array('action_id' => $data['action_id']), 0, -1);
         if ($member_info) {
             //发送通知
             include_once ROOT_PATH . '/lib/class/notify.class.php';
             $notify = new notify();
             $send_arr = array();
Example #5
0
         }
     }
     $this->output();
 }
 //创建
 public function create()
 {
     $data = array();
     //加载数据
     $data = $this->getData();
     //加载原始数据
     $rawData = $this->libactivity->get('activity_apply', 'id,apply_status', array('user_id' => $data['user_id'], 'action_id' => $data['action_id'], 'state' => 1), 0, 1, array());
     $result = $this->team->get_permission($data['team_id'], $data['user_id'], 'ADD_ACTIVITY');
     if (!$result['permission']) {
         //$this->errorOutput("你没有权限操作");
     }
     //加载创建时间
     $data['apply_time'] = TIMENOW;
     //来源ip
     $data['from_ip'] = hg_getip();
     //来源部分
     $data['app_name'] = $this->user['display_name'];
     //来源客户端
     $data['client'] = $_SERVER['HTTP_USER_AGENT'];
     //有效的
     $data['state'] = 1;
     unset($data['team_id']);
     if (!$rawData) {
         //加载审核状态
         $data['apply_status'] = 0;
         $result = $this->libactivity->insert('activity_apply', $data);
         if ($result) {
             //$this->libactivity->updateData($data['action_id'], array('apply_num'=>$data['part_num'],'yet_join'=>$data['part_num']), "+");
             $this->libactivity->update('activity', array('apply_num' => $data['part_num'], 'yet_join' => 1), array('action_id' => $data['action_id']), array('apply_num' => $data['part_num'], 'yet_join' => $data['part_num']));
         }
         $result = $data['apply_status'];
     } else {
         if ($this->libactivity->update('activity_apply', $data, array('id' => $rawData['id']))) {
             $result = $rawData['apply_status'];
         }
     }
     $action_arr = $this->libactivity->get('activity', 'user_id, action_name', array('action_id' => $data['action_id']), 0, 1, array());
     //发送通知
     include_once ROOT_PATH . '/lib/class/notify.class.php';
     $notify = new notify();
     $send_arr = array();
     $send_arr[] = array('from_id' => 0, 'to_id' => $action_arr['user_id'], 'content' => '您的"' . $action_arr['action_name'] . '"行动有人报名!', 'page_link' => 'action.php?a=userList&action_id=' . $data['action_id'], 'link_text' => '去看看');
     if ($send_arr) {
         $notify->notify_send(json_encode($send_arr), 0);