ManagePermissions.template.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2014 Simple Machines and individual contributors
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. function template_permission_index()
  13. {
  14. global $context, $settings, $scripturl, $txt, $modSettings;
  15. // Not allowed to edit?
  16. if (!$context['can_modify'])
  17. echo '
  18. <div class="errorbox">
  19. ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
  20. </div>';
  21. echo '
  22. <div id="admin_form_wrapper">
  23. <form action="', $scripturl, '?action=admin;area=permissions;sa=quick" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" id="permissionForm">';
  24. if (!empty($context['profile']))
  25. echo '
  26. <div class="cat_bar">
  27. <h3 class="catbg">', $txt['permissions_for_profile'], ': &quot;', $context['profile']['name'], '&quot;</h3>
  28. </div>';
  29. else
  30. echo '
  31. <div class="cat_bar">
  32. <h3 class="catbg">', $txt['permissions_title'], '</h3>
  33. </div>';
  34. echo '
  35. <table class="table_grid">
  36. <thead>
  37. <tr class="catbg">
  38. <th class="first_th">', $txt['membergroups_name'], '</th>
  39. <th width="10%" style="text-align:center" valign="middle">', $txt['membergroups_members_top'], '</th>';
  40. if (empty($modSettings['permission_enable_deny']))
  41. echo '
  42. <th width="16%" style="text-align:center">', $txt['membergroups_permissions'], '</th>';
  43. else
  44. echo '
  45. <th width="8%" style="text-align:center">', $txt['permissions_allowed'], '</th>
  46. <th width="8%" style="text-align:center">', $txt['permissions_denied'], '</th>';
  47. echo '
  48. <th width="10%" style="text-align:center" valign="middle">', $context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view'], '</th>
  49. <th class="last_th" width="4%" style="text-align: center" valign="middle">
  50. ', $context['can_modify'] ? '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \'group\');">' : '', '
  51. </th>
  52. </tr>
  53. </thead>
  54. <tbody>';
  55. $alternate = false;
  56. foreach ($context['groups'] as $group)
  57. {
  58. $alternate = !$alternate;
  59. echo '
  60. <tr class="windowbg', $alternate ? '2' : '', '">
  61. <td>
  62. ', !empty($group['help']) ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=' . $group['help'] . '" onclick="return reqOverlayDiv(this.href);"><img class="icon" src="' . $settings['images_url'] . '/helptopics.png" alt="' . $txt['help'] . '"></a>' : '<img class="icon" src="' . $settings['images_url'] . '/blank.png" alt="' . $txt['help'] . '">', '&nbsp;<span>', $group['name'], '</span>';
  63. if (!empty($group['children']))
  64. echo '
  65. <br>
  66. <span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
  67. echo '
  68. </td>
  69. <td align="center">', $group['can_search'] ? $group['link'] : $group['num_members'], '</td>';
  70. if (empty($modSettings['permission_enable_deny']))
  71. echo '
  72. <td width="16%" align="center">', $group['num_permissions']['allowed'], '</td>';
  73. else
  74. echo '
  75. <td width="8%" align="center"', $group['id'] == 1 ? ' style="font-style: italic;"' : '', '>', $group['num_permissions']['allowed'], '</td>
  76. <td width="8%" align="center"', $group['id'] == 1 || $group['id'] == -1 ? ' style="font-style: italic;"' : (!empty($group['num_permissions']['denied']) ? ' style="color: red;"' : ''), '>', $group['num_permissions']['denied'], '</td>';
  77. echo '
  78. <td align="center">', $group['allow_modify'] ? '<a href="' . $scripturl . '?action=admin;area=permissions;sa=modify;group=' . $group['id'] . (empty($context['profile']) ? '' : ';pid=' . $context['profile']['id']) . '">' . ($context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view']). '</a>' : '', '</td>
  79. <td align="center">', $group['allow_modify'] && $context['can_modify'] ? '<input type="checkbox" name="group[]" value="' . $group['id'] . '" class="input_check">' : '', '</td>
  80. </tr>';
  81. }
  82. echo '
  83. </tbody>
  84. </table>
  85. <br>';
  86. // Advanced stuff...
  87. if ($context['can_modify'])
  88. {
  89. echo '
  90. <div class="cat_bar">
  91. <h3 class="catbg">
  92. <span id="permissions_panel_toggle" class="', empty($context['show_advanced_options']) ? 'toggle_down' : 'toggle_up', ' floatright" style="display: none;"></span>
  93. <a href="#" id="permissions_panel_link">', $txt['permissions_advanced_options'], '</a>
  94. </h3>
  95. </div>
  96. <div id="permissions_panel_advanced" class="windowbg">
  97. <div class="content">
  98. <fieldset>
  99. <legend>', $txt['permissions_with_selection'], '</legend>
  100. <dl class="settings admin_permissions">
  101. <dt>
  102. <a class="help" href="', $scripturl, '?action=helpadmin;help=permissions_quickgroups" onclick="return reqOverlayDiv(this.href);"><img class="icon" src="' . $settings['images_url'] . '/helptopics.png" alt="' . $txt['help'] . '"></a>', $txt['permissions_apply_pre_defined'], ':
  103. </dt>
  104. <dd>
  105. <select name="predefined">
  106. <option value="">(', $txt['permissions_select_pre_defined'], ')</option>
  107. <option value="restrict">', $txt['permitgroups_restrict'], '</option>
  108. <option value="standard">', $txt['permitgroups_standard'], '</option>
  109. <option value="moderator">', $txt['permitgroups_moderator'], '</option>
  110. <option value="maintenance">', $txt['permitgroups_maintenance'], '</option>
  111. </select>
  112. </dd>
  113. <dt>
  114. ', $txt['permissions_like_group'], ':
  115. </dt>
  116. <dd>
  117. <select name="copy_from">
  118. <option value="empty">(', $txt['permissions_select_membergroup'], ')</option>';
  119. foreach ($context['groups'] as $group)
  120. {
  121. if ($group['id'] != 1)
  122. echo '
  123. <option value="', $group['id'], '">', $group['name'], '</option>';
  124. }
  125. echo '
  126. </select>
  127. </dd>
  128. <dt>
  129. <select name="add_remove">
  130. <option value="add">', $txt['permissions_add'], '...</option>
  131. <option value="clear">', $txt['permissions_remove'], '...</option>';
  132. if (!empty($modSettings['permission_enable_deny']))
  133. echo '
  134. <option value="deny">', $txt['permissions_deny'], '...</option>';
  135. echo '
  136. </select>
  137. </dt>
  138. <dd style="overflow:auto;">
  139. <select name="permissions">
  140. <option value="">(', $txt['permissions_select_permission'], ')</option>';
  141. foreach ($context['permissions'] as $permissionType)
  142. {
  143. if ($permissionType['id'] == 'membergroup' && !empty($context['profile']))
  144. continue;
  145. foreach ($permissionType['columns'] as $column)
  146. {
  147. foreach ($column as $permissionGroup)
  148. {
  149. if ($permissionGroup['hidden'])
  150. continue;
  151. echo '
  152. <option value="" disabled>[', $permissionGroup['name'], ']</option>';
  153. foreach ($permissionGroup['permissions'] as $perm)
  154. {
  155. if ($perm['hidden'])
  156. continue;
  157. if ($perm['has_own_any'])
  158. echo '
  159. <option value="', $permissionType['id'], '/', $perm['own']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['own']['name'], ')</option>
  160. <option value="', $permissionType['id'], '/', $perm['any']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['any']['name'], ')</option>';
  161. else
  162. echo '
  163. <option value="', $permissionType['id'], '/', $perm['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], '</option>';
  164. }
  165. }
  166. }
  167. }
  168. echo '
  169. </select>
  170. </dd>
  171. </dl>
  172. </fieldset>
  173. <input type="submit" value="', $txt['permissions_set_permissions'], '" onclick="return checkSubmit();" class="button_submit">
  174. </div>
  175. </div>';
  176. // Javascript for the advanced stuff.
  177. echo '
  178. <script><!-- // --><![CDATA[
  179. var oPermissionsPanelToggle = new smc_Toggle({
  180. bToggleEnabled: true,
  181. bCurrentlyCollapsed: ', empty($context['show_advanced_options']) ? 'true' : 'false', ',
  182. aSwappableContainers: [
  183. \'permissions_panel_advanced\'
  184. ],
  185. aSwapImages: [
  186. {
  187. sId: \'permissions_panel_toggle\',
  188. altExpanded: ', JavaScriptEscape($txt['hide']), ',
  189. altCollapsed: ', JavaScriptEscape($txt['show']), '
  190. }
  191. ],
  192. aSwapLinks: [
  193. {
  194. sId: \'permissions_panel_link\',
  195. msgExpanded: ', JavaScriptEscape($txt['permissions_advanced_options']), ',
  196. msgCollapsed: ', JavaScriptEscape($txt['permissions_advanced_options']), '
  197. }
  198. ],
  199. oThemeOptions: {
  200. bUseThemeSettings: true,
  201. sOptionName: \'admin_preferences\',
  202. sSessionVar: smf_session_var,
  203. sSessionId: smf_session_id,
  204. sThemeId: \'1\',
  205. sAdditionalVars: \';admin_key=app\'
  206. }
  207. });';
  208. echo '
  209. function checkSubmit()
  210. {
  211. if ((document.forms.permissionForm.predefined.value != "" && (document.forms.permissionForm.copy_from.value != "empty" || document.forms.permissionForm.permissions.value != "")) || (document.forms.permissionForm.copy_from.value != "empty" && document.forms.permissionForm.permissions.value != ""))
  212. {
  213. alert("', $txt['permissions_only_one_option'], '");
  214. return false;
  215. }
  216. if (document.forms.permissionForm.predefined.value == "" && document.forms.permissionForm.copy_from.value == "" && document.forms.permissionForm.permissions.value == "")
  217. {
  218. alert("', $txt['permissions_no_action'], '");
  219. return false;
  220. }
  221. if (document.forms.permissionForm.permissions.value != "" && document.forms.permissionForm.add_remove.value == "deny")
  222. return confirm("', $txt['permissions_deny_dangerous'], '");
  223. return true;
  224. }
  225. // ]]></script>';
  226. if (!empty($context['profile']))
  227. echo '
  228. <input type="hidden" name="pid" value="', $context['profile']['id'], '">';
  229. echo '
  230. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  231. <input type="hidden" name="', $context['admin-mpq_token_var'], '" value="', $context['admin-mpq_token'], '">';
  232. }
  233. else
  234. echo '
  235. </table>';
  236. echo '
  237. </form>
  238. </div>';
  239. }
  240. function template_by_board()
  241. {
  242. global $context, $scripturl, $txt, $modSettings;
  243. echo '
  244. <div id="admincenter">
  245. <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=permissions;sa=board" method="post" accept-charset="', $context['character_set'], '">
  246. <div class="cat_bar">
  247. <h3 class="catbg">', $txt['permissions_boards'], '</h3>
  248. </div>
  249. <div class="information">
  250. ', $txt['permissions_boards_desc'], '
  251. </div>
  252. <div class="title_bar title_top">
  253. <h3 id="board_permissions" class="titlebg flow_hidden">
  254. <span class="perm_name floatleft">', $txt['board_name'], '</span>
  255. <span class="perm_profile floatleft">', $txt['permission_profile'], '</span>';
  256. echo '
  257. </h3>
  258. </div>';
  259. foreach ($context['categories'] as $category)
  260. {
  261. echo '
  262. <div class="cat_bar">
  263. <h3 class="catbg">', $category['name'], '</h3>
  264. </div>';
  265. if (!empty($category['boards']))
  266. echo '
  267. <div class="windowbg">
  268. <div class="content">
  269. <ul class="perm_boards flow_hidden">';
  270. $alternate = false;
  271. foreach ($category['boards'] as $board)
  272. {
  273. $alternate = !$alternate;
  274. echo '
  275. <li class="flow_hidden' ,' windowbg', $alternate ? '' : '2','">
  276. <span class="perm_board floatleft">
  277. <a href="', $scripturl, '?action=admin;area=manageboards;sa=board;boardid=', $board['id'], ';rid=permissions;', $context['session_var'], '=', $context['session_id'], '">', str_repeat('-', $board['child_level']), ' ', $board['name'], '</a>
  278. </span>
  279. <span class="perm_boardprofile floatleft">';
  280. if ($context['edit_all'])
  281. {
  282. echo '
  283. <select name="boardprofile[', $board['id'], ']">';
  284. foreach ($context['profiles'] as $id => $profile)
  285. echo '
  286. <option value="', $id, '"', $id == $board['profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
  287. echo '
  288. </select>';
  289. }
  290. else
  291. echo '
  292. <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $board['profile'], ';', $context['session_var'], '=', $context['session_id'], '"> [', $board['profile_name'], ']</a>';
  293. echo '
  294. </span>
  295. </li>';
  296. }
  297. if (!empty($category['boards']))
  298. echo '
  299. </ul>
  300. </div>
  301. </div>';
  302. }
  303. echo '
  304. <div class="content">';
  305. if ($context['edit_all'])
  306. echo '
  307. <input type="submit" name="save_changes" value="', $txt['save'], '" class="button_submit">';
  308. else
  309. echo '
  310. <a class="button_link" href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">', $txt['permissions_board_all'], '</a>';
  311. echo '
  312. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  313. <input type="hidden" name="', $context['admin-mpb_token_var'], '" value="', $context['admin-mpb_token'], '">
  314. </div>
  315. </form>
  316. </div>';
  317. }
  318. // Edit permission profiles (predefined).
  319. function template_edit_profiles()
  320. {
  321. global $context, $scripturl, $txt, $modSettings;
  322. echo '
  323. <div id="admin_form_wrapper">
  324. <form action="', $scripturl, '?action=admin;area=permissions;sa=profiles" method="post" accept-charset="', $context['character_set'], '">
  325. <div class="cat_bar">
  326. <h3 class="catbg">', $txt['permissions_profile_edit'], '</h3>
  327. </div>
  328. <table class="table_grid">
  329. <thead>
  330. <tr class="catbg">
  331. <th class="first_th">', $txt['permissions_profile_name'], '</th>
  332. <th', !empty($context['show_rename_boxes']) ? ' class="last_th"' : '', '>', $txt['permissions_profile_used_by'], '</th>
  333. <th class="last_th"', !empty($context['show_rename_boxes']) ? ' style="display:none"' : '', ' width="5%">', $txt['delete'], '</th>
  334. </tr>
  335. </thead>
  336. <tbody>';
  337. $alternate = false;
  338. foreach ($context['profiles'] as $profile)
  339. {
  340. echo '
  341. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
  342. <td>';
  343. if (!empty($context['show_rename_boxes']) && $profile['can_edit'])
  344. echo '
  345. <input type="text" name="rename_profile[', $profile['id'], ']" value="', $profile['name'], '" class="input_text">';
  346. else
  347. echo '
  348. <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $profile['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $profile['name'], '</a>';
  349. echo '
  350. </td>
  351. <td>
  352. ', !empty($profile['boards_text']) ? $profile['boards_text'] : $txt['permissions_profile_used_by_none'], '
  353. </td>
  354. <td align="center"', !empty($context['show_rename_boxes']) ? ' style="display:none"' : '', '>
  355. <input type="checkbox" name="delete_profile[]" value="', $profile['id'], '" ', $profile['can_delete'] ? '' : 'disabled', ' class="input_check">
  356. </td>
  357. </tr>';
  358. $alternate = !$alternate;
  359. }
  360. echo '
  361. </tbody>
  362. </table>
  363. <div class="flow_auto righttext padding">
  364. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  365. <input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '">';
  366. if ($context['can_edit_something'])
  367. echo '
  368. <input type="submit" name="rename" value="', empty($context['show_rename_boxes']) ? $txt['permissions_profile_rename'] : $txt['permissions_commit'], '" class="button_submit">';
  369. echo '
  370. <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" class="button_submit" ', !empty($context['show_rename_boxes']) ? ' style="display:none"' : '', '/>
  371. </div>
  372. </form>
  373. <br>
  374. <form action="', $scripturl, '?action=admin;area=permissions;sa=profiles" method="post" accept-charset="', $context['character_set'], '">
  375. <div class="cat_bar">
  376. <h3 class="catbg">', $txt['permissions_profile_new'], '</h3>
  377. </div>
  378. <div class="windowbg">
  379. <div class="content">
  380. <dl class="settings">
  381. <dt>
  382. <strong>', $txt['permissions_profile_name'], ':</strong>
  383. </dt>
  384. <dd>
  385. <input type="text" name="profile_name" value="" class="input_text">
  386. </dd>
  387. <dt>
  388. <strong>', $txt['permissions_profile_copy_from'], ':</strong>
  389. </dt>
  390. <dd>
  391. <select name="copy_from">';
  392. foreach ($context['profiles'] as $id => $profile)
  393. echo '
  394. <option value="', $id, '">', $profile['name'], '</option>';
  395. echo '
  396. </select>
  397. </dd>
  398. </dl>
  399. <hr class="hrcolor">
  400. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  401. <input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '">
  402. <input type="submit" name="create" value="', $txt['permissions_profile_new_create'], '" class="button_submit">
  403. </div>
  404. </div>
  405. </form>
  406. </div>';
  407. }
  408. function template_modify_group()
  409. {
  410. global $context, $scripturl, $txt, $modSettings;
  411. // Cannot be edited?
  412. if (!$context['profile']['can_modify'])
  413. {
  414. echo '
  415. <div class="errorbox">
  416. ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
  417. </div>';
  418. }
  419. else
  420. {
  421. echo '
  422. <script><!-- // --><![CDATA[
  423. window.smf_usedDeny = false;
  424. function warnAboutDeny()
  425. {
  426. if (window.smf_usedDeny)
  427. return confirm("', $txt['permissions_deny_dangerous'], '");
  428. else
  429. return true;
  430. }
  431. // ]]></script>';
  432. }
  433. echo '
  434. <div id="admincenter">
  435. <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=permissions;sa=modify2;group=', $context['group']['id'], ';pid=', $context['profile']['id'], '" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" onsubmit="return warnAboutDeny();">';
  436. if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1)
  437. echo '
  438. <div class="information">
  439. ', $txt['permissions_option_desc'], '
  440. </div>';
  441. echo '
  442. <div class="cat_bar">
  443. <h3 class="catbg">';
  444. if ($context['permission_type'] == 'board')
  445. echo '
  446. ', $txt['permissions_local_for'], ' &quot;', $context['group']['name'], '&quot; ', $txt['permissions_on'], ' &quot;', $context['profile']['name'], '&quot;';
  447. else
  448. echo '
  449. ', $context['permission_type'] == 'membergroup' ? $txt['permissions_general'] : $txt['permissions_board'], ' - &quot;', $context['group']['name'], '&quot;';
  450. echo '
  451. </h3>
  452. </div>
  453. <div class="flow_hidden">';
  454. // Draw out the main bits.
  455. template_modify_group_display($context['permission_type']);
  456. // If this is general permissions also show the default profile.
  457. if ($context['permission_type'] == 'membergroup')
  458. {
  459. echo '
  460. </div>
  461. <br>
  462. <div class="cat_bar">
  463. <h3 class="catbg">', $txt['permissions_board'], '</h3>
  464. </div>
  465. <div class="information">
  466. ', $txt['permissions_board_desc'], '
  467. </div>
  468. <div class="flow_hidden">';
  469. template_modify_group_display('board');
  470. echo '
  471. </div>';
  472. }
  473. if ($context['profile']['can_modify'])
  474. echo '
  475. <div class="padding">
  476. <input type="submit" value="', $txt['permissions_commit'], '" class="button_submit">
  477. </div>';
  478. foreach ($context['hidden_perms'] as $hidden_perm)
  479. echo '
  480. <input type="hidden" name="perm[', $hidden_perm[0], '][', $hidden_perm[1], ']" value="', $hidden_perm[2], '">';
  481. echo '
  482. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  483. <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">
  484. </form>
  485. </div>';
  486. }
  487. // The way of looking at permissions.
  488. function template_modify_group_display($type)
  489. {
  490. global $context, $settings, $scripturl, $txt, $modSettings;
  491. $permission_type = &$context['permissions'][$type];
  492. $disable_field = $context['profile']['can_modify'] ? '' : 'disabled ';
  493. echo '
  494. <div class="windowbg2">
  495. <div class="content">';
  496. foreach ($permission_type['columns'] as $column)
  497. {
  498. echo '
  499. <table class="table_grid perm_grid floatleft">';
  500. foreach ($column as $permissionGroup)
  501. {
  502. if (empty($permissionGroup['permissions']))
  503. continue;
  504. // Are we likely to have something in this group to display or is it all hidden?
  505. $has_display_content = false;
  506. if (!$permissionGroup['hidden'])
  507. {
  508. // Before we go any further check we are going to have some data to print otherwise we just have a silly heading.
  509. foreach ($permissionGroup['permissions'] as $permission)
  510. if (!$permission['hidden'])
  511. $has_display_content = true;
  512. if ($has_display_content)
  513. {
  514. echo '
  515. <tr class="catbg">
  516. <th width="10"></th>
  517. <th', $context['group']['id'] == -1 ? ' colspan="2"' : '', ' class="smalltext">', $permissionGroup['name'], '</th>';
  518. if ($context['group']['id'] != -1)
  519. echo '
  520. <th align="center">', $txt['permissions_option_own'], '</th>
  521. <th align="center">', $txt['permissions_option_any'], '</th>';
  522. echo '
  523. </tr>';
  524. }
  525. }
  526. foreach ($permissionGroup['permissions'] as $permission)
  527. {
  528. if (!$permission['hidden'] && !$permissionGroup['hidden'])
  529. {
  530. echo '
  531. <tr>
  532. <td width="10">
  533. ', $permission['show_help'] ? '<a href="' . $scripturl . '?action=helpadmin;help=permissionhelp_' . $permission['id'] . '" onclick="return reqOverlayDiv(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.png" alt="' . $txt['help'] . '"></a>' : '', '
  534. </td>
  535. <td class="lefttext full_width">', $permission['name'], '</td><td>';
  536. if ($permission['has_own_any'])
  537. {
  538. // Guests can't do their own thing.
  539. if ($context['group']['id'] != -1)
  540. {
  541. if (empty($modSettings['permission_enable_deny']))
  542. echo '
  543. <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" id="', $permission['own']['id'], '_on" class="input_check" ', $disable_field, '/>';
  544. else
  545. {
  546. echo '
  547. <select name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']" ', $disable_field, '>';
  548. foreach (array('on', 'off', 'deny') as $c)
  549. echo '
  550. <option ', $permission['own']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
  551. echo '
  552. </select>';
  553. }
  554. echo '
  555. </td>
  556. <td>';
  557. }
  558. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  559. echo '
  560. <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_check" ', $disable_field, '/>';
  561. else
  562. {
  563. echo '
  564. <select name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']" ', $disable_field, '>';
  565. foreach (array('on', 'off', 'deny') as $c)
  566. echo '
  567. <option ', $permission['any']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
  568. echo '
  569. </select>';
  570. }
  571. }
  572. else
  573. {
  574. if ($context['group']['id'] != -1)
  575. echo '
  576. </td>
  577. <td>';
  578. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  579. echo '
  580. <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_check" ', $disable_field, '/>';
  581. else
  582. {
  583. echo '
  584. <select name="perm[', $permission_type['id'], '][', $permission['id'], ']" ', $disable_field, '>';
  585. foreach (array('on', 'off', 'deny') as $c)
  586. echo '
  587. <option ', $permission['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
  588. echo '
  589. </select>';
  590. }
  591. }
  592. echo '
  593. </td>
  594. </tr>';
  595. }
  596. }
  597. }
  598. echo '
  599. </table>';
  600. }
  601. echo '
  602. <br class="clear">
  603. </div>
  604. </div>';
  605. }
  606. function template_inline_permissions()
  607. {
  608. global $context, $txt, $modSettings;
  609. // This looks really weird, but it keeps things nested properly...
  610. echo '
  611. <fieldset id="', $context['current_permission'], '">
  612. <legend><a href="javascript:void(0);" onclick="document.getElementById(\'', $context['current_permission'], '\').style.display = \'none\';document.getElementById(\'', $context['current_permission'], '_groups_link\').style.display = \'block\'; return false;">', $txt['avatar_select_permission'], '</a></legend>';
  613. if (empty($modSettings['permission_enable_deny']))
  614. echo '
  615. <ul class="permission_groups">';
  616. else
  617. echo '
  618. <div class="information">', $txt['permissions_option_desc'], '</div>
  619. <dl class="settings">
  620. <dt>
  621. <span class="perms"><strong>', $txt['permissions_option_on'], '</strong></span>
  622. <span class="perms"><strong>', $txt['permissions_option_off'], '</strong></span>
  623. <span class="perms" style="color: red;"><strong>', $txt['permissions_option_deny'], '</strong></span>
  624. </dt>
  625. <dd>
  626. </dd>';
  627. foreach ($context['member_groups'] as $group)
  628. {
  629. if (!empty($modSettings['permission_enable_deny']))
  630. echo '
  631. <dt>';
  632. else
  633. echo '
  634. <li>';
  635. if (empty($modSettings['permission_enable_deny']))
  636. echo '
  637. <input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', ' class="input_check">';
  638. else
  639. echo '
  640. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', ' class="input_radio"></span>
  641. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked' : '', ' class="input_radio"></span>
  642. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked' : '', ' class="input_radio"></span>';
  643. if (!empty($modSettings['permission_enable_deny']))
  644. echo '
  645. </dt>
  646. <dd>
  647. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  648. </dd>';
  649. else
  650. echo '
  651. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  652. </li>';
  653. }
  654. if (empty($modSettings['permission_enable_deny']))
  655. echo '
  656. </ul>';
  657. else
  658. echo '
  659. </dl>';
  660. echo '
  661. </fieldset>
  662. <a href="javascript:void(0);" onclick="document.getElementById(\'', $context['current_permission'], '\').style.display = \'block\'; document.getElementById(\'', $context['current_permission'], '_groups_link\').style.display = \'none\'; return false;" id="', $context['current_permission'], '_groups_link" style="display: none;">[ ', $txt['avatar_select_permission'], ' ]</a>
  663. <script><!-- // --><![CDATA[
  664. document.getElementById("', $context['current_permission'], '").style.display = "none";
  665. document.getElementById("', $context['current_permission'], '_groups_link").style.display = "";
  666. // ]]></script>';
  667. }
  668. // Edit post moderation permissions.
  669. function template_postmod_permissions()
  670. {
  671. global $context, $settings, $scripturl, $txt, $modSettings;
  672. echo '
  673. <div id="admin_form_wrapper">
  674. <form action="', $scripturl, '?action=admin;area=permissions;sa=postmod;', $context['session_var'], '=', $context['session_id'], '" method="post" name="postmodForm" id="postmodForm" accept-charset="', $context['character_set'], '">
  675. <div class="cat_bar">
  676. <h3 class="catbg">', $txt['permissions_post_moderation'], '</h3>
  677. </div>';
  678. // First, we have the bit where we can enable or disable this bad boy.
  679. echo '
  680. <div class="windowbg2">
  681. <div class="content">
  682. <dl class="settings">
  683. <dt>', $txt['permissions_post_moderation_enable'], '</dt>
  684. <dd><input type="checkbox" name="postmod_active"', !empty($modSettings['postmod_active']) ? ' checked' : '', '></dd>
  685. </dl>
  686. <hr class="hrcolor clear">
  687. </div>
  688. </div>';
  689. // If we're not active, there's a bunch of stuff we don't need to show.
  690. if (!empty($modSettings['postmod_active']))
  691. {
  692. // Got advanced permissions - if so warn!
  693. if (!empty($modSettings['permission_enable_deny']))
  694. echo '
  695. <div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>';
  696. echo '
  697. <div class="padding">
  698. <p class="smalltext" style="padding-left: 10px; padding-bottom: 10px; float: left;">
  699. <strong>', $txt['permissions_post_moderation_legend'], ':</strong><br>
  700. <img src="', $settings['default_images_url'], '/admin/post_moderation_allow.png" alt="', $txt['permissions_post_moderation_allow'], '"> - ', $txt['permissions_post_moderation_allow'], '<br>
  701. <img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.png" alt="', $txt['permissions_post_moderation_moderate'], '"> - ', $txt['permissions_post_moderation_moderate'], '<br>
  702. <img src="', $settings['default_images_url'], '/admin/post_moderation_deny.png" alt="', $txt['permissions_post_moderation_disallow'], '"> - ', $txt['permissions_post_moderation_disallow'], '
  703. </p>
  704. <span class="righttext" style="float: right">
  705. <br><br><br>
  706. ', $txt['permissions_post_moderation_select'], ':
  707. <select name="pid" onchange="document.forms.postmodForm.submit();">';
  708. foreach ($context['profiles'] as $profile)
  709. if ($profile['can_modify'])
  710. echo '
  711. <option value="', $profile['id'], '"', $profile['id'] == $context['current_profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
  712. echo '
  713. </select>
  714. <input type="submit" value="', $txt['go'], '" class="button_submit">
  715. </span>
  716. </div>
  717. <table class="table_grid">
  718. <thead>
  719. <tr class="catbg">
  720. <th class="first_th"></th>
  721. <th class="centercol" colspan="3">
  722. ', $txt['permissions_post_moderation_new_topics'], '
  723. </th>
  724. <th class="centercol" colspan="3">
  725. ', $txt['permissions_post_moderation_replies_own'], '
  726. </th>
  727. <th class="centercol" colspan="3">
  728. ', $txt['permissions_post_moderation_replies_any'], '
  729. </th>';
  730. if ($modSettings['attachmentEnable'] == 1)
  731. echo '
  732. <th class="last_th centercol" colspan="3">
  733. ', $txt['permissions_post_moderation_attachments'], '
  734. </th>';
  735. echo '
  736. </tr>
  737. <tr>
  738. <th width="30%">
  739. ', $txt['permissions_post_moderation_group'], '
  740. </th>
  741. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_allow.png" alt="', $txt['permissions_post_moderation_allow'], '" title="', $txt['permissions_post_moderation_allow'], '"></th>
  742. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.png" alt="', $txt['permissions_post_moderation_moderate'], '" title="', $txt['permissions_post_moderation_moderate'], '"></th>
  743. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_deny.png" alt="', $txt['permissions_post_moderation_disallow'], '" title="', $txt['permissions_post_moderation_disallow'], '"></th>
  744. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_allow.png" alt="', $txt['permissions_post_moderation_allow'], '" title="', $txt['permissions_post_moderation_allow'], '"></th>
  745. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.png" alt="', $txt['permissions_post_moderation_moderate'], '" title="', $txt['permissions_post_moderation_moderate'], '"></th>
  746. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_deny.png" alt="', $txt['permissions_post_moderation_disallow'], '" title="', $txt['permissions_post_moderation_disallow'], '"></th>
  747. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_allow.png" alt="', $txt['permissions_post_moderation_allow'], '" title="', $txt['permissions_post_moderation_allow'], '"></th>
  748. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.png" alt="', $txt['permissions_post_moderation_moderate'], '" title="', $txt['permissions_post_moderation_moderate'], '"></th>
  749. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_deny.png" alt="', $txt['permissions_post_moderation_disallow'], '" title="', $txt['permissions_post_moderation_disallow'], '"></th>';
  750. if ($modSettings['attachmentEnable'] == 1)
  751. echo '
  752. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_allow.png" alt="', $txt['permissions_post_moderation_allow'], '" title="', $txt['permissions_post_moderation_allow'], '"></th>
  753. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.png" alt="', $txt['permissions_post_moderation_moderate'], '" title="', $txt['permissions_post_moderation_moderate'], '"></th>
  754. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_deny.png" alt="', $txt['permissions_post_moderation_disallow'], '" title="', $txt['permissions_post_moderation_disallow'], '"></th>';
  755. echo '
  756. </tr>
  757. </thead>
  758. <tbody>';
  759. foreach ($context['profile_groups'] as $group)
  760. {
  761. echo '
  762. <tr>
  763. <td width="40%" class="windowbg">
  764. <span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>';
  765. if (!empty($group['children']))
  766. echo '
  767. <br><span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
  768. echo '
  769. </td>
  770. <td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="allow"', $group['new_topic'] == 'allow' ? ' checked' : '', ' class="input_radio"></td>
  771. <td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="moderate"', $group['new_topic'] == 'moderate' ? ' checked' : '', ' class="input_radio"></td>
  772. <td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="disallow"', $group['new_topic'] == 'disallow' ? ' checked' : '', ' class="input_radio"></td>';
  773. // Guests can't have "own" permissions
  774. if ($group['id'] == '-1')
  775. {
  776. echo '
  777. <td align="center" class="windowbg" colspan="3"></td>';
  778. }
  779. else
  780. {
  781. echo '
  782. <td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="allow"', $group['replies_own'] == 'allow' ? ' checked' : '', ' class="input_radio"></td>
  783. <td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="moderate"', $group['replies_own'] == 'moderate' ? ' checked' : '', ' class="input_radio"></td>
  784. <td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="disallow"', $group['replies_own'] == 'disallow' ? ' checked' : '', ' class="input_radio"></td>';
  785. }
  786. echo '
  787. <td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="allow"', $group['replies_any'] == 'allow' ? ' checked' : '', ' class="input_radio"></td>
  788. <td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="moderate"', $group['replies_any'] == 'moderate' ? ' checked' : '', ' class="input_radio"></td>
  789. <td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="disallow"', $group['replies_any'] == 'disallow' ? ' checked' : '', ' class="input_radio"></td>';
  790. if ($modSettings['attachmentEnable'] == 1)
  791. {
  792. echo '
  793. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="allow"', $group['attachment'] == 'allow' ? ' checked' : '', ' class="input_radio"></td>
  794. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="moderate"', $group['attachment'] == 'moderate' ? ' checked' : '', ' class="input_radio"></td>
  795. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="disallow"', $group['attachment'] == 'disallow' ? ' checked' : '', ' class="input_radio"></td>';
  796. }
  797. echo '
  798. </tr>';
  799. }
  800. echo '
  801. </tbody>
  802. </table>';
  803. }
  804. echo '
  805. <div class="righttext padding">
  806. <input type="submit" name="save_changes" value="', $txt['permissions_commit'], '" class="button_submit">
  807. <input type="hidden" name="', $context['admin-mppm_token_var'], '" value="', $context['admin-mppm_token'], '">
  808. </div>
  809. </form>';
  810. echo '
  811. </div>';
  812. }
  813. ?>