예제 #1
0
 /**
  * 编辑话题
  */
 public function edit_themeOp()
 {
     // 身份验证
     $rs = $this->checkIdentity('cm');
     if (!empty($rs)) {
         uk86_showMessage($rs);
     }
     $t_id = intval($_GET['t_id']);
     if ($t_id <= 0) {
         uk86_showMessage(L('wrong_argument'));
     }
     Tpl::output('t_id', $t_id);
     $model = Model();
     if (uk86_chksubmit()) {
         // 主题分类
         $thclass_id = intval($_POST['thtype']);
         $thclass_name = '';
         if ($thclass_id > 0) {
             $thclass_info = $model->table('circle_thclass')->find($thclass_id);
             $thclass_name = $thclass_info['thclass_name'];
         }
         $model = Model();
         $update = array();
         $update['theme_id'] = $t_id;
         $update['theme_name'] = circleCenterCensor($_POST['name']);
         $update['theme_content'] = circleCenterCensor($_POST['themecontent']);
         $update['thclass_id'] = $thclass_id;
         $update['thclass_name'] = $thclass_name;
         $update['theme_editname'] = $_SESSION['member_name'];
         $update['theme_edittime'] = time();
         $update['theme_readperm'] = intval($_POST['readperm']);
         $rs = $model->table('circle_theme')->update($update);
         if ($rs) {
             $has_goods = 0;
             // 存在商品标记
             $has_affix = 0;
             // 存在附件标记
             // 删除原有商品
             $goods_list = Model()->table('circle_thg')->where(array('theme_id' => $t_id, 'reply_id' => 0))->delete();
             // 插入话题商品
             if (!empty($_POST['goods'])) {
                 $goods_insert = array();
                 foreach ($_POST['goods'] as $key => $val) {
                     $p = array();
                     $p['theme_id'] = $t_id;
                     $p['reply_id'] = 0;
                     $p['circle_id'] = $this->c_id;
                     $p['goods_id'] = $key;
                     $p['goods_name'] = $val['name'];
                     $p['goods_price'] = $val['price'];
                     $p['goods_image'] = $val['image'];
                     $p['store_id'] = $val['storeid'];
                     $goods_insert[] = $p;
                 }
                 $rs = $model->table('circle_thg')->insertAll($goods_insert);
                 $has_goods = 1;
             }
             // 更新话题信息
             $affixe_count = $model->table('circle_affix')->where(array('affix_type' => 1, 'theme_id' => $t_id))->count();
             if ($affixe_count > 0) {
                 $has_affix = 1;
             }
             if ($has_goods || $has_affix) {
                 $update = array();
                 $update['theme_id'] = $t_id;
                 $update['has_goods'] = $has_goods;
                 $update['has_affix'] = $has_affix;
                 $model->table('circle_theme')->update($update);
             }
             // Special theme
             if ($_GET['sp'] == 1) {
                 // Update the vote
                 $update = array();
                 $update['theme_id'] = $t_id;
                 $update['poll_multiple'] = intval($_POST['multiple']);
                 $update['poll_startime'] = time();
                 $update['poll_endtime'] = intval($_POST['days']) != 0 ? time() + intval($_POST['days']) * 60 * 60 * 12 : 0;
                 $update['poll_days'] = intval($_POST['days']);
                 $model->table('circle_thpoll')->update($update);
                 // Update the voting options
                 if (!empty($_POST['polloption'])) {
                     $insert_array = array();
                     foreach ($_POST['polloption'] as $key => $val) {
                         $option_info = $model->table('circle_thpolloption')->where(array('pollop_id' => $key, 'theme_id' => $t_id))->find();
                         if (!empty($option_info)) {
                             $update = array();
                             $update['pollop_id'] = $key;
                             $update['pollop_option'] = $val;
                             $update['pollop_sort'] = $_POST['pollsort'][$key];
                             $model->table('circle_thpolloption')->update($update);
                         } else {
                             if ($val == '') {
                                 continue;
                             }
                             $i = array();
                             $i['theme_id'] = $t_id;
                             $i['pollop_option'] = $val;
                             $i['pollop_sort'] = $_POST['pollsort'][$key];
                             $insert_array[] = $i;
                         }
                     }
                     if (!empty($insert_array)) {
                         $model->table('circle_thpolloption')->insertAll($insert_array);
                     }
                 }
             }
             showDialog(L('nc_common_op_succ'), CIRCLE_SITE_URL . '/index.php?act=theme&op=theme_detail&c_id=' . $this->c_id . '&t_id=' . $t_id, 'succ');
         } else {
             showDialog(L('nc_common_op_fail'));
         }
     }
     // 圈子信息
     $this->circleInfo();
     // 圈主和管理信息
     $this->manageList();
     // 会员信息
     $this->memberInfo();
     // 话题信息
     $this->theme_info = $model->table('circle_theme')->where(array('theme_id' => $t_id, 'circle_id' => $this->c_id))->find();
     if (empty($this->theme_info)) {
         uk86_showMessage(L('wrong_argument'));
     }
     Tpl::output('theme_info', $this->theme_info);
     // 话题商品
     $goods_list = $model->table('circle_thg')->where(array('theme_id' => $t_id, 'reply_id' => 0))->select();
     $goods_list = tidyThemeGoods($goods_list, 'themegoods_id');
     Tpl::output('goods_list', $goods_list);
     // 话题附件
     $affix_list = $model->table('circle_affix')->where(array('affix_type' => 1, 'theme_id' => $t_id))->select();
     Tpl::output('affix_list', $affix_list);
     // 话题分类
     $where = array();
     $where['circle_id'] = $this->c_id;
     $where['thclass_status'] = 1;
     $thclass_list = $model->table('circle_thclass')->where($where)->select();
     $thclass_list = uk86_array_under_reset($thclass_list, 'thclass_id');
     Tpl::output('thclass_list', $thclass_list);
     // Read permissions
     $readperm = $this->readPermissions($this->cm_info);
     Tpl::output('readperm', $readperm);
     // breadcrumb navigation
     $this->breadcrumd(L('nc_edit_theme'));
     if ($this->theme_info['theme_special'] == 1) {
         $poll_info = $model->table('circle_thpoll')->find($t_id);
         Tpl::output('poll_info', $poll_info);
         $option_list = $model->table('circle_thpolloption')->where(array('theme_id' => $t_id))->order('pollop_sort asc')->select();
         Tpl::output('option_list', $option_list);
         Tpl::showpage('group_manage_edit_themepoll');
     } else {
         Tpl::showpage('group_manage_edit_theme');
     }
 }
예제 #2
0
 /**
  * 话题回复保存
  */
 public function save_replyOp()
 {
     // Reply function does close,throw error.
     if (!intval(C('circle_istalk'))) {
         showDialog(L('circle_has_been_closed_reply'));
     }
     // checked cookie of SEC
     if (cookie(circle_intervaltime)) {
         showDialog(L('circle_operation_too_frequent'));
     }
     // 会员信息
     $this->memberInfo();
     // 不是圈子成员不能发帖
     if (!in_array($this->identity, array(1, 2, 3))) {
         showDialog(L('circle_no_join_ban_reply'));
     }
     // 话题信息
     $this->themeInfo();
     if (chksubmit()) {
         /**
          * 验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["replycontent"], "require" => "true", "message" => L('circle_reply_not_null')));
         $error = $obj_validate->validate();
         if ($error != '') {
             showDialog($error);
         } else {
             $model = Model();
             $insert = array();
             $insert['theme_id'] = $this->t_id;
             $insert['circle_id'] = $this->c_id;
             $insert['member_id'] = $_SESSION['member_id'];
             $insert['member_name'] = $_SESSION['member_name'];
             $insert['reply_content'] = circleCenterCensor($_POST['replycontent']);
             $insert['reply_addtime'] = time();
             $insert['is_closed'] = 0;
             // 回复楼层验证
             if ($_POST['answer_id'] != '') {
                 $reply_info = Model()->table('circle_threply')->where(array('theme_id' => $this->t_id, 'reply_id' => intval($_POST['answer_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) {
                 if ($_GET['type'] == 'adv') {
                     // 插入话题商品
                     if (!empty($_POST['goods'])) {
                         $goods_insert = array();
                         foreach ($_POST['goods'] as $key => $val) {
                             $p = array();
                             $p['theme_id'] = $this->t_id;
                             $p['reply_id'] = $reply_id;
                             $p['circle_id'] = $this->c_id;
                             $p['goods_id'] = $val['id'];
                             $p['goods_name'] = $val['name'];
                             $p['goods_price'] = $val['price'];
                             $p['goods_image'] = $val['image'];
                             $p['store_id'] = $val['storeid'];
                             $p['thg_type'] = $val['type'];
                             $p['thg_url'] = $val['type'] == 1 ? $val['uri'] : '';
                             $goods_insert[] = $p;
                         }
                         $rs = $model->table('circle_thg')->insertAll($goods_insert);
                     }
                     // 更新话题附件
                     $model->table('circle_affix')->where(array('affix_type' => 2, 'member_id' => $_SESSION['member_id'], 'reply_id' => 0))->update(array('theme_id' => $this->t_id, 'reply_id' => $reply_id, 'circle_id' => $this->c_id));
                 }
                 // 话题被回复数增加 最后发言人发言时间
                 $update = array();
                 $update['theme_id'] = $this->t_id;
                 $update['theme_commentcount'] = array('exp', 'theme_commentcount+1');
                 $update['lastspeak_id'] = $_SESSION['member_id'];
                 $update['lastspeak_name'] = $_SESSION['member_name'];
                 $update['lastspeak_time'] = time();
                 $model->table('circle_theme')->update($update);
                 // 成员回复数增加 最后回复时间
                 $model->table('circle_member')->where(array('member_id' => $_SESSION['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'] != $_SESSION['member_id']) {
                     // Experience for replyer
                     $param = array();
                     $param['member_id'] = $_SESSION['member_id'];
                     $param['member_name'] = $_SESSION['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);
                 }
                 if ($_GET['type'] == 'quick') {
                     showDialog(L('nc_common_op_succ'), '', 'succ', '$(\'li[nctype="li' . $this->t_id . '"]\').find(\'.quick-reply-2\').removeClass(\'t\').html(\'\').end().find(\'.quick-reply-list-2\').remove().end().end().find(\'a[nctype="reply"]\').click().click();');
                 } else {
                     showDialog(L('nc_common_op_succ'), 'index.php?act=theme&op=theme_detail&c_id=' . $this->c_id . '&t_id=' . $this->t_id, 'succ');
                 }
             }
         }
     }
 }
예제 #3
0
 /**
  * POST 创建一个话题
  */
 public function create_themeOp()
 {
     if (isset($_POST)) {
         // Reply function does close,throw error.
         if (!intval(C('circle_istalk'))) {
             output_error(L('circle_theme_cannot_be_published'), array('code' => 501));
         }
         // checked cookie of SEC
         if (cookie(circle_intervaltime)) {
             output_error(L('circle_operation_too_frequent'), array('code' => 501));
         }
         // 圈子信息
         $this->circleInfo();
         // 会员信息
         $this->memberInfo();
         // 不是圈子成员不能发帖
         if (!in_array($this->identity, array(1, 2, 3))) {
             output_error(L('circle_no_join_ban_release'), array('code' => 502));
         }
         $model = Model();
         // 主题分类 默认为0
         $thclass_id = intval($_POST['thtype']);
         $thclass_name = '';
         if ($thclass_id > 0) {
             $thclass_info = $model->table('circle_thclass')->find($thclass_id);
             $thclass_name = $thclass_info['thclass_name'];
         }
         /**
          * 验证
          */
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => $_POST["name"], "require" => "true", "message" => '话题名称不能为空'), array("input" => $_POST["name"], "validator" => 'Length', "min" => 4, "max" => 45, "message" => '名称长度不符合要求'), array("input" => $_POST["themecontent"], "require" => "true", "message" => '话题内容不能为空'), array("input" => $_POST["themecontent"], "validator" => 'Length', "min" => 4, "max" => 2500, "message" => '内容长度不符合要求'));
         $error = $obj_validate->validate();
         if ($error != '') {
             output_error($error);
             die;
         }
         $insert = array();
         $insert['theme_name'] = circleCenterCensor($_POST['name']);
         $insert['theme_content'] = circleCenterCensor($_POST['themecontent']);
         $insert['circle_id'] = $this->c_id;
         $insert['circle_name'] = $this->circle_info['circle_name'];
         $insert['thclass_id'] = $thclass_id;
         $insert['thclass_name'] = $thclass_name;
         $insert['member_id'] = $this->member_info['member_id'];
         $insert['member_name'] = $this->member_info['member_name'];
         $insert['is_identity'] = $this->identity;
         $insert['theme_addtime'] = time();
         $insert['lastspeak_time'] = time();
         $insert['theme_readperm'] = intval($_POST['readperm']);
         $insert['theme_special'] = intval($_GET['sp']);
         $themeid = $model->table('circle_theme')->insert($insert);
         if ($themeid) {
             // 更新圈子表话题数
             $update = array('circle_id' => $this->c_id, 'circle_thcount' => array('exp', 'circle_thcount+1'));
             $model->table('circle')->update($update);
             // 更新用户相关信息
             $update = array('cm_thcount' => array('exp', 'cm_thcount+1'), 'cm_lastspeaktime' => time());
             $model->table('circle_member')->where(array('member_id' => $this->member_info['member_id'], 'circle_id' => $this->c_id))->update($update);
             // set cookie of SEC
             if (intval(C('circle_intervaltime')) > 0) {
                 setNcCookie('circle_intervaltime', true, intval(C('circle_intervaltime')));
             }
             // Experience
             $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['type'] = 'release';
             $param['itemid'] = $themeid;
             Model('circle_exp')->saveExp($param);
             $data['id'] = $themeid;
             $data['url'] = $theme_url = CIRCLE_SITE_URL . '/index.php?act=theme&op=theme_detail&c_id=' . $this->c_id . '&t_id=' . $themeid;
             output_data(array('ok' => $data));
         } else {
             output_error("创建失败");
         }
     }
     output_error('request error');
 }
예제 #4
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("回复失败");
             }
         }
     }
 }
예제 #5
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('回复失败');
             }
         }
     }
 }