Esempio n. 1
0
 /**
  * POST 话题回复
  */
 public function create_replyOp()
 {
     $model = Model();
     $m_theme = $model->table('circle_theme');
     $theme = $m_theme->where(array("theme_id" => $this->t_id))->select();
     $this->c_id = $theme[0]['circle_id'];
     $to_user_id = $theme[0]['member_id'];
     //        var_dump($this->c_id);
     //圈子信息
     $this->circleInfo();
     // 会员信息
     $this->memberInfo();
     // 不是圈子成员不能发帖
     if (!in_array($this->identity, array(1, 2, 3))) {
         output_error("您不是圈子成员");
     }
     // 话题信息
     $this->themeInfo();
     if (isset($_POST)) {
         /**
          * 验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["replycontent"], "require" => "true", "message" => '回复不能为空'));
         $error = $obj_validate->validate();
         if ($error != '') {
             output_error($error);
         } else {
             $model = Model();
             $insert = array();
             $insert['theme_id'] = $this->t_id;
             $insert['circle_id'] = $this->c_id;
             $insert['member_id'] = $this->member_info['member_id'];
             $insert['member_name'] = $this->member_info['member_name'];
             $insert['reply_content'] = circleCenterCensor($_POST['replycontent']);
             $insert['reply_addtime'] = time();
             $insert['is_closed'] = 0;
             // 回复楼层验证
             if ($this->r_id != '') {
                 $reply_info = Model()->table('circle_threply')->where(array('theme_id' => $this->t_id, 'reply_id' => $this->r_id))->find();
                 if (!empty($reply_info)) {
                     $insert['reply_replyid'] = $reply_info['reply_id'];
                     $insert['reply_replyname'] = $reply_info['member_name'];
                 }
             }
             $reply_id = $model->table('circle_threply')->insert($insert);
             if ($reply_id) {
                 // 话题被回复数增加 最后发言人发言时间
                 $update = array();
                 $update['theme_id'] = $this->t_id;
                 $update['theme_commentcount'] = array('exp', 'theme_commentcount+1');
                 $update['lastspeak_id'] = $this->member_info['member_id'];
                 $update['lastspeak_name'] = $this->member_info['member_name'];
                 $update['lastspeak_time'] = time();
                 $model->table('circle_theme')->update($update);
                 // 成员回复数增加 最后回复时间
                 $model->table('circle_member')->where(array('member_id' => $this->member_info['member_id'], 'circle_id' => $this->c_id))->update(array('cm_comcount' => array('exp', 'cm_comcount+1'), 'cm_lastspeaktime' => time()));
                 // set cookie of SEC
                 if (intval(C('circle_intervaltime')) > 0) {
                     setNcCookie('circle_intervaltime', true, intval(C('circle_intervaltime')));
                 }
                 if ($this->theme_info['member_id'] != $this->member_info['member_id']) {
                     // Experience for replyer
                     $param = array();
                     $param['member_id'] = $this->member_info['member_id'];
                     $param['member_name'] = $this->member_info['member_name'];
                     $param['circle_id'] = $this->c_id;
                     $param['theme_id'] = $this->t_id;
                     $param['type'] = 'reply';
                     $param['itemid'] = $this->t_id . ',' . $reply_id;
                     Model('circle_exp')->saveExp($param);
                     // Experience for releaser
                     $param = array();
                     $param['member_id'] = $this->theme_info['member_id'];
                     $param['member_name'] = $this->theme_info['member_name'];
                     $param['theme_id'] = $this->t_id;
                     $param['circle_id'] = $this->c_id;
                     $param['type'] = 'replied';
                     $param['itemid'] = $this->t_id;
                     Model('circle_exp')->saveExp($param);
                 }
                 $jpush = new JPush();
                 $extras = array();
                 $extras['push_type'] = "hasReply";
                 $extras['id'] = $this->t_id;
                 $extras['circle_id'] = $this->theme_info['circle_id'];
                 //  回复自己的帖子不推送
                 if ($to_user_id != $this->member_info['member_id']) {
                     $jpush->pushMessageByAlias($this->member_info['member_name'] . "发表了新的回帖", "有新的回贴", $extras, array($to_user_id));
                 }
                 output_data(array('success' => '回复成功'));
             } else {
                 output_error("回复失败");
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * POST 问题回复(回答)
  */
 public function create_answerOp()
 {
     // Reply function does close,throw error.
     if (!intval(C('circle_istalk'))) {
         output_error(L('circle_has_been_closed_reply'));
     }
     // checked cookie of SEC
     if (cookie(circle_intervaltime)) {
         output_error(L('circle_operation_too_frequent'));
     }
     // 问题信息
     $this->questionInfo();
     if (isset($_POST)) {
         /**
          * 验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["content"], "require" => "true", "message" => '回复不能为空'));
         $error = $obj_validate->validate();
         if ($error != '') {
             output_error($error);
         } else {
             $model = Model();
             $insert = array();
             $insert['theme_id'] = $this->q_id;
             $insert['circle_id'] = $this->c_id;
             $insert['member_id'] = $this->member_info['member_id'];
             $insert['member_name'] = $this->member_info['member_name'];
             $insert['reply_content'] = circleCenterCensor($_POST['content']);
             $insert['reply_addtime'] = time();
             $insert['is_closed'] = 0;
             // 回复楼层验证
             if ($this->r_id != '') {
                 $reply_info = Model()->table('circle_threply')->where(array('theme_id' => $this->q_id, 'reply_id' => $this->r_id))->find();
                 if (!empty($reply_info)) {
                     $insert['reply_replyid'] = $reply_info['reply_id'];
                     $insert['reply_replyname'] = $reply_info['member_name'];
                 }
             }
             $reply_id = $model->table('circle_threply')->insert($insert);
             if ($reply_id) {
                 // 话题被回复数增加 最后发言人发言时间
                 $update = array();
                 $update['theme_id'] = $this->q_id;
                 $update['theme_commentcount'] = array('exp', 'theme_commentcount+1');
                 $update['lastspeak_id'] = $this->member_info['member_id'];
                 $update['lastspeak_name'] = $this->member_info['member_name'];
                 $update['lastspeak_time'] = time();
                 $model->table('circle_theme')->update($update);
                 // 成员回复数增加 最后回复时间
                 $model->table('circle_member')->where(array('member_id' => $this->member_info['member_id'], 'circle_id' => $this->c_id))->update(array('cm_comcount' => array('exp', 'cm_comcount+1'), 'cm_lastspeaktime' => time()));
                 // set cookie of SEC
                 if (intval(C('circle_intervaltime')) > 0) {
                     setNcCookie('circle_intervaltime', true, intval(C('circle_intervaltime')));
                 }
                 if ($this->question_info['member_id'] != $this->member_info['member_id']) {
                     // Experience for replyer
                     $param = array();
                     $param['member_id'] = $this->member_info['member_id'];
                     $param['member_name'] = $this->member_info['member_name'];
                     $param['circle_id'] = $this->c_id;
                     $param['theme_id'] = $this->q_id;
                     $param['type'] = 'reply';
                     $param['itemid'] = $this->q_id . ',' . $reply_id;
                     Model('circle_exp')->saveExp($param);
                     // Experience for releaser
                     $param = array();
                     $param['member_id'] = $this->question_info['member_id'];
                     $param['member_name'] = $this->question_info['member_name'];
                     $param['theme_id'] = $this->q_id;
                     $param['circle_id'] = $this->c_id;
                     $param['type'] = 'replied';
                     $param['itemid'] = $this->q_id;
                     Model('circle_exp')->saveExp($param);
                 }
                 $jpush = new JPush();
                 $extras = array();
                 $extras['push_type'] = "hasAnswer";
                 $extras['id'] = $this->q_id;
                 //  回复自己的帖子不推送
                 if ($this->question_info['member_id'] != $this->member_info['member_id']) {
                     $jpush->pushMessageByAlias($this->member_info['member_name'] . "发表了新的回答", "有新的回答", $extras, array($this->question_info['member_id']));
                 }
                 output_data(array('code' => 201, 'success' => '回复成功'));
             } else {
                 output_error('回复失败');
             }
         }
     }
 }