manage.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. <?php
  2. /**
  3. * 圈子首页
  4. *
  5. *
  6. *********************************/
  7. defined('InShopNC') or exit('Access Invalid!');
  8. class manageControl extends BaseCircleManageControl{
  9. public function __construct(){
  10. parent::__construct();
  11. Language::read('circle');
  12. $this->circleSEO();
  13. }
  14. /**
  15. * 圈子管理
  16. */
  17. public function indexOp(){
  18. // 圈子信息
  19. $this->circleInfo();
  20. // 会员信息
  21. $this->circleMemberInfo();
  22. if($this->identity == 2){
  23. @header("location: ".CIRCLE_SITE_URL.'/index.php?act=manage&op=applying&c_id='.$this->c_id);
  24. }
  25. // 会员加入圈子列表
  26. $this->memberJoinCircle();
  27. $model = Model();
  28. if(chksubmit()){
  29. $update = array();
  30. $update['circle_id'] = $this->c_id;
  31. // 上传图片
  32. if (!empty($_FILES['c_img']['name'])){
  33. $upload = new UploadFile();
  34. $upload->set('default_dir', ATTACH_CIRCLE.'/group');
  35. $upload->set('thumb_width', 120);
  36. $upload->set('thumb_height', 120);
  37. $upload->set('thumb_ext', '_120x120');
  38. $upload->set('ifremove', true);
  39. $result = $upload->upfile('c_img');
  40. if ($result){
  41. $update['circle_img'] = $upload->thumb_image;
  42. $model->table('circle')->update($update);
  43. }else {
  44. showDialog($upload->error);
  45. }
  46. }
  47. $update['circle_desc'] = $_POST['c_desc'];
  48. $update['circle_notice'] = $_POST['c_notice'];
  49. $update['circle_joinaudit'] = $_POST['c_joinaudit'];
  50. if($_POST['c_mapply'] == 1){
  51. $update['mapply_open'] = 1;
  52. $update['mapply_ml'] = $_POST['c_ml'];
  53. }else{
  54. $update['mapply_open'] = 0;
  55. $update['mapply_ml'] = 0;
  56. $update['new_mapplycount'] = 0;
  57. // Delete the application information
  58. $model->table('circle_mapply')->where(array('circle_id'=>$this->c_id))->delete();
  59. }
  60. $model->table('circle')->update($update);
  61. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  62. }
  63. $circle_info = $model->table('circle')->find($this->c_id);
  64. Tpl::output('circle_info', $circle_info);
  65. // member level
  66. $ml_info = $model->table('circle_ml')->find($this->c_id);
  67. if(empty($ml_info)){
  68. $mld_array = rkcache('circle_level') ? rkcache('circle_level') : rkcache('circle_level', true);
  69. $ml_info['ml_1'] = $mld_array['1']['mld_name'];
  70. $ml_info['ml_2'] = $mld_array['2']['mld_name'];
  71. $ml_info['ml_3'] = $mld_array['3']['mld_name'];
  72. $ml_info['ml_4'] = $mld_array['4']['mld_name'];
  73. $ml_info['ml_5'] = $mld_array['5']['mld_name'];
  74. $ml_info['ml_6'] = $mld_array['6']['mld_name'];
  75. $ml_info['ml_7'] = $mld_array['7']['mld_name'];
  76. $ml_info['ml_8'] = $mld_array['8']['mld_name'];
  77. $ml_info['ml_9'] = $mld_array['9']['mld_name'];
  78. $ml_info['ml_10'] = $mld_array['10']['mld_name'];
  79. $ml_info['ml_11'] = $mld_array['11']['mld_name'];
  80. $ml_info['ml_12'] = $mld_array['12']['mld_name'];
  81. $ml_info['ml_13'] = $mld_array['13']['mld_name'];
  82. $ml_info['ml_14'] = $mld_array['14']['mld_name'];
  83. $ml_info['ml_15'] = $mld_array['15']['mld_name'];
  84. $ml_info['ml_16'] = $mld_array['16']['mld_name'];
  85. }
  86. Tpl::output('ml_info', $ml_info);
  87. $this->sidebar_menu('index');
  88. Tpl::showpage('group_manage_index');
  89. }
  90. /**
  91. * 成员管理
  92. */
  93. public function member_manageOp(){
  94. // 圈子信息
  95. $this->circleInfo();
  96. // 会员信息
  97. $this->circleMemberInfo();
  98. // 会员加入圈子列表
  99. $this->memberJoinCircle();
  100. $model = Model();
  101. // 条件
  102. $where = array();
  103. $where['circle_id'] = $this->c_id;
  104. $where['cm_state'] = 1;
  105. if($_GET['mname'] != ''){
  106. $where['member_name'] = array('like', '%'.$_GET['mname'].'%');
  107. }
  108. $cm_list = $model->table('circle_member')->where($where)
  109. ->order('is_identity asc,cm_jointime desc')->page(15)->select();
  110. Tpl::output('show_page', $model->showpage('2'));
  111. Tpl::output('cm_list', $cm_list);
  112. $this->sidebar_menu('member');
  113. Tpl::showpage('group_manage_member');
  114. }
  115. /**
  116. * 会员操作 禁言/解禁 设为明星/取消明星
  117. */
  118. public function settingOp(){
  119. // 身份验证
  120. $rs = $this->checkIdentity('c');
  121. if(!empty($rs)){
  122. showDialog($rs);
  123. }
  124. $cmid_array = explode(',', $_GET['cm_id']);
  125. if(empty($cmid_array)){
  126. showDialog(L('wrong_argument'));
  127. }
  128. // 条件
  129. $where = array();
  130. $where['member_id'] = array('in', $cmid_array);
  131. $where['circle_id'] = $this->c_id;
  132. // 更新数据
  133. $update = array();
  134. if($_GET['type'] == 'yes'){
  135. $val = 1;
  136. }else if($_GET['type'] == 'no'){
  137. $val = 0;
  138. }
  139. if($_GET['sign'] == 'speak'){
  140. $key = 'is_allowspeak';
  141. $cmid_array = $this->removeManager($cmid_array); // 去除圈主和管理
  142. $where['member_id'] = array('in', $cmid_array);
  143. }else if($_GET['sign'] == 'star'){
  144. $key = 'is_star';
  145. }
  146. if(isset($val) && isset($key)){
  147. $update[$key] = $val;
  148. }else{
  149. showDialog(L('wrong_argument'));
  150. }
  151. Model()->table('circle_member')->where($where)->update($update);
  152. if($key == 'is_allowspeak'){
  153. // 话题/回复 屏蔽
  154. $update = array();
  155. $update['is_closed'] = ($val == 1)?0:1;
  156. Model()->table('circle_theme')->where($where)->update($update);
  157. Model()->table('circle_threply')->where($where)->update($update);
  158. }
  159. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  160. }
  161. /**
  162. * 删除会员操作
  163. */
  164. public function delmemberOp(){
  165. // 身份验证
  166. $rs = $this->checkIdentity('c');
  167. if(!empty($rs)){
  168. showDialog($rs);
  169. }
  170. if (chksubmit()) {
  171. $cmid_array = explode(',', $_GET['cm_id']);
  172. $cmid_array = $this->removeCreator($cmid_array); // 去除圈主
  173. if(empty($cmid_array)){
  174. showDialog(L('wrong_argument'));
  175. }
  176. // 条件
  177. $where = array();
  178. $where['member_id'] = array('in', $cmid_array);
  179. $where['circle_id'] = $this->c_id;
  180. Model()->table('circle_member')->where($where)->delete();
  181. if ($_POST['all']) {
  182. Model()->table('circle_theme')->where($where)->delete();
  183. Model()->table('circle_threply')->where($where)->delete();
  184. }
  185. // 更新圈子成员数量
  186. $count = Model()->table('circle_member')->where(array('circle_id'=>$this->c_id, 'cm_state'=>1))->count();
  187. Model()->table('circle')->update(array('circle_id'=>$this->c_id, 'circle_mcount'=>$count));
  188. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  189. }
  190. Tpl::showpage('group_manage_memberdel', 'null_layout');
  191. }
  192. /**
  193. * 设置/取消管理
  194. */
  195. public function setmanageOp(){
  196. // 身份验证
  197. $rs = $this->checkIdentity('c');
  198. if(!empty($rs)){
  199. showDialog($rs);
  200. }
  201. $cmid_array = explode(',', $_GET['cm_id']);
  202. if(empty($cmid_array)){
  203. showDialog(L('wrong_argument'));
  204. }
  205. // 计算允许添加管理员个数
  206. if($_GET['type'] == 'yes'){
  207. $cmid_array = $this->removeManager($cmid_array); // 去除圈主和管理
  208. $manage_count = Model()->table('circle_member')->where(array('circle_id'=>$this->c_id, 'is_identity'=>2))->count();
  209. $i = intval(C('circle_managesum')) - intval($manage_count);
  210. $cmid_array = array_slice($cmid_array, 0, $i);
  211. }else{
  212. $cmid_array = $this->removeCreator($cmid_array); // 去除圈主
  213. }
  214. // 条件
  215. $where = array();
  216. $where['member_id'] = array('in', $cmid_array);
  217. $where['circle_id'] = $this->c_id;
  218. // 更新数据
  219. $update = array();
  220. if($_GET['type'] == 'yes'){
  221. $update['is_identity'] = 2;
  222. }else if($_GET['type'] == 'no'){
  223. $update['is_identity'] = 3;
  224. }
  225. Model()->table('circle_member')->where($where)->update($update);
  226. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  227. }
  228. /**
  229. * 正在申请成员列表
  230. */
  231. public function applyingOp(){
  232. // 圈子信息
  233. $this->circleInfo();
  234. // 会员信息
  235. $this->circleMemberInfo();
  236. // 会员加入圈子列表
  237. $this->memberJoinCircle();
  238. // 成员列表
  239. $cm_list = Model()->table('circle_member')->where(array('circle_id'=>$this->c_id, 'cm_state'=>0))->order('is_identity asc,cm_jointime desc')->select();
  240. Tpl::output('cm_list', $cm_list);
  241. $this->sidebar_menu('applying');
  242. Tpl::showpage('group_manage_memberapplying');
  243. }
  244. /**
  245. * 申请中成员操作
  246. */
  247. public function applying_manageOp(){
  248. // 身份验证
  249. $rs = $this->checkIdentity('cm');
  250. if(!empty($rs)){
  251. showDialog($rs);
  252. }
  253. $cmid_array = explode(',', $_GET['cm_id']);
  254. if(empty($cmid_array)){
  255. showDialog(L('wrong_argument'));
  256. }
  257. $model = Model();
  258. // 条件
  259. $where = array();
  260. $where['circle_id'] = $this->c_id;
  261. $where['member_id'] = array('in', $cmid_array);
  262. // 更新数据
  263. $update = array();
  264. if($_GET['type'] == 'yes'){
  265. $update['cm_state'] = 1;
  266. }elseif ($_GET['type'] == 'no'){
  267. $update['cm_state'] = 2;
  268. }
  269. $model->table('circle_member')->where($where)->update($update);
  270. // Update the number of members
  271. $count = $model->table('circle_member')->where(array('circle_id'=>$this->c_id, 'cm_state'=>1))->count();
  272. $model->table('circle')->update(array('circle_id'=>$this->c_id, 'circle_mcount'=>$count));
  273. // Update is applying for membership
  274. $count = $model->table('circle_member')->where(array('circle_id'=>$this->c_id, 'cm_state'=>0))->count();
  275. $model->table('circle')->update(array('circle_id'=>$this->c_id, 'new_verifycount'=>$count));
  276. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  277. }
  278. /**
  279. * 分类管理
  280. */
  281. public function classOp(){
  282. // 圈子信息
  283. $this->circleInfo();
  284. // 会员信息
  285. $this->circleMemberInfo();
  286. // 会员加入圈子列表
  287. $this->memberJoinCircle();
  288. $model = Model();
  289. $thclass_list = $model->table('circle_thclass')->where(array('circle_id'=>$this->c_id))->order('thclass_sort asc')->select();
  290. Tpl::output('thclass_list', $thclass_list);
  291. $this->sidebar_menu('class');
  292. Tpl::showpage('group_manage_class');
  293. }
  294. /**
  295. * 分类添加
  296. */
  297. public function class_addOp(){
  298. // 身份验证
  299. $rs = $this->checkIdentity('c');
  300. if(!empty($rs)){
  301. showDialog($rs);
  302. }
  303. if(chksubmit()){
  304. // 超过10不能继续添加
  305. $count = Model()->table('circle_thclass')->where(array('circle_id'=>$this->c_id))->count();
  306. if($count >= 10){
  307. showDialog(L('circle_tclass_max_10'));
  308. }
  309. /**
  310. * 验证
  311. */
  312. $obj_validate = new Validator();
  313. $obj_validate->validateparam = array(
  314. array("input"=>$_POST["name"], "require"=>"true", "message"=>L('circle_tclass_name_not_null')),
  315. array("input"=>$_POST["sort"], "require"=>"true", 'validator'=>'Number', "message"=>L('circle_sort_error')),
  316. );
  317. $error = $obj_validate->validate();
  318. if($error != ''){
  319. showDialog($error);
  320. }else{
  321. $insert = array();
  322. $insert['thclass_name'] = $_POST['name'];
  323. $insert['thclass_status'] = intval($_POST['status']);
  324. $insert['is_moderator'] = intval($_POST['moderator']);
  325. $insert['thclass_sort'] = $_POST['sort'];
  326. $insert['circle_id'] = $this->c_id;
  327. Model()->table('circle_thclass')->insert($insert);
  328. showDialog(L('nc_common_op_succ'), 'reload', 'succ', 'CUR_DIALOG.close();');
  329. }
  330. }
  331. Tpl::showpage('group_manage_classadd', 'null_layout');
  332. }
  333. /**
  334. * 分类编辑
  335. */
  336. public function class_editOp(){
  337. // 身份验证
  338. $rs = $this->checkIdentity('c');
  339. if(!empty($rs)){
  340. showDialog($rs);
  341. }
  342. if(chksubmit()){
  343. /**
  344. * 验证
  345. */
  346. $obj_validate = new Validator();
  347. $obj_validate->validateparam = array(
  348. array("input"=>$_POST["name"], "require"=>"true", "message"=>L('circle_tclass_name_not_null')),
  349. array("input"=>$_POST["sort"], "require"=>"true", 'validator'=>'Number', "message"=>L('circle_sort_error')),
  350. );
  351. $error = $obj_validate->validate();
  352. if($error != ''){
  353. showDialog($error);
  354. }else{
  355. $update = array();
  356. $update['thclass_id'] = intval($_POST['thc_id']);
  357. $update['thclass_name'] = $_POST['name'];
  358. $update['thclass_status'] = intval($_POST['status']);
  359. $update['is_moderator'] = intval($_POST['moderator']);
  360. $update['thclass_sort'] = $_POST['sort'];
  361. $update['circle_id'] = $this->c_id;
  362. Model()->table('circle_thclass')->where(array('thclass_id'=>intval($_POST['thc_id']), 'circle_id'=>$this->c_id))->update($update);
  363. showDialog(L('nc_common_op_succ'), 'reload', 'succ', 'CUR_DIALOG.close();');
  364. }
  365. }
  366. $thc_id = intval($_GET['thc_id']);
  367. if($thc_id <= 0){
  368. showDialog(L('wrong_argument'));
  369. }
  370. $thclass_info = Model()->table('circle_thclass')->where(array('circle_id'=>$this->c_id, 'thclass_id'=>$thc_id))->find();
  371. if(empty($thclass_info)){
  372. showDialog(L('wrong_argument'));
  373. }
  374. Tpl::output('thclass_info', $thclass_info);
  375. Tpl::showpage('group_manage_classedit', 'null_layout');
  376. }
  377. /**
  378. * 删除分类
  379. */
  380. public function class_delOp(){
  381. // 身份验证
  382. $rs = $this->checkIdentity('c');
  383. if(!empty($rs)){
  384. showDialog($rs);
  385. }
  386. $thcid_array = explode(',', $_GET['thc_id']);
  387. if(empty($thcid_array)){
  388. showDialog(L('wrong_argument'));
  389. }
  390. // 条件
  391. $where = array();
  392. $where['circle_id'] = $this->c_id;
  393. $where['thclass_id']= array('in', $thcid_array);
  394. Model()->table('circle_thclass')->where($where)->delete();
  395. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  396. }
  397. /**
  398. * 友情圈子
  399. */
  400. public function friendshipOp(){
  401. // 圈子信息
  402. $this->circleInfo();
  403. // 会员信息
  404. $this->circleMemberInfo();
  405. // 会员加入圈子列表
  406. $this->memberJoinCircle();
  407. $fs_list = Model()->table('circle_fs')->where(array('circle_id'=>$this->c_id))->order('friendship_sort asc')->select();
  408. Tpl::output('fs_list', $fs_list);
  409. $this->sidebar_menu('friendship');
  410. Tpl::showpage('group_manage_fs');
  411. }
  412. /**
  413. * 添加友情圈子
  414. */
  415. public function friendship_addOp(){
  416. // 身份验证
  417. $rs = $this->checkIdentity('c');
  418. if(!empty($rs)){
  419. showDialog($rs);
  420. }
  421. if(chksubmit()){
  422. /**
  423. * 验证
  424. */
  425. $obj_validate = new Validator();
  426. $obj_validate->validateparam = array(
  427. array("input"=>$_POST["cid"], "require"=>"true", 'validator'=>'Number', "message"=>L('fcircle_please_choose')),
  428. array("input"=>$_POST["sort"], "require"=>"true", 'validator'=>'Number', "message"=>L('circle_sort_error')),
  429. );
  430. $error = $obj_validate->validate();
  431. if($error != ''){
  432. showDialog($error);
  433. }else{
  434. if($_POST['cid'] <= 0){
  435. showDialog(L('fcircle_please_choose'));
  436. }
  437. $insert = array();
  438. $insert['circle_id'] = $this->c_id;
  439. $insert['friendship_id'] = $_POST['cid'];
  440. $insert['friendship_name'] = $_POST['cname'];
  441. $insert['friendship_sort'] = $_POST['sort'];
  442. $insert['friendship_status']= $_POST['status']?1:0;
  443. Model()->table('circle_fs')->insert($insert);
  444. showDialog(L('nc_common_op_succ'), 'reload', 'succ', 'CUR_DIALOG.close();');
  445. }
  446. }
  447. Tpl::showpage('group_manage_fsadd', 'null_layout');
  448. }
  449. /**
  450. * ajax根据名称搜索
  451. */
  452. public function search_circleOp(){
  453. // 身份验证
  454. $rs = $this->checkIdentity('c');
  455. if(!empty($rs)){
  456. echo 'false';die;
  457. }
  458. $model = Model();
  459. // 查询已加友情圈子
  460. $circle_list = $model->table('circle_fs')->where(array('circle_id'=>$this->c_id))->select();
  461. if (!empty($circle_list)){
  462. $circle_list = array_under_reset($circle_list, 'friendship_id'); $circle_array = array_keys($circle_list);
  463. }
  464. $where = array();
  465. $where['circle_name'] = array('like', '%'.$_GET['name'].'%');
  466. $where['circle_status'] = 1;
  467. if(!empty($circle_array)){
  468. $circle_array[] = $this->c_id;
  469. $where['circle_id'] = array('not in', $circle_array);
  470. }else{
  471. $where['circle_id'] = array('neq', $this->c_id);
  472. }
  473. $circle_list = $model->table('circle')->field('circle_id,circle_name')->where($where)->select();
  474. if (empty($circle_list)) {
  475. echo 'false';die;
  476. }
  477. if (strtoupper(CHARSET) == 'GBK'){
  478. $circle_list = Language::getUTF8($circle_list);
  479. }
  480. echo json_encode($circle_list);
  481. }
  482. /**
  483. * 编辑圈子
  484. */
  485. public function friendship_editOp(){
  486. // 身份验证
  487. $rs = $this->checkIdentity('c');
  488. if(!empty($rs)){
  489. showDialog($rs);
  490. }
  491. if(chksubmit()){
  492. /**
  493. * 验证
  494. */
  495. $obj_validate = new Validator();
  496. $obj_validate->validateparam = array(
  497. array("input"=>$_POST["sort"], "require"=>"true", 'validator'=>'Number', "message"=>L('circle_sort_error')),
  498. );
  499. $error = $obj_validate->validate();
  500. if($error != ''){
  501. showDialog($error);
  502. }else{
  503. $update = array();
  504. $update['friendship_sort'] = $_POST['sort'];
  505. $update['friendship_status']= $_POST['status']?1:0;
  506. Model()->table('circle_fs')->where(array('circle_id'=>$this->c_id, 'friendship_id'=>intval($_GET['fs_id'])))->update($update);
  507. showDialog(L('nc_common_op_succ'), 'reload', 'succ', 'CUR_DIALOG.close();');
  508. }
  509. }
  510. $fs_id = intval($_GET['fs_id']);
  511. if($fs_id <= 0){
  512. showDialog(L('wrong_argument'));
  513. }
  514. $friendship_info = Model()->table('circle_fs')->where(array('circle_id'=>$this->c_id, 'friendship_id'=>$fs_id))->find();
  515. if(empty($friendship_info)){
  516. showDialog(L('wrong_argument'));
  517. }
  518. Tpl::output('fs_id', $fs_id);
  519. Tpl::output('friendship_info', $friendship_info);
  520. Tpl::showpage('group_manage_fsedit', 'null_layout');
  521. }
  522. /**
  523. * 删除友情圈子
  524. */
  525. public function friendship_delOp(){
  526. // 身份验证
  527. $rs = $this->checkIdentity('c');
  528. if(!empty($rs)){
  529. showDialog($rs);
  530. }
  531. $fs_array = explode(',', $_GET['fs_id']);
  532. if(empty($fs_array)){
  533. showDialog(L('wrong_argument'));
  534. }
  535. $where = array();
  536. $where['circle_id'] = $this->c_id;
  537. $where['friendship_id'] = array('in', $fs_array);
  538. Model()->table('circle_fs')->where($where)->delete();
  539. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  540. }
  541. /**
  542. * 加精/取消加精
  543. * 置顶/取消置顶
  544. */
  545. public function ajaxOp(){
  546. // 身份验证
  547. $rs = $this->checkIdentity('cm');
  548. if(!empty($rs)){
  549. echo 'false';exit;
  550. }
  551. $update = array();
  552. $update['theme_id'] = intval($_GET['id']);
  553. switch ($_GET['column']){
  554. case 'digest':
  555. $update['is_digest'] = $_GET['value'];
  556. break;
  557. case 'top':
  558. $update['is_stick'] = $_GET['value'];
  559. break;
  560. case 'shut':
  561. $update['is_shut'] = $_GET['value'];
  562. break;
  563. }
  564. Model()->table('circle_theme')->update($update);
  565. echo 'true';exit;
  566. }
  567. /**
  568. * 编辑话题
  569. */
  570. public function edit_themeOp(){
  571. // 身份验证
  572. $rs = $this->checkIdentity('cm');
  573. if(!empty($rs)){
  574. showMessage($rs);
  575. }
  576. $t_id = intval($_GET['t_id']);
  577. if($t_id <= 0){
  578. showMessage(L('wrong_argument'));
  579. }
  580. Tpl::output('t_id', $t_id);
  581. $model = Model();
  582. if(chksubmit()){
  583. // 主题分类
  584. $thclass_id = intval($_POST['thtype']);
  585. $thclass_name = '';
  586. if($thclass_id > 0){
  587. $thclass_info = $model->table('circle_thclass')->find($thclass_id);
  588. $thclass_name = $thclass_info['thclass_name'];
  589. }
  590. $model = Model();
  591. $update = array();
  592. $update['theme_id'] = $t_id;
  593. $update['theme_name'] = circleCenterCensor($_POST['name']);
  594. $update['theme_content'] = circleCenterCensor($_POST['themecontent']);
  595. $update['thclass_id'] = $thclass_id;
  596. $update['thclass_name'] = $thclass_name;
  597. $update['theme_editname'] = $_SESSION['member_name'];
  598. $update['theme_edittime'] = time();
  599. $update['theme_readperm'] = intval($_POST['readperm']);
  600. $rs = $model->table('circle_theme')->update($update);
  601. if($rs){
  602. $has_goods = 0; // 存在商品标记
  603. $has_affix = 0;// 存在附件标记
  604. // 删除原有商品
  605. $goods_list = Model()->table('circle_thg')->where(array('theme_id'=>$t_id, 'reply_id'=>0))->delete();
  606. // 插入话题商品
  607. if(!empty($_POST['goods'])){
  608. $goods_insert = array();
  609. foreach ($_POST['goods'] as $key=>$val){
  610. $p = array();
  611. $p['theme_id'] = $t_id;
  612. $p['reply_id'] = 0;
  613. $p['circle_id'] = $this->c_id;
  614. $p['goods_id'] = $key;
  615. $p['goods_name'] = $val['name'];
  616. $p['goods_price'] = $val['price'];
  617. $p['goods_image'] = $val['image'];
  618. $p['store_id'] = $val['storeid'];
  619. $goods_insert[] = $p;
  620. }
  621. $rs = $model->table('circle_thg')->insertAll($goods_insert);
  622. $has_goods = 1;
  623. }
  624. // 更新话题信息
  625. $affixe_count = $model->table('circle_affix')->where(array('affix_type'=>1, 'theme_id'=>$t_id))->count();
  626. if($affixe_count > 0){
  627. $has_affix = 1;
  628. }
  629. if($has_goods || $has_affix){
  630. $update = array();
  631. $update['theme_id'] = $t_id;
  632. $update['has_goods'] = $has_goods;
  633. $update['has_affix'] = $has_affix;
  634. $model->table('circle_theme')->update($update);
  635. }
  636. // Special theme
  637. if($_GET['sp'] == 1){
  638. // Update the vote
  639. $update = array();
  640. $update['theme_id'] = $t_id;
  641. $update['poll_multiple'] = intval($_POST['multiple']);
  642. $update['poll_startime'] = time();
  643. $update['poll_endtime'] = intval($_POST['days'])!=0?time()+intval($_POST['days'])*60*60*12:0;
  644. $update['poll_days'] = intval($_POST['days']);
  645. $model->table('circle_thpoll')->update($update);
  646. // Update the voting options
  647. if(!empty($_POST['polloption'])){
  648. $insert_array = array();
  649. foreach ($_POST['polloption'] as $key=>$val){
  650. $option_info = $model->table('circle_thpolloption')->where(array('pollop_id'=>$key, 'theme_id'=>$t_id))->find();
  651. if(!empty($option_info)){
  652. $update = array();
  653. $update['pollop_id'] = $key;
  654. $update['pollop_option']= $val;
  655. $update['pollop_sort'] = $_POST['pollsort'][$key];
  656. $model->table('circle_thpolloption')->update($update);
  657. }else{
  658. if ($val == '') continue;
  659. $i = array();
  660. $i['theme_id'] = $t_id;
  661. $i['pollop_option'] = $val;
  662. $i['pollop_sort'] = $_POST['pollsort'][$key];
  663. $insert_array[] = $i;
  664. }
  665. }
  666. if(!empty($insert_array)) $model->table('circle_thpolloption')->insertAll($insert_array);
  667. }
  668. }
  669. 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');
  670. }else{
  671. showDialog(L('nc_common_op_fail'));
  672. }
  673. }
  674. // 圈子信息
  675. $this->circleInfo();
  676. // 圈主和管理信息
  677. $this->manageList();
  678. // 会员信息
  679. $this->memberInfo();
  680. // 话题信息
  681. $this->theme_info = $model->table('circle_theme')->where(array('theme_id'=>$t_id, 'circle_id'=>$this->c_id))->find();
  682. if(empty($this->theme_info)){
  683. showMessage(L('wrong_argument'));
  684. }
  685. Tpl::output('theme_info', $this->theme_info);
  686. // 话题商品
  687. $goods_list = $model->table('circle_thg')->where(array('theme_id'=>$t_id, 'reply_id'=>0))->select();
  688. $goods_list = tidyThemeGoods($goods_list, 'themegoods_id');
  689. Tpl::output('goods_list', $goods_list);
  690. // 话题附件
  691. $affix_list = $model->table('circle_affix')->where(array('affix_type'=>1, 'theme_id'=>$t_id))->select();
  692. Tpl::output('affix_list', $affix_list);
  693. // 话题分类
  694. $where = array();
  695. $where['circle_id'] = $this->c_id;
  696. $where['thclass_status']= 1;
  697. $thclass_list = $model->table('circle_thclass')->where($where)->select();
  698. $thclass_list = array_under_reset($thclass_list, 'thclass_id');
  699. Tpl::output('thclass_list', $thclass_list);
  700. // Read permissions
  701. $readperm = $this->readPermissions($this->cm_info);
  702. Tpl::output('readperm', $readperm);
  703. // breadcrumb navigation
  704. $this->breadcrumd(L('nc_edit_theme'));
  705. if($this->theme_info['theme_special'] == 1){
  706. $poll_info = $model->table('circle_thpoll')->find($t_id);
  707. Tpl::output('poll_info', $poll_info);
  708. $option_list = $model->table('circle_thpolloption')->where(array('theme_id'=>$t_id))->order('pollop_sort asc')->select();
  709. Tpl::output('option_list', $option_list);
  710. Tpl::showpage('group_manage_edit_themepoll');
  711. }else{
  712. Tpl::showpage('group_manage_edit_theme');
  713. }
  714. }
  715. /**
  716. * 附件删除
  717. */
  718. public function delimgOp(){
  719. // 身份验证
  720. $rs = $this->checkIdentity('cm');
  721. if(!empty($rs)){
  722. echo false;exit;
  723. }
  724. $id = intval($_GET['id']);
  725. if($id <= 0){
  726. echo false;exit;
  727. }
  728. // 附件详细
  729. $affix_info = Model()->table('circle_affix')->where(array('member_id'=>$_SESSION['member_id'], 'affix_id'=>$id))->find();
  730. if(empty($affix_info)){
  731. echo false;exit;
  732. }
  733. // 验证是否为该圈子附件
  734. $theme_info = Model()->table('circle_theme')->where(array('circle_id'=>$this->c_id, 'theme_id'=>$affix_info['theme_id']))->find();
  735. if(empty($theme_info)){
  736. echo false;exit;
  737. }
  738. @unlink(themeImagePath($affix_info['affix_filename']));
  739. @unlink(themeImagePath($affix_info['affix_filethumb']));
  740. Model()->table('circle_affix')->delete($id);
  741. echo true;exit;
  742. }
  743. /**
  744. * 删除话题
  745. */
  746. public function del_themeOp(){
  747. // 身份验证
  748. $rs = $this->checkIdentity('cm');
  749. if(!empty($rs)){
  750. showMessage($rs);
  751. }
  752. $model = Model();
  753. // 验证话题
  754. $t_id = intval($_GET['t_id']);
  755. $theme_info = $model->table('circle_theme')->where(array('theme_id'=>$t_id, 'circle_id'=>$this->c_id))->find();
  756. if(empty($theme_info)){
  757. showDialog(L('wrong_argument'));
  758. }
  759. // 删除附件
  760. $affix_list = $model->table('circle_affix')->where(array('theme_id'=>$t_id))->select();
  761. if(!empty($affix_list)){
  762. foreach ($affix_list as $val){
  763. @unlink(themeImagePath($val['affix_filename']));
  764. @unlink(themeImagePath($val['affix_filethumb']));
  765. }
  766. $model->table('circle_affix')->where(array('theme_id'=>$t_id))->delete();
  767. }
  768. // 删除商品
  769. $model->table('circle_thg')->where(array('theme_id'=>$t_id))->delete();
  770. // 删除赞表相关
  771. $model->table('circle_like')->where(array('theme_id'=>$t_id))->delete();
  772. // 删除回复
  773. $model->table('circle_threply')->where(array('theme_id'=>$t_id))->delete();
  774. // The recycle bin add delete records
  775. $param = array();
  776. $param['theme_id'] = $t_id;
  777. $param['op_id'] = $_SESSION['member_id'];
  778. $param['op_name'] = $_SESSION['member_name'];
  779. $param['type'] = 'theme';
  780. Model('circle_recycle')->saveRecycle($param);
  781. // 删除话题
  782. $model->table('circle_theme')->delete($t_id);
  783. // Experience
  784. if(intval($theme_info['theme_exp']) > 0){
  785. $param = array();
  786. $param['member_id'] = $theme_info['member_id'];
  787. $param['member_name'] = $theme_info['member_name'];
  788. $param['circle_id'] = $this->c_id;
  789. $param['itemid'] = $t_id;
  790. $param['type'] = 'delRelease';
  791. $param['exp'] = $theme_info['theme_exp'];
  792. Model('circle_exp')->saveExp($param);
  793. }
  794. showDialog(L('nc_common_op_succ'), CIRCLE_SITE_URL.'/index.php?act=group&c_id='.$this->c_id, 'succ');
  795. }
  796. /**
  797. * 删除回复
  798. */
  799. public function del_replyOp(){
  800. // 身份验证
  801. $rs = $this->checkIdentity('cm');
  802. if(!empty($rs)){
  803. showMessage($rs);
  804. }
  805. $t_id = intval($_GET['t_id']);
  806. $r_id = intval($_GET['r_id']);
  807. // 验证回复
  808. $model = Model();
  809. $where = array();
  810. $where['theme_id'] = $t_id;
  811. $where['reply_id'] = $r_id;
  812. $where['circle_id'] = $this->c_id;
  813. $reply_info = $model->table('circle_threply')->where($where)->find();
  814. if(empty($reply_info)){
  815. showDialog(L('circle_reply_not_exists'), 'reload');
  816. }
  817. // 删除附件
  818. $affix_list = $model->table('circle_affix')->where(array('affix_type'=>2, 'theme_id'=>$t_id, 'reply_id'=>$r_id))->select();
  819. if(!empty($affix_list)){
  820. foreach ($affix_list as $val){
  821. @unlink(themeImagePath($val['affix_filename']));
  822. @unlink(themeImagePath($val['affix_filethumb']));
  823. }
  824. $model->table('circle_affix')->where(array('affix_type'=>2 ,'theme_id'=>$t_id, 'reply_id'=>$r_id))->delete();
  825. }
  826. // 删除商品
  827. $model->table('circle_thg')->where(array('theme_id'=>$t_id, 'reply_id'=>$r_id))->delete();
  828. // The recycle bin add delete records
  829. $param = array();
  830. $param['theme_id'] = $t_id;
  831. $param['reply_id'] = $r_id;
  832. $param['op_id'] = $_SESSION['member_id'];
  833. $param['op_name'] = $_SESSION['member_name'];
  834. $param['type'] = 'reply';
  835. Model('circle_recycle')->saveRecycle($param);
  836. // 删除回复
  837. $rs = $model->table('circle_threply')->where(array('theme_id'=>$t_id, 'reply_id'=>$r_id))->delete();
  838. // 更新话题回复数
  839. $model->table('circle_theme')->update(array('theme_id'=>$t_id, 'theme_commentcount'=>array('exp', 'theme_commentcount-1')));
  840. // Experience
  841. if(intval($reply_info['reply_exp']) > 0){
  842. $param = array();
  843. $param['member_id'] = $reply_info['member_id'];
  844. $param['member_name'] = $reply_info['member_name'];
  845. $param['circle_id'] = $this->c_id;
  846. $param['itemid'] = $t_id.','.$r_id;
  847. $param['type'] = 'delReplied';
  848. $param['exp'] = $reply_info['reply_exp'];
  849. Model('circle_exp')->saveExp($param);
  850. }
  851. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  852. }
  853. /**
  854. * ajax禁言
  855. */
  856. public function ajax_nospeakOp(){
  857. // 身份验证
  858. $rs = $this->checkIdentity('cm');
  859. if(!empty($rs)){
  860. showDialog($rs);
  861. }
  862. // 条件
  863. $where = array();
  864. $where['member_id'] = intval($_GET['m_id']);
  865. $where['circle_id'] = $this->c_id;
  866. // 圈主和管理不能被禁言
  867. $m_info = Model()->table('circle_member')->where($where)->find();
  868. if(in_array($m_info['is_identity'], array(1,2))){
  869. showDialog(L('circle_manager_shutup_error'));
  870. }
  871. // 更新数据
  872. $update = array();
  873. $update['is_allowspeak'] = intval($_GET['value']);
  874. Model()->table('circle_member')->where($where)->update($update);
  875. // 话题/回复 屏蔽
  876. $update = array();
  877. $update['is_closed'] = (intval($_GET['value']) == 1) ? 0 : 1;
  878. Model()->table('circle_theme')->where($where)->update($update);
  879. Model()->table('circle_threply')->where($where)->update($update);
  880. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  881. }
  882. }