admincp_usergroups.php 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  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_usergroups.php 35097 2014-11-17 09:43:10Z laoguozhang $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. cpheader();
  12. if(!$operation) {
  13. if(!submitcheck('groupsubmit')) {
  14. $sgroups = $smembers = $specialgroup = array();
  15. $sgroupids = '0';
  16. $smembernum = $membergroup = $sysgroup = $membergroupoption = $specialgroupoption = '';
  17. foreach(C::t('common_usergroup')->range_orderby_creditshigher() as $group) {
  18. if($group['type'] == 'member') {
  19. $membergroupoption .= "<option value=\"g{$group[groupid]}\">".addslashes($group['grouptitle'])."</option>";
  20. $membergroup .= showtablerow('', array('class="td25"', '', 'class="td23 lightfont"', 'class="td28"', 'class=td28'), array(
  21. "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$group[groupid]]\" value=\"$group[groupid]\">",
  22. "<input type=\"text\" class=\"txt\" size=\"12\" name=\"groupnew[$group[groupid]][grouptitle]\" value=\"$group[grouptitle]\">",
  23. "(groupid:$group[groupid])",
  24. "<input type=\"text\" class=\"txt\" size=\"6\" name=\"groupnew[$group[groupid]][creditshigher]\" value=\"$group[creditshigher]\" /> ~ <input type=\"text\" class=\"txt\" size=\"6\" name=\"groupnew[$group[groupid]][creditslower]\" value=\"$group[creditslower]\" disabled />",
  25. "<input type=\"text\" class=\"txt\" size=\"2\" name=\"groupnew[$group[groupid]][stars]\" value=\"$group[stars]\">",
  26. "<input type=\"text\" id=\"group_color_$group[groupid]_v\" class=\"left txt\" size=\"6\" name=\"groupnew[$group[groupid]][color]\" value=\"$group[color]\" onchange=\"updatecolorpreview('group_color_$group[groupid]')\"><input type=\"button\" id=\"group_color_$group[groupid]\" class=\"colorwd\" onclick=\"group_color_$group[groupid]_frame.location='static/image/admincp/getcolor.htm?group_color_$group[groupid]|group_color_$group[groupid]_v';showMenu({'ctrlid':'group_color_$group[groupid]'})\" /><span id=\"group_color_$group[groupid]_menu\" style=\"display: none\"><iframe name=\"group_color_$group[groupid]_frame\" src=\"\" frameborder=\"0\" width=\"210\" height=\"148\" scrolling=\"no\"></iframe></span>",
  27. "<input class=\"checkbox\" type=\"checkbox\" chkvalue=\"gmember\" value=\"$group[groupid]\" onclick=\"multiupdate(this)\" /><a href=\"".ADMINSCRIPT."?action=usergroups&operation=edit&id=$group[groupid]\" class=\"act\">$lang[edit]</a>".
  28. "<a href=\"".ADMINSCRIPT."?action=usergroups&operation=copy&source=$group[groupid]\" title=\"$lang[usergroups_copy_comment]\" class=\"act\">$lang[usergroups_copy]</a>".
  29. "<a href=\"".ADMINSCRIPT."?action=usergroups&operation=merge&source=$group[groupid]\" title=\"$lang[usergroups_merge_comment]\" class=\"act\">$lang[usergroups_merge_link]</a>"
  30. ), TRUE);
  31. } elseif($group['type'] == 'system') {
  32. $sysgroup .= showtablerow('', array('', 'class="td23 lightfont"', '', 'class="td28"'), array(
  33. "<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_title[$group[groupid]]\" value=\"$group[grouptitle]\">",
  34. "(groupid:$group[groupid])",
  35. $lang['usergroups_system_'.$group['groupid']],
  36. "<input type=\"text\" class=\"txt\" size=\"2\"name=\"group_stars[$group[groupid]]\" value=\"$group[stars]\">",
  37. "<input type=\"text\" id=\"group_color_$group[groupid]_v\" class=\"left txt\" size=\"6\"name=\"group_color[$group[groupid]]\" value=\"$group[color]\" onchange=\"updatecolorpreview('group_color_$group[groupid]')\"><input type=\"button\" id=\"group_color_$group[groupid]\" class=\"colorwd\" onclick=\"group_color_$group[groupid]_frame.location='static/image/admincp/getcolor.htm?group_color_$group[groupid]|group_color_$group[groupid]_v';showMenu({'ctrlid':'group_color_$group[groupid]'})\" /><span id=\"group_color_$group[groupid]_menu\" style=\"display: none\"><iframe name=\"group_color_$group[groupid]_frame\" src=\"\" frameborder=\"0\" width=\"210\" height=\"148\" scrolling=\"no\"></iframe></span>",
  38. "<input class=\"checkbox\" type=\"checkbox\" chkvalue=\"gsystem\" value=\"$group[groupid]\" onclick=\"multiupdate(this)\" /><a href=\"".ADMINSCRIPT."?action=usergroups&operation=edit&id=$group[groupid]\" class=\"act\">$lang[edit]</a>".
  39. "<a href=\"".ADMINSCRIPT."?action=usergroups&operation=copy&source=$group[groupid]\" title=\"$lang[usergroups_copy_comment]\" class=\"act\">$lang[usergroups_copy]</a>"
  40. ), TRUE);
  41. } elseif($group['type'] == 'special' && $group['radminid'] == '0') {
  42. $specialgroupoption .= "<option value=\"g{$group[groupid]}\">".addslashes($group['grouptitle'])."</option>";
  43. $sgroups[] = $group;
  44. $sgroupids .= ','.$group['groupid'];
  45. }
  46. }
  47. foreach($sgroups as $group) {
  48. if(is_array($smembers[$group['groupid']])) {
  49. $num = count($smembers[$group['groupid']]);
  50. $specifiedusers = implode('', $smembers[$group['groupid']]).($num > $smembernum[$group['groupid']] ? '<br /><div style="float: right; clear: both; margin:5px"><a href="'.ADMINSCRIPT.'?action=members&submit=yes&usergroupid[]='.$group['groupid'].'" style="text-align: right;">'.$lang['more'].'&raquo;</a>&nbsp;</div>' : '<br /><br/>');
  51. unset($smembers[$group['groupid']]);
  52. } else {
  53. $specifiedusers = '';
  54. $num = 0;
  55. }
  56. $specifiedusers = "<style>#specifieduser span{width: 9em; height: 2em; float: left; overflow: hidden; margin: 2px;}</style><div id=\"specifieduser\">$specifiedusers</div>";
  57. $sg = showtablerow('', array('class="td25"', '', 'class="td23 lightfont"', 'class="td28"'), array(
  58. "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$group[groupid]]\" value=\"$group[groupid]\">",
  59. "<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_title[$group[groupid]]\" value=\"$group[grouptitle]\">",
  60. "(groupid:$group[groupid])",
  61. "<input type=\"text\" class=\"txt\" size=\"2\"name=\"group_stars[$group[groupid]]\" value=\"$group[stars]\">",
  62. "<input type=\"text\" id=\"group_color_$group[groupid]_v\" class=\"left txt\" size=\"6\"name=\"group_color[$group[groupid]]\" value=\"$group[color]\" onchange=\"updatecolorpreview('group_color_$group[groupid]')\"><input type=\"button\" id=\"group_color_$group[groupid]\" class=\"colorwd\" onclick=\"group_color_$group[groupid]_frame.location='static/image/admincp/getcolor.htm?group_color_$group[groupid]|group_color_$group[groupid]_v';showMenu({'ctrlid':'group_color_$group[groupid]'})\" /><span id=\"group_color_$group[groupid]_menu\" style=\"display: none\"><iframe name=\"group_color_$group[groupid]_frame\" src=\"\" frameborder=\"0\" width=\"210\" height=\"148\" scrolling=\"no\"></iframe></span>",
  63. "<input class=\"checkbox\" type=\"checkbox\" chkvalue=\"gspecial\" value=\"$group[groupid]\" onclick=\"multiupdate(this)\" /><a href=\"".ADMINSCRIPT."?action=usergroups&operation=edit&id=$group[groupid]\" class=\"act\">$lang[edit]</a>".
  64. "<a href=\"".ADMINSCRIPT."?action=usergroups&operation=copy&source=$group[groupid]\" title=\"$lang[usergroups_copy_comment]\" class=\"act\">$lang[usergroups_copy]</a>".
  65. "<a href=\"".ADMINSCRIPT."?action=usergroups&operation=merge&source=$group[groupid]\" title=\"$lang[usergroups_merge_comment]\" class=\"act\">$lang[usergroups_merge_link]</a>".
  66. "<a href=\"".ADMINSCRIPT."?action=usergroups&operation=viewsgroup&sgroupid=$group[groupid]\" onclick=\"ajaxget(this.href, 'sgroup_$group[groupid]', 'sgroup_$group[groupid]');doane(event);\" class=\"act\">$lang[view]</a> &nbsp;"
  67. ), TRUE);
  68. $sg .= showtablerow('', array('colspan="5" id="sgroup_'.$group['groupid'].'" style="display: none"'), array(''), TRUE);
  69. if($group['system'] == 'private') {
  70. $st = 'private';
  71. } else {
  72. list($dailyprice) = explode("\t", $group['system']);
  73. $st = $dailyprice > 0 ? 'buy' : 'free';
  74. }
  75. $specialgroup[$st] .= $sg;
  76. }
  77. echo <<<EOT
  78. <script type="text/JavaScript">
  79. var rowtypedata = [
  80. [
  81. [1,'', 'td25'],
  82. [2,'<input type="text" class="txt" size="12" name="groupnewadd[grouptitle][]"><select name="groupnewadd[projectid][]"><option value="">$lang[usergroups_project]</option><option value="0">------------</option>$membergroupoption</select>'],
  83. [1,'<input type="text" class="txt" size="6" name="groupnewadd[creditshigher][]">', 'td28'],
  84. [1,'<input type="text" class="txt" size="2" name="groupnewadd[stars][]">', 'td28'],
  85. [2,'<input type="text" class="txt" size="6" name="groupnewadd[color][]">']
  86. ],
  87. [
  88. [1,'', 'td25'],
  89. [2,'<input type="text" class="txt" size="12" name="grouptitlenewadd[]"><select name="groupnewaddproject[]"><option value="">$lang[usergroups_project]</option><option value="0">------------</option>$specialgroupoption</select>'],
  90. [1,'<input type="text" class="txt" size="2" name="starsnewadd[]">', 'td28'],
  91. [2,'<input type="text" class="txt" size="6" name="colornewadd[]">']
  92. ]
  93. ];
  94. </script>
  95. EOT;
  96. shownav('user', 'nav_usergroups');
  97. showsubmenuanchors('nav_usergroups', array(
  98. array('usergroups_member', 'membergroups', !$_GET['type'] || $_GET['type'] == 'member'),
  99. array('usergroups_special', 'specialgroups', $_GET['type'] == 'special'),
  100. array('usergroups_system', 'systemgroups', $_GET['type'] == 'system')
  101. ));
  102. showtips('usergroups_tips');
  103. showformheader('usergroups&type=member');
  104. showtableheader('usergroups_member', 'fixpadding', 'id="membergroups"'.($_GET['type'] && $_GET['type'] != 'member' ? ' style="display: none"' : ''));
  105. showsubtitle(array('', 'usergroups_title', '', 'usergroups_creditsrange', 'usergroups_stars', 'usergroups_color', '<input class="checkbox" type="checkbox" name="gcmember" onclick="checkAll(\'value\', this.form, \'gmember\', \'gcmember\', 1)" /> <a href="javascript:;" onclick="if(getmultiids()) location.href=\''.ADMINSCRIPT.'?action=usergroups&operation=edit&multi=\' + getmultiids();return false;">'.$lang['multiedit'].'</a>'));
  106. echo $membergroup;
  107. echo '<tr><td>&nbsp;</td><td colspan="8"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['usergroups_add'].'</a></div></td></tr>';
  108. showsubmit('groupsubmit', 'submit', 'del');
  109. showtablefooter();
  110. showformfooter();
  111. showformheader('usergroups&type=special');
  112. showtableheader('usergroups_special', 'fixpadding', 'id="specialgroups"'.($_GET['type'] != 'special' ? ' style="display: none"' : ''));
  113. showsubtitle(array('', 'usergroups_title', '', 'usergroups_stars', 'usergroups_color', '<input class="checkbox" type="checkbox" name="gcspecial" onclick="checkAll(\'value\', this.form, \'gspecial\', \'gcspecial\', 1)" /> <a href="javascript:;" onclick="if(getmultiids()) location.href=\''.ADMINSCRIPT.'?action=usergroups&operation=edit&multi=\' + getmultiids();return false;">'.$lang['multiedit'].'</a>'));
  114. if($specialgroup['private']) {
  115. echo $specialgroup['private'];
  116. }
  117. if($specialgroup['buy']) {
  118. showsubtitle(array('', 'usergroups_edit_system_buy'));
  119. echo $specialgroup['buy'];
  120. }
  121. if($specialgroup['free']) {
  122. showsubtitle(array('', 'usergroups_edit_system_free'));
  123. echo $specialgroup['free'];
  124. }
  125. echo '<tr><td>&nbsp;</td><td colspan="5"><div><a href="###" onclick="addrow(this, 1)" class="addtr">'.$lang['usergroups_sepcial_add'].'</a></div></td></tr>';
  126. showsubmit('groupsubmit', 'submit', 'del');
  127. showtablefooter();
  128. showformfooter();
  129. showformheader('usergroups&type=system');
  130. showtableheader('usergroups_system', 'fixpadding', 'id="systemgroups"'.($_GET['type'] != 'system' ? ' style="display: none"' : ''));
  131. showsubtitle(array('usergroups_title', '', 'usergroups_status', 'usergroups_stars', 'usergroups_color', '<input class="checkbox" type="checkbox" name="gcsystem" onclick="checkAll(\'value\', this.form, \'gsystem\', \'gcsystem\', 1)" /> <a href="javascript:;" onclick="if(getmultiids()) location.href=\''.ADMINSCRIPT.'?action=usergroups&operation=edit&multi=\' + getmultiids();return false;">'.$lang['multiedit'].'</a>'));
  132. echo $sysgroup;
  133. showsubmit('groupsubmit');
  134. showtablefooter();
  135. showformfooter();
  136. } else {
  137. if(empty($_GET['type']) || !in_array($_GET['type'], array('member', 'special', 'system'))) {
  138. cpmsg('usergroups_type_nonexistence');
  139. }
  140. $oldgroups = $extadd = array();
  141. foreach(C::t('common_usergroup')->fetch_all_by_type($_GET['type'], null, true) as $gp) {
  142. $oldgroups[$gp['groupid']] = $gp;
  143. }
  144. foreach($oldgroups as $id => $vals) {
  145. $data = array();
  146. foreach($vals as $k => $v) {
  147. $v = addslashes($v);
  148. if(!in_array($k, array('groupid', 'radminid', 'type', 'system', 'grouptitle', 'creditshigher', 'creditslower', 'stars', 'color', 'icon'))) {
  149. $data[$k] = $v;
  150. }
  151. }
  152. $extadd['g'.$id] = $data;
  153. }
  154. if($_GET['type'] == 'member') {
  155. $groupnewadd = array_flip_keys($_GET['groupnewadd']);
  156. foreach($groupnewadd as $k => $v) {
  157. if(!$v['grouptitle']) {
  158. unset($groupnewadd[$k]);
  159. } elseif(!$v['creditshigher']) {
  160. cpmsg('usergroups_update_creditshigher_invalid', '', 'error');
  161. }
  162. }
  163. $groupnewkeys = array_keys($_GET['groupnew']);
  164. $maxgroupid = max($groupnewkeys);
  165. foreach($groupnewadd as $k=>$v) {
  166. $_GET['groupnew'][$k+$maxgroupid+1] = $v;
  167. }
  168. $orderarray = array();
  169. if(is_array($_GET['groupnew'])) {
  170. foreach($_GET['groupnew'] as $id => $group) {
  171. if((is_array($_GET['delete']) && in_array($id, $_GET['delete'])) || ($id == 0 && (!$group['grouptitle'] || $group['creditshigher'] == ''))) {
  172. unset($_GET['groupnew'][$id]);
  173. } else {
  174. $orderarray[$group['creditshigher']] = $id;
  175. }
  176. }
  177. }
  178. if(empty($orderarray[0]) || min(array_flip($orderarray)) >= 0) {
  179. cpmsg('usergroups_update_credits_invalid', '', 'error');
  180. }
  181. ksort($orderarray);
  182. $rangearray = array();
  183. $lowerlimit = array_keys($orderarray);
  184. for($i = 0; $i < count($lowerlimit); $i++) {
  185. $rangearray[$orderarray[$lowerlimit[$i]]] = array(
  186. 'creditshigher' => isset($lowerlimit[$i - 1]) ? $lowerlimit[$i] : -999999999,
  187. 'creditslower' => isset($lowerlimit[$i + 1]) ? $lowerlimit[$i + 1] : 999999999
  188. );
  189. }
  190. foreach($_GET['groupnew'] as $id => $group) {
  191. $creditshighernew = $rangearray[$id]['creditshigher'];
  192. $creditslowernew = $rangearray[$id]['creditslower'];
  193. if($creditshighernew == $creditslowernew) {
  194. cpmsg('usergroups_update_credits_duplicate', '', 'error');
  195. }
  196. if(in_array($id, $groupnewkeys)) {
  197. C::t('common_usergroup')->update($id, array('grouptitle' => $group['grouptitle'], 'creditshigher' => $creditshighernew, 'creditslower' => $creditslowernew, 'stars' => $group['stars'], 'color' => $group['color']), 'member');
  198. C::t('forum_onlinelist')->update_by_groupid($id, array('title' => $group['grouptitle']));
  199. } elseif($group['grouptitle'] && $group['creditshigher'] != '') {
  200. $data = array(
  201. 'grouptitle' => $group['grouptitle'],
  202. 'creditshigher' => $creditshighernew,
  203. 'creditslower' => $creditslowernew,
  204. 'stars' => $group['stars'],
  205. 'color' => $group['color'],
  206. );
  207. if(!empty($group['projectid']) && !empty($extadd[$group['projectid']])) {
  208. $data = array_merge($data, $extadd[$group['projectid']]);
  209. }
  210. $newgid = C::t('common_usergroup')->insert($data, true);
  211. $datafield = array(
  212. 'groupid' => $newgid,
  213. 'allowsearch' => 2,
  214. );
  215. C::t('common_usergroup_field')->insert($datafield);
  216. C::t('forum_onlinelist')->insert(array(
  217. 'groupid' => $newgid,
  218. 'title' => $data['grouptitle'],
  219. 'displayorder' => '0',
  220. 'url' => '',
  221. ));
  222. $sqladd = !empty($group['projectid']) && !empty($extadd[$group['projectid']]) ? $extadd[$group['projectid']] : '';
  223. if($sqladd) {
  224. $projectid = substr($group['projectid'], 1);
  225. $group_fields = C::t('common_usergroup_field')->fetch($projectid);
  226. unset($group_fields['groupid']);
  227. C::t('common_usergroup_field')->update($newgid, $group_fields);
  228. $query = C::t('forum_forumfield')->fetch_all_field_perm();
  229. foreach($query as $row) {
  230. $upforumperm = array();
  231. if($row['viewperm'] && in_array($projectid, explode("\t", $row['viewperm']))) {
  232. $upforumperm['viewperm'] = "$row[viewperm]$newgid\t";
  233. }
  234. if($row['postperm'] && in_array($projectid, explode("\t", $row['postperm']))) {
  235. $upforumperm['postperm'] = "$row[postperm]$newgid\t";
  236. }
  237. if($row['replyperm'] && in_array($projectid, explode("\t", $row['replyperm']))) {
  238. $upforumperm['replyperm'] = "$row[replyperm]$newgid\t";
  239. }
  240. if($row['getattachperm'] && in_array($projectid, explode("\t", $row['getattachperm']))) {
  241. $upforumperm['getattachperm'] = "$row[getattachperm]$newgid\t";
  242. }
  243. if($row['postattachperm'] && in_array($projectid, explode("\t", $row['postattachperm']))) {
  244. $upforumperm['postattachperm'] = "$row[postattachperm]$newgid\t";
  245. }
  246. if($row['postimageperm'] && in_array($projectid, explode("\t", $row['postimageperm']))) {
  247. $upforumperm['postimageperm'] = "$row[postimageperm]$newgid\t";
  248. }
  249. if($upforumperm) {
  250. C::t('forum_forumfield')->update($row['fid'], $upforumperm);
  251. }
  252. }
  253. }
  254. }
  255. }
  256. if($_GET['delete']) {
  257. C::t('common_usergroup')->delete($_GET['delete'], 'member');
  258. C::t('common_usergroup_field')->delete($_GET['delete']);
  259. C::t('forum_onlinelist')->delete_by_groupid($_GET['delete']);
  260. deletegroupcache($_GET['delete']);
  261. }
  262. } elseif($_GET['type'] == 'special') {
  263. if(is_array($_GET['grouptitlenewadd'])) {
  264. foreach($_GET['grouptitlenewadd'] as $k => $v) {
  265. if($v) {
  266. $data = array(
  267. 'type' => 'special',
  268. 'grouptitle' => $_GET['grouptitlenewadd'][$k],
  269. 'color' => $_GET['colornewadd'][$k],
  270. 'stars' => $_GET['starsnewadd'][$k],
  271. );
  272. if(!empty($_GET['groupnewaddproject'][$k]) && !empty($extadd[$_GET['groupnewaddproject'][$k]])) {
  273. $data = array_merge($data, $extadd[$_GET['groupnewaddproject'][$k]]);
  274. }
  275. $newgid = C::t('common_usergroup')->insert($data, true);
  276. $datafield = array(
  277. 'groupid' => $newgid,
  278. 'allowsearch' => 2,
  279. );
  280. C::t('common_usergroup_field')->insert($datafield);
  281. C::t('forum_onlinelist')->insert(array(
  282. 'groupid' => $newgid,
  283. 'title' => $data['grouptitle'],
  284. 'url' => '',
  285. ));
  286. $sqladd = !empty($_GET['groupnewaddproject'][$k]) && !empty($extadd[$_GET['groupnewaddproject'][$k]]) ? $extadd[$_GET['groupnewaddproject'][$k]] : '';
  287. if($sqladd) {
  288. $projectid = substr($_GET['groupnewaddproject'][$k], 1);
  289. $group_fields = C::t('common_usergroup_field')->fetch($projectid);
  290. unset($group_fields['groupid']);
  291. C::t('common_usergroup_field')->update($newgid, $group_fields);
  292. $query = C::t('forum_forumfield')->fetch_all_field_perm();
  293. foreach($query as $row) {
  294. $upforumperm = array();
  295. if($row['viewperm'] && in_array($projectid, explode("\t", $row['viewperm']))) {
  296. $upforumperm['viewperm'] = "$row[viewperm]$newgid\t";
  297. }
  298. if($row['postperm'] && in_array($projectid, explode("\t", $row['postperm']))) {
  299. $upforumperm['postperm'] = "$row[postperm]$newgid\t";
  300. }
  301. if($row['replyperm'] && in_array($projectid, explode("\t", $row['replyperm']))) {
  302. $upforumperm['replyperm'] = "$row[replyperm]$newgid\t";
  303. }
  304. if($row['getattachperm'] && in_array($projectid, explode("\t", $row['getattachperm']))) {
  305. $upforumperm['getattachperm'] = "$row[getattachperm]$newgid\t";
  306. }
  307. if($row['postattachperm'] && in_array($projectid, explode("\t", $row['postattachperm']))) {
  308. $upforumperm['postattachperm'] = "$row[postattachperm]$newgid\t";
  309. }
  310. if($row['postimageperm'] && in_array($projectid, explode("\t", $row['postimageperm']))) {
  311. $upforumperm['postimageperm'] = "$row[postimageperm]$newgid\t";
  312. }
  313. if($upforumperm) {
  314. C::t('forum_forumfield')->update($row['fid'], $upforumperm);
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. if(is_array($_GET['group_title'])) {
  322. foreach($_GET['group_title'] as $id => $title) {
  323. if(!$_GET['delete'][$id]) {
  324. C::t('common_usergroup')->update($id, array('grouptitle' => $_GET['group_title'][$id], 'stars' => $_GET['group_stars'][$id], 'color' => $_GET['group_color'][$id]));
  325. C::t('forum_onlinelist')->update_by_groupid($id, array('title' => $_GET['group_title'][$id]));
  326. }
  327. }
  328. }
  329. if(($ids = $_GET['delete'])) {
  330. C::t('common_usergroup')->delete($ids, 'special');
  331. C::t('forum_onlinelist')->delete_by_groupid($ids);
  332. C::t('common_admingroup')->delete($ids);
  333. $newgroupid = C::t('common_usergroup')->fetch_new_groupid();
  334. C::t('common_member')->update_by_groupid($ids, array('groupid' => $newgroupid, 'adminid' => '0'));
  335. deletegroupcache($ids);
  336. }
  337. } elseif($_GET['type'] == 'system') {
  338. if(is_array($_GET['group_title'])) {
  339. foreach($_GET['group_title'] as $id => $title) {
  340. C::t('common_usergroup')->update($id, array('grouptitle' => $_GET['group_title'][$id], 'stars' => $_GET['group_stars'][$id], 'color' => $_GET['group_color'][$id]));
  341. C::t('forum_onlinelist')->update_by_groupid($id, array('title' => $_GET['group_title'][$id]));
  342. }
  343. }
  344. }
  345. updatecache(array('usergroups', 'onlinelist', 'groupreadaccess'));
  346. cpmsg('usergroups_update_succeed', 'action=usergroups&type='.$_GET['type'], 'succeed');
  347. }
  348. } elseif($operation == 'viewsgroup') {
  349. $sgroupid = $_GET['sgroupid'];
  350. $num = C::t('common_member')->count_by_groupid($sgroupid);
  351. $sgroups = '';
  352. foreach(C::t('common_member')->fetch_all_by_groupid($sgroupid, 0, 80) as $uid => $member) {
  353. $sgroups .= '<li><a href="home.php?mod=space&uid='.$uid.'" target="_blank">'.$member['username'].'</a></li>';
  354. }
  355. ajaxshowheader();
  356. echo '<ul class="userlist"><li class="unum">'.$lang['usernum'].$num.($num > 80 ? '&nbsp;<a href="'.ADMINSCRIPT.'?action=members&operation=search&submit=yes&groupid='.$sgroupid.'">'.$lang['more'].'&raquo;</a>' : '').'</li>'.$sgroups.'</ul>';
  357. ajaxshowfooter();
  358. } elseif($operation == 'edit') {
  359. $return = isset($_GET['return']) && $_GET['return'] ? 'admin' : '';
  360. list($pluginsetting, $pluginvalue) = get_pluginsetting('groups');
  361. $multiset = 0;
  362. $gids = array();
  363. if(empty($_GET['multi'])) {
  364. if($_GET['id']) {
  365. $gids[0] = $_GET['id'];
  366. }
  367. } else {
  368. $multiset = 1;
  369. if(is_array($_GET['multi'])) {
  370. $gids = &$_GET['multi'];
  371. } else {
  372. $_GET['multi'] = explode(',', $_GET['multi']);
  373. $gids = &$_GET['multi'];
  374. }
  375. }
  376. if(count($_GET['multi']) == 1) {
  377. if ($_GET['multi'][0]) {
  378. $gids[0] = $_GET['multi'][0];
  379. }
  380. $multiset = 0;
  381. }
  382. if(!count($gids)) {
  383. $grouplist = "<select name=\"id\" style=\"width:150px\">\n";
  384. $conditions = !empty($_GET['anchor']) && $_GET['anchor'] == 'system' ? 'special' : '';
  385. foreach(C::t('common_usergroup')->fetch_all_by_type($conditions) as $group) {
  386. $grouplist .= "<option value=\"$group[groupid]\">$group[grouptitle]</option>\n";
  387. }
  388. $grouplist .= '</select>';
  389. cpmsg('usergroups_edit_nonexistence', 'action=usergroups&operation=edit'.(!empty($_GET['highlight']) ? "&highlight={$_GET['highlight']}" : '').(!empty($_GET['highlight']) ? "&anchor={$_GET['anchor']}" : ''), 'form', array(), $grouplist);
  390. }
  391. $group_data = C::t('common_usergroup')->fetch_all($gids);
  392. $groupfield_data = C::t('common_usergroup_field')->fetch_all($gids);
  393. if(!$group_data) {
  394. cpmsg('usergroups_nonexistence', '', 'error');
  395. } else {
  396. foreach($group_data as $curgid => $group) {
  397. $group = array_merge($group, (array)$groupfield_data[$curgid]);
  398. if(isset($pluginvalue[$group['groupid']])) {
  399. $group['plugin'] = $pluginvalue[$group['groupid']];
  400. }
  401. $mgroup[] = $group;
  402. }
  403. }
  404. $allowthreadplugin = $_G['setting']['threadplugins'] ? C::t('common_setting')->fetch('allowthreadplugin', true) : array();
  405. if(!submitcheck('detailsubmit')) {
  406. $grouplist = $groupcount = array();
  407. foreach(C::t('common_usergroup')->range_orderby_credit() as $ggroup) {
  408. $checked = $_GET['id'] == $ggroup['groupid'] || in_array($ggroup['groupid'], $_GET['multi']);
  409. $ggroup['type'] = $ggroup['type'] == 'special' && $ggroup['radminid'] ? 'specialadmin' : $ggroup['type'];
  410. $groupcount[$ggroup['type']]++;
  411. $grouplist[$ggroup['type']] .= '<input class="left checkbox ck" chkvalue="'.$ggroup['type'].'" name="multi[]" value="'.$ggroup['groupid'].'" type="checkbox" '.($checked ? 'checked="checked" ' : '').'/>'.
  412. '<a href="###" onclick="location.href=\''.ADMINSCRIPT.'?action=usergroups&operation=edit&switch=yes&id='.$ggroup['groupid'].'&anchor=\'+currentAnchor+\'&scrolltop=\'+scrollTopBody()"'.($checked ? ' class="current"' : '').'>'.$ggroup['grouptitle'].'</a>';
  413. if(!($groupcount[$ggroup['type']] % 3)) {
  414. $grouplist[$ggroup['type']] .= '<br style="clear:both" />';
  415. }
  416. }
  417. $gselect = '<span id="ugselect" class="right popupmenu_dropmenu" onmouseover="showMenu({\'ctrlid\':this.id,\'pos\':\'34\'});$(\'ugselect_menu\').style.top=(parseInt($(\'ugselect_menu\').style.top)-scrollTopBody())+\'px\';$(\'ugselect_menu\').style.left=(parseInt($(\'ugselect_menu\').style.left)-document.documentElement.scrollLeft-20)+\'px\'">'.$lang['usergroups_switch'].'<em>&nbsp;&nbsp;</em></span>'.
  418. '<div id="ugselect_menu" class="popupmenu_popup" style="display:none">'.
  419. '<em class="cl"><span class="right"><input name="checkall_member" onclick="checkAll(\'value\', this.form, \'member\', \'checkall_member\')" type="checkbox" class="vmiddle checkbox" /></span>'.$lang['usergroups_member'].'</em>'.$grouplist['member'].'<br />'.
  420. ($grouplist['special'] ? '<em class="cl"><span class="right"><input name="checkall_special" onclick="checkAll(\'value\', this.form, \'special\', \'checkall_special\')" type="checkbox" class="vmiddle checkbox" /></span>'.$lang['usergroups_special'].'</em>'.$grouplist['special'].'<br />' : '').
  421. ($grouplist['specialadmin'] ? '<em class="cl"><span class="right"><input name="checkall_specialadmin" onclick="checkAll(\'value\', this.form, \'specialadmin\', \'checkall_specialadmin\')" type="checkbox" class="vmiddle checkbox" /></span>'.$lang['usergroups_specialadmin'].'</em>'.$grouplist['specialadmin'].'<br />' : '').
  422. '<em class="cl"><span class="right"><input name="checkall_system" onclick="checkAll(\'value\', this.form, \'system\', \'checkall_system\')" type="checkbox" class="vmiddle checkbox" /></span>'.$lang['usergroups_system'].'</em>'.$grouplist['system'].
  423. '<br style="clear:both" /><div class="cl"><input type="button" class="btn right" onclick="$(\'menuform\').submit()" value="'.cplang('usergroups_multiedit').'" /></div>'.
  424. '</div>';
  425. $anchor = in_array($_GET['anchor'], array('basic', 'system', 'special', 'post', 'attach', 'magic', 'invite', 'pm', 'credit', 'home', 'group', 'portal', 'plugin')) ? $_GET['anchor'] : 'basic';
  426. showformheader('', '', 'menuform', 'get');
  427. showhiddenfields(array('action' => 'usergroups', 'operation' => 'edit'));
  428. showsubmenuanchors(cplang('usergroups_edit').(count($mgroup) == 1 ? ' - '.$mgroup[0]['grouptitle'].'(groupid:'.$mgroup[0]['groupid'].')' : ''), array(
  429. array('usergroups_edit_basic', 'basic', $anchor == 'basic'),
  430. count($mgroup) == 1 && $mgroup[0]['type'] == 'special' && $mgroup[0]['radminid'] < 1 ? array('usergroups_edit_system', 'system', $anchor == 'system') : array(),
  431. array(array('menu' => 'usergroups_edit_forum', 'submenu' => array(
  432. array('usergroups_edit_post', 'post', $anchor == 'post'),
  433. array('usergroups_edit_attach', 'attach', $anchor == 'attach'),
  434. array('usergroups_edit_special', 'special', $anchor == 'special')
  435. ))),
  436. array('usergroups_edit_group', 'group', $anchor == 'group'),
  437. array('usergroups_edit_portal', 'portal', $anchor == 'portal'),
  438. array('usergroups_edit_home', 'home', $anchor == 'home'),
  439. array(array('menu' => 'usergroups_edit_other', 'submenu' => array(
  440. array('usergroups_edit_credit', 'credit', $anchor == 'credit'),
  441. array('usergroups_edit_magic', 'magic', $anchor == 'magic'),
  442. array('usergroups_edit_invite', 'invite', $anchor == 'invite'),
  443. !$pluginsetting ? array() : array('usergroups_edit_plugin', 'plugin', $anchor == 'plugin'),
  444. ))),
  445. ), $gselect);
  446. showformfooter();
  447. if(count($mgroup) == 1 && $mgroup[0]['type'] == 'special' && $mgroup[0]['radminid'] < 1) {
  448. showtips('usergroups_edit_system_tips', 'system_tips', $anchor == 'system');
  449. }
  450. if($multiset) {
  451. showtips('setting_multi_tips');
  452. }
  453. showtips('usergroups_edit_magic_tips', 'magic_tips', $anchor == 'magic');
  454. showtips('usergroups_edit_invite_tips', 'invite_tips', $anchor == 'invite');
  455. if($_GET['id'] == 7) {
  456. showtips('usergroups_edit_system_guest_portal_tips', 'portal_tips', $anchor == 'portal');
  457. showtips('usergroups_edit_system_guest_home_tips', 'home_tips', $anchor == 'home');
  458. }
  459. showformheader("usergroups&operation=edit&id={$_GET['id']}&return=$return", 'enctype');
  460. if($multiset) {
  461. $_G['showsetting_multi'] = 0;
  462. $_G['showsetting_multicount'] = count($mgroup);
  463. foreach($mgroup as $group) {
  464. $_G['showtableheader_multi'][] = '<a href="javascript:;" onclick="location.href=\''.ADMINSCRIPT.'?action=usergroups&operation=edit&id='.$group['groupid'].'&anchor=\'+$(\'cpform\').anchor.value;return false">'.$group['grouptitle'].'(groupid:'.$group['groupid'].')</a>';
  465. }
  466. }
  467. $mgids = array();
  468. foreach($mgroup as $group) {
  469. $_GET['id'] = $gid = $group['groupid'];
  470. $mgids[] = $gid;
  471. if(!$multiset && $group['type'] == 'special' && $group['radminid'] < 1) {
  472. showtagheader('div', 'system', $anchor == 'system');
  473. showtableheader();
  474. if($group['system'] == 'private') {
  475. $system = array('public' => 0, 'dailyprice' => 0, 'minspan' => 0);
  476. } else {
  477. $system = array('public' => 1, 'dailyprice' => 0, 'minspan' => 0);
  478. list($system['dailyprice'], $system['minspan']) = explode("\t", $group['system']);
  479. }
  480. showsetting('usergroups_edit_system_public', 'system_publicnew', $system['public'], 'radio', 0, 1);
  481. showsetting('usergroups_edit_system_dailyprice', 'system_dailypricenew', $system['dailyprice'], 'text');
  482. showsetting('usergroups_edit_system_minspan', 'system_minspannew', $system['minspan'], 'text');
  483. showtablefooter();
  484. showtagfooter('div');
  485. }
  486. showmultititle();
  487. showtagheader('div', 'basic', $anchor == 'basic');
  488. showtableheader();
  489. showtitle('usergroups_edit_basic');
  490. showsetting('usergroups_edit_basic_title', 'grouptitlenew', $group['grouptitle'], 'text');
  491. $group['exempt'] = strrev(sprintf('%0'.strlen($group['exempt']).'b', $group['exempt']));
  492. if(!$multiset) {
  493. if($group['icon']) {
  494. $valueparse = parse_url($group['icon']);
  495. if(isset($valueparse['host'])) {
  496. $groupicon = $group['icon'];
  497. } else {
  498. $groupicon = $_G['setting']['attachurl'].'common/'.$group['icon'].'?'.random(6);
  499. }
  500. $groupiconhtml = '<label><input type="checkbox" class="checkbox" name="deleteicon[$group[groupid]]" value="yes" /> '.$lang['delete'].'</label><br /><img src="'.$groupicon.'" />';
  501. }
  502. showsetting('usergroups_icon', 'iconnew', $group['icon'], 'filetext', '', 0, $groupiconhtml);
  503. }
  504. $group['allowvisit'] = $group['groupid'] == 1 ? 2 : $group['allowvisit'];
  505. showsetting('usergroups_edit_basic_visit', array('allowvisitnew', array(
  506. array(0, cplang('usergroups_edit_basic_visit_none')),
  507. array(1, cplang('usergroups_edit_basic_visit_normal')),
  508. array(2, cplang('usergroups_edit_basic_visit_super')),
  509. )), $group['allowvisit'], 'mradio');
  510. showsetting('usergroups_edit_basic_read_access', 'readaccessnew', $group['readaccess'], 'text');
  511. showsetting('usergroups_edit_basic_max_friend_number', 'maxfriendnumnew', $group['maxfriendnum'], 'text');
  512. showsetting('usergroups_edit_basic_domain_length', 'domainlengthnew', $group['domainlength'], 'text');
  513. showsetting('usergroups_edit_basic_invisible', 'allowinvisiblenew', $group['allowinvisible'], 'radio');
  514. showsetting('usergroups_edit_basic_allowtransfer', 'allowtransfernew', $group['allowtransfer'], 'radio');
  515. showsetting('usergroups_edit_basic_allowsendpm', 'allowsendpmnew', $group['allowsendpm'], 'radio', 0, 1);
  516. showsetting('usergroups_edit_pm_sendpmmaxnum', 'allowsendpmmaxnumnew', $group['allowsendpmmaxnum'], 'text');
  517. showsetting('usergroups_edit_pm_sendallpm', 'allowsendallpmnew', $group['allowsendallpm'], 'radio');
  518. showtagfooter('tbody');
  519. showsetting('usergroups_edit_post_html', 'allowhtmlnew', $group['allowhtml'], 'radio');
  520. showsetting('usergroups_edit_post_url', array('allowposturlnew', array(
  521. array(0, $lang['usergroups_edit_post_url_banned']),
  522. array(1, $lang['usergroups_edit_post_url_mod']),
  523. array(2, $lang['usergroups_edit_post_url_unhandle']),
  524. array(3, $lang['usergroups_edit_post_url_enable'])
  525. )), $group['allowposturl'], 'mradio');
  526. showsetting('usergroups_edit_basic_allow_statdata', 'allowstatdatanew', $group['allowstatdata'], 'radio');
  527. showsetting('usergroups_edit_basic_search_post', 'allowfulltextnew', $group['allowsearch'] & 32, 'radio');
  528. $group['allowsearch'] = $group['allowsearch'] > 128 ? $group['allowsearch'] - 128 : $group['allowsearch'];
  529. showsetting('usergroups_edit_basic_search', array('allowsearchnew', array(
  530. cplang('setting_search_status_portal'),
  531. cplang('setting_search_status_forum'),
  532. cplang('setting_search_status_blog'),
  533. cplang('setting_search_status_album'),
  534. cplang('setting_search_status_group'),
  535. false,
  536. cplang('setting_search_status_collection')
  537. )), $group['allowsearch'], 'binmcheckbox');
  538. showsetting('usergroups_edit_basic_reasonpm', array('reasonpmnew', array(
  539. array(0, $lang['usergroups_edit_basic_reasonpm_none']),
  540. array(1, $lang['usergroups_edit_basic_reasonpm_reason']),
  541. array(2, $lang['usergroups_edit_basic_reasonpm_pm']),
  542. array(3, $lang['usergroups_edit_basic_reasonpm_both'])
  543. )), $group['reasonpm'], 'mradio');
  544. showsetting('usergroups_edit_basic_cstatus', 'allowcstatusnew', $group['allowcstatus'], 'radio');
  545. showsetting('usergroups_edit_basic_disable_periodctrl', 'disableperiodctrlnew', $group['disableperiodctrl'], 'radio');
  546. showsetting('usergroups_edit_basic_hour_threads', 'maxthreadsperhournew', intval($group['maxthreadsperhour']), 'text');
  547. showsetting('usergroups_edit_basic_hour_posts', 'maxpostsperhournew', intval($group['maxpostsperhour']), 'text');
  548. showsetting('usergroups_edit_basic_seccode', 'seccodenew', $group['seccode'], 'radio', $group['groupid'] == 7);
  549. showsetting('usergroups_edit_basic_forcesecques', 'forcesecquesnew', $group['forcesecques'], 'radio');
  550. if(!in_array($gid, array(7, 8))) {
  551. showsetting('usergroups_edit_basic_forcelogin', array('forceloginnew', array(
  552. array(0, $lang['usergroups_edit_basic_forcelogin_none']),
  553. array(1, $lang['usergroups_edit_basic_forcelogin_qq']),
  554. array(2, $lang['usergroups_edit_basic_forcelogin_mail']),
  555. )), $group['forcelogin'], 'mradio');
  556. }
  557. showsetting('usergroups_edit_basic_disable_postctrl', 'disablepostctrlnew', $group['disablepostctrl'], 'radio');
  558. showsetting('usergroups_edit_basic_ignore_censor', 'ignorecensornew', $group['ignorecensor'], 'radio');
  559. showsetting('usergroups_edit_basic_allowcreatecollection', 'allowcreatecollectionnew', intval($group['allowcreatecollection']), 'text');
  560. showsetting('usergroups_edit_basic_allowfollowcollection', 'allowfollowcollectionnew', intval($group['allowfollowcollection']), 'text');
  561. showsetting('usergroups_edit_basic_close_ad', 'closeadnew', $group['closead'], 'radio');
  562. showtablefooter();
  563. showtagfooter('div');
  564. showtagheader('div', 'special', $anchor == 'special');
  565. showtableheader();
  566. showtitle('usergroups_edit_special');
  567. showsetting('usergroups_edit_special_activity', 'allowpostactivitynew', $group['allowpostactivity'], 'radio');
  568. showsetting('usergroups_edit_special_poll', 'allowpostpollnew', $group['allowpostpoll'], 'radio');
  569. showsetting('usergroups_edit_special_vote', 'allowvotenew', $group['allowvote'], 'radio');
  570. showsetting('usergroups_edit_special_reward', 'allowpostrewardnew', $group['allowpostreward'], 'radio');
  571. showsetting('usergroups_edit_special_reward_min', 'minrewardpricenew', $group['minrewardprice'], "text");
  572. showsetting('usergroups_edit_special_reward_max', 'maxrewardpricenew', $group['maxrewardprice'], "text");
  573. showsetting('usergroups_edit_special_trade', 'allowposttradenew', $group['allowposttrade'], 'radio');
  574. showsetting('usergroups_edit_special_trade_min', 'mintradepricenew', $group['mintradeprice'], "text");
  575. showsetting('usergroups_edit_special_trade_max', 'maxtradepricenew', $group['maxtradeprice'], "text");
  576. showsetting('usergroups_edit_special_trade_stick', 'tradesticknew', $group['tradestick'], "text");
  577. showsetting('usergroups_edit_special_debate', 'allowpostdebatenew', $group['allowpostdebate'], "radio");
  578. showsetting('usergroups_edit_special_rushreply', 'allowpostrushreplynew', $group['allowpostrushreply'], "radio");
  579. $threadpluginselect = array();
  580. if(is_array($_G['setting']['threadplugins'])) foreach($_G['setting']['threadplugins'] as $tpid => $data) {
  581. $threadpluginselect[] = array($tpid, $data['name']);
  582. }
  583. if($threadpluginselect) {
  584. showsetting('usergroups_edit_special_allowthreadplugin', array('allowthreadpluginnew', $threadpluginselect), $allowthreadplugin[$_GET['id']], 'mcheckbox');
  585. }
  586. showtablefooter();
  587. showtagfooter('div');
  588. showtagheader('div', 'post', $anchor == 'post');
  589. showtableheader();
  590. showtitle('usergroups_edit_post');
  591. showsetting('usergroups_edit_post_new', 'allowpostnew', $group['allowpost'], 'radio');
  592. showsetting('usergroups_edit_post_reply', 'allowreplynew', $group['allowreply'], 'radio');
  593. showsetting('usergroups_edit_post_direct', array('allowdirectpostnew', array(
  594. array(0, $lang['usergroups_edit_post_direct_none']),
  595. array(1, $lang['usergroups_edit_post_direct_reply']),
  596. array(2, $lang['usergroups_edit_post_direct_thread']),
  597. array(3, $lang['usergroups_edit_post_direct_all'])
  598. )), $group['allowdirectpost'], 'mradio');
  599. showsetting('usergroups_edit_post_allow_down_remote_img', 'allowdownremoteimgnew', $group['allowdownremoteimg'], 'radio');
  600. showsetting('usergroups_edit_post_anonymous', 'allowanonymousnew', $group['allowanonymous'], 'radio');
  601. showsetting('usergroups_edit_post_set_read_perm', 'allowsetreadpermnew', $group['allowsetreadperm'], 'radio');
  602. showsetting('usergroups_edit_post_maxprice', 'maxpricenew', $group['maxprice'], 'text');
  603. showsetting('usergroups_edit_post_hide_code', 'allowhidecodenew', $group['allowhidecode'], 'radio');
  604. showsetting('usergroups_edit_post_mediacode', 'allowmediacodenew', $group['allowmediacode'], 'radio');
  605. showsetting('usergroups_edit_post_begincode', 'allowbegincodenew', $group['allowbegincode'], 'radio');
  606. showsetting('usergroups_edit_post_sig_bbcode', 'allowsigbbcodenew', $group['allowsigbbcode'], 'radio');
  607. showsetting('usergroups_edit_post_sig_img_code', 'allowsigimgcodenew', $group['allowsigimgcode'], 'radio');
  608. showsetting('usergroups_edit_post_max_sig_size', 'maxsigsizenew', $group['maxsigsize'], 'text');
  609. if($group['groupid'] != 7) {
  610. showsetting('usergroups_edit_post_recommend', 'allowrecommendnew', $group['allowrecommend'], 'text');
  611. }
  612. showsetting('usergroups_edit_post_edit_time_limit', 'edittimelimitnew', intval($group['edittimelimit']), 'text');
  613. showsetting('usergroups_edit_post_allowreplycredit', 'allowreplycreditnew', $group['allowreplycredit'], 'radio');
  614. showsetting('usergroups_edit_post_tag', 'allowposttagnew', $group['allowposttag'], 'radio');
  615. showsetting('usergroups_edit_post_allowcommentpost', array('allowcommentpostnew', array(
  616. $lang['usergroups_edit_post_allowcommentpost_firstpost'],
  617. $lang['usergroups_edit_post_allowcommentpost_reply'],
  618. )), $group['allowcommentpost'], 'binmcheckbox', !in_array(1, $_G['setting']['allowpostcomment']));
  619. showsetting('usergroups_edit_post_allowcommentreply', 'allowcommentreplynew', $group['allowcommentreply'], 'radio', !in_array(2, $_G['setting']['allowpostcomment']));
  620. showsetting('usergroups_edit_post_allowcommentitem', 'allowcommentitemnew', $group['allowcommentitem'], 'radio', !in_array(1, $_G['setting']['allowpostcomment']));
  621. showsetting('usergroups_edit_post_allowat', 'allowatnew', $group['allowat'], 'text');
  622. showsetting('usergroups_edit_post_allowsetpublishdate', 'allowsetpublishdatenew', $group['allowsetpublishdate'], 'radio');
  623. showsetting('usergroups_edit_post_allowcommentcollection', 'allowcommentcollectionnew', $group['allowcommentcollection'], 'radio');
  624. showsetting('usergroups_edit_post_allowimgcontent', 'allowimgcontentnew', $group['allowimgcontent'], 'radio');
  625. showtablefooter();
  626. showtagfooter('div');
  627. $group['maxattachsize'] = intval($group['maxattachsize'] / 1024);
  628. $group['maxsizeperday'] = intval($group['maxsizeperday'] / 1024);
  629. $group['maximagesize'] = intval($group['maximagesize'] / 1024);
  630. showtagheader('div', 'attach', $anchor == 'attach');
  631. showtableheader();
  632. showtitle('usergroups_edit_attach');
  633. showsetting('usergroups_edit_attach_get', 'allowgetattachnew', $group['allowgetattach'], 'radio');
  634. showsetting('usergroups_edit_attach_getimage', 'allowgetimagenew', $group['allowgetimage'], 'radio');
  635. showsetting('usergroups_edit_attach_post', 'allowpostattachnew', $group['allowpostattach'], 'radio');
  636. showsetting('usergroups_edit_attach_set_perm', 'allowsetattachpermnew', $group['allowsetattachperm'], 'radio');
  637. showsetting('usergroups_edit_image_post', 'allowpostimagenew', $group['allowpostimage'], 'radio');
  638. showsetting('usergroups_edit_attach_max_size', 'maxattachsizenew', $group['maxattachsize'], 'text');
  639. showsetting('usergroups_edit_attach_max_size_per_day', 'maxsizeperdaynew', $group['maxsizeperday'], 'text');
  640. showsetting('usergroups_edit_attach_max_number_per_day', 'maxattachnumnew', $group['maxattachnum'], 'text');
  641. showsetting('usergroups_edit_attach_ext', 'attachextensionsnew', $group['attachextensions'], 'text');
  642. showtablefooter();
  643. showtagfooter('div');
  644. showtagheader('div', 'magic', $anchor == 'magic');
  645. showtableheader();
  646. showtitle('usergroups_edit_magic');
  647. showsetting('usergroups_edit_magic_permission', array('allowmagicsnew', array(
  648. array(0, $lang['usergroups_edit_magic_unallowed']),
  649. array(1, $lang['usergroups_edit_magic_allow']),
  650. array(2, $lang['usergroups_edit_magic_allow_and_pass'])
  651. )), $group['allowmagics'], 'mradio');
  652. showsetting('usergroups_edit_magic_discount', 'magicsdiscountnew', $group['magicsdiscount'], 'text');
  653. showsetting('usergroups_edit_magic_max', 'maxmagicsweightnew', $group['maxmagicsweight'], 'text');
  654. showtablefooter();
  655. showtagfooter('div');
  656. showtagheader('div', 'invite', $anchor == 'invite');
  657. showtableheader();
  658. showtitle('usergroups_edit_invite');
  659. showsetting('usergroups_edit_invite_permission', 'allowinvitenew', $group['allowinvite'], 'radio');
  660. showsetting('usergroups_edit_invite_send_permission', 'allowmailinvitenew', $group['allowmailinvite'], 'radio');
  661. showsetting('usergroups_edit_invite_price', 'invitepricenew', $group['inviteprice'], 'text');
  662. showsetting('usergroups_edit_invite_buynum', 'maxinvitenumnew', $group['maxinvitenum'], 'text');
  663. showsetting('usergroups_edit_invite_maxinviteday', 'maxinvitedaynew', $group['maxinviteday'], 'text');
  664. showtablefooter();
  665. showtagfooter('div');
  666. $raterangearray = array();
  667. foreach(explode("\n", $group['raterange']) as $range) {
  668. $range = explode("\t", $range);
  669. $raterangearray[$range[0]] = array('isself' => $range[1], 'min' => $range[2], 'max' => $range[3], 'mrpd' => $range[4]);
  670. }
  671. if($multiset) {
  672. showtagheader('div', 'credit', $anchor == 'credit');
  673. showtableheader();
  674. showtitle('usergroups_edit_credit');
  675. showsetting('usergroups_edit_credit_exempt_sendpm', 'exemptnew[0]', $group['exempt'][0], 'radio');
  676. showsetting('usergroups_edit_credit_exempt_search', 'exemptnew[1]', $group['exempt'][1], 'radio');
  677. $exempttype = $group['radminid'] ? ($group['radminid'] == 3 ? 1 : 2) : 3;
  678. showsetting(($group['radminid'] ? $lang['usergroups_edit_credit_exempt_outperm'] : '').$lang['usergroups_edit_credit_exempt_getattch'], 'exemptnew[2]', $group['exempt'][2], 'radio', $exempttype == 2 ? 'readonly' : 0, '', '', '', 'm_getattch');
  679. showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_getattch'], 'exemptnew[5]', $group['exempt'][5], 'radio', $exempttype == 1 ? 0 : 'readonly');
  680. showsetting(($group['radminid'] ? $lang['usergroups_edit_credit_exempt_outperm'] : '').$lang['usergroups_edit_credit_exempt_attachpay'], 'exemptnew[3]', $group['exempt'][3], 'radio', $exempttype == 2 ? 'readonly' : 0, '', '', '', 'm_attachpay');
  681. showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_attachpay'], 'exemptnew[6]', $group['exempt'][6], 'radio', $exempttype == 1 ? 0 : 'readonly');
  682. showsetting(($group['radminid'] ? $lang['usergroups_edit_credit_exempt_outperm'] : '').$lang['usergroups_edit_credit_exempt_threadpay'], 'exemptnew[4]', $group['exempt'][4], 'radio', $exempttype == 2 ? 'readonly' : 0, '', '', '', 'm_threadpay');
  683. showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_threadpay'], 'exemptnew[7]', $group['exempt'][7], 'radio', $exempttype == 1 ? 0 : 'readonly');
  684. showtitle('usergroups_edit_credit_allowrate', '', 0);
  685. for($i = 1; $i <= 8; $i++) {
  686. if(isset($_G['setting']['extcredits'][$i])) {
  687. showsetting($_G['setting']['extcredits'][$i]['title'], 'raterangenew['.$i.'][allowrate]', $raterangearray[$i], 'radio');
  688. showsetting($_G['setting']['extcredits'][$i]['title'].' '.$lang['usergroups_edit_credit_rate_isself'], 'raterangenew['.$i.'][isself]', $raterangearray[$i]['isself'], 'radio');
  689. showsetting($_G['setting']['extcredits'][$i]['title'].' '.$lang['usergroups_edit_credit_rate_min'], 'raterangenew['.$i.'][min]', $raterangearray[$i]['min'], 'text');
  690. showsetting($_G['setting']['extcredits'][$i]['title'].' '.$lang['usergroups_edit_credit_rate_max'], 'raterangenew['.$i.'][max]', $raterangearray[$i]['max'], 'text');
  691. showsetting($_G['setting']['extcredits'][$i]['title'].' '.$lang['usergroups_edit_credit_rate_mrpd'], 'raterangenew['.$i.'][mrpd]', $raterangearray[$i]['mrpd'], 'text');
  692. }
  693. }
  694. showtablefooter();
  695. showtagfooter('div');
  696. } else {
  697. showtagheader('div', 'credit', $anchor == 'credit');
  698. showtableheader();
  699. showtitle('usergroups_edit_credit');
  700. showsetting('usergroups_edit_credit_exempt_sendpm', 'exemptnew[0]', $group['exempt'][0], 'radio');
  701. showsetting('usergroups_edit_credit_exempt_search', 'exemptnew[1]', $group['exempt'][1], 'radio');
  702. if($group['radminid']) {
  703. if($group['radminid'] == 3) {
  704. showsetting($lang['usergroups_edit_credit_exempt_outperm'].$lang['usergroups_edit_credit_exempt_getattch'], 'exemptnew[2]', $group['exempt'][2], 'radio');
  705. showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_getattch'], 'exemptnew[5]', $group['exempt'][5], 'radio');
  706. showsetting($lang['usergroups_edit_credit_exempt_outperm'].$lang['usergroups_edit_credit_exempt_attachpay'], 'exemptnew[3]', $group['exempt'][3], 'radio');
  707. showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_attachpay'], 'exemptnew[6]', $group['exempt'][6], 'radio');
  708. showsetting($lang['usergroups_edit_credit_exempt_outperm'].$lang['usergroups_edit_credit_exempt_threadpay'], 'exemptnew[4]', $group['exempt'][4], 'radio');
  709. showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_threadpay'], 'exemptnew[7]', $group['exempt'][7], 'radio');
  710. } else {
  711. echo '<input name="exemptnew[2]" type="hidden" value="1" /><input name="exemptnew[3]" type="hidden" value="1" /><input name="exemptnew[4]" type="hidden" value="1" />'.
  712. '<input name="exemptnew[5]" type="hidden" value="1" /><input name="exemptnew[6]" type="hidden" value="1" /><input name="exemptnew[7]" type="hidden" value="1" />';
  713. }
  714. } else {
  715. showsetting('usergroups_edit_credit_exempt_getattch', 'exemptnew[2]', $group['exempt'][2], 'radio');
  716. showsetting('usergroups_edit_credit_exempt_attachpay', 'exemptnew[3]', $group['exempt'][3], 'radio');
  717. showsetting('usergroups_edit_credit_exempt_threadpay', 'exemptnew[4]', $group['exempt'][4], 'radio');
  718. }
  719. echo '<tr><td colspan="2">'.$lang['usergroups_edit_credit_exempt_comment'].'</td></tr>';
  720. showtablefooter();
  721. showtableheader('usergroups_edit_credit_allowrate', '');
  722. $titlecolumn[0] = $lang['name'];
  723. for($i = 1; $i <= 8; $i++) {
  724. if(isset($_G['setting']['extcredits'][$i])) {
  725. $titlecolumn[$i] = $_G['setting']['extcredits'][$i]['title'];
  726. }
  727. }
  728. showsubtitle($titlecolumn);
  729. $leftcolumn = array('enable', 'usergroups_edit_credit_rate_isself', 'usergroups_edit_credit_rate_min', 'usergroups_edit_credit_rate_max', 'usergroups_edit_credit_rate_mrpd');
  730. foreach($leftcolumn as $value) {
  731. echo '<tr><td>'.$lang[$value].'</td>';
  732. foreach($titlecolumn as $subkey => $subvalue) {
  733. if(!$subkey) continue;
  734. if($value == 'enable') {
  735. echo '<td><input type="checkbox" class="checkbox" name="raterangenew['.$subkey.'][allowrate]" value="1" '.(empty($raterangearray[$subkey]) ? '' : 'checked').'></td>';
  736. } elseif($value == 'usergroups_edit_credit_rate_isself') {
  737. echo '<td><input type="checkbox" class="checkbox" name="raterangenew['.$subkey.'][isself]" value="1" '.(empty($raterangearray[$subkey]['isself']) ? '' : 'checked').'></td>';
  738. } elseif($value == 'usergroups_edit_credit_rate_min') {
  739. echo '<td class="td28"><input type="text" class="txt" name="raterangenew['.$subkey.'][min]" size="3" value="'.$raterangearray[$subkey]['min'].'"></td>';
  740. } elseif($value == 'usergroups_edit_credit_rate_max') {
  741. echo '<td class="td28"><input type="text" class="txt" name="raterangenew['.$subkey.'][max]" size="3" value="'.$raterangearray[$subkey]['max'].'"></td>';
  742. } elseif($value == 'usergroups_edit_credit_rate_mrpd') {
  743. echo '<td class="td28"><input type="text" class="txt" name="raterangenew['.$subkey.'][mrpd]" size="3" value="'.$raterangearray[$subkey]['mrpd'].'"></td>';
  744. }
  745. }
  746. echo '</tr>';
  747. }
  748. echo '<tr><td class="lineheight" colspan="9">'.$lang['usergroups_edit_credit_rate_tips'].'</td></tr>';
  749. showtablefooter();
  750. showtagfooter('div');
  751. }
  752. showtagheader('div', 'home', $anchor == 'home');
  753. showtableheader();
  754. showtitle('usergroups_edit_home');
  755. showsetting('usergroups_edit_attach_max_space_size', 'maxspacesizenew', $group['maxspacesize'], 'text');
  756. showsetting('usergroups_edit_home_allow_blog', 'allowblognew', $group['allowblog'], 'radio', '', 1);
  757. showsetting('usergroups_edit_home_allow_blog_mod', 'allowblogmodnew', $group['allowblogmod'], 'radio');
  758. showtagfooter('tbody');
  759. showsetting('usergroups_edit_home_allow_doing', 'allowdoingnew', $group['allowdoing'], 'radio', '', 1);
  760. showsetting('usergroups_edit_home_allow_doing_mod', 'allowdoingmodnew', $group['allowdoingmod'], 'radio');
  761. showtagfooter('tbody');
  762. showsetting('usergroups_edit_home_allow_upload', 'allowuploadnew', $group['allowupload'], 'radio', '', 1);
  763. showsetting('usergroups_edit_home_allow_upload_mod', 'allowuploadmodnew', $group['allowuploadmod'], 'radio');
  764. showsetting('usergroups_edit_home_image_max_size', 'maximagesizenew', $group['maximagesize'], 'text');
  765. showtagfooter('tbody');
  766. showsetting('usergroups_edit_home_allow_share', 'allowsharenew', $group['allowshare'], 'radio', '', 1);
  767. showsetting('usergroups_edit_home_allow_share_mod', 'allowsharemodnew', $group['allowsharemod'], 'radio');
  768. showtagfooter('tbody');
  769. showsetting('usergroups_edit_home_allow_poke', 'allowpokenew', $group['allowpoke'], 'radio');
  770. showsetting('usergroups_edit_home_allow_friend', 'allowfriendnew', $group['allowfriend'], 'radio');
  771. showsetting('usergroups_edit_home_allow_click', 'allowclicknew', $group['allowclick'], 'radio');
  772. showsetting('usergroups_edit_home_allow_comment', 'allowcommentnew', $group['allowcomment'], 'radio');
  773. showsetting('usergroups_edit_home_allow_myop', 'allowmyopnew', $group['allowmyop'], 'radio');
  774. showsetting('usergroups_edit_home_allow_video_photo_ignore', 'videophotoignorenew', $group['videophotoignore'], 'radio');
  775. showsetting('usergroups_edit_home_allow_view_video_photo', 'allowviewvideophotonew', $group['allowviewvideophoto'], 'radio');
  776. showsetting('usergroups_edit_home_allow_space_diy_html', 'allowspacediyhtmlnew', $group['allowspacediyhtml'], 'radio');
  777. showsetting('usergroups_edit_home_allow_space_diy_bbcode', 'allowspacediybbcodenew', $group['allowspacediybbcode'], 'radio');
  778. showsetting('usergroups_edit_home_allow_space_diy_imgcode', 'allowspacediyimgcodenew', $group['allowspacediyimgcode'], 'radio');
  779. showtablefooter();
  780. showtagfooter('div');
  781. showtagheader('div', 'group', $anchor == 'group');
  782. showtableheader();
  783. showtitle('usergroups_edit_group');
  784. showsetting('usergroups_edit_group_build', 'allowbuildgroupnew', $group['allowbuildgroup'], 'text');
  785. showsetting('usergroups_edit_group_buildcredits', 'buildgroupcreditsnew', $group['buildgroupcredits'], 'text');
  786. showsetting('usergroups_edit_post_direct_group', array('allowgroupdirectpostnew', array(
  787. array(0, $lang['usergroups_edit_post_direct_none']),
  788. array(1, $lang['usergroups_edit_post_direct_reply']),
  789. array(2, $lang['usergroups_edit_post_direct_thread']),
  790. array(3, $lang['usergroups_edit_post_direct_all'])
  791. )), $group['allowgroupdirectpost'], 'mradio');
  792. showsetting('usergroups_edit_post_url_group', array('allowgroupposturlnew', array(
  793. array(0, $lang['usergroups_edit_post_url_banned']),
  794. array(1, $lang['usergroups_edit_post_url_mod']),
  795. array(2, $lang['usergroups_edit_post_url_unhandle']),
  796. array(3, $lang['usergroups_edit_post_url_enable'])
  797. )), $group['allowgroupposturl'], 'mradio');
  798. showtablefooter();
  799. showtagfooter('div');
  800. showtagheader('div', 'portal', $anchor == 'portal');
  801. showtableheader();
  802. showtitle('usergroups_edit_portal');
  803. showsetting('usergroups_edit_portal_allow_comment_article', 'allowcommentarticlenew', $group['allowcommentarticle'], 'text');
  804. showsetting('usergroups_edit_portal_allow_post_article', 'allowpostarticlenew', $group['allowpostarticle'], 'radio', '', 1);
  805. showsetting('usergroups_edit_portal_allow_down_local_img', 'allowdownlocalimgnew', $group['allowdownlocalimg'], 'radio');
  806. showsetting('usergroups_edit_portal_allow_post_article_moderate', 'allowpostarticlemodnew', $group['allowpostarticlemod'], 'radio');
  807. showtablefooter();
  808. showtagfooter('div');
  809. if($pluginsetting) {
  810. showtagheader('div', 'plugin', $anchor == 'plugin');
  811. showtableheader();
  812. foreach($pluginsetting as $setting) {
  813. showtitle($setting['name']);
  814. foreach($setting['setting'] as $varid => $var) {
  815. if($var['type'] != 'select') {
  816. showsetting($var['title'], 'pluginnew['.$varid.']', $group['plugin'][$varid], $var['type'], '', 0, $var['description']);
  817. } else {
  818. showsetting($var['title'], array('pluginnew['.$varid.']', $var['select']), $group['plugin'][$varid], $var['type'], '', 0, $var['description']);
  819. }
  820. }
  821. }
  822. showtablefooter();
  823. showtagfooter('div');
  824. }
  825. showtableheader();
  826. showsubmit('detailsubmit', 'submit');
  827. showtablefooter();
  828. $_G['showsetting_multi']++;
  829. }
  830. if($_G['showsetting_multicount'] > 1) {
  831. showhiddenfields(array('multi' => implode(',', $mgids)));
  832. showmulti();
  833. }
  834. showformfooter();
  835. } else {
  836. if(!$multiset) {
  837. $_GET['multinew'] = array(0 => array('single' => 1));
  838. }
  839. $pluginvars = array();
  840. foreach($_GET['multinew'] as $k => $row) {
  841. if(empty($row['single'])) {
  842. foreach($row as $key => $value) {
  843. $_GET[''.$key] = $value;
  844. }
  845. $_GET['id'] = $_GET['multi'][$k];
  846. }
  847. $group = $mgroup[$k];
  848. $systemnew = 'private';
  849. if($group['type'] == 'special' && $group['radminid'] > 0) {
  850. $radminidnew = $group['radminid'];
  851. } elseif($group['type'] == 'special') {
  852. $radminidnew = '0';
  853. if(!$multiset && $_GET['system_publicnew']) {
  854. if($_GET['system_dailypricenew'] > 0) {
  855. if(!$_G['setting']['creditstrans']) {
  856. cpmsg('usergroups_edit_creditstrans_disabled', '', 'error');
  857. } else {
  858. $system_minspannew = $_GET['system_minspannew'] <= 0 ? 1 : $_GET['system_minspannew'];
  859. $systemnew = intval($_GET['system_dailypricenew'])."\t".intval($system_minspannew);
  860. }
  861. } else {
  862. $systemnew = "0\t0";
  863. }
  864. }
  865. } else {
  866. $radminidnew = in_array($group['groupid'], array(1, 2, 3)) ? $group['groupid'] : 0;
  867. }
  868. if(is_array($_GET['raterangenew'])) {
  869. foreach($_GET['raterangenew'] as $key => $rate) {
  870. if($key >= 1 && $key <= 8 && $rate['allowrate']) {
  871. if(!$rate['mrpd'] || $rate['max'] <= $rate['min'] || $rate['mrpd'] < max(abs($rate['min']), abs($rate['max']))) {
  872. cpmsg('usergroups_edit_rate_invalid', '', 'error');
  873. } else {
  874. $_GET['raterangenew'][$key] = implode("\t", array($key, ($rate['isself'] ? $rate['isself'] : 0), $rate['min'], $rate['max'], $rate['mrpd']));
  875. }
  876. } else {
  877. unset($_GET['raterangenew'][$key]);
  878. }
  879. }
  880. }
  881. if(in_array($group['groupid'], array(1))) {
  882. $_GET['allowvisitnew'] = 2;
  883. }
  884. $raterangenew = $_GET['raterangenew'] ? implode("\n", $_GET['raterangenew']) : '';
  885. $maxpricenew = $_GET['maxpricenew'] < 0 ? 0 : intval($_GET['maxpricenew']);
  886. $maxpostsperhournew = $_GET['maxpostsperhournew'] > 255 ? 255 : intval($_GET['maxpostsperhournew']);
  887. $maxthreadsperhournew = $_GET['maxthreadsperhournew'] > 255 ? 255 : intval($_GET['maxthreadsperhournew']);
  888. $extensionarray = array();
  889. foreach(explode(',', $_GET['attachextensionsnew']) as $extension) {
  890. if($extension = trim($extension)) {
  891. $extensionarray[] = $extension;
  892. }
  893. }
  894. $attachextensionsnew = implode(', ', $extensionarray);
  895. if($_GET['maxtradepricenew'] == $_GET['mintradepricenew'] || $_GET['maxtradepricenew'] < 0 || $_GET['mintradepricenew'] <= 0 || ($_GET['maxtradepricenew'] && $_GET['maxtradepricenew'] < $_GET['mintradepricenew'])) {
  896. cpmsg('trade_fee_error', '', 'error');
  897. } elseif(($_GET['maxrewardpricenew'] != 0 && $_GET['minrewardpricenew'] >= $_GET['maxrewardpricenew']) || $_GET['minrewardpricenew'] < 1 || $_GET['minrewardpricenew'] < 0 || $_GET['maxrewardpricenew'] < 0) {
  898. cpmsg('reward_credits_error', '', 'error');
  899. }
  900. $exemptnewbin = '';
  901. for($i = 0;$i < 8;$i++) {
  902. $exemptnewbin = intval($_GET['exemptnew'][$i]).$exemptnewbin;
  903. }
  904. $exemptnew = bindec($exemptnewbin);
  905. $tradesticknew = $_GET['tradesticknew'] > 0 ? intval($_GET['tradesticknew']) : 0;
  906. $maxinvitedaynew = $_GET['maxinvitedaynew'] > 0 ? intval($_GET['maxinvitedaynew']) : 10;
  907. $maxattachsizenew = $_GET['maxattachsizenew'] > 0 ? intval($_GET['maxattachsizenew'] * 1024) : 0;
  908. $maximagesizenew = $_GET['maximagesizenew'] > 0 ? intval($_GET['maximagesizenew'] * 1024) : 0;
  909. $maxsizeperdaynew = $_GET['maxsizeperdaynew'] > 0 ? intval($_GET['maxsizeperdaynew'] * 1024) : 0;
  910. $maxattachnumnew = $_GET['maxattachnumnew'] > 0 ? intval($_GET['maxattachnumnew']) : 0;
  911. $allowrecommendnew = $_GET['allowrecommendnew'] > 0 ? intval($_GET['allowrecommendnew']) : 0;
  912. $dataarr = array(
  913. 'grouptitle' => $_GET['grouptitlenew'],
  914. 'radminid' => $radminidnew,
  915. 'allowvisit' => $_GET['allowvisitnew'],
  916. 'allowsendpm' => $_GET['allowsendpmnew'],
  917. 'maxinvitenum' => $_GET['maxinvitenumnew'],
  918. 'maxinviteday' => $maxinvitedaynew,
  919. 'allowinvite' => $_GET['allowinvitenew'],
  920. 'allowmailinvite' => $_GET['allowmailinvitenew'],
  921. 'inviteprice' => $_GET['invitepricenew']
  922. );
  923. if(!$multiset) {
  924. $dataarr['system'] = $systemnew;
  925. if($_FILES['iconnew']) {
  926. $data = array('extid' => "$_GET[id]");
  927. $iconnew = upload_icon_banner($data, $_FILES['iconnew'], 'usergroup_icon');
  928. } else {
  929. $iconnew = $_GET['iconnew'];
  930. }
  931. if($iconnew) {
  932. $dataarr['icon'] = $iconnew;
  933. }
  934. if($_GET['deleteicon']) {
  935. $valueparse = parse_url($group['icon']);
  936. if(!isset($valueparse['host'])) {
  937. $group['icon'] = str_replace(array('..', '//'), array('','/'), $group['icon']);
  938. @unlink($_G['setting']['attachurl'].'common/'.$group['icon']);
  939. }
  940. $dataarr['icon'] = '';
  941. }
  942. }
  943. C::t('common_usergroup')->update($_GET['id'], $dataarr);
  944. if($pluginsetting) {
  945. foreach($_GET['pluginnew'] as $pluginvarid => $value) {
  946. $pluginvars[$pluginvarid][$_GET['id']] = $value;
  947. }
  948. }
  949. C::t('forum_onlinelist')->update_by_groupid($_GET['id'], array('title' => $_GET['grouptitlenew']));
  950. $dataarr = array(
  951. 'readaccess' => $_GET['readaccessnew'],
  952. 'allowpost' => $_GET['allowpostnew'],
  953. 'allowreply' => $_GET['allowreplynew'],
  954. 'allowpostpoll' => $_GET['allowpostpollnew'],
  955. 'allowpostreward' => $_GET['allowpostrewardnew'],
  956. 'allowposttrade' => $_GET['allowposttradenew'],
  957. 'allowpostactivity' => $_GET['allowpostactivitynew'],
  958. 'allowdirectpost' => $_GET['allowdirectpostnew'],
  959. 'allowgetattach' => $_GET['allowgetattachnew'],
  960. 'allowgetimage' => $_GET['allowgetimagenew'],
  961. 'allowpostattach' => $_GET['allowpostattachnew'],
  962. 'allowvote' => $_GET['allowvotenew'],
  963. 'allowsearch' => bindec(intval($_GET['allowsearchnew'][7]).intval($_GET['allowfulltextnew']).intval($_GET['allowsearchnew'][5]).intval($_GET['allowsearchnew'][4]).intval($_GET['allowsearchnew'][3]).intval($_GET['allowsearchnew'][2]).intval($_GET['allowsearchnew'][1])),
  964. 'allowcstatus' => $_GET['allowcstatusnew'],
  965. 'allowinvisible' => $_GET['allowinvisiblenew'],
  966. 'allowtransfer' => $_GET['allowtransfernew'],
  967. 'allowsetreadperm' => $_GET['allowsetreadpermnew'],
  968. 'allowsetattachperm' => $_GET['allowsetattachpermnew'],
  969. 'allowpostimage' => $_GET['allowpostimagenew'],
  970. 'allowposttag' => $_GET['allowposttagnew'],
  971. 'allowhidecode' => $_GET['allowhidecodenew'],
  972. 'allowmediacode' => $_GET['allowmediacodenew'],
  973. 'allowbegincode' => $_GET['allowbegincodenew'],
  974. 'allowhtml' => $_GET['allowhtmlnew'],
  975. 'allowanonymous' => $_GET['allowanonymousnew'],
  976. 'allowsigbbcode' => $_GET['allowsigbbcodenew'],
  977. 'allowsigimgcode' => $_GET['allowsigimgcodenew'],
  978. 'allowmagics' => $_GET['allowmagicsnew'],
  979. 'disableperiodctrl' => $_GET['disableperiodctrlnew'],
  980. 'reasonpm' => $_GET['reasonpmnew'],
  981. 'maxprice' => $maxpricenew,
  982. 'maxsigsize' => $_GET['maxsigsizenew'],
  983. 'maxspacesize' => $_GET['maxspacesizenew'],
  984. 'maxattachsize' => $maxattachsizenew,
  985. 'maximagesize' => $maximagesizenew,
  986. 'maxsizeperday' => $maxsizeperdaynew,
  987. 'maxpostsperhour' => $maxpostsperhournew,
  988. 'maxthreadsperhour' => $maxthreadsperhournew,
  989. 'attachextensions' => $attachextensionsnew,
  990. 'mintradeprice' => $_GET['mintradepricenew'],
  991. 'maxtradeprice' => $_GET['maxtradepricenew'],
  992. 'minrewardprice' => $_GET['minrewardpricenew'],
  993. 'maxrewardprice' => $_GET['maxrewardpricenew'],
  994. 'magicsdiscount' => $_GET['magicsdiscountnew'] >= 0 && $_GET['magicsdiscountnew'] < 10 ? $_GET['magicsdiscountnew'] : 0,
  995. 'maxmagicsweight' => $_GET['maxmagicsweightnew'] >= 0 && $_GET['maxmagicsweightnew'] <= 60000 ? $_GET['maxmagicsweightnew'] : 1,
  996. 'allowpostdebate' => $_GET['allowpostdebatenew'],
  997. 'tradestick' => $tradesticknew,
  998. 'maxattachnum' => $maxattachnumnew,
  999. 'allowposturl' => $_GET['allowposturlnew'],
  1000. 'allowrecommend' => $allowrecommendnew,
  1001. 'allowpostrushreply' => $_GET['allowpostrushreplynew'],
  1002. 'maxfriendnum' => $_GET['maxfriendnumnew'],
  1003. 'seccode' => $_GET['seccodenew'],
  1004. 'forcesecques' => $_GET['forcesecquesnew'],
  1005. 'forcelogin' => $_GET['forceloginnew'],
  1006. 'domainlength' => $_GET['domainlengthnew'],
  1007. 'disablepostctrl' => $_GET['disablepostctrlnew'],
  1008. 'allowblog' => $_GET['allowblognew'],
  1009. 'allowdoing' => $_GET['allowdoingnew'],
  1010. 'allowupload' => $_GET['allowuploadnew'],
  1011. 'allowshare' => $_GET['allowsharenew'],
  1012. 'allowblogmod' => $_GET['allowblogmodnew'],
  1013. 'allowdoingmod' => $_GET['allowdoingmodnew'],
  1014. 'allowuploadmod' => $_GET['allowuploadmodnew'],
  1015. 'allowsharemod' => $_GET['allowsharemodnew'],
  1016. 'allowpoke' => $_GET['allowpokenew'],
  1017. 'allowfriend' => $_GET['allowfriendnew'],
  1018. 'allowclick' => $_GET['allowclicknew'],
  1019. 'allowcomment' => $_GET['allowcommentnew'],
  1020. 'allowcommentarticle' => intval($_GET['allowcommentarticlenew']),
  1021. 'allowmyop' => $_GET['allowmyopnew'],
  1022. 'allowcommentpost' => bindec(intval($_GET['allowcommentpostnew'][2]).intval($_GET['allowcommentpostnew'][1])),
  1023. 'videophotoignore' => $_GET['videophotoignorenew'],
  1024. 'allowviewvideophoto' => $_GET['allowviewvideophotonew'],
  1025. 'allowspacediyhtml' => $_GET['allowspacediyhtmlnew'],
  1026. 'allowspacediybbcode' => $_GET['allowspacediybbcodenew'],
  1027. 'allowspacediyimgcode' => $_GET['allowspacediyimgcodenew'],
  1028. 'allowstatdata' => $_GET['allowstatdatanew'],
  1029. 'allowpostarticle' => $_GET['allowpostarticlenew'],
  1030. 'allowpostarticlemod' => $_GET['allowpostarticlemodnew'],
  1031. 'allowbuildgroup' => $_GET['allowbuildgroupnew'],
  1032. 'buildgroupcredits' => $_GET['buildgroupcreditsnew'],
  1033. 'allowgroupdirectpost' => intval($_GET['allowgroupdirectpostnew']),
  1034. 'allowgroupposturl' => intval($_GET['allowgroupposturlnew']),
  1035. 'edittimelimit' => intval($_GET['edittimelimitnew']),
  1036. 'allowcommentreply' => intval($_GET['allowcommentreplynew']),
  1037. 'allowdownlocalimg' => intval($_GET['allowdownlocalimgnew']),
  1038. 'allowdownremoteimg' => intval($_GET['allowdownremoteimgnew']),
  1039. 'allowcommentitem' => intval($_GET['allowcommentitemnew']),
  1040. 'allowat' => intval($_GET['allowatnew']),
  1041. 'allowreplycredit' => intval($_GET['allowreplycreditnew']),
  1042. 'allowsetpublishdate' => intval($_GET['allowsetpublishdatenew']),
  1043. 'allowcommentcollection' => intval($_GET['allowcommentcollectionnew']),
  1044. 'allowimgcontent' => intval($_GET['allowimgcontentnew']),
  1045. 'allowcreatecollection' => intval($_GET['allowcreatecollectionnew']),
  1046. 'allowfollowcollection' => intval($_GET['allowfollowcollectionnew']),
  1047. 'exempt' => $exemptnew,
  1048. 'raterange' => $raterangenew,
  1049. 'ignorecensor' => intval($_GET['ignorecensornew']),
  1050. 'allowsendallpm' => intval($_GET['allowsendallpmnew']),
  1051. 'allowsendpmmaxnum' => intval($_GET['allowsendpmmaxnumnew']),
  1052. 'closead' => intval($_GET['closeadnew']),
  1053. );
  1054. C::t('common_usergroup_field')->update($_GET['id'], $dataarr);
  1055. if($_G['setting']['threadplugins']) {
  1056. $allowthreadplugin = C::t('common_setting')->fetch('allowthreadplugin', true);
  1057. $allowthreadplugin[$_GET['id']] = $_GET['allowthreadpluginnew'];
  1058. C::t('common_setting')->update('allowthreadplugin', $allowthreadplugin);
  1059. }
  1060. if(empty($row['single'])) {
  1061. foreach($row as $key => $value) {
  1062. unset($_GET[''.$key]);
  1063. }
  1064. }
  1065. }
  1066. if($pluginvars) {
  1067. set_pluginsetting($pluginvars);
  1068. }
  1069. updatecache(array('setting', 'usergroups', 'onlinelist', 'groupreadaccess'));
  1070. cpmsg('usergroups_edit_succeed', 'action=usergroups&operation=edit&'.($multiset ? 'multi='.implode(',', $_GET['multi']) : 'id='.$_GET['id']).'&anchor='.$_GET['anchor'], 'succeed');
  1071. }
  1072. } elseif($operation == 'copy') {
  1073. loadcache('usergroups');
  1074. $source = intval($_GET['source']);
  1075. $sourceusergroup = $_G['cache']['usergroups'][$source];
  1076. if(empty($sourceusergroup)) {
  1077. cpmsg('usergroups_copy_source_invalid', '', 'error');
  1078. }
  1079. $delfields = array(
  1080. 'usergroups' => array('groupid', 'radminid', 'type', 'system', 'grouptitle', 'creditshigher', 'creditslower', 'stars', 'color', 'icon', 'groupavatar'),
  1081. );
  1082. $fields = array(
  1083. 'usergroups' => C::t('common_usergroup')->fetch_table_struct(),
  1084. 'usergroupfields' => C::t('common_usergroup_field')->fetch_table_struct(),
  1085. );
  1086. if(!submitcheck('copysubmit')) {
  1087. $groupselect = array();
  1088. foreach(C::t('common_usergroup')->fetch_all_not(array(6, 7), true) as $group) {
  1089. $group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
  1090. $groupselect[$group['type']] .= "<option value=\"$group[groupid]\">$group[grouptitle]</option>\n";
  1091. }
  1092. $groupselect = '<optgroup label="'.$lang['usergroups_member'].'">'.$groupselect['member'].'</optgroup>'.
  1093. ($groupselect['special'] ? '<optgroup label="'.$lang['usergroups_special'].'">'.$groupselect['special'].'</optgroup>' : '').
  1094. ($groupselect['specialadmin'] ? '<optgroup label="'.$lang['usergroups_specialadmin'].'">'.$groupselect['specialadmin'].'</optgroup>' : '').
  1095. '<optgroup label="'.$lang['usergroups_system'].'">'.$groupselect['system'].'</optgroup>';
  1096. $usergroupselect = '<select name="target[]" size="10" multiple="multiple">'.$groupselect.'</select>';
  1097. $optselect = '<select name="options[]" size="10" multiple="multiple">';
  1098. $fieldarray = array_merge($fields['usergroups'], $fields['usergroupfields']);
  1099. $listfields = array_diff($fieldarray, $delfields['usergroups']);
  1100. foreach($listfields as $field) {
  1101. if(isset($lang['project_option_group_'.$field])) {
  1102. $optselect .= '<option value="'.$field.'">'.$lang['project_option_group_'.$field].'</option>';
  1103. }
  1104. }
  1105. $optselect .= '</select>';
  1106. shownav('user', 'usergroups_copy');
  1107. showsubmenu('usergroups_copy');
  1108. showtips('usergroups_copy_tips');
  1109. showformheader('usergroups&operation=copy');
  1110. showhiddenfields(array('source' => $source));
  1111. showtableheader();
  1112. showtitle('usergroups_copy');
  1113. showsetting(cplang('usergroups_copy_source').':','','', $sourceusergroup['grouptitle']);
  1114. showsetting('usergroups_copy_target', '', '', $usergroupselect);
  1115. showsetting('usergroups_copy_options', '', '', $optselect);
  1116. showsubmit('copysubmit');
  1117. showtablefooter();
  1118. showformfooter();
  1119. } else {
  1120. $gids = $comma = '';
  1121. if(is_array($_GET['target']) && count($_GET['target'])) {
  1122. foreach($_GET['target'] as $key => $gid) {
  1123. $_GET['target'][$key] = intval($gid);
  1124. if(empty($_GET['target'][$key]) || $_GET['target'][$key] == $source) {
  1125. unset($_GET['target'][$key]);
  1126. }
  1127. }
  1128. }
  1129. if(empty($_GET['target'])) {
  1130. cpmsg('usergroups_copy_target_invalid', '', 'error');
  1131. }
  1132. $groupoptions = array();
  1133. if(is_array($_GET['options']) && !empty($_GET['options'])) {
  1134. foreach($_GET['options'] as $option) {
  1135. if($option = trim($option)) {
  1136. if(in_array($option, $fields['usergroups'])) {
  1137. $groupoptions['common_usergroup'][] = $option;
  1138. } elseif(in_array($option, $fields['usergroupfields'])) {
  1139. $groupoptions['common_usergroup_field'][] = $option;
  1140. }
  1141. }
  1142. }
  1143. }
  1144. if(empty($groupoptions)) {
  1145. cpmsg('usergroups_copy_options_invalid', '', 'error');
  1146. }
  1147. foreach(array('common_usergroup', 'common_usergroup_field') as $table) {
  1148. if(is_array($groupoptions[$table]) && !empty($groupoptions[$table])) {
  1149. $sourceusergroup = C::t($table)->fetch($source);
  1150. if(!$sourceusergroup) {
  1151. cpmsg('usergroups_copy_source_invalid', '', 'error');
  1152. }
  1153. foreach($sourceusergroup as $key=>$value) {
  1154. if(!in_array($key, $groupoptions[$table])) {
  1155. unset($sourceusergroup[$key]);
  1156. }
  1157. }
  1158. C::t($table)->update($_GET['target'], $sourceusergroup);
  1159. }
  1160. }
  1161. updatecache('usergroups');
  1162. cpmsg('usergroups_copy_succeed', 'action=usergroups', 'succeed');
  1163. }
  1164. } elseif($operation == 'merge') {
  1165. loadcache('usergroups');
  1166. $source = intval($_GET['source']);
  1167. $sourceusergroup = $_G['cache']['usergroups'][$source];
  1168. if(empty($sourceusergroup) || $sourceusergroup['type'] == 'system' || ($sourceusergroup['type'] == 'special' && $sourceusergroup['radminid'])) {
  1169. cpmsg('usergroups_copy_source_invalid', '', 'error');
  1170. }
  1171. if(!submitcheck('copysubmit')) {
  1172. $groupselect = array();
  1173. foreach(C::t('common_usergroup')->fetch_all_not(array(6, 7), true) as $group) {
  1174. $group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
  1175. $groupselect[$group['type']] .= "<option value=\"$group[groupid]\">$group[grouptitle]</option>\n";
  1176. }
  1177. $groupselect = '<optgroup label="'.$lang['usergroups_member'].'">'.$groupselect['member'].'</optgroup>'.
  1178. ($groupselect['special'] ? '<optgroup label="'.$lang['usergroups_special'].'">'.$groupselect['special'].'</optgroup>' : '');
  1179. $usergroupselect = '<select name="target" size="10">'.$groupselect.'</select>';
  1180. shownav('user', 'usergroups_merge');
  1181. showsubmenu('usergroups_merge');
  1182. showtips('usergroups_merge_tips');
  1183. showformheader('usergroups&operation=merge');
  1184. showhiddenfields(array('source' => $source));
  1185. showtableheader();
  1186. showtitle('usergroups_copy');
  1187. showsetting(cplang('usergroups_copy_source').':','','', $sourceusergroup['grouptitle']);
  1188. showsetting('usergroups_merge_target', '', '', $usergroupselect);
  1189. showsetting('usergroups_merge_delete_source', 'delete_source', 0, 'radio');
  1190. showsubmit('copysubmit');
  1191. showtablefooter();
  1192. showformfooter();
  1193. } else {
  1194. $target = intval($_GET['target']);
  1195. $targetusergroup = $_G['cache']['usergroups'][$target];
  1196. if(empty($targetusergroup) || $targetusergroup['type'] == 'system' || ($targetusergroup['type'] == 'special' && $targetusergroup['radminid'])) {
  1197. cpmsg('usergroups_copy_target_invalid', '', 'error');
  1198. }
  1199. C::t('common_member')->update_groupid_by_groupid($source, $target);
  1200. if(helper_dbtool::isexisttable('common_member_archive')) {
  1201. C::t('common_member_archive')->update_groupid_by_groupid($source, $target);
  1202. }
  1203. if($_GET['delete_source']) {
  1204. C::t('common_usergroup')->delete($source, $sourceusergroup['type']);
  1205. C::t('common_usergroup_field')->delete($source);
  1206. C::t('forum_onlinelist')->delete_by_groupid($source);
  1207. }
  1208. updatecache('usergroups');
  1209. cpmsg('usergroups_merge_succeed', 'action=usergroups', 'succeed');
  1210. }
  1211. }
  1212. function array_flip_keys($arr) {
  1213. $arr2 = array();
  1214. $arrkeys = @array_keys($arr);
  1215. list(, $first) = @each(array_slice($arr, 0, 1));
  1216. if($first) {
  1217. foreach($first as $k=>$v) {
  1218. foreach($arrkeys as $key) {
  1219. $arr2[$k][$key] = $arr[$key][$k];
  1220. }
  1221. }
  1222. }
  1223. return $arr2;
  1224. }
  1225. function deletegroupcache($groupidarray) {
  1226. if(!empty($groupidarray) && is_array($groupidarray)) {
  1227. $cachenames = array();
  1228. foreach ($groupidarray as $id) {
  1229. if(($id = dintval($id))) {
  1230. $cachenames['usergroup_'.$id] = 'usergroup_'.$id;
  1231. $cachenames['admingroup_'.$id] = 'admingroup_'.$id;
  1232. }
  1233. }
  1234. if(!empty($cachenames)) {
  1235. C::t('common_syscache')->delete($cachenames);
  1236. }
  1237. }
  1238. }
  1239. ?>