PageRenderTime 64ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/source/admincp/admincp_forums.php

https://github.com/kuaileshike/upload
PHP | 2132 lines | 2037 code | 89 blank | 6 comment | 188 complexity | e6434f688b192061a19a56355c706540 MD5 | raw file
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: admincp_forums.php 31327 2012-08-13 07:01:41Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. cpheader();
  12. $operation = empty($operation) ? 'admin' : $operation;
  13. $fid = getgpc('fid');
  14. if($operation == 'admin') {
  15. if(!submitcheck('editsubmit')) {
  16. shownav('forum', 'forums_admin');
  17. showsubmenu('forums_admin');
  18. showtips('forums_admin_tips');
  19. require_once libfile('function/forumlist');
  20. $forums = str_replace("'", "\'", forumselect(false, 0, 0, 1));
  21. ?>
  22. <script type="text/JavaScript">
  23. var forumselect = '<?php echo $forums;?>';
  24. var rowtypedata = [
  25. [[1, ''], [1,'<input type="text" class="txt" name="newcatorder[]" value="0" />', 'td25'], [5, '<div><input name="newcat[]" value="<?php cplang('forums_admin_add_category_name', null, true);?>" size="20" type="text" class="txt" /><a href="javascript:;" class="deleterow" onClick="deleterow(this)"><?php cplang('delete', null, true);?></a></div>']],
  26. [[1, ''], [1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [5, '<div class="board"><input name="newforum[{1}][]" value="<?php cplang('forums_admin_add_forum_name', null, true);?>" size="20" type="text" class="txt" /><a href="javascript:;" class="deleterow" onClick="deleterow(this)"><?php cplang('delete', null, true);?></a><select name="newinherited[{1}][]"><option value=""><?php cplang('forums_edit_newinherited', null, true);?></option>' + forumselect + '</select></div>']],
  27. [[1, ''], [1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [5, '<div class="childboard"><input name="newforum[{1}][]" value="<?php cplang('forums_admin_add_forum_name', null, true);?>" size="20" type="text" class="txt" /><a href="javascript:;" class="deleterow" onClick="deleterow(this)"><?php cplang('delete', null, true);?></a>&nbsp;<label><input name="inherited[{1}][]" type="checkbox" class="checkbox" value="1">&nbsp;<?php cplang('forums_edit_inherited', null, true);?></label></div>']],
  28. ];
  29. </script>
  30. <?php
  31. showformheader('forums');
  32. echo '<div style="height:30px;line-height:30px;"><a href="javascript:;" onclick="show_all()">'.cplang('show_all').'</a> | <a href="javascript:;" onclick="hide_all()">'.cplang('hide_all').'</a> <input type="text" id="srchforumipt" class="txt" /> <input type="submit" class="btn" value="'.cplang('search').'" onclick="return srchforum()" /></div>';
  33. showtableheader('');
  34. showsubtitle(array('', 'display_order', 'forums_admin_name', '', 'forums_moderators', '<a href="javascript:;" onclick="if(getmultiids()) location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&multi=\' + getmultiids();return false;">'.$lang['multiedit'].'</a>'));
  35. $forumcount = C::t('forum_forum')->fetch_forum_num();
  36. $query = C::t('forum_forum')->fetch_all_forum_for_sub_order();
  37. $groups = $forums = $subs = $fids = $showed = array();
  38. foreach($query as $forum) {
  39. if($forum['type'] == 'group') {
  40. $groups[$forum['fid']] = $forum;
  41. } elseif($forum['type'] == 'sub') {
  42. $subs[$forum['fup']][] = $forum;
  43. } else {
  44. $forums[$forum['fup']][] = $forum;
  45. }
  46. $fids[] = $forum['fid'];
  47. }
  48. foreach ($groups as $id => $gforum) {
  49. $toggle = $forumcount > 50 && count($forums[$id]) > 2;
  50. $showed[] = showforum($gforum, 'group', '', $toggle);
  51. if(!empty($forums[$id])) {
  52. foreach ($forums[$id] as $forum) {
  53. $showed[] = showforum($forum);
  54. $lastfid = 0;
  55. if(!empty($subs[$forum['fid']])) {
  56. foreach ($subs[$forum['fid']] as $sub) {
  57. $showed[] = showforum($sub, 'sub');
  58. $lastfid = $sub['fid'];
  59. }
  60. }
  61. showforum($forum, $lastfid, 'lastchildboard');
  62. }
  63. }
  64. showforum($gforum, '', 'lastboard');
  65. }
  66. if(count($fids) != count($showed)) {
  67. foreach($fids as $fid) {
  68. if(!in_array($fid, $showed)) {
  69. C::t('forum_forum')->update($fid, array('fup' => '0', 'type' => 'forum'));
  70. }
  71. }
  72. }
  73. showforum($gforum, '', 'last');
  74. showsubmit('editsubmit');
  75. showtablefooter();
  76. showformfooter();
  77. } else {
  78. $usergroups = array();
  79. $query = C::t('common_usergroup')->range();
  80. foreach($query as $group) {
  81. $usergroups[$group['groupid']] = $group;
  82. }
  83. if(is_array($_GET['order'])) {
  84. foreach($_GET['order'] as $fid => $value) {
  85. C::t('forum_forum')->update($fid, array('name' => $_GET['name'][$fid], 'displayorder' => $_GET['order'][$fid]));
  86. }
  87. }
  88. if(is_array($_GET['newcat'])) {
  89. foreach($_GET['newcat'] as $key => $forumname) {
  90. if(empty($forumname)) {
  91. continue;
  92. }
  93. $fid = C::t('forum_forum')->insert(array('type' => 'group', 'name' => $forumname, 'status' => 1, 'displayorder' => $_GET['newcatorder'][$key]), 1);
  94. C::t('forum_forumfield')->insert(array('fid' => $fid));
  95. }
  96. }
  97. $table_forum_columns = array('fup', 'type', 'name', 'status', 'displayorder', 'styleid', 'allowsmilies',
  98. 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowanonymous', 'allowpostspecial', 'alloweditrules',
  99. 'alloweditpost', 'modnewposts', 'recyclebin', 'jammer', 'forumcolumns', 'threadcaches', 'disablewatermark', 'disablethumb',
  100. 'autoclose', 'simple', 'allowside', 'allowfeed');
  101. $table_forumfield_columns = array('fid', 'attachextensions', 'threadtypes', 'viewperm', 'postperm', 'replyperm',
  102. 'getattachperm', 'postattachperm', 'postimageperm');
  103. if(is_array($_GET['newforum'])) {
  104. foreach($_GET['newforum'] as $fup => $forums) {
  105. $fupforum = C::t('forum_forum')->get_forum_by_fid($fup);
  106. if(empty($fupforum)) continue;
  107. if($fupforum['fup']) {
  108. $groupforum = C::t('forum_forum')->get_forum_by_fid($fupforum['fup']);
  109. } else {
  110. $groupforum = $fupforum;
  111. }
  112. foreach($forums as $key => $forumname) {
  113. if(empty($forumname) || strlen($forumname) > 50) continue;
  114. $forum = $forumfields = array();
  115. $inheritedid = !empty($_GET['inherited'][$fup]) ? $fup : (!empty($_GET['newinherited'][$fup][$key]) ? $_GET['newinherited'][$fup][$key] : '');
  116. if(!empty($inheritedid)) {
  117. $forum = C::t('forum_forum')->get_forum_by_fid($inheritedid);
  118. $forumfield = C::t('forum_forum')->get_forum_by_fid($inheritedid, null, 'forumfield');
  119. foreach($table_forum_columns as $field) {
  120. $forumfields[$field] = $forum[$field];
  121. }
  122. foreach($table_forumfield_columns as $field) {
  123. $forumfields[$field] = $forumfield[$field];
  124. }
  125. } else {
  126. $forumfields['allowsmilies'] = $forumfields['allowbbcode'] = $forumfields['allowimgcode'] = 1;
  127. $forumfields['allowpostspecial'] = 1;
  128. $forumfields['allowside'] = 0;
  129. $forumfields['allowfeed'] = 0;
  130. $forumfields['recyclebin'] = 1;
  131. }
  132. $forumfields['fup'] = $fup ? $fup : 0;
  133. $forumfields['type'] = $fupforum['type'] == 'forum' ? 'sub' : 'forum';
  134. $forumfields['styleid'] = $groupforum['styleid'];
  135. $forumfields['name'] = $forumname;
  136. $forumfields['status'] = 1;
  137. $forumfields['displayorder'] = $_GET['neworder'][$fup][$key];
  138. $data = array();
  139. foreach($table_forum_columns as $field) {
  140. if(isset($forumfields[$field])) {
  141. $data[$field] = $forumfields[$field];
  142. }
  143. }
  144. $forumfields['fid'] = $fid = C::t('forum_forum')->insert($data, 1);
  145. $data = array();
  146. $forumfields['threadtypes'] = copy_threadclasses($forumfields['threadtypes'], $fid);
  147. foreach($table_forumfield_columns as $field) {
  148. if(isset($forumfields[$field])) {
  149. $data[$field] = $forumfields[$field];
  150. }
  151. }
  152. C::t('forum_forumfield')->insert($data);
  153. foreach(C::t('forum_moderator')->fetch_all_by_fid($fup, false) as $mod) {
  154. if($mod['inherited'] || $fupforum['inheritedmod']) {
  155. C::t('forum_moderator')->insert(array('uid' => $mod['uid'], 'fid' => $fid, 'inherited' => 1), false, true);
  156. }
  157. }
  158. }
  159. }
  160. }
  161. updatecache('forums');
  162. cpmsg('forums_update_succeed', 'action=forums', 'succeed');
  163. }
  164. } elseif($operation == 'moderators' && $fid) {
  165. if(!submitcheck('modsubmit')) {
  166. $forum = C::t('forum_forum')->fetch($fid);
  167. shownav('forum', 'forums_moderators_edit');
  168. showsubmenu(cplang('forums_moderators_edit').' - '.$forum['name']);
  169. showtips('forums_moderators_tips');
  170. showformheader("forums&operation=moderators&fid=$fid&");
  171. showtableheader('', 'fixpadding');
  172. showsubtitle(array('', 'display_order', 'username', 'usergroups', 'forums_moderators_inherited'));
  173. $modgroups = C::t('common_admingroup')->fetch_all_merge_usergroup(array_keys(C::t('common_usergroup')->fetch_all_by_radminid(0)));
  174. $groupselect = '<select name="newgroup">';
  175. foreach($modgroups as $modgroup) {
  176. if($modgroup['radminid'] == 3) {
  177. $groupselect .= '<option value="'.$modgroup['admingid'].'">'.$modgroup['grouptitle'].'</option>';
  178. }
  179. $modgroups[$modgroup['admingid']] = $modgroup['grouptitle'];
  180. }
  181. $groupselect .= '</select>';
  182. $moderators = C::t('forum_moderator')->fetch_all_by_fid($fid);
  183. $uids = array_keys($moderators);
  184. if($uids) {
  185. $users = C::t('common_member')->fetch_all($uids);
  186. }
  187. foreach($moderators as $mod) {
  188. showtablerow('', array('class="td25"', 'class="td28"'), array(
  189. '<input type="checkbox" class="checkbox" name="delete[]" value="'.$mod[uid].'"'.($mod['inherited'] ? ' disabled' : '').' />',
  190. '<input type="text" class="txt" name="displayordernew['.$mod[uid].']" value="'.$mod[displayorder].'" size="2" />',
  191. "<a href=\"".ADMINSCRIPT."?mod=forum&action=members&operation=group&uid=$mod[uid]\" target=\"_blank\">{$users[$mod['uid']]['username']}</a>",
  192. $modgroups[$users[$mod['uid']]['groupid']],
  193. cplang($mod['inherited'] ? 'yes' : 'no'),
  194. ));
  195. }
  196. if($forum['type'] == 'group' || $forum['type'] == 'sub') {
  197. $checked = $forum['type'] == 'group' ? 'checked' : '';
  198. $disabled = 'disabled';
  199. } else {
  200. $checked = $forum['inheritedmod'] ? 'checked' : '';
  201. $disabled = '';
  202. }
  203. showtablerow('', array('class="td25"', 'class="td28"'), array(
  204. cplang('add_new'),
  205. '<input type="text" class="txt" name="newdisplayorder" value="0" size="2" />',
  206. '<input type="text" class="txt" name="newmoderator" value="" size="20" />',
  207. $groupselect,
  208. ''
  209. ));
  210. showsubmit('modsubmit', 'submit', 'del', '<input class="checkbox" type="checkbox" name="inheritedmodnew" value="1" '.$checked.' '.$disabled.' id="inheritedmodnew" /><label for="inheritedmodnew">'.cplang('forums_moderators_inherit').'</label>');
  211. showtablefooter();
  212. showformfooter();
  213. } else {
  214. $forum = C::t('forum_forum')->fetch($fid);
  215. $inheritedmodnew = $_GET['inheritedmodnew'];
  216. if($forum['type'] == 'group') {
  217. $inheritedmodnew = 1;
  218. } elseif($forum['type'] == 'sub') {
  219. $inheritedmodnew = 0;
  220. }
  221. if(!empty($_GET['delete']) || $_GET['newmoderator'] || (bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) {
  222. $fidarray = $newmodarray = $origmodarray = array();
  223. if($forum['type'] == 'group') {
  224. $query = C::t('forum_forum')->fetch_all_fids(1, 'forum', $fid);
  225. foreach($query as $sub) {
  226. $fidarray[] = $sub['fid'];
  227. }
  228. $query = C::t('forum_forum')->fetch_all_fids(1, 'sub', $fidarray);
  229. foreach($query as $sub) {
  230. $fidarray[] = $sub['fid'];
  231. }
  232. } elseif($forum['type'] == 'forum') {
  233. $query = C::t('forum_forum')->fetch_all_fids(1, 'sub', $fid);
  234. foreach($query as $sub) {
  235. $fidarray[] = $sub['fid'];
  236. }
  237. }
  238. if(is_array($_GET['delete'])) {
  239. foreach($_GET['delete'] as $uid) {
  240. C::t('forum_moderator')->delete_by_uid_fid_inherited($uid, $fid, $fidarray);
  241. }
  242. $excludeuids = array();
  243. $deleteuids = '\''.implode('\',\'', $_GET['delete']).'\'';
  244. foreach(C::t('forum_moderator')->fetch_all_by_uid($_GET['delete']) as $mod) {
  245. $excludeuids[] = $mod['uid'];
  246. }
  247. $usergroups = array();
  248. $query = C::t('common_usergroup')->range();
  249. foreach($query as $group) {
  250. $usergroups[$group['groupid']] = $group;
  251. }
  252. $members = C::t('common_member')->fetch_all($_GET['delete'], false, 0);
  253. foreach($members as $uid => $member) {
  254. if(!in_array($uid, $excludeuids) && !in_array($member['adminid'], array(1,2))) {
  255. if($usergroups[$member['groupid']]['type'] == 'special' && $usergroups[$member['groupid']]['radminid'] != 3) {
  256. $adminidnew = -1;
  257. $groupidnew = $member['groupid'];
  258. } else {
  259. $adminidnew = 0;
  260. foreach($usergroups as $group) {
  261. if($group['type'] == 'member' && $member['credits'] >= $group['creditshigher'] && $member['credits'] < $group['creditslower']) {
  262. $groupidnew = $group['groupid'];
  263. break;
  264. }
  265. }
  266. }
  267. C::t('common_member')->update($member['uid'], array('adminid'=>$adminidnew, 'groupid'=>$groupidnew));
  268. }
  269. }
  270. }
  271. if($_GET['newmoderator']) {
  272. $member = C::t('common_member')->fetch_by_username($_GET['newmoderator']);
  273. if(!$member) {
  274. cpmsg_error('members_edit_nonexistence');
  275. } else {
  276. $newmodarray[] = $member['uid'];
  277. $membersetarr = array();
  278. if(!in_array($member['adminid'],array(1,2,3,4,5,6,7,8,-1))) {
  279. $membersetarr['groupid'] = $_GET['newgroup'];
  280. }
  281. if(!in_array($member['adminid'],array(1,2))) {
  282. $membersetarr['adminid'] = '3';
  283. }
  284. if(!empty($membersetarr)) {
  285. C::t('common_member')->update($member['uid'], $membersetarr);
  286. }
  287. C::t('forum_moderator')->insert(array(
  288. 'uid' => $member['uid'],
  289. 'fid' => $fid,
  290. 'displayorder' => $_GET['newdisplayorder'],
  291. 'inherited' => '0',
  292. ), false, true);
  293. }
  294. }
  295. if((bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) {
  296. foreach(C::t('forum_moderator')->fetch_all_by_fid_inherited($fid) as $mod) {
  297. $origmodarray[] = $mod['uid'];
  298. if(!$forum['inheritedmod'] && $inheritedmodnew) {
  299. $newmodarray[] = $mod['uid'];
  300. }
  301. }
  302. if($forum['inheritedmod'] && !$inheritedmodnew) {
  303. C::t('forum_moderator')->delete_by_uid_fid($origmodarray, $fidarray);
  304. }
  305. }
  306. foreach($newmodarray as $uid) {
  307. C::t('forum_moderator')->insert(array(
  308. 'uid' => $uid,
  309. 'fid' => $fid,
  310. 'displayorder' => $_GET['newdisplayorder'],
  311. 'inherited' => '0',
  312. ), false, true);
  313. if($inheritedmodnew) {
  314. foreach($fidarray as $ifid) {
  315. C::t('forum_moderator')->insert(array(
  316. 'uid' => $uid,
  317. 'fid' => $ifid,
  318. 'inherited' => '1',
  319. ), false, true);
  320. }
  321. }
  322. }
  323. if($forum['type'] == 'group') {
  324. $inheritedmodnew = 1;
  325. } elseif($forum['type'] == 'sub') {
  326. $inheritedmodnew = 0;
  327. }
  328. C::t('forum_forum')->update($fid, array('inheritedmod' => $inheritedmodnew));
  329. }
  330. if(is_array($_GET['displayordernew'])) {
  331. foreach($_GET['displayordernew'] as $uid => $order) {
  332. C::t('forum_moderator')->update_by_fid_uid($fid, $uid, array(
  333. 'displayorder' => $order,
  334. ));
  335. }
  336. }
  337. $fidarray[] = $fid;
  338. foreach($fidarray as $fid) {
  339. $moderators = $tab = '';
  340. $modorder = array();
  341. $modmemberarray = C::t('forum_moderator')->fetch_all_no_inherited_by_fid($fid);
  342. foreach($modmemberarray as $moduid => $modmember) {
  343. $modorder[] = $moduid;
  344. }
  345. $members = C::t('common_member')->fetch_all_username_by_uid($modorder);
  346. foreach($modorder as $mod) {
  347. if(!$members[$mod]) {
  348. continue;
  349. }
  350. $moderators .= $tab.addslashes($members[$mod]);
  351. $tab = "\t";
  352. }
  353. C::t('forum_forumfield')->update($fid, array('moderators' => $moderators));
  354. }
  355. cpmsg('forums_moderators_update_succeed', "mod=forum&action=forums&operation=moderators&fid=$fid", 'succeed');
  356. }
  357. } elseif($operation == 'merge') {
  358. $source = $_GET['source'];
  359. $target = $_GET['target'];
  360. if(!submitcheck('mergesubmit') || $source == $target) {
  361. require_once libfile('function/forumlist');
  362. loadcache('forums');
  363. $forumselect = "<select name=\"%s\">\n<option value=\"\">&nbsp;&nbsp;> ".cplang('select')."</option><option value=\"\">&nbsp;</option>".str_replace('%', '%%', forumselect(FALSE, 0, 0, TRUE)).'</select>';
  364. shownav('forum', 'forums_merge');
  365. showsubmenu('forums_merge');
  366. showformheader('forums&operation=merge');
  367. showtableheader();
  368. showsetting('forums_merge_source', '', '', sprintf($forumselect, 'source'));
  369. showsetting('forums_merge_target', '', '', sprintf($forumselect, 'target'));
  370. showsubmit('mergesubmit');
  371. showtablefooter();
  372. showformfooter();
  373. } else {
  374. if(C::t('forum_forum')->check_forum_exists(array($source,$target)) != 2) {
  375. cpmsg_error('forums_nonexistence');
  376. }
  377. if(C::t('forum_forum')->fetch_forum_num('', $source)) {
  378. cpmsg_error('forums_merge_source_sub_notnull');
  379. }
  380. C::t('forum_thread')->update_by_fid($source, array('fid' => $target));
  381. loadcache('posttableids');
  382. $posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
  383. foreach($posttableids as $id) {
  384. C::t('forum_post')->update_fid_by_fid($id, $source, $target);
  385. }
  386. $sourceforum = C::t('forum_forum')->fetch_info_by_fid($source);
  387. $targetforum = C::t('forum_forum')->fetch_info_by_fid($target);
  388. $sourcethreadtypes = (array)dunserialize($sourceforum['threadtypes']);
  389. $targethreadtypes = (array)dunserialize($targetforum['threadtypes']);
  390. $targethreadtypes['types'] = array_merge((array)$targethreadtypes['types'], (array)$sourcethreadtypes['types']);
  391. $targethreadtypes['icons'] = array_merge((array)$targethreadtypes['icons'], (array)$sourcethreadtypes['icons']);
  392. C::t('forum_forum')->update($target, array('threads' => $targetforum['threads'] + $sourceforum['threads'], 'posts' => $targetforum['posts'] + $sourceforum['posts']));
  393. C::t('forum_forumfield')->update($target, array('threadtypes' => serialize($targethreadtypes)));
  394. C::t('forum_threadclass')->update_by_fid($source, array('fid' => $target));
  395. C::t('forum_forum')->delete_by_fid($source);
  396. C::t('home_favorite')->delete_by_id_idtype($source, 'fid');
  397. C::t('forum_moderator')->delete_by_fid($source);
  398. $log_handler = Cloud::loadClass('Cloud_Service_SearchHelper');
  399. $log_handler->myThreadLog('mergeforum', array('fid' => $source, 'otherid' => $target));
  400. $query = C::t('forum_access')->fetch_all_by_fid_uid($source);
  401. foreach($query as $access) {
  402. C::t('forum_access')->insert(array('uid' => $access['uid'], 'fid' => $target, 'allowview' => $access['allowview'], 'allowpost' => $access['allowpost'], 'allowreply' => $access['allowreply'], 'allowgetattach' => $access['allowgetattach']));
  403. }
  404. C::t('forum_access')->delete_by_fid($source);
  405. C::t('forum_thread')->clear_cache(array($source,$target), 'forumdisplay_');
  406. updatecache('forums');
  407. cpmsg('forums_merge_succeed', 'action=forums', 'succeed');
  408. }
  409. } elseif($operation == 'edit') {
  410. require_once libfile('function/forumlist');
  411. require_once libfile('function/domain');
  412. $highlight = getgpc('highlight');
  413. $anchor = getgpc('anchor');
  414. list($pluginsetting, $pluginvalue) = get_pluginsetting('forums');
  415. $multiset = 0;
  416. if(empty($_GET['multi'])) {
  417. $fids = $fid;
  418. } else {
  419. $multiset = 1;
  420. if(is_array($_GET['multi'])) {
  421. $fids = $_GET['multi'];
  422. } else {
  423. $_GET['multi'] = explode(',', $_GET['multi']);
  424. $fids = &$_GET['multi'];
  425. }
  426. }
  427. if(count($_GET['multi']) == 1) {
  428. $fids = $_GET['multi'][0];
  429. $multiset = 0;
  430. }
  431. if(empty($fids)) {
  432. cpmsg('forums_edit_nonexistence', 'action=forums&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : '').(!empty($anchor) ? "&anchor=$anchor" : ''), 'form', array(), '<select name="fid">'.forumselect(FALSE, 0, 0, TRUE).'</select>');
  433. }
  434. $mforum = array();
  435. $perms = array('viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm', 'postimageperm');
  436. $query = C::t('forum_forum')->fetch_all_info_by_fids($fids);
  437. if(empty($query)) {
  438. cpmsg('forums_nonexistence', '', 'error');
  439. } else {
  440. foreach($query as $forum) {
  441. if(isset($pluginvalue[$forum['fid']])) {
  442. $forum['plugin'] = $pluginvalue[$forum['fid']];
  443. }
  444. $mforum[] = $forum;
  445. }
  446. }
  447. $dactionarray = array();
  448. $allowthreadtypes = !in_array('threadtypes', $dactionarray);
  449. $forumkeys = C::t('common_setting')->fetch('forumkeys', true);
  450. $rules = array();
  451. foreach(C::t('common_credit_rule')->fetch_all_by_action(array('reply', 'post', 'digest', 'postattach', 'getattach')) as $value) {
  452. $rules[$value['rid']] = $value;
  453. }
  454. if(!submitcheck('detailsubmit')) {
  455. $anchor = in_array($_GET['anchor'], array('basic', 'extend', 'posts', 'attachtype', 'credits', 'threadtypes', 'threadsorts', 'perm', 'plugin')) ? $_GET['anchor'] : 'basic';
  456. shownav('forum', 'forums_edit');
  457. loadcache('forums');
  458. $forumselect = '';
  459. $sgid = 0;
  460. foreach($_G['cache']['forums'] as $forums) {
  461. $checked = $fid == $forums['fid'] || in_array($forums['fid'], $_GET['multi']);
  462. if($forums['type'] == 'group') {
  463. $sgid = $forums['fid'];
  464. $forumselect .= '</div><em class="cl">'.
  465. '<span class="right"><input name="checkall_'.$forums['fid'].'" onclick="checkAll(\'value\', this.form, '.$forums['fid'].', \'checkall_'.$forums['fid'].'\')" type="checkbox" class="vmiddle checkbox" /></span>'.
  466. '<span class="pointer" onclick="sdisplay(\'g_'.$forums['fid'].'\', this)"><img src="static/image/admincp/desc.gif" class="vmiddle" /></span> <span class="pointer" onclick="location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&switch=yes&fid='.$forums['fid'].'\'">'.$forums['name'].'</span></em><div id="g_'.$forums['fid'].'" style="display:">';
  467. } elseif($forums['type'] == 'forum') {
  468. $forumselect .= '<input class="left checkbox ck" chkvalue="'.$sgid.'" name="multi[]" value="'.$forums['fid'].'" type="checkbox" '.($checked ? 'checked="checked" ' : '').'/><a class="f'.($checked ? ' current"' : '').'" href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&switch=yes&fid='.$forums['fid'].($mforum[0]['type'] != 'group' ? '&anchor=\'+currentAnchor' : '\'').'+\'&scrolltop=\'+scrollTopBody()">'.$forums['name'].'</a>';
  469. } elseif($forums['type'] == 'sub') {
  470. $forumselect .= '<input class="left checkbox ck" chkvalue="'.$sgid.'" name="multi[]" value="'.$forums['fid'].'" type="checkbox" '.($checked ? 'checked="checked" ' : '').'/><a class="s'.($checked ? ' current"' : '').'" href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&switch=yes&fid='.$forums['fid'].($mforum[0]['type'] != 'group' ? '&anchor=\'+currentAnchor' : '\'').'+\'&scrolltop=\'+scrollTopBody()">'.$forums['name'].'</a>';
  471. }
  472. }
  473. $forumselect = '<span id="fselect" class="right popupmenu_dropmenu" onmouseover="showMenu({\'ctrlid\':this.id,\'pos\':\'34\'});$(\'fselect_menu\').style.top=(parseInt($(\'fselect_menu\').style.top)-scrollTopBody())+\'px\';$(\'fselect_menu\').style.left=(parseInt($(\'fselect_menu\').style.left)-document.documentElement.scrollLeft-20)+\'px\'">'.cplang('forums_edit_switch').'<em>&nbsp;&nbsp;</em></span>'.
  474. '<div id="fselect_menu" class="popupmenu_popup" style="display:none"><div class="fsel"><div>'.$forumselect.'</div></div><div class="cl"><input type="button" class="btn right" onclick="$(\'menuform\').submit()" value="'.cplang('forums_multiedit').'" /></div></div>';
  475. showformheader('', '', 'menuform', 'get');
  476. showhiddenfields(array('action' => 'forums', 'operation' => 'edit'));
  477. if(count($mforum) == 1 && $mforum[0]['type'] == 'group') {
  478. showsubmenu(cplang('forums_cat_detail').(count($mforum) == 1 ? ' - '.$mforum[0]['name'].'(gid:'.$mforum[0]['fid'].')' : ''), array(), $forumselect);
  479. } else {
  480. if($multiset && !in_array($anchor, array('basic', 'extend', 'posts', 'perm', 'plugin'))) {
  481. $anchor = 'basic';
  482. }
  483. showsubmenuanchors(cplang('forums_edit').(count($mforum) == 1 ? ' - '.$mforum[0]['name'].'(fid:'.$mforum[0]['fid'].')' : ''), array(
  484. array('forums_edit_basic', 'basic', $anchor == 'basic'),
  485. array('forums_edit_extend', 'extend', $anchor == 'extend'),
  486. array('forums_edit_posts', 'posts', $anchor == 'posts'),
  487. array('forums_edit_perm', 'perm', $anchor == 'perm'),
  488. !$multiset ? array('forums_edit_credits', 'credits', $anchor == 'credits') : array(),
  489. !$multiset ? array(array('menu' => 'usergroups_edit_other', 'submenu' => array(
  490. array('forums_edit_threadtypes', 'threadtypes', $anchor == 'threadtypes'),
  491. array('forums_edit_threadsorts', 'threadsorts', $anchor == 'threadsorts'),
  492. !$multiset ? array('forums_edit_attachtype', 'attachtype', $anchor == 'attachtype') : array(),
  493. !$pluginsetting ? array() : array('forums_edit_plugin', 'plugin', $anchor == 'plugin'),
  494. ))) : array(),
  495. $multiset && $pluginsetting ? array('forums_edit_plugin', 'plugin', $anchor == 'plugin') : array(),
  496. ), $forumselect);
  497. }
  498. showformfooter();
  499. $groups = array();
  500. $query = C::t('common_usergroup')->range_orderby_credit();
  501. foreach($query as $group) {
  502. $group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
  503. $groups[$group['type']][] = $group;
  504. }
  505. $styleselect = "<select name=\"styleidnew\"><option value=\"0\">$lang[use_default]</option>";
  506. foreach(C::t('common_style')->fetch_all_data(false, false) as $style) {
  507. $styleselect .= "<option value=\"$style[styleid]\" ".
  508. ($style['styleid'] == $mforum[0]['styleid'] ? 'selected="selected"' : NULL).
  509. ">$style[name]</option>\n";
  510. }
  511. $styleselect .= '</select>';
  512. if(!$multiset) {
  513. $attachtypes = '';
  514. foreach(C::t('forum_attachtype')->fetch_all_by_fid($fid) as $type) {
  515. $type['maxsize'] = round($type['maxsize'] / 1024);
  516. $attachtypes .= showtablerow('', array('class="td25"', 'class="td24"'), array(
  517. "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[id]\" />",
  518. "<input type=\"text\" class=\"txt\" size=\"10\" name=\"extension[$type[id]]\" value=\"$type[extension]\" />",
  519. "<input type=\"text\" class=\"txt\" size=\"15\" name=\"maxsize[$type[id]]\" value=\"$type[maxsize]\" />"
  520. ), TRUE);
  521. }
  522. } else {
  523. showtips('setting_multi_tips');
  524. }
  525. showformheader("forums&operation=edit&fid=$fid&", 'enctype');
  526. showhiddenfields(array('type' => $mforum[0]['type']));
  527. if(count($mforum) == 1 && $mforum[0]['type'] == 'group') {
  528. $mforum[0]['extra'] = dunserialize($mforum[0]['extra']);
  529. showtableheader();
  530. showsetting('forums_edit_basic_cat_name', 'namenew', $mforum[0]['name'], 'text');
  531. showsetting('forums_edit_basic_cat_name_color', 'extranew[namecolor]', $mforum[0]['extra']['namecolor'], 'color');
  532. showsetting('forums_edit_basic_cat_style', '', '', $styleselect);
  533. showsetting('forums_edit_extend_forum_horizontal', 'forumcolumnsnew', $mforum[0]['forumcolumns'], 'text');
  534. showsetting('forums_edit_extend_cat_sub_horizontal', 'catforumcolumnsnew', $mforum[0]['catforumcolumns'], 'text');
  535. if(!empty($_G['setting']['domain']['root']['forum'])) {
  536. showsetting('forums_edit_extend_domain', '', '', 'http://<input type="text" name="domainnew" class="txt" value="'.$mforum[0]['domain'].'" style="width:100px; margin-right:0px;" >.'.$_G['setting']['domain']['root']['forum']);
  537. } else {
  538. showsetting('forums_edit_extend_domain', 'domainnew', '', 'text', 'disabled');
  539. }
  540. showsetting('forums_cat_display', 'statusnew', $mforum[0]['status'], 'radio');
  541. showtablefooter();
  542. showtips('setting_seo_forum_tips', 'seo_tips', true, 'setseotips');
  543. showtableheader();
  544. showsetting('forums_edit_basic_seotitle', 'seotitlenew', dhtmlspecialchars($mforum[0]['seotitle']), 'text');
  545. showsetting('forums_edit_basic_keyword', 'keywordsnew', dhtmlspecialchars($mforum[0]['keywords']), 'text');
  546. showsetting('forums_edit_basic_seodescription', 'seodescriptionnew', dhtmlspecialchars($mforum[0]['seodescription']), 'textarea');
  547. showsubmit('detailsubmit');
  548. showtablefooter();
  549. } else {
  550. require_once libfile('function/editor');
  551. if($multiset) {
  552. $_G['showsetting_multi'] = 0;
  553. $_G['showsetting_multicount'] = count($mforum);
  554. foreach($mforum as $forum) {
  555. $_G['showtableheader_multi'][] = '<a href="javascript:;" onclick="location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&fid='.$forum['fid'].'&anchor=\'+$(\'cpform\').anchor.value;return false">'.$forum['name'].'(fid:'.$forum['fid'].')</a>';
  556. }
  557. }
  558. $mfids = array();
  559. foreach($mforum as $forum) {
  560. $fid = $forum['fid'];
  561. $mfids[] = $fid;
  562. if(!$multiset) {
  563. $fupselect = "<select name=\"fupnew\">\n";
  564. $query = C::t('forum_forum')->fetch_all_info_by_ignore_fid($fid);
  565. foreach($query as $fup) {
  566. $fups[] = $fup;
  567. }
  568. if(is_array($fups)) {
  569. foreach($fups as $forum1) {
  570. if($forum1['type'] == 'group') {
  571. $selected = $forum1['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
  572. $fupselect .= "<option value=\"$forum1[fid]\" $selected>$forum1[name]</option>\n";
  573. foreach($fups as $forum2) {
  574. if($forum2['type'] == 'forum' && $forum2['fup'] == $forum1['fid']) {
  575. $selected = $forum2['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
  576. $fupselect .= "<option value=\"$forum2[fid]\" $selected>&nbsp; &gt; $forum2[name]</option>\n";
  577. }
  578. }
  579. }
  580. }
  581. foreach($fups as $forum0) {
  582. if($forum0['type'] == 'forum' && $forum0['fup'] == 0) {
  583. $selected = $forum0['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
  584. $fupselect .= "<option value=\"$forum0[fid]\" $selected>$forum0[name]</option>\n";
  585. }
  586. }
  587. }
  588. $fupselect .= '</select>';
  589. if($forum['threadtypes']) {
  590. $forum['threadtypes'] = dunserialize($forum['threadtypes']);
  591. $forum['threadtypes']['status'] = 1;
  592. } else {
  593. $forum['threadtypes'] = array('status' => 0, 'required' => 0, 'listable' => 0, 'prefix' => 0, 'options' => array());
  594. }
  595. if($forum['threadsorts']) {
  596. $forum['threadsorts'] = dunserialize($forum['threadsorts']);
  597. $forum['threadsorts']['status'] = 1;
  598. } else {
  599. $forum['threadsorts'] = array('status' => 0, 'required' => 0, 'listable' => 0, 'prefix' => 0, 'options' => array());
  600. }
  601. $typeselect = $sortselect = '';
  602. $query = C::t('forum_threadtype')->fetch_all_for_order();
  603. $typeselect = getthreadclasses_html($fid);
  604. foreach($query as $type) {
  605. $typeselected = array();
  606. $enablechecked = '';
  607. $keysort = $type['special'] ? 'threadsorts' : 'threadtypes';
  608. if(isset($forum[$keysort]['types'][$type['typeid']])) {
  609. $enablechecked = ' checked="checked"';
  610. }
  611. $showtype = TRUE;
  612. loadcache('threadsort_option_'.$type['typeid']);
  613. if($type['special'] && !$_G['cache']['threadsort_option_'.$type['typeid']]) {
  614. $showtype = FALSE;
  615. }
  616. if($type['special']) {
  617. $typeselected[3] = $forum['threadsorts']['show'][$type['typeid']] ? ' checked="checked"' : '';
  618. $sortselect .= $showtype ? showtablerow('', array('class="td25"'), array(
  619. '<input type="checkbox" name="threadsortsnew[options][enable]['.$type['typeid'].']" value="1" class="checkbox"'.$enablechecked.' />',
  620. $type['name'],
  621. $type['description'],
  622. "<input class=\"checkbox\" type=\"checkbox\" name=\"threadsortsnew[options][show][{$type[typeid]}]\" value=\"3\" $typeselected[3] />",
  623. "<input class=\"radio\" type=\"radio\" name=\"threadsortsnew[defaultshow]\" value=\"$type[typeid]\" ".($forum['threadsorts']['defaultshow'] == $type['typeid'] ? 'checked' : '')." />"
  624. ), TRUE) : '';
  625. }
  626. }
  627. $forum['creditspolicy'] = $forum['creditspolicy'] ? dunserialize($forum['creditspolicy']) : array();
  628. }
  629. if($forum['autoclose']) {
  630. $forum['autoclosetime'] = abs($forum['autoclose']);
  631. $forum['autoclose'] = $forum['autoclose'] / abs($forum['autoclose']);
  632. }
  633. if($forum['threadplugin']) {
  634. $forum['threadplugin'] = dunserialize($forum['threadplugin']);
  635. }
  636. $simplebin = sprintf('%08b', $forum['simple']);
  637. $forum['defaultorderfield'] = bindec(substr($simplebin, 0, 2));
  638. $forum['defaultorder'] = ($forum['simple'] & 32) ? 1 : 0;
  639. $forum['subforumsindex'] = bindec(substr($simplebin, 3, 2));
  640. $forum['subforumsindex'] = $forum['subforumsindex'] == 0 ? -1 : ($forum['subforumsindex'] == 2 ? 0 : 1);
  641. $forum['simple'] = $forum['simple'] & 1;
  642. $forum['modrecommend'] = $forum['modrecommend'] ? dunserialize($forum['modrecommend']) : '';
  643. $forum['formulaperm'] = dunserialize($forum['formulaperm']);
  644. $forum['medal'] = $forum['formulaperm']['medal'];
  645. $forum['formulapermmessage'] = $forum['formulaperm']['message'];
  646. $forum['formulapermusers'] = $forum['formulaperm']['users'];
  647. $forum['formulaperm'] = $forum['formulaperm'][0];
  648. $forum['extra'] = dunserialize($forum['extra']);
  649. $forum['threadsorts']['default'] = $forum['threadsorts']['defaultshow'] ? 1 : 0;
  650. $_G['multisetting'] = $multiset ? 1 : 0;
  651. showmultititle();
  652. showtagheader('div', 'basic', $anchor == 'basic');
  653. if(!$multiset) {
  654. showtips('forums_edit_tips');
  655. }
  656. showtableheader('forums_edit_basic', 'nobottom');
  657. showsetting('forums_edit_basic_name', 'namenew', $forum['name'], 'text');
  658. showsetting('forums_edit_base_name_color', 'extranew[namecolor]', $forum['extra']['namecolor'], 'color');
  659. if(!$multiset) {
  660. if($forum['icon']) {
  661. $valueparse = parse_url($forum['icon']);
  662. if(isset($valueparse['host'])) {
  663. $forumicon = $forum['icon'];
  664. } else {
  665. $forumicon = $_G['setting']['attachurl'].'common/'.$forum['icon'].'?'.random(6);
  666. }
  667. $forumiconhtml = '<label><input type="checkbox" class="checkbox" name="deleteicon" value="yes" /> '.$lang['delete'].'</label><br /><img src="'.$forumicon.'" /><br />';
  668. }
  669. showsetting('forums_edit_basic_icon', 'iconnew', $forum['icon'], 'filetext', '', 0, $forumiconhtml);
  670. showsetting('forums_edit_basic_icon_width', 'extranew[iconwidth]', $forum['extra']['iconwidth'], 'text');
  671. if($forum['banner']) {
  672. $valueparse = parse_url($forum['banner']);
  673. if(isset($valueparse['host'])) {
  674. $forumbanner = $forum['banner'];
  675. } else {
  676. $forumbanner = $_G['setting']['attachurl'].'common/'.$forum['banner'].'?'.random(6);
  677. }
  678. $forumbannerhtml = '<label><input type="checkbox" class="checkbox" name="deletebanner" value="yes" /> '.$lang['delete'].'</label><br /><img src="'.$forumbanner.'" /><br />';
  679. }
  680. showsetting('forums_edit_basic_banner', 'bannernew', $forum['banner'], 'filetext', '', 0, $forumbannerhtml);
  681. }
  682. showsetting('forums_edit_basic_display', 'statusnew', $forum['status'], 'radio');
  683. if(!$multiset) {
  684. showsetting('forums_edit_basic_up', '', '', $fupselect);
  685. }
  686. showsetting('forums_edit_basic_redirect', 'redirectnew', $forum['redirect'], 'text');
  687. showsetting('forums_edit_basic_description', 'descriptionnew', str_replace('&amp;', '&', html2bbcode($forum['description'])), 'textarea');
  688. showsetting('forums_edit_basic_rules', 'rulesnew', str_replace('&amp;', '&', html2bbcode($forum['rules'])), 'textarea');
  689. showsetting('forums_edit_basic_keys', 'keysnew', $forumkeys[$fid], 'text');
  690. if(!empty($_G['setting']['domain']['root']['forum'])) {
  691. $iname = $multiset ? "multinew[{$_G[showsetting_multi]}][domainnew]" : 'domainnew';
  692. showsetting('forums_edit_extend_domain', '', '', 'http://<input type="text" name="'.$iname.'" class="txt" value="'.$forum['domain'].'" style="width:100px; margin-right:0px;" >.'.$_G['setting']['domain']['root']['forum']);
  693. } elseif(!$multiset) {
  694. showsetting('forums_edit_extend_domain', 'domainnew', '', 'text', 'disabled');
  695. }
  696. showtablefooter();
  697. if(!$multiset) {
  698. showtips('setting_seo_forum_tips', 'seo_tips', true, 'setseotips');
  699. }
  700. showtableheader();
  701. showsetting('forums_edit_basic_seotitle', 'seotitlenew', dhtmlspecialchars($forum['seotitle']), 'text');
  702. showsetting('forums_edit_basic_keyword', 'keywordsnew', dhtmlspecialchars($forum['keywords']), 'text');
  703. showsetting('forums_edit_basic_seodescription', 'seodescriptionnew', dhtmlspecialchars($forum['seodescription']), 'textarea');
  704. showtablefooter();
  705. showtagfooter('div');
  706. showtagheader('div', 'extend', $anchor == 'extend');
  707. if(!$multiset) {
  708. showtips('forums_edit_tips');
  709. }
  710. showtableheader('forums_edit_extend', 'nobottom');
  711. showsetting('forums_edit_extend_style', '', '', $styleselect);
  712. if($forum['type'] != 'sub') {
  713. showsetting('forums_edit_extend_sub_horizontal', 'forumcolumnsnew', $forum['forumcolumns'], 'text');
  714. showsetting('forums_edit_extend_subforumsindex', array('subforumsindexnew', array(
  715. array(-1, cplang('default')),
  716. array(1, cplang('yes')),
  717. array(0, cplang('no'))
  718. ), 1), $forum['subforumsindex'], 'mradio');
  719. showsetting('forums_edit_extend_simple', 'simplenew', $forum['simple'], 'radio');
  720. } else {
  721. if($_GET['multi']) {
  722. showsetting('forums_edit_extend_sub_horizontal', '', '', cplang('forums_edit_sub_multi_tips'));
  723. showsetting('forums_edit_extend_subforumsindex', '', '', cplang('forums_edit_sub_multi_tips'));
  724. showsetting('forums_edit_extend_simple', '', '', cplang('forums_edit_sub_multi_tips'));
  725. }
  726. }
  727. showsetting('forums_edit_extend_widthauto', array('widthautonew', array(
  728. array(0, cplang('default')),
  729. array(-1, cplang('forums_edit_extend_widthauto_-1')),
  730. array(1, cplang('forums_edit_extend_widthauto_1')),
  731. ), 1), $forum['widthauto'], 'mradio');
  732. showsetting('forums_edit_extend_picstyle', 'picstylenew', $forum['picstyle'], 'radio');
  733. showsetting('forums_edit_extend_allowside', 'allowsidenew', $forum['allowside'], 'radio');
  734. showsetting('forums_edit_extend_recommend_top', 'allowglobalsticknew', $forum['allowglobalstick'], 'radio');
  735. showsetting('forums_edit_extend_defaultorderfield', array('defaultorderfieldnew', array(
  736. array(0, cplang('forums_edit_extend_order_lastpost')),
  737. array(1, cplang('forums_edit_extend_order_starttime')),
  738. array(2, cplang('forums_edit_extend_order_replies')),
  739. array(3, cplang('forums_edit_extend_order_views'))
  740. )), $forum['defaultorderfield'], 'mradio');
  741. showsetting('forums_edit_extend_defaultorder', array('defaultordernew', array(
  742. array(0, cplang('forums_edit_extend_order_desc')),
  743. array(1, cplang('forums_edit_extend_order_asc'))
  744. )), $forum['defaultorder'], 'mradio');
  745. showsetting('forums_edit_extend_threadcache', 'threadcachesnew', $forum['threadcaches'], 'text');
  746. showsetting('forums_edit_extend_relatedgroup', 'relatedgroupnew', $forum['relatedgroup'], 'text');
  747. showsetting('forums_edit_extend_edit_rules', 'alloweditrulesnew', $forum['alloweditrules'], 'radio');
  748. showsetting('forums_edit_extend_disablecollect', 'disablecollectnew', $forum['disablecollect'], 'radio');
  749. showsetting('forums_edit_extend_recommend', 'modrecommendnew[open]', $forum['modrecommend']['open'], 'radio', '', 1);
  750. showsetting('forums_edit_extend_recommend_sort', array('modrecommendnew[sort]', array(
  751. array(1, cplang('forums_edit_extend_recommend_sort_auto')),
  752. array(0, cplang('forums_edit_extend_recommend_sort_manual')),
  753. array(2, cplang('forums_edit_extend_recommend_sort_mix')))), $forum['modrecommend']['sort'], 'mradio');
  754. showsetting('forums_edit_extend_recommend_orderby', array('modrecommendnew[orderby]', array(
  755. array(0, cplang('forums_edit_extend_recommend_orderby_dateline')),
  756. array(1, cplang('forums_edit_extend_recommend_orderby_lastpost')),
  757. array(2, cplang('forums_edit_extend_recommend_orderby_views')),
  758. array(3, cplang('forums_edit_extend_recommend_orderby_replies')),
  759. array(4, cplang('forums_edit_extend_recommend_orderby_digest')),
  760. array(5, cplang('forums_edit_extend_recommend_orderby_recommend')),
  761. array(6, cplang('forums_edit_extend_recommend_orderby_heats')),
  762. )), $forum['modrecommend']['orderby'], 'mradio');
  763. showsetting('forums_edit_extend_recommend_num', 'modrecommendnew[num]', $forum['modrecommend']['num'], 'text');
  764. showsetting('forums_edit_extend_recommend_imagenum', 'modrecommendnew[imagenum]', $forum['modrecommend']['imagenum'], 'text');
  765. showsetting('forums_edit_extend_recommend_imagesize', array('modrecommendnew[imagewidth]', 'modrecommendnew[imageheight]'), array(intval($forum['modrecommend']['imagewidth']), intval($forum['modrecommend']['imageheight'])), 'multiply');
  766. showsetting('forums_edit_extend_recommend_maxlength', 'modrecommendnew[maxlength]', $forum['modrecommend']['maxlength'], 'text');
  767. showsetting('forums_edit_extend_recommend_cachelife', 'modrecommendnew[cachelife]', $forum['modrecommend']['cachelife'], 'text');
  768. showsetting('forums_edit_extend_recommend_dateline', 'modrecommendnew[dateline]', $forum['modrecommend']['dateline'], 'text');
  769. showtablefooter();
  770. showtagfooter('div');
  771. showtagheader('div', 'posts', $anchor == 'posts');
  772. if(!$multiset) {
  773. showtips('forums_edit_tips');
  774. }
  775. showtableheader('forums_edit_posts', 'nobottom');
  776. showsetting('forums_edit_posts_modposts', array('modnewpostsnew', array(
  777. array(0, cplang('none')),
  778. array(1, cplang('forums_edit_posts_modposts_threads')),
  779. array(2, cplang('forums_edit_posts_modposts_posts'))
  780. )), $forum['modnewposts'], 'mradio');
  781. showsetting('forums_edit_posts_alloweditpost', 'alloweditpostnew', $forum['alloweditpost'], 'radio');
  782. showsetting('forums_edit_posts_recyclebin', 'recyclebinnew', $forum['recyclebin'], 'radio');
  783. showsetting('forums_edit_posts_html', 'allowhtmlnew', $forum['allowhtml'], 'radio');
  784. showsetting('forums_edit_posts_bbcode', 'allowbbcodenew', $forum['allowbbcode'], 'radio');
  785. showsetting('forums_edit_posts_imgcode', 'allowimgcodenew', $forum['allowimgcode'], 'radio');
  786. showsetting('forums_edit_posts_mediacode', 'allowmediacodenew', $forum['allowmediacode'], 'radio');
  787. showsetting('forums_edit_posts_smilies', 'allowsmiliesnew', $forum['allowsmilies'], 'radio');
  788. showsetting('forums_edit_posts_jammer', 'jammernew', $forum['jammer'], 'radio');
  789. showsetting('forums_edit_posts_anonymous', 'allowanonymousnew', $forum['allowanonymous'], 'radio');
  790. showsetting('forums_edit_posts_disablethumb', 'disablethumbnew', $forum['disablethumb'], 'radio');
  791. showsetting('forums_edit_posts_disablewatermark', 'disablewatermarknew', $forum['disablewatermark'], 'radio');
  792. showsetting('forums_edit_posts_allowpostspecial', array('allowpostspecialnew', array(
  793. cplang('thread_poll'),
  794. cplang('thread_trade'),
  795. cplang('thread_reward'),
  796. cplang('thread_activity'),
  797. cplang('thread_debate')
  798. )), $forum['allowpostspecial'], 'binmcheckbox');
  799. $threadpluginarray = '';
  800. if(is_array($_G['setting']['threadplugins'])) foreach($_G['setting']['threadplugins'] as $tpid => $data) {
  801. $threadpluginarray[] = array($tpid, $data['name']);
  802. }
  803. if($threadpluginarray) {
  804. showsetting('forums_edit_posts_threadplugin', array('threadpluginnew', $threadpluginarray), $forum['threadplugin'], 'mcheckbox');
  805. }
  806. showsetting('forums_edit_posts_allowspecialonly', 'allowspecialonlynew', $forum['allowspecialonly'], 'radio');
  807. showsetting('forums_edit_posts_autoclose', array('autoclosenew', array(
  808. array(0, cplang('forums_edit_posts_autoclose_none'), array('autoclose_time' => 'none')),
  809. array(1, cplang('forums_edit_posts_autoclose_dateline'), array('autoclose_time' => '')),
  810. array(-1, cplang('forums_edit_posts_autoclose_lastpost'), array('autoclose_time' => ''))
  811. )), $forum['autoclose'], 'mradio');
  812. showtagheader('tbody', 'autoclose_time', $forum['autoclose'], 'sub');
  813. showsetting('forums_edit_posts_autoclose_time', 'autoclosetimenew', $forum['autoclosetime'], 'text');
  814. showtagfooter('tbody');
  815. showsetting('forums_edit_posts_attach_ext', 'attachextensionsnew', $forum['attachextensions'], 'text');
  816. showsetting('forums_edit_posts_allowfeed', 'allowfeednew', $forum['allowfeed'], 'radio');
  817. showsetting('forums_edit_posts_commentitem', 'commentitemnew', $forum['commentitem'], 'textarea');
  818. showtablefooter();
  819. showtagfooter('div');
  820. if(!$multiset) {
  821. showtagheader('div', 'attachtype', $anchor == 'attachtype');
  822. showtips('forums_edit_attachtype_tips');
  823. showtableheader();
  824. showtablerow('class="partition"', array('class="td25"', 'class="td24"'), array(cplang('del'), cplang('misc_attachtype_ext'), cplang('misc_attachtype_maxsize')));
  825. echo $attachtypes;
  826. echo '<tr><td></td><td colspan="2"><div><a href="###" onclick="addrow(this, 1)" class="addtr">'.$lang['misc_attachtype_add'].'</a></div></tr>';
  827. showtablefooter();
  828. showtagfooter('div');
  829. showtagheader('div', 'credits', $anchor == 'credits');
  830. if(!$multiset) {
  831. showtips('forums_edit_tips');
  832. }
  833. showtableheader('forums_edit_credits_policy', 'fixpadding');
  834. echo '<tr class="header"><th>'.cplang('credits_id').'</th><th>'.cplang('setting_credits_policy_cycletype').'</th><th>'.cplang('setting_credits_policy_rewardnum').'</th><th class="td25">'.cplang('custom').'</th>';
  835. foreach($_G['setting']['extcredits'] as $i => $extcredit) {
  836. echo '<th>'.$extcredit['title'].'</th>';
  837. }
  838. echo '<th>&nbsp;</th></tr>';
  839. if(is_array($_G['setting']['extcredits'])) {
  840. foreach($rules as $rid => $rule) {
  841. $globalrule = $rule;
  842. $readonly = $checked = '';
  843. if(isset($forum['creditspolicy'][$rule['action']])) {
  844. $rule = $forum['creditspolicy'][$rule['action']];
  845. $checked = ' checked="checked"';
  846. } else {
  847. for($i = 1; $i <= 8; $i++) {
  848. $rule['extcredits'.$i] = '';
  849. }
  850. $readonly = ' readonly="readonly" style="display:none;"';
  851. }
  852. $usecustom = '<input type="checkbox" name="usecustom['.$rule['rid'].']" onclick="modifystate(this);" value="1" class="checkbox" '.$checked.' />';
  853. $tdarr = array($rule['rulename'], $rule['rid'] ? cplang('setting_credits_policy_cycletype_'.$rule['cycletype']) : 'N/A', $rule['rid'] && $rule['cycletype'] ? $rule['rewardnum'] : 'N/A', $usecustom);
  854. for($i = 1; $i <= 8; $i++) {
  855. if($_G['setting']['extcredits'][$i]) {
  856. array_push($tdarr, '<input type="text" name="creditnew['.$rule['rid'].']['.$i.']" class="txt smtxt" value="'.$rule['extcredits'.$i].'" '.$readonly.' /><span class="sml">('.($globalrule['extcredits'.$i]).')</span>');
  857. }
  858. }
  859. $opstr = '<a href="'.ADMINSCRIPT.'?action=credits&operation=edit&rid='.$rule['rid'].'&fid='.$fid.'" title="" class="act">'.cplang('edit').'</a>';
  860. array_push($tdarr, $opstr);
  861. showtablerow('', array_fill(4, count($_G['setting']['extcredits']) + 4, 'width="70"'), $tdarr);
  862. }
  863. }
  864. showtablerow('', 'class="lineheight" colspan="13"', cplang('forums_edit_credits_comment', array('fid' => $fid)));
  865. showtablefooter();
  866. print <<<EOF
  867. <script type="text/javascript">
  868. function modifystate(custom) {
  869. var trObj = custom.parentNode.parentNode;
  870. var inputsObj = trObj.getElementsByTagName('input');
  871. for(key in inputsObj) {
  872. var obj = inputsObj[key];
  873. if(typeof obj == 'object' && obj.type != 'checkbox') {
  874. obj.value = '';
  875. obj.readOnly = custom.checked ? false : true;
  876. obj.style.display = obj.readOnly ? 'none' : '';
  877. }
  878. }
  879. }
  880. </script>
  881. EOF;
  882. showtagfooter('div');
  883. }
  884. if($allowthreadtypes && !$multiset) {
  885. $lang_forums_edit_threadtypes_use_cols = cplang('forums_edit_threadtypes_use_cols');
  886. $lang_forums_edit_threadtypes_use_choice = cplang('forums_edit_threadtypes_use_choice');
  887. echo <<<EOT
  888. <script type="text/JavaScript">
  889. var rowtypedata = [
  890. [
  891. [1,'', 'td25'],
  892. [1,'<input type="text" size="2" name="newdisplayorder[]" value="0" />'],
  893. [1,'<input type="text" name="newname[]" />'],
  894. [1,'<input type="text" name="newicon[]" />'],
  895. [1,'<input type="hidden" name="newenable[]" value="1"><input type="checkbox" class="checkbox" checked="checked" disabled/>'],
  896. [1,'<input type="checkbox" class="checkbox" name="newmoderators[]" value="1" />'],
  897. [1,'']
  898. ],
  899. [
  900. [1,'', 'td25'],
  901. [1,'<input name="newextension[]" type="text" class="txt" size="10">', 'td24'],
  902. [1,'<input name="newmaxsize[]" type="text" class="txt" size="15">']
  903. ]
  904. ];
  905. </script>
  906. EOT;
  907. showtagheader('div', 'threadtypes', $anchor == 'threadtypes');
  908. if(!$multiset) {
  909. showtips('forums_edit_tips');
  910. }
  911. showtableheader('forums_edit_threadtypes_config', 'nobottom');
  912. showsetting('forums_edit_threadtypes_status', array('threadtypesnew[status]', array(
  913. array(1, cplang('yes'), array('threadtypes_config' => '', 'threadtypes_manage' => '')),
  914. array(0, cplang('no'), array('threadtypes_config' => 'none', 'threadtypes_manage' => 'none'))
  915. ), TRUE), $forum['threadtypes']['status'], 'mradio');
  916. showtagheader('tbody', 'threadtypes_config', $forum['threadtypes']['status']);
  917. showsetting('forums_edit_threadtypes_required', 'threadtypesnew[required]', $forum['threadtypes']['required'], 'radio');
  918. showsetting('forums_edit_threadtypes_listable', 'threadtypesnew[listable]', $forum['threadtypes']['listable'], 'radio');
  919. showsetting('forums_edit_threadtypes_prefix',
  920. array(
  921. 'threadtypesnew[prefix]',
  922. array(
  923. array(0, cplang('forums_edit_threadtypes_noprefix')),
  924. array(1, cplang('forums_edit_threadtypes_textonly')),
  925. array(2, cplang('forums_edit_threadtypes_icononly')),
  926. ),
  927. ),
  928. $forum['threadtypes']['prefix'], 'mradio'
  929. );
  930. showtagfooter('tbody');
  931. showtablefooter();
  932. showtagheader('div', 'threadtypes_manage', $forum['threadtypes']['status']);
  933. showtableheader('forums_edit_threadtypes', 'noborder fixpadding');
  934. showsubtitle(array('delete', 'display_order', 'forums_edit_threadtypes_name', 'forums_edit_threadtypes_icon', 'enable', 'forums_edit_threadtypes_moderators'));
  935. echo $typeselect;
  936. echo '<tr><td colspan="7"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.cplang('threadtype_infotypes_add').'</a></div></td></tr>';
  937. showtablefooter();
  938. showtagfooter('div');
  939. showtagfooter('div');
  940. showtagheader('div', 'threadsorts', $anchor == 'threadsorts');
  941. if(!$multiset) {
  942. showtips('forums_edit_tips');
  943. }
  944. showtableheader('forums_edit_threadsorts', 'nobottom');
  945. showsetting('forums_edit_threadsorts_status', array('threadsortsnew[status]', array(
  946. array(1, cplang('yes'), array('threadsorts_config' => '', 'threadsorts_manage' => '')),
  947. array(0, cplang('no'), array('threadsorts_config' => 'none', 'threadsorts_manage' => 'none'))
  948. ), TRUE), $forum['threadsorts']['status'], 'mradio');
  949. showtagheader('tbody', 'threadsorts_config', $forum['threadsorts']['status']);
  950. showsetting('forums_edit_threadtypes_required', 'threadsortsnew[required]', $forum['threadsorts']['required'], 'radio');
  951. showsetting('forums_edit_threadtypes_prefix', 'threadsortsnew[prefix]', $forum['threadsorts']['prefix'], 'radio');
  952. showsetting('forums_edit_threadsorts_default', 'threadsortsnew[default]', $forum['threadsorts']['default'], 'radio');
  953. showtagfooter('tbody');
  954. showtablefooter();
  955. showtagheader('div', 'threadsorts_manage', $forum['threadsorts']['status']);
  956. showtableheader('', 'noborder fixpadding');
  957. showsubtitle(array('enable', 'forums_edit_threadtypes_name', 'forums_edit_threadtypes_note', 'forums_edit_threadtypes_show', 'forums_edit_threadtypes_defaultshow'));
  958. echo $sortselect;
  959. showtablefooter();
  960. showtagfooter('div');
  961. showtagfooter('div');
  962. }
  963. showtagheader('div', 'perm', $anchor == 'perm');
  964. if(!$multiset) {
  965. showtips('forums_edit_tips');
  966. }
  967. showtableheader('forums_edit_perm_forum', 'nobottom');
  968. showsetting('forums_edit_perm_passwd', 'passwordnew', $forum['password'], 'text');
  969. showsetting('forums_edit_perm_users', 'formulapermusersnew', $forum['formulapermusers'], 'textarea');
  970. $colums = array();
  971. loadcache('medals');
  972. foreach($_G['cache']['medals'] as $medalid => $medal) {
  973. $colums[] = array($medalid, $medal['name']);
  974. }
  975. showtagheader('tbody', '', $_G['setting']['medalstatus']);
  976. showsetting('forums_edit_perm_medal', array('medalnew', $colums), $forum['medal'], 'mcheckbox');
  977. showtagfooter('tbody');
  978. showtablefooter();
  979. if(!$multiset) {
  980. showtableheader('forums_edit_perm_forum', 'noborder fixpadding');
  981. showsubtitle(array(
  982. '',
  983. '<input class="checkbox" type="checkbox" name="chkall1" onclick="checkAll(\'prefix\', this.form, \'^viewperm\', \'chkall1\')" id="chkall1" /><label for="chkall1"><br />'.cplang('forums_edit_perm_view').'</label>',
  984. '<input class="checkbox" type="checkbox" name="chkall2" onclick="checkAll(\'prefix\', this.form, \'^postperm\', \'chkall2\')" id="chkall2" /><label for="chkall2"><br />'.cplang('forums_edit_perm_post').'</label>',
  985. '<input class="checkbox" type="checkbox" name="chkall3" onclick="checkAll(\'prefix\', this.form, \'^replyperm\', \'chkall3\')" id="chkall3" /><label for="chkall3"><br />'.cplang('forums_edit_perm_reply').'</label>',
  986. '<input class="checkbox" type="checkbox" name="chkall4" onclick="checkAll(\'prefix\', this.form, \'^getattachperm\', \'chkall4\')" id="chkall4" /><label for="chkall4"><br />'.cplang('forums_edit_perm_getattach').'</label>',
  987. '<input class="checkbox" type="checkbox" name="chkall5" onclick="checkAll(\'prefix\', this.form, \'^postattachperm\', \'chkall5\')" id="chkall5" /><label for="chkall5"><br />'.cplang('forums_edit_perm_postattach').'</label>',
  988. '<input class="checkbox" type="checkbox" name="chkall6" onclick="checkAll(\'prefix\', this.form, \'^postimageperm\', \'chkall6\')" id="chkall6" /><label for="chkall6"><br />'.cplang('forums_edit_perm_postimage').'</label>'
  989. ));
  990. $spviewgroup = array();
  991. foreach(array('member', 'special', 'specialadmin', 'system') as $type) {
  992. $tgroups = is_array($groups[$type]) ? $groups[$type] : array();
  993. showtablerow('', '', array('<b>'.cplang('usergroups_'.$type).'</b>'));
  994. foreach($tgroups as $group) {
  995. if($group['groupid'] != 1) {
  996. $spviewgroup[] = array($group['groupid'], $group['grouptitle']);
  997. }
  998. $colums = array('<input class="checkbox" title="'.cplang('select_all').'" type="checkbox" name="chkallv'.$group['groupid'].'" onclick="checkAll(\'value\', this.form, '.$group['groupid'].', \'chkallv'.$group['groupid'].'\')" id="chkallv_'.$group['groupid'].'" /><label for="chkallv_'.$group['groupid'].'"> '.$group['grouptitle'].'</label>');
  999. foreach($perms as $perm) {
  1000. $checked = strstr($forum[$perm], "\t$group[groupid]\t") ? 'checked="checked"' : NULL;
  1001. $colums[] = '<input class="checkbox" type="checkbox" name="'.$perm.'[]" value="'.$group['groupid'].'" chkvalue="'.$group['groupid'].'" '.$checked.'>';
  1002. }
  1003. showtablerow('', array('width="21%"', 'width="13%"', 'width="13%"', 'width="13%"', 'width="16%"', 'width="13%"', 'width="13%"'), $colums);
  1004. }
  1005. }
  1006. $showverify = true;
  1007. foreach($_G['setting']['verify'] as $vid => $verify) {
  1008. if($verify['available']) {
  1009. if($showverify) {
  1010. showtablerow('', '', array('<b>'.$lang['forums_edit_perm_verify'].'</b>'));
  1011. $showverify = false;
  1012. }
  1013. $colums = array('<input class="checkbox" title="'.cplang('select_all').'" type="checkbox" name="chkallverify'.$vid.'" onclick="checkAll(\'value\', this.form, \'verify'.$vid.'\', \'chkallverify'.$vid.'\')" id="chkallverify_'.$vid.'" /><label for="chkallverify_'.$vid.'"> '.$verify['title'].'</label>');
  1014. foreach($perms as $perm) {
  1015. $checked = strstr($forum[$perm], "\tv$vid\t") ? 'checked="checked"' : NULL;
  1016. $colums[] = '<input class="checkbox" type="checkbox" name="'.$perm.'[]" value="v'.$vid.'" chkvalue="verify'.$vid.'" '.$checked.'>';
  1017. }
  1018. showtablerow('', array('width="21%"', 'width="13%"', 'width="13%"', 'width="13%"', 'width="13%"', 'width="13%"', 'width="13%"'), $colums);
  1019. }
  1020. }
  1021. showtablerow('', 'class="lineheight" colspan="6"', cplang('forums_edit_perm_forum_comment'));
  1022. showtablefooter();
  1023. showtableheader('forums_edit_perm_formula', 'fixpadding');
  1024. $formulareplace .= '\'<u>'.cplang('setting_credits_formula_digestposts').'</u>\',\'<u>'.cplang('setting_credits_formula_posts').'</u>\'';
  1025. ?>
  1026. <script type="text/JavaScript">
  1027. function isUndefined(variable) {
  1028. return typeof variable == 'undefined' ? true : false;
  1029. }
  1030. function insertunit(text, textend) {
  1031. $('formulapermnew').focus();
  1032. textend = isUndefined(textend) ? '' : textend;
  1033. if(!isUndefined($('formulapermnew').selectionStart)) {
  1034. var opn = $('formulapermnew').selectionStart + 0;
  1035. if(textend != '') {
  1036. text = text + $('formulapermnew').value.substring($('formulapermnew').selectionStart, $('formulapermnew').selectionEnd) + textend;
  1037. }
  1038. $('formulapermnew').value = $('formulapermnew').value.substr(0, $('formulapermnew').selectionStart) + text + $('formulapermnew').value.substr($('formulapermnew').selectionEnd);
  1039. } else if(document.selection && document.selection.createRange) {
  1040. var sel = document.selection.createRange();
  1041. if(textend != '') {
  1042. text = text + sel.text + textend;
  1043. }
  1044. sel.text = text.replace(/\r?\n/g, '\r\n');
  1045. sel.moveStart('character', -strlen(text));
  1046. } else {
  1047. $('formulapermnew').value += text;
  1048. }
  1049. formulaexp();
  1050. }
  1051. var formulafind = new Array('digestposts', 'posts');
  1052. var formulareplace = new Array(<?php echo $formulareplace?>);
  1053. function formulaexp() {
  1054. var result = $('formulapermnew').value;
  1055. <?php
  1056. $extcreditsbtn = '';
  1057. for($i = 1; $i <= 8; $i++) {
  1058. $extcredittitle = $_G['setting']['extcredits'][$i]['title'] ? $_G['setting']['extcredits'][$i]['title'] : cplang('setting_credits_formula_extcredits').$i;
  1059. echo 'result = result.replace(/extcredits'.$i.'/g, \'<u>'.str_replace("'", "\'", $extcredittitle).'</u>\');';
  1060. $extcreditsbtn .= '<a href="###" onclick="insertunit(\'extcredits'.$i.'\')">'.$extcredittitle.'</a> &nbsp;';
  1061. }
  1062. $profilefields = '';
  1063. foreach(C::t('common_member_profile_setting')->fetch_all_by_available_unchangeable(1, 1) as $profilefield) {
  1064. echo 'result = result.replace(/'.$profilefield['fieldid'].'/g, \'<u>'.str_replace("'", "\'", $profilefield['title']).'</u>\');';
  1065. $profilefields .= '<a href="###" onclick="insertunit(\' '.$profilefield['fieldid'].' \')">&nbsp;'.$profilefield['title'].'&nbsp;</a>&nbsp;';
  1066. }
  1067. echo 'result = result.replace(/regdate/g, \'<u>'.cplang('forums_edit_perm_formula_regdate').'</u>\');';
  1068. echo 'result = result.replace(/regday/g, \'<u>'.cplang('forums_edit_perm_formula_regday').'</u>\');';
  1069. echo 'result = result.replace(/regip/g, \'<u>'.cplang('forums_edit_perm_formula_regip').'</u>\');';
  1070. echo 'result = result.replace(/lastip/g, \'<u>'.cplang('forums_edit_perm_formula_lastip').'</u>\');';
  1071. echo 'result = result.replace(/buyercredit/g, \'<u>'.cplang('forums_edit_perm_formula_buyercredit').'</u>\');';
  1072. echo 'result = result.replace(/sellercredit/g, \'<u>'.cplang('forums_edit_perm_formula_sellercredit').'</u>\');';
  1073. echo 'result = result.replace(/digestposts/g, \'<u>'.cplang('setting_credits_formula_digestposts').'</u>\');';
  1074. echo 'result = result.replace(/posts/g, \'<u>'.cplang('setting_credits_formula_posts').'</u>\');';
  1075. echo 'result = result.replace(/threads/g, \'<u>'.cplang('setting_credits_formula_threads').'</u>\');';
  1076. echo 'result = result.replace(/oltime/g, \'<u>'.cplang('setting_credits_formula_oltime').'</u>\');';
  1077. echo 'result = result.replace(/and/g, \'&nbsp;&nbsp;<b>'.cplang('forums_edit_perm_formula_and').'</b>&nbsp;&nbsp;\');';
  1078. echo 'result = result.replace(/or/g, \'&nbsp;&nbsp;<b>'.cplang('forums_edit_perm_formula_or').'</b>&nbsp;&nbsp;\');';
  1079. echo 'result = result.replace(/>=/g, \'&ge;\');';
  1080. echo 'result = result.replace(/<=/g, \'&le;\');';
  1081. echo 'result = result.replace(/==/g, \'=\');';
  1082. ?>
  1083. $('formulapermexp').innerHTML = result;
  1084. }
  1085. </script>
  1086. <tr><td colspan="2"><div class="extcredits">
  1087. <?php echo $extcreditsbtn;?>
  1088. <a href="###" onclick="insertunit(' regdate ')">&nbsp;<?php echo cplang('forums_edit_perm_formula_regdate')?>&nbsp;</a>&nbsp;
  1089. <a href="###" onclick="insertunit(' regday ')">&nbsp;<?php echo cplang('forums_edit_perm_formula_regday')?>&nbsp;</a>&nbsp;
  1090. <a href="###" onclick="insertunit(' regip ')">&nbsp;<?php echo cplang('forums_edit_perm_formula_regip')?>&nbsp;</a>&nbsp;
  1091. <a href="###" onclick="insertunit(' lastip ')">&nbsp;<?php echo cplang('forums_edit_perm_formula_lastip')?>&nbsp;</a>&nbsp;
  1092. <a href="###" onclick="insertunit(' buyercredit ')">&nbsp;<?php echo cplang('forums_edit_perm_formula_buyercredit')?>&nbsp;</a>&nbsp;
  1093. <a href="###" onclick="insertunit(' sellercredit ')">&nbsp;<?php echo cplang('forums_edit_perm_formula_sellercredit')?>&nbsp;</a>&nbsp;
  1094. <a href="###" onclick="insertunit(' digestposts ')"><?php echo cplang('forums_edit_perm_formula_digestposts')?></a>&nbsp;
  1095. <a href="###" onclick="insertunit(' posts ')"><?php echo cplang('forums_edit_perm_formula_posts')?></a>&nbsp;
  1096. <a href="###" onclick="insertunit(' threads ')"><?php echo cplang('forums_edit_perm_formula_threads')?></a>&nbsp;
  1097. <a href="###" onclick="insertunit(' oltime ')"><?php echo cplang('forums_edit_perm_formula_oltime')?></a>&nbsp;
  1098. <a href="###" onclick="insertunit(' + ')">&nbsp;+&nbsp;</a>&nbsp;
  1099. <a href="###" onclick="insertunit(' - ')">&nbsp;-&nbsp;</a>&nbsp;
  1100. <a href="###" onclick="insertunit(' * ')">&nbsp;*&nbsp;</a>&nbsp;
  1101. <a href="###" onclick="insertunit(' / ')">&nbsp;/&nbsp;</a>&nbsp;
  1102. <a href="###" onclick="insertunit(' > ')">&nbsp;>&nbsp;</a>&nbsp;
  1103. <a href="###" onclick="insertunit(' >= ')">&nbsp;>=&nbsp;</a>&nbsp;
  1104. <a href="###" onclick="insertunit(' < ')">&nbsp;<&nbsp;</a>&nbsp;
  1105. <a href="###" onclick="insertunit(' <= ')">&nbsp;<=&nbsp;</a>&nbsp;
  1106. <a href="###" onclick="insertunit(' == ')">&nbsp;=&nbsp;</a>&nbsp;
  1107. <a href="###" onclick="insertunit(' != ')">&nbsp;!=&nbsp;</a>&nbsp;
  1108. <a href="###" onclick="insertunit(' (', ') ')">&nbsp;(&nbsp;)&nbsp;</a>&nbsp;
  1109. <a href="###" onclick="insertunit(' and ')">&nbsp;<?php echo cplang('forums_edit_perm_formula_and')?>&nbsp;</a>&nbsp;
  1110. <a href="###" onclick="insertunit(' or ')">&nbsp;<?php echo cplang('forums_edit_perm_formula_or')?>&nbsp;</a>&nbsp;<br />
  1111. <?php echo $profilefields;?>
  1112. <div id="formulapermexp" class="margintop marginbot diffcolor2"><?php echo $formulapermexp?></div>
  1113. </div>
  1114. <textarea name="formulapermnew" id="formulapermnew" class="marginbot" style="width:80%" rows="3" onkeyup="formulaexp()"><?php echo dhtmlspecialchars($forum['formulaperm'])?></textarea>
  1115. <script type="text/JavaScript">formulaexp()</script>
  1116. <br /><span class="smalltxt"><?php cplang('forums_edit_perm_formula_comment', null, true);?></span>
  1117. </td></tr>
  1118. <?php
  1119. showtablefooter();
  1120. showtableheader('', 'noborder fixpadding');
  1121. $forum['spviewperm'] = explode("\t", $forum['spviewperm']);
  1122. showsetting('forums_edit_perm_spview', array('spviewpermnew', $spviewgroup), $forum['spviewperm'], 'mcheckbox');
  1123. showsetting('forums_edit_perm_formulapermmessage', 'formulapermmessagenew', $forum['formulapermmessage'], 'textarea');
  1124. showtablefooter();
  1125. }
  1126. if($pluginsetting) {
  1127. showtagfooter('div');
  1128. showtagheader('div', 'plugin', $anchor == 'plugin');
  1129. showtableheader('', 'noborder fixpadding');
  1130. foreach($pluginsetting as $setting) {
  1131. showtitle($setting['name']);
  1132. foreach($setting['setting'] as $varid => $var) {
  1133. if($var['type'] != 'select') {
  1134. showsetting($var['title'], 'pluginnew['.$varid.']', $forum['plugin'][$varid], $var['type'], '', 0, $var['description']);
  1135. } else {
  1136. showsetting($var['title'], array('pluginnew['.$varid.']', $var['select']), $forum['plugin'][$varid], $var['type'], '', 0, $var['description']);
  1137. }
  1138. }
  1139. }
  1140. showtablefooter();
  1141. }
  1142. showtagfooter('div');
  1143. showtableheader('', 'notop');
  1144. showsubmit('detailsubmit', 'submit');
  1145. showtablefooter();
  1146. $_G['showsetting_multi']++;
  1147. }}
  1148. if($_G['showsetting_multicount'] > 1) {
  1149. showhiddenfields(array('multi' => implode(',', $mfids)));
  1150. showmulti();
  1151. }
  1152. showformfooter();
  1153. } else {
  1154. if(!$multiset) {
  1155. $_GET['multinew'] = array(0 => array('single' => 1));
  1156. }
  1157. $pluginvars = array();
  1158. require_once libfile('function/delete');
  1159. foreach($_GET['multinew'] as $k => $row) {
  1160. if(empty($row['single'])) {
  1161. foreach($row as $key => $value) {
  1162. $_GET[''.$key] = $value;
  1163. }
  1164. $fid = $_GET['multi'][$k];
  1165. }
  1166. $forum = $mforum[$k];
  1167. if(strlen($_GET['namenew']) > 50) {
  1168. cpmsg('forums_name_toolong', '', 'error');
  1169. }
  1170. if(!$multiset) {
  1171. if(!checkformulaperm($_GET['formulapermnew'])) {
  1172. cpmsg('forums_formulaperm_error', '', 'error');
  1173. }
  1174. $formulapermary[0] = $_GET['formulapermnew'];
  1175. $formulapermary[1] = preg_replace(
  1176. array("/(digestposts|posts|threads|oltime|extcredits[1-8])/", "/(regdate|regday|regip|lastip|buyercredit|sellercredit|field\d+)/"),
  1177. array("getuserprofile('\\1')", "\$memberformula['\\1']"),
  1178. $_GET['formulapermnew']);
  1179. $formulapermary['message'] = $_GET['formulapermmessagenew'];
  1180. } else {
  1181. $formulapermary = dunserialize($forum['formulaperm']);
  1182. }
  1183. $formulapermary['medal'] = $_GET['medalnew'];
  1184. $formulapermary['users'] = $_GET['formulapermusersnew'];
  1185. $_GET['formulapermnew'] = serialize($formulapermary);
  1186. $domain = '';
  1187. if(!empty($_GET['domainnew']) && !empty($_G['setting']['domain']['root']['forum'])) {
  1188. $domain = strtolower(trim($_GET['domainnew']));
  1189. }
  1190. require_once libfile('function/discuzcode');
  1191. if($_GET['type'] == 'group') {
  1192. if($_GET['namenew']) {
  1193. $newstyleid = intval($_GET['styleidnew']);
  1194. $forumcolumnsnew = $_GET['forumcolumnsnew'] > 1 ? intval($_GET['forumcolumnsnew']) : 0;
  1195. $catforumcolumnsnew = $_GET['catforumcolumnsnew'] > 1 ? intval($_GET['catforumcolumnsnew']) : 0;
  1196. $descriptionnew = preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode($_GET['descriptionnew'], 1, 0, 0, 0, 1, 1, 0, 0, 1));
  1197. if(!empty($_G['setting']['domain']['root']['forum'])) {
  1198. deletedomain($fid, 'subarea');
  1199. if(!empty($domain)) {
  1200. domaincheck($domain, $_G['setting']['domain']['root']['forum'], 1, 0);
  1201. C::t('common_domain')->insert(array('domain' => $domain, 'domainroot' => $_G['setting']['domain']['root']['forum'], 'id' => $fid, 'idtype' => 'subarea'));
  1202. }
  1203. }
  1204. C::t('forum_forum')->update($fid, array(
  1205. 'name' => $_GET['namenew'],
  1206. 'forumcolumns' => $forumcolumnsnew,
  1207. 'catforumcolumns' => $catforumcolumnsnew,
  1208. 'domain' => $domain,
  1209. 'status' => intval($_GET['statusnew']),
  1210. 'styleid' => $newstyleid,
  1211. ));
  1212. $extranew = is_array($_GET['extranew']) ? $_GET['extranew'] : array();
  1213. $extranew = serialize($extranew);
  1214. C::t('forum_forumfield')->update($fid, array(
  1215. 'extra' => $extranew,
  1216. 'description' => $descriptionnew,
  1217. 'seotitle' => $_GET['seotitlenew'],
  1218. 'keywords' => $_GET['keywordsnew'],
  1219. 'seodescription' => $_GET['seodescriptionnew'],
  1220. ));
  1221. loadcache('forums');
  1222. $subfids = array();
  1223. get_subfids($fid);
  1224. if($newstyleid != $mforum[0]['styleid'] && !empty($subfids)) {
  1225. C::t('forum_forum')->update($subfids, array('styleid' => $newstyleid));
  1226. }
  1227. updatecache('forums');
  1228. cpmsg('forums_edit_succeed', 'action=forums', 'succeed');
  1229. } else {
  1230. cpmsg('forums_edit_name_invalid', '', 'error');
  1231. }
  1232. } else {
  1233. $extensionarray = array();
  1234. foreach(explode(',', $_GET['attachextensionsnew']) as $extension) {
  1235. if($extension = trim($extension)) {
  1236. $extensionarray[] = $extension;
  1237. }
  1238. }
  1239. $_GET['attachextensionsnew'] = strtolower(implode(', ', $extensionarray));
  1240. foreach($perms as $perm) {
  1241. $_GET[''.$perm.'new'] = is_array($_GET[''.$perm]) && !empty($_GET[''.$perm]) ? "\t".implode("\t", $_GET[''.$perm])."\t" : '';
  1242. }
  1243. if(!$multiset) {
  1244. if($_GET['delete']) {
  1245. C::t('forum_attachtype')->delete_by_id_fid($_GET['delete'], $fid);
  1246. }
  1247. if(is_array($_GET['extension'])) {
  1248. foreach($_GET['extension'] as $id => $val) {
  1249. C::t('forum_attachtype')->update($id, array(
  1250. 'extension' => $_GET['extension'][$id],
  1251. 'maxsize' => $_GET['maxsize'][$id] * 1024,
  1252. ));
  1253. }
  1254. }
  1255. if(is_array($_GET['newextension'])) {
  1256. foreach($_GET['newextension'] as $key => $value) {
  1257. if($newextension1 = trim($value)) {
  1258. if(C::t('forum_attachtype')->count_by_extension_fid($newextension1, $fid)) {
  1259. cpmsg('attachtypes_duplicate', '', 'error');
  1260. }
  1261. C::t('forum_attachtype')->insert(array(
  1262. 'extension' => $newextension1,
  1263. 'maxsize' => $_GET['newmaxsize'][$key] * 1024,
  1264. 'fid' => $fid
  1265. ));
  1266. }
  1267. }
  1268. }
  1269. }
  1270. $fupadd = '';
  1271. $forumdata = $forumfielddata = array();
  1272. if($_GET['fupnew'] != $forum['fup'] && !$multiset) {
  1273. if(C::t('forum_forum')->fetch_forum_num('', $fid)) {
  1274. cpmsg('forums_edit_sub_notnull', '', 'error');
  1275. }
  1276. $fup = C::t('forum_forum')->fetch($_GET['fupnew']);
  1277. $fupadd = ", type='".($fup['type'] == 'forum' ? 'sub' : 'forum')."', fup='$fup[fid]'";
  1278. $forumdata['type'] = $fup['type'] == 'forum' ? 'sub' : 'forum';
  1279. $forumdata['fup'] = $fup['fid'];
  1280. C::t('forum_moderator')->delete_by_fid_inherited($fid, 1);
  1281. if($fup['inheritedmod']) {
  1282. $query = C::t('forum_moderator')->fetch_all_by_fid($_GET['fupnew'], FALSE);
  1283. } else {
  1284. $query = C::t('forum_moderator')->fetch_all_by_fid_inherited($_GET['fupnew'], 1);
  1285. }
  1286. foreach($query as $mod) {
  1287. C::t('forum_moderator')->insert(array(
  1288. 'uid' => $mod['uid'],
  1289. 'fid' => $fid,
  1290. 'displayorder' => 0,
  1291. 'inherited' => 1
  1292. ), false, true);
  1293. }
  1294. $moderators = '';
  1295. $modmemberarray = C::t('forum_moderator')->fetch_all_no_inherited_by_fid($fid);
  1296. $members = C::t('common_member')->fetch_all_username_by_uid(array_keys($modmemberarray));
  1297. $moderators = implode("\t", $members);
  1298. C::t('forum_forumfield')->update($fid, array('moderators' => $moderators));
  1299. }
  1300. $allowpostspecialtrade = intval($_GET['allowpostspecialnew'][2]);
  1301. $_GET['allowpostspecialnew'] = bindec(intval($_GET['allowpostspecialnew'][6]).intval($_GET['allowpostspecialnew'][5]).intval($_GET['allowpostspecialnew'][4]).intval($_GET['allowpostspecialnew'][3]).intval($_GET['allowpostspecialnew'][2]).intval($_GET['allowpostspecialnew'][1]));
  1302. $allowspecialonlynew = $_GET['allowpostspecialnew'] || $_G['setting']['threadplugins'] && $_GET['threadpluginnew'] ? $_GET['allowspecialonlynew'] : 0;
  1303. $forumcolumnsnew = $_GET['forumcolumnsnew'] > 1 ? intval($_GET['forumcolumnsnew']) : 0;
  1304. $threadcachesnew = max(0, min(100, intval($_GET['threadcachesnew'])));
  1305. $subforumsindexnew = $_GET['subforumsindexnew'] == -1 ? 0 : ($_GET['subforumsindexnew'] == 0 ? 2 : 1);
  1306. $_GET['simplenew'] = isset($_GET['simplenew']) ? $_GET['simplenew'] : 0;
  1307. $simplenew = bindec(sprintf('%02d', decbin($_GET['defaultorderfieldnew'])).$_GET['defaultordernew'].sprintf('%02d', decbin($subforumsindexnew)).'00'.$_GET['simplenew']);
  1308. $allowglobalsticknew = $_GET['allowglobalsticknew'] ? 1 : 0;
  1309. if(!empty($_G['setting']['domain']['root']['forum'])) {
  1310. deletedomain($fid, 'forum');
  1311. if(!empty($domain)) {
  1312. domaincheck($domain, $_G['setting']['domain']['root']['forum'], 1, 0);
  1313. C::t('common_domain')->insert(array('domain' => $domain, 'domainroot' => $_G['setting']['domain']['root']['forum'], 'id' => $fid, 'idtype' => 'forum'));
  1314. }
  1315. }
  1316. $forumdata = array_merge($forumdata, array(
  1317. 'status' => $_GET['statusnew'],
  1318. 'name' => $_GET['namenew'],
  1319. 'styleid' => $_GET['styleidnew'],
  1320. 'alloweditpost' => $_GET['alloweditpostnew'],
  1321. 'allowpostspecial' => $_GET['allowpostspecialnew'],
  1322. 'allowspecialonly' => $allowspecialonlynew,
  1323. 'allowhtml' => $_GET['allowhtmlnew'],
  1324. 'allowbbcode' => $_GET['allowbbcodenew'],
  1325. 'allowimgcode' => $_GET['allowimgcodenew'],
  1326. 'allowmediacode' => $_GET['allowmediacodenew'],
  1327. 'allowsmilies' => $_GET['allowsmiliesnew'],
  1328. 'alloweditrules' => $_GET['alloweditrulesnew'],
  1329. 'allowside' => $_GET['allowsidenew'],
  1330. 'disablecollect' => $_GET['disablecollectnew'],
  1331. 'modnewposts' => $_GET['modnewpostsnew'],
  1332. 'recyclebin' => $_GET['recyclebinnew'],
  1333. 'jammer' => $_GET['jammernew'],
  1334. 'allowanonymous' => $_GET['allowanonymousnew'],
  1335. 'forumcolumns' => $forumcolumnsnew,
  1336. 'catforumcolumns' => $catforumcolumnsnew,
  1337. 'threadcaches' => $threadcachesnew,
  1338. 'simple' => $simplenew,
  1339. 'allowglobalstick' => $allowglobalsticknew,
  1340. 'disablethumb' => $_GET['disablethumbnew'],
  1341. 'disablewatermark' => $_GET['disablewatermarknew'],
  1342. 'autoclose' => intval($_GET['autoclosenew'] * $_GET['autoclosetimenew']),
  1343. 'allowfeed' => $_GET['allowfeednew'],
  1344. 'domain' => $domain,
  1345. ));
  1346. C::t('forum_forum')->update($fid, $forumdata);
  1347. if(!(C::t('forum_forumfield')->fetch($fid))) {
  1348. C::t('forum_forumfield')->insert(array('fid' => $fid));
  1349. }
  1350. if(!$multiset) {
  1351. $creditspolicynew = array();
  1352. $creditspolicy = $forum['creditspolicy'] ? dunserialize($forum['creditspolicy']) : array();
  1353. foreach($_GET['creditnew'] as $rid => $rule) {
  1354. $creditspolicynew[$rules[$rid]['action']] = isset($creditspolicy[$rules[$rid]['action']]) ? $creditspolicy[$rules[$rid]['action']] : $rules[$rid];
  1355. $usedefault = $_GET['usecustom'][$rid] ? false : true;
  1356. if(!$usedefault) {
  1357. foreach($rule as $i => $v) {
  1358. $creditspolicynew[$rules[$rid]['action']]['extcredits'.$i] = is_numeric($v) ? intval($v) : 0;
  1359. }
  1360. }
  1361. $cpfids = explode(',', $rules[$rid]['fids']);
  1362. $cpfidsnew = array();
  1363. foreach($cpfids as $cpfid) {
  1364. if(!$cpfid) {
  1365. continue;
  1366. }
  1367. if($cpfid != $fid) {
  1368. $cpfidsnew[] = $cpfid;
  1369. }
  1370. }
  1371. if(!$usedefault) {
  1372. $cpfidsnew[] = $fid;
  1373. $creditspolicynew[$rules[$rid]['action']]['fids'] = $rules[$rid]['fids'] = implode(',', $cpfidsnew);
  1374. } else {
  1375. $rules[$rid]['fids'] = implode(',', $cpfidsnew);
  1376. unset($creditspolicynew[$rules[$rid]['action']]);
  1377. }
  1378. C::t('common_credit_rule')->update($rid, array('fids' => $rules[$rid]['fids']));
  1379. }
  1380. $forumfielddata = array();
  1381. $forumfielddata['creditspolicy'] = serialize($creditspolicynew);
  1382. $threadtypesnew = $_GET['threadtypesnew'];
  1383. $threadtypesnew['types'] = $threadtypes['special'] = $threadtypes['show'] = array();
  1384. $threadsortsnew['types'] = $threadsorts['special'] = $threadsorts['show'] = array();
  1385. if($allowthreadtypes) {
  1386. if(is_array($_GET['newname']) && $_GET['newname']) {
  1387. $newname = array_unique($_GET['newname']);
  1388. if($newname) {
  1389. foreach($newname as $key => $val) {
  1390. $newname[$key] = $val = strip_tags(trim(str_replace(array("'", "\""), array(), $val)), "<font><span><b><strong>");
  1391. if($_GET['newenable'][$key] && $val) {
  1392. $newtypearr = C::t('forum_threadclass')->fetch_by_fid_name($fid, $val);
  1393. $newtypeid = $newtypearr['typeid'];
  1394. if(!$newtypeid) {
  1395. $threadtypes_newdisplayorder = intval($_GET['newdisplayorder'][$key]);
  1396. $threadtypes_newicon = trim($_GET['newicon'][$key]);
  1397. $newtypeid = C::t('forum_threadclass')->insert(array('fid' => $fid, 'name' => $val, 'displayorder' => $threadtypes_newdisplayorder, 'icon' => $threadtypes_newicon, 'moderators' => intval($_GET['newmoderators'][$key])), true);
  1398. }
  1399. $threadtypesnew['options']['name'][$newtypeid] = $val;
  1400. $threadtypesnew['options']['icon'][$newtypeid] = $threadtypes_newicon;
  1401. $threadtypesnew['options']['displayorder'][$newtypeid] = $threadtypes_newdisplayorder;
  1402. $threadtypesnew['options']['enable'][$newtypeid] = 1;
  1403. $threadtypesnew['options']['moderators'][$newtypeid] = $_GET['newmoderators'][$key];
  1404. }
  1405. }
  1406. }
  1407. $threadtypesnew['status'] = 1;
  1408. } else {
  1409. $newname = array();
  1410. }
  1411. if($threadtypesnew['status']) {
  1412. if(is_array($threadtypesnew['options']) && $threadtypesnew['options']) {
  1413. if(!empty($threadtypesnew['options']['enable'])) {
  1414. $typeids = array_keys($threadtypesnew['options']['enable']);
  1415. } else {
  1416. $typeids = array(0);
  1417. }
  1418. foreach(C::t('forum_threadclass')->fetch_all_by_typeid($typeids) as $type) {
  1419. if($threadtypesnew['options']['name'][$type['typeid']] != $type['name'] ||
  1420. $threadtypesnew['options']['displayorder'][$type['typeid']] != $type['displayorder'] ||
  1421. $threadtypesnew['options']['icon'][$type['typeid']] != $type['icon'] ||
  1422. $threadtypesnew['options']['moderators'][$type['typeid']] != $type['moderators']) {
  1423. $threadtypesnew['options']['name'][$type['typeid']] = strip_tags(trim(str_replace(array("'", "\""), array(), $threadtypesnew['options']['name'][$type['typeid']])), "<font><span><b><strong>");
  1424. C::t('forum_threadclass')->update_by_typeid($type['typeid'], array(
  1425. 'name' => $threadtypesnew['options']['name'][$type['typeid']],
  1426. 'displayorder' => $threadtypesnew['options']['displayorder'][$type['typeid']],
  1427. 'icon' => $threadtypesnew['options']['icon'][$type['typeid']],
  1428. 'moderators' => $threadtypesnew['options']['moderators'][$type['typeid']],
  1429. ));
  1430. }
  1431. }
  1432. if(!empty($threadtypesnew['options']['delete'])) {
  1433. C::t('forum_threadclass')->delete_by_typeid($threadtypesnew['options']['delete']);
  1434. }
  1435. }
  1436. } else {
  1437. $threadtypesnew = '';
  1438. }
  1439. if($threadtypesnew && $typeids) {
  1440. foreach(C::t('forum_threadclass')->fetch_all_by_typeid($typeids) as $type) {
  1441. if($threadtypesnew['options']['enable'][$type['typeid']]) {
  1442. $threadtypesnew['types'][$type['typeid']] = $threadtypesnew['options']['name'][$type['typeid']];
  1443. }
  1444. $threadtypesnew['icons'][$type['typeid']] = trim($threadtypesnew['options']['icon'][$type['typeid']]);
  1445. $threadtypesnew['moderators'][$type['typeid']] = $threadtypesnew['options']['moderators'][$type['typeid']];
  1446. }
  1447. $threadtypesnew = $threadtypesnew['types'] ? serialize(array
  1448. (
  1449. 'required' => (bool)$threadtypesnew['required'],
  1450. 'listable' => (bool)$threadtypesnew['listable'],
  1451. 'prefix' => $threadtypesnew['prefix'],
  1452. 'types' => $threadtypesnew['types'],
  1453. 'icons' => $threadtypesnew['icons'],
  1454. 'moderators' => $threadtypesnew['moderators'],
  1455. )) : '';
  1456. }
  1457. $forumfielddata['threadtypes'] = is_array($threadtypesnew) ? serialize($threadtypesnew) : $threadtypesnew;
  1458. $threadsortsnew = $_GET['threadsortsnew'];
  1459. if($threadsortsnew['status']) {
  1460. if(is_array($threadsortsnew['options']) && $threadsortsnew['options']) {
  1461. if(!empty($threadsortsnew['options']['enable'])) {
  1462. $sortids = array_keys($threadsortsnew['options']['enable']);
  1463. } else {
  1464. $sortids = array();
  1465. }
  1466. $query = C::t('forum_threadtype')->fetch_all_for_order($sortids);
  1467. foreach($query as $sort) {
  1468. if($threadsortsnew['options']['enable'][$sort['typeid']]) {
  1469. $threadsortsnew['types'][$sort['typeid']] = $sort['name'];
  1470. }
  1471. $threadsortsnew['expiration'][$sort['typeid']] = $sort['expiration'];
  1472. $threadsortsnew['description'][$sort['typeid']] = $sort['description'];
  1473. $threadsortsnew['show'][$sort['typeid']] = $threadsortsnew['options']['show'][$sort['typeid']] ? 1 : 0;
  1474. }
  1475. }
  1476. if($threadsortsnew['default'] && !$threadsortsnew['defaultshow']) {
  1477. cpmsg('forums_edit_threadsort_nonexistence', '', 'error');
  1478. }
  1479. $threadsortsnew = $threadsortsnew['types'] ? serialize(array
  1480. (
  1481. 'required' => (bool)$threadsortsnew['required'],
  1482. 'prefix' => (bool)$threadsortsnew['prefix'],
  1483. 'types' => $threadsortsnew['types'],
  1484. 'show' => $threadsortsnew['show'],
  1485. 'expiration' => $threadsortsnew['expiration'],
  1486. 'description' => $threadsortsnew['description'],
  1487. 'defaultshow' => $threadsortsnew['default'] ? $threadsortsnew['defaultshow'] : '',
  1488. 'templatelist' => $threadsortsnew['templatelist'],
  1489. )) : '';
  1490. } else {
  1491. $threadsortsnew = '';
  1492. }
  1493. $forumfielddata['threadsorts'] = $threadsortsnew;
  1494. }
  1495. }
  1496. $threadpluginnew = serialize($_GET['threadpluginnew']);
  1497. $modrecommendnew = $_GET['modrecommendnew'];
  1498. $modrecommendnew['num'] = $modrecommendnew['num'] ? intval($modrecommendnew['num']) : 10;
  1499. $modrecommendnew['cachelife'] = intval($modrecommendnew['cachelife']);
  1500. $modrecommendnew['maxlength'] = $modrecommendnew['maxlength'] ? intval($modrecommendnew['maxlength']) : 0;
  1501. $modrecommendnew['dateline'] = $modrecommendnew['dateline'] ? intval($modrecommendnew['dateline']) : 0;
  1502. $modrecommendnew['imagenum'] = $modrecommendnew['imagenum'] ? intval($modrecommendnew['imagenum']) : 0;
  1503. $modrecommendnew['imagewidth'] = $modrecommendnew['imagewidth'] ? intval($modrecommendnew['imagewidth']) : 300;
  1504. $modrecommendnew['imageheight'] = $modrecommendnew['imageheight'] ? intval($modrecommendnew['imageheight']): 250;
  1505. $descriptionnew = preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode($_GET['descriptionnew'], 1, 0, 0, 0, 1, 1, 0, 0, 1));
  1506. $rulesnew = preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode($_GET['rulesnew'], 1, 0, 0, 0, 1, 1, 0, 0, 1));
  1507. $extranew = is_array($_GET['extranew']) ? $_GET['extranew'] : array();
  1508. $forum['extra'] = dunserialize($forum['extra']);
  1509. $forum['extra']['namecolor'] = $extranew['namecolor'];
  1510. if(!$multiset) {
  1511. if(($_GET['deletebanner'] || $_FILES['bannernew']) && $forum['banner']) {
  1512. $valueparse = parse_url($forum['banner']);
  1513. if(!isset($valueparse['host'])) {
  1514. @unlink($_G['setting']['attachurl'].'common/'.$forum['banner']);
  1515. }
  1516. $forumfielddata['banner'] = '';
  1517. if($_GET['bannernew'] == $forum['banner']) {
  1518. $_GET['bannernew'] = '';
  1519. }
  1520. }
  1521. if($_FILES['bannernew']) {
  1522. $bannernew = upload_icon_banner($forum, $_FILES['bannernew'], 'banner');
  1523. } else {
  1524. $bannernew = $_GET['bannernew'];
  1525. }
  1526. if($bannernew) {
  1527. $forumfielddata['banner'] = $bannernew;
  1528. }
  1529. if($_GET['deleteicon'] || $_FILES['iconnew']) {
  1530. $valueparse = parse_url($forum['icon']);
  1531. if(!isset($valueparse['host'])) {
  1532. @unlink($_G['setting']['attachurl'].'common/'.$forum['icon']);
  1533. }
  1534. $forumfielddata['icon'] = '';
  1535. $forum['extra']['iconwidth'] = '';
  1536. if($_GET['iconnew'] == $forum['icon']) {
  1537. $_GET['iconnew'] = '';
  1538. }
  1539. }
  1540. if($_FILES['iconnew']) {
  1541. $iconnew = upload_icon_banner($forum, $_FILES['iconnew'], 'icon');
  1542. } else {
  1543. $iconnew = $_GET['iconnew'];
  1544. }
  1545. if($iconnew) {
  1546. $forumfielddata['icon'] = $iconnew;
  1547. if(!$extranew['iconwidth']) {
  1548. $valueparse = parse_url($forumfielddata['icon']);
  1549. if(!isset($valueparse['host'])) {
  1550. $iconnew = $_G['setting']['attachurl'].'common/'.$forumfielddata['icon'];
  1551. }
  1552. if($info = @getimagesize($iconnew)) {
  1553. $extranew['iconwidth'] = $info[0];
  1554. }
  1555. }
  1556. $forum['extra']['iconwidth'] = $extranew['iconwidth'];
  1557. } else {
  1558. $forum['extra']['iconwidth'] = '';
  1559. }
  1560. }
  1561. $extranew = serialize($forum['extra']);
  1562. $forumfielddata = array_merge($forumfielddata, array(
  1563. 'description' => $descriptionnew,
  1564. 'password' => $_GET['passwordnew'],
  1565. 'redirect' => $_GET['redirectnew'],
  1566. 'rules' => $rulesnew,
  1567. 'attachextensions' => $_GET['attachextensionsnew'],
  1568. 'modrecommend' => $modrecommendnew && is_array($modrecommendnew) ? serialize($modrecommendnew) : '',
  1569. 'seotitle' => $_GET['seotitlenew'],
  1570. 'keywords' => $_GET['keywordsnew'],
  1571. 'seodescription' => $_GET['seodescriptionnew'],
  1572. 'threadplugin' => $threadpluginnew,
  1573. 'extra' => $extranew,
  1574. 'commentitem' => $_GET['commentitemnew'],
  1575. 'formulaperm' => $_GET['formulapermnew'],
  1576. 'picstyle' => $_GET['picstylenew'],
  1577. 'widthauto' => $_GET['widthautonew'],
  1578. ));
  1579. if(!$multiset) {
  1580. $forumfielddata = array_merge($forumfielddata, array(
  1581. 'viewperm' => $_GET['viewpermnew'],
  1582. 'postperm' => $_GET['postpermnew'],
  1583. 'replyperm' => $_GET['replypermnew'],
  1584. 'getattachperm' => $_GET['getattachpermnew'],
  1585. 'postattachperm' => $_GET['postattachpermnew'],
  1586. 'postimageperm' => $_GET['postimagepermnew'],
  1587. 'relatedgroup' => $_GET['relatedgroupnew'],
  1588. 'spviewperm' => implode("\t", $_GET['spviewpermnew']),
  1589. ));
  1590. }
  1591. if($forumfielddata) {
  1592. C::t('forum_forumfield')->update($fid, $forumfielddata);
  1593. }
  1594. if($pluginsetting) {
  1595. foreach($_GET['pluginnew'] as $pluginvarid => $value) {
  1596. $pluginvars[$pluginvarid][$fid] = $value;
  1597. }
  1598. }
  1599. if($modrecommendnew && !$modrecommendnew['sort']) {
  1600. require_once libfile('function/forumlist');
  1601. recommendupdate($fid, $modrecommendnew, '1');
  1602. }
  1603. if($forumkeys[$fid] != $_GET['keysnew'] && preg_match('/^\w*$/', $_GET['keysnew']) && !preg_match('/^\d+$/', $_GET['keysnew'])) {
  1604. $forumkeys[$fid] = $_GET['keysnew'];
  1605. C::t('common_setting')->update('forumkeys', $forumkeys);
  1606. }
  1607. }
  1608. if(empty($row['single'])) {
  1609. foreach($row as $key => $value) {
  1610. unset($_GET[''.$key]);
  1611. }
  1612. }
  1613. }
  1614. if($pluginvars) {
  1615. set_pluginsetting($pluginvars);
  1616. }
  1617. updatecache(array('forums', 'setting', 'creditrule', 'attachtype'));
  1618. cpmsg('forums_edit_succeed', "mod=forum&action=forums&operation=edit&".($multiset ? 'multi='.implode(',', $_GET['multi']) : "fid=$fid").($_GET['anchor'] ? "&anchor={$_GET['anchor']}" : ''), 'succeed');
  1619. }
  1620. } elseif($operation == 'delete') {
  1621. $ajax = $_GET['ajax'];
  1622. $confirmed = $_GET['confirmed'];
  1623. $finished = $_GET['finished'];
  1624. $total = intval($_GET['total']);
  1625. $pp = intval($_GET['pp']);
  1626. $currow = intval($_GET['currow']);
  1627. if($_GET['ajax']) {
  1628. ob_end_clean();
  1629. require_once libfile('function/post');
  1630. $tids = array();
  1631. foreach(C::t('forum_thread')->fetch_all_by_fid($fid, $pp) as $thread) {
  1632. $tids[] = $thread['tid'];
  1633. }
  1634. require_once libfile('function/delete');
  1635. deletethread($tids);
  1636. deletedomain($fid, 'forum');
  1637. deletedomain($fid, 'subarea');
  1638. if($currow + $pp > $total) {
  1639. $log_handler = Cloud::loadClass('Cloud_Service_SearchHelper');
  1640. $log_handler->myThreadLog('delforum', array('fid' => $fid));
  1641. C::t('forum_forum')->delete_by_fid($fid);
  1642. C::t('home_favorite')->delete_by_id_idtype($fid, 'fid');
  1643. C::t('forum_moderator')->delete_by_fid($fid);
  1644. C::t('forum_access')->delete_by_fid($fid);
  1645. echo 'TRUE';
  1646. exit;
  1647. }
  1648. echo 'GO';
  1649. exit;
  1650. } else {
  1651. if($_GET['finished']) {
  1652. updatecache('forums');
  1653. cpmsg('forums_delete_succeed', 'action=forums', 'succeed');
  1654. }
  1655. if(C::t('forum_forum')->fetch_forum_num('', $fid)) {
  1656. cpmsg('forums_delete_sub_notnull', '', 'error');
  1657. }
  1658. if(!$_GET['confirmed']) {
  1659. cpmsg('forums_delete_confirm', "mod=forum&action=forums&operation=delete&fid=$fid", 'form');
  1660. } else {
  1661. $threads = C::t('forum_thread')->count_by_fid($fid);
  1662. cpmsg('forums_delete_alarm', "mod=forum&action=forums&operation=delete&fid=$fid&confirmed=1", 'loadingform', '', '<div id="percent">0%</div>', FALSE);
  1663. echo "
  1664. <div id=\"statusid\" style=\"display:none\"></div>
  1665. <script type=\"text/JavaScript\">
  1666. var xml_http_building_link = '".cplang('xml_http_building_link')."';
  1667. var xml_http_sending = '".cplang('xml_http_sending')."';
  1668. var xml_http_loading = '".cplang('xml_http_loading')."';
  1669. var xml_http_load_failed = '".cplang('xml_http_load_failed')."';
  1670. var xml_http_data_in_processed = '".cplang('xml_http_data_in_processed')."';
  1671. var adminfilename = '".ADMINSCRIPT."';
  1672. function forumsdelete(url, total, pp, currow) {
  1673. var x = new Ajax('HTML', 'statusid');
  1674. x.get(url+'&ajax=1&pp='+pp+'&total='+total+'&currow='+currow, function(s) {
  1675. if(s != 'GO') {
  1676. location.href = adminfilename + '?action=forums&operation=delete&finished=1';
  1677. }
  1678. currow += pp;
  1679. var percent = ((currow / total) * 100).toFixed(0);
  1680. percent = percent > 100 ? 100 : percent;
  1681. document.getElementById('percent').innerHTML = percent+'%';
  1682. document.getElementById('percent').style.backgroundPosition = '-'+percent+'%';
  1683. if(currow < total) {
  1684. forumsdelete(url, total, pp, currow);
  1685. }
  1686. });
  1687. }
  1688. forumsdelete(adminfilename + '?action=forums&operation=delete&fid=$fid&confirmed=1', $threads, 2000, 0);
  1689. </script>
  1690. ";
  1691. }
  1692. }
  1693. } elseif($operation == 'copy') {
  1694. loadcache('forums');
  1695. $source = intval($_GET['source']);
  1696. $sourceforum = $_G['cache']['forums'][$source];
  1697. if(empty($sourceforum) || $sourceforum['type'] == 'group') {
  1698. cpmsg('forums_copy_source_invalid', '', 'error');
  1699. }
  1700. $delfields = array(
  1701. 'forums' => array('fid', 'fup', 'type', 'name', 'status', 'displayorder', 'threads', 'posts', 'todayposts', 'lastpost', 'modworks', 'icon', 'level', 'commoncredits', 'archive', 'recommend'),
  1702. 'forumfields' => array('description', 'password', 'redirect', 'moderators', 'rules', 'threadtypes', 'threadsorts', 'threadplugin', 'jointype', 'gviewperm', 'membernum', 'dateline', 'lastupdate', 'founderuid', 'foundername', 'banner', 'groupnum', 'activity'),
  1703. );
  1704. $fields = array(
  1705. 'forums' => C::t('forum_forum')->fetch_table_struct('forum_forum'),
  1706. 'forumfields' => C::t('forum_forum')->fetch_table_struct('forum_forumfield'),
  1707. );
  1708. if(!submitcheck('copysubmit')) {
  1709. require_once libfile('function/forumlist');
  1710. $forumselect = '<select name="target[]" size="10" multiple="multiple">'.forumselect(FALSE, 0, 0, TRUE).'</select>';
  1711. $optselect = '<select name="options[]" size="10" multiple="multiple">';
  1712. $fieldarray = array_merge($fields['forums'], $fields['forumfields']);
  1713. $listfields = array_diff($fieldarray, array_merge($delfields['forums'], $delfields['forumfields']));
  1714. foreach($listfields as $field) {
  1715. $optselect .= '<option value="'.$field.'">'.($lang['project_option_forum_'.$field] ? $lang['project_option_forum_'.$field] : $field).'</option>';
  1716. }
  1717. $optselect .= '</select>';
  1718. shownav('forum', 'forums_copy');
  1719. showsubmenu('forums_copy');
  1720. showtips('forums_copy_tips');
  1721. showformheader('forums&operation=copy');
  1722. showhiddenfields(array('source' => $source));
  1723. showtableheader();
  1724. showtitle('forums_copy');
  1725. showsetting(cplang('forums_copy_source').':','','', $sourceforum['name']);
  1726. showsetting('forums_copy_target', '', '', $forumselect);
  1727. showsetting('forums_copy_options', '', '', $optselect);
  1728. showsubmit('copysubmit');
  1729. showtablefooter();
  1730. showformfooter();
  1731. } else {
  1732. $fids = array();
  1733. if(is_array($_GET['target']) && count($_GET['target'])) {
  1734. foreach($_GET['target'] as $fid) {
  1735. if(($fid = intval($fid)) && $fid != $source ) {
  1736. $fids[] = $fid;
  1737. }
  1738. }
  1739. }
  1740. if(empty($fids)) {
  1741. cpmsg('forums_copy_target_invalid', '', 'error');
  1742. }
  1743. $forumoptions = array();
  1744. if(is_array($_GET['options']) && !empty($_GET['options'])) {
  1745. foreach($_GET['options'] as $option) {
  1746. if($option = trim($option)) {
  1747. if(in_array($option, $fields['forums'])) {
  1748. $forumoptions['forum_forum'][] = $option;
  1749. } elseif(in_array($option, $fields['forumfields'])) {
  1750. $forumoptions['forum_forumfield'][] = $option;
  1751. }
  1752. }
  1753. }
  1754. }
  1755. if(empty($forumoptions)) {
  1756. cpmsg('forums_copy_options_invalid', '', 'error');
  1757. }
  1758. foreach(array('forum_forum', 'forum_forumfield') as $table) {
  1759. if(is_array($forumoptions[$table]) && !empty($forumoptions[$table])) {
  1760. $sourceforum = C::t($table)->fetch($source);
  1761. foreach($sourceforum as $key=>$value) {
  1762. if(!in_array($key, $forumoptions[$table])) {
  1763. unset($sourceforum[$key]);
  1764. }
  1765. }
  1766. if(!$sourceforum) {
  1767. cpmsg('forums_copy_source_invalid', '', 'error');
  1768. }
  1769. C::t($table)->update($fids, $sourceforum);
  1770. }
  1771. }
  1772. updatecache('forums');
  1773. cpmsg('forums_copy_succeed', 'action=forums', 'succeed');
  1774. }
  1775. }
  1776. function showforum(&$forum, $type = '', $last = '', $toggle = false) {
  1777. global $_G;
  1778. if($last == '') {
  1779. $return = '<tr class="hover">'.
  1780. '<td class="td25"'.($type == 'group' ? ' onclick="toggle_group(\'group_'.$forum['fid'].'\', $(\'a_group_'.$forum['fid'].'\'))"' : '').'>'.($type == 'group' ? '<a href="javascript:;" id="a_group_'.$forum['fid'].'">'.($toggle ? '[+]' : '[-]').'</a>' : '').'</td>
  1781. <td class="td25"><input type="text" class="txt" name="order['.$forum['fid'].']" value="'.$forum['displayorder'].'" /></td><td>';
  1782. if($type == 'group') {
  1783. $return .= '<div class="parentboard">';
  1784. $_G['fg'] = !empty($_G['fg']) ? intval($_G['fg']) : 0;
  1785. $_G['fg']++;
  1786. } elseif($type == '') {
  1787. $return .= '<div class="board">';
  1788. } elseif($type == 'sub') {
  1789. $return .= '<div id="cb_'.$forum['fid'].'" class="childboard">';
  1790. }
  1791. $boardattr = '';
  1792. if(!$forum['status'] || $forum['password'] || $forum['redirect']) {
  1793. $boardattr = '<div class="boardattr">';
  1794. $boardattr .= $forum['status'] ? '' : cplang('forums_admin_hidden');
  1795. $boardattr .= !$forum['password'] ? '' : ' '.cplang('forums_admin_password');
  1796. $boardattr .= !$forum['redirect'] ? '' : ' '.cplang('forums_admin_url');
  1797. $boardattr .= '</div>';
  1798. }
  1799. $return .= '<input type="text" name="name['.$forum['fid'].']" value="'.dhtmlspecialchars($forum['name']).'" class="txt" />'.
  1800. ($type == '' ? '<a href="###" onclick="addrowdirect = 1;addrow(this, 2, '.$forum['fid'].')" class="addchildboard">'.cplang('forums_admin_add_sub').'</a>' : '').
  1801. '</div>'.$boardattr.
  1802. '</td><td align="right" class="td23 lightfont">('.($type == 'group' ? 'gid:' : 'fid:').$forum['fid'].')</td>'.
  1803. '</td><td class="td23">'.showforum_moderators($forum).'</td>
  1804. <td width="160"><input class="checkbox" value="'.$forum['fid'].'" type="checkbox"'.($type != 'group' ? ' chkvalue="g'.$_G['fg'].'" onclick="multiupdate(this, '.$forum['fid'].')"' : ' name="gc'.$_G['fg'].'" onclick="checkAll(\'value\', this.form, \'g'.$_G['fg'].'\', \'gc'.$_G['fg'].'\', 1)"').' />'.'
  1805. <a href="'.ADMINSCRIPT.'?action=forums&operation=edit&fid='.$forum['fid'].'" title="'.cplang('forums_edit_comment').'" class="act">'.cplang('edit').'</a>'.
  1806. ($type != 'group' ? '<a href="'.ADMINSCRIPT.'?action=forums&operation=copy&source='.$forum['fid'].'" title="'.cplang('forums_copy_comment').'" class="act">'.cplang('forums_copy').'</a>' : '').
  1807. '<a href="'.ADMINSCRIPT.'?action=forums&operation=delete&fid='.$forum['fid'].'" title="'.cplang('forums_delete_comment').'" class="act">'.cplang('delete').'</a></td></tr>';
  1808. if($type == 'group') $return .= '<tbody id="group_'.$forum['fid'].'"'.($toggle ? ' style="display:none;"' : '').'>';
  1809. } else {
  1810. if($last == 'lastboard') {
  1811. $return = '</tbody><tr><td></td><td colspan="4"><div class="lastboard"><a href="###" onclick="addrow(this, 1, '.$forum['fid'].')" class="addtr">'.cplang('forums_admin_add_forum').'</a></div></td><td>&nbsp;</td></tr>';
  1812. } elseif($last == 'lastchildboard' && $type) {
  1813. $return = '<script type="text/JavaScript">$(\'cb_'.$type.'\').className = \'lastchildboard\';</script>';
  1814. } elseif($last == 'last') {
  1815. $return = '</tbody><tr><td></td><td colspan="4"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.cplang('forums_admin_add_category').'</a></div></td>'.
  1816. '<td class="bold"><a href="javascript:;" onclick="if(getmultiids()) location.href=\''.ADMINSCRIPT.'?action=forums&operation=edit&multi=\' + getmultiids();return false;">'.cplang('multiedit').'</a></td>'.
  1817. '</tr>';
  1818. }
  1819. }
  1820. echo $return = isset($return) ? $return : '';
  1821. return $forum['fid'];
  1822. }
  1823. function showforum_moderators($forum) {
  1824. global $_G;
  1825. if($forum['moderators']) {
  1826. $moderators = explode("\t", $forum['moderators']);
  1827. $count = count($moderators);
  1828. $max = $count > 2 ? 2 : $count;
  1829. $mods = array();
  1830. for($i = 0;$i < $max;$i++) {
  1831. $mods[] = $forum['inheritedmod'] ? '<b>'.$moderators[$i].'</b>' : $moderators[$i];
  1832. }
  1833. $r = implode(', ', $mods);
  1834. if($count > 2) {
  1835. $r = '<span onmouseover="showMenu({\'ctrlid\':this.id})" id="mods_'.$forum['fid'].'">'.$r.'</span>';
  1836. $mods = array();
  1837. foreach($moderators as $moderator) {
  1838. $mods[] = $forum['inheritedmod'] ? '<b>'.$moderator.'</b>' : $moderator;
  1839. }
  1840. $r = '<a href="'.ADMINSCRIPT.'?action=forums&operation=moderators&fid='.$forum['fid'].'" title="'.cplang('forums_moderators_comment').'">'.$r.' &raquo;</a>';
  1841. $r .= '<div class="dropmenu1" id="mods_'.$forum['fid'].'_menu" style="display: none">'.implode('<br />', $mods).'</div>';
  1842. } else {
  1843. $r = '<a href="'.ADMINSCRIPT.'?action=forums&operation=moderators&fid='.$forum['fid'].'" title="'.cplang('forums_moderators_comment').'">'.$r.' &raquo;</a>';
  1844. }
  1845. } else {
  1846. $r = '<a href="'.ADMINSCRIPT.'?action=forums&operation=moderators&fid='.$forum['fid'].'" title="'.cplang('forums_moderators_comment').'">'.cplang('forums_admin_no_moderator').'</a>';
  1847. }
  1848. return $r;
  1849. }
  1850. function getthreadclasses_html($fid) {
  1851. $threadtypes = C::t('forum_forumfield')->fetch($fid);
  1852. $threadtypes = dunserialize($threadtypes['threadtypes']);
  1853. foreach(C::t('forum_threadclass')->fetch_all_by_fid($fid) as $type) {
  1854. $enablechecked = $moderatorschecked = '';
  1855. $typeselected = array();
  1856. if(isset($threadtypes['types'][$type['typeid']])) {
  1857. $enablechecked = ' checked="checked"';
  1858. }
  1859. if($type['moderators']) {
  1860. $moderatorschecked = ' checked="checked"';
  1861. }
  1862. $typeselect .= showtablerow('', array('class="td25"'), array(
  1863. "<input type=\"checkbox\" class=\"checkbox\" name=\"threadtypesnew[options][delete][]\" value=\"{$type['typeid']}\" />",
  1864. "<input type=\"text\" size=\"2\" name=\"threadtypesnew[options][displayorder][{$type['typeid']}]\" value=\"{$type['displayorder']}\" />",
  1865. "<input type=\"text\" name=\"threadtypesnew[options][name][{$type['typeid']}]\" value=\"".(str_replace(array("'", "\""), array(), $type['name']))."\" />",
  1866. "<input type=\"text\" name=\"threadtypesnew[options][icon][{$type['typeid']}]\" value=\"{$type['icon']}\" />",
  1867. '<input type="checkbox" name="threadtypesnew[options][enable]['.$type['typeid'].']" value="1" class="checkbox"'.$enablechecked.' />',
  1868. "<input type=\"checkbox\" class=\"checkbox\" name=\"threadtypesnew[options][moderators][{$type['typeid']}]\" value=\"1\"{$moderatorschecked} />",
  1869. ), TRUE);
  1870. }
  1871. return $typeselect;
  1872. }
  1873. function get_subfids($fid) {
  1874. global $subfids, $_G;
  1875. $subfids[] = $fid;
  1876. foreach($_G['cache']['forums'] as $key => $value) {
  1877. if($value['fup'] == $fid) {
  1878. get_subfids($value['fid']);
  1879. }
  1880. }
  1881. }
  1882. function copy_threadclasses($threadtypes, $fid) {
  1883. global $_G;
  1884. if($threadtypes) {
  1885. $threadtypes = dunserialize($threadtypes);
  1886. $i = 0;
  1887. $data = array();
  1888. foreach($threadtypes['types'] as $key => $val) {
  1889. $data = array('fid' => $fid, 'name' => $val, 'displayorder' => $i++, 'icon' => $threadtypes['icons'][$key], 'moderators' => $threadtypes['moderators'][$key]);
  1890. $newtypeid = C::t('forum_threadclass')->insert($data, true);
  1891. $newtypes[$newtypeid] = $val;
  1892. $newicons[$newtypeid] = $threadtypes['icons'][$key];
  1893. $newmoderators[$newtypeid] = $threadtypes['moderators'][$key];
  1894. }
  1895. $threadtypes['types'] = $newtypes;
  1896. $threadtypes['icons'] = $newicons;
  1897. $threadtypes['moderators'] = $newmoderators;
  1898. return serialize($threadtypes);
  1899. }
  1900. return '';
  1901. }
  1902. ?>