ManagePermissions.template.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  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="title_bar">
  27. <h3 class="titlebg">', $txt['permissions_for_profile'], ': &quot;', $context['profile']['name'], '&quot;</h3>
  28. </div>';
  29. else
  30. echo '
  31. <div class="title_bar">
  32. <h3 class="titlebg">', $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">
  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="title_bar">
  263. <h3 class="titlebg">', $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. echo '
  479. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  480. <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">
  481. </form>
  482. </div>';
  483. }
  484. // The way of looking at permissions.
  485. function template_modify_group_display($type)
  486. {
  487. global $context, $settings, $scripturl, $txt, $modSettings;
  488. $permission_type = &$context['permissions'][$type];
  489. $disable_field = $context['profile']['can_modify'] ? '' : 'disabled ';
  490. echo '
  491. <div class="windowbg2">
  492. <div class="content">';
  493. foreach ($permission_type['columns'] as $column)
  494. {
  495. echo '
  496. <table class="table_grid perm_grid floatleft">';
  497. foreach ($column as $permissionGroup)
  498. {
  499. if (empty($permissionGroup['permissions']))
  500. continue;
  501. // Are we likely to have something in this group to display or is it all hidden?
  502. $has_display_content = false;
  503. if (!$permissionGroup['hidden'])
  504. {
  505. // Before we go any further check we are going to have some data to print otherwise we just have a silly heading.
  506. foreach ($permissionGroup['permissions'] as $permission)
  507. if (!$permission['hidden'])
  508. $has_display_content = true;
  509. if ($has_display_content)
  510. {
  511. echo '
  512. <tr class="catbg">
  513. <th colspan="2" width="100%" align="left"><strong class="smalltext">', $permissionGroup['name'], '</strong></th>';
  514. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  515. echo '
  516. <th colspan="3" width="10"></th>';
  517. else
  518. echo '
  519. <th align="center"><div>', $txt['permissions_option_on'], '</div></th>
  520. <th align="center"><div>', $txt['permissions_option_off'], '</div></th>
  521. <th align="center"><div>', $txt['permissions_option_deny'], '</div></th>';
  522. echo '
  523. </tr>';
  524. }
  525. }
  526. $alternate = false;
  527. foreach ($permissionGroup['permissions'] as $permission)
  528. {
  529. // If it's hidden keep the last value.
  530. if ($permission['hidden'] || $permissionGroup['hidden'])
  531. {
  532. echo '
  533. <tr style="display: none;">
  534. <td>';
  535. if ($permission['has_own_any'])
  536. {
  537. // Guests can't have own permissions.
  538. if ($context['group']['id'] != -1)
  539. echo '
  540. <input type="hidden" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']" value="', $permission['own']['select'] == 'denied' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $permission['own']['select'], '">';
  541. echo '
  542. <input type="hidden" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']" value="', $permission['any']['select'] == 'denied' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $permission['any']['select'], '">';
  543. }
  544. else
  545. echo '
  546. <input type="hidden" name="perm[', $permission_type['id'], '][', $permission['id'], ']" value="', $permission['select'] == 'denied' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $permission['select'], '">';
  547. echo '
  548. </td>
  549. </tr>';
  550. }
  551. else
  552. {
  553. echo '
  554. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
  555. <td width="10">
  556. ', $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>' : '', '
  557. </td>';
  558. if ($permission['has_own_any'])
  559. {
  560. echo '
  561. <td colspan="4" width="100%" align="left">', $permission['name'], '</td>
  562. </tr><tr class="', $alternate ? 'windowbg' : 'windowbg2', '">';
  563. // Guests can't do their own thing.
  564. if ($context['group']['id'] != -1)
  565. {
  566. echo '
  567. <td></td>
  568. <td width="100%" class="smalltext" align="right">', $permission['own']['name'], ':</td>';
  569. if (empty($modSettings['permission_enable_deny']))
  570. echo '
  571. <td colspan="3"><input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked' : '', ' value="on" id="', $permission['own']['id'], '_on" class="input_check" ', $disable_field, '/></td>';
  572. else
  573. echo '
  574. <td width="10"><input type="radio" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked' : '', ' value="on" id="', $permission['own']['id'], '_on" class="input_radio" ', $disable_field, '/></td>
  575. <td width="10"><input type="radio" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'off' ? ' checked' : '', ' value="off" class="input_radio" ', $disable_field, '/></td>
  576. <td width="10"><input type="radio" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'denied' ? ' checked' : '', ' value="deny" class="input_radio" ', $disable_field, '/></td>';
  577. echo '
  578. </tr><tr class="', $alternate ? 'windowbg' : 'windowbg2', '">';
  579. }
  580. echo '
  581. <td></td>
  582. <td width="100%" class="smalltext" align="right">', $permission['any']['name'], ':</td>';
  583. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  584. echo '
  585. <td colspan="3"><input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked' : '', ' value="on" class="input_check" ', $disable_field, '/></td>';
  586. else
  587. echo '
  588. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked' : '', ' value="on" onclick="document.forms.permissionForm.', $permission['own']['id'], '_on.checked = true;" class="input_radio" ', $disable_field, '/></td>
  589. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'off' ? ' checked' : '', ' value="off" class="input_radio" ', $disable_field, '/></td>
  590. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select']== 'denied' ? ' checked' : '', ' value="deny" id="', $permission['any']['id'], '_deny" onclick="window.smf_usedDeny = true;" class="input_radio" ', $disable_field, '/></td>';
  591. echo '
  592. </tr>';
  593. }
  594. else
  595. {
  596. echo '
  597. <td width="100%" align="left">', $permission['name'], '</td>';
  598. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  599. echo '
  600. <td><input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked' : '', ' value="on" class="input_check" ', $disable_field, '/></td>';
  601. else
  602. echo '
  603. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked' : '', ' value="on" class="input_radio" ', $disable_field, '/></td>
  604. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'off' ? ' checked' : '', ' value="off" class="input_radio" ', $disable_field, '/></td>
  605. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'denied' ? ' checked' : '', ' value="deny" onclick="window.smf_usedDeny = true;" class="input_radio" ', $disable_field, '/></td>';
  606. echo '
  607. </tr>';
  608. }
  609. }
  610. $alternate = !$alternate;
  611. }
  612. if (!$permissionGroup['hidden'] && $has_display_content)
  613. echo '
  614. <tr class="windowbg2">
  615. <td colspan="5" width="100%"><!--separator--></td>
  616. </tr>';
  617. }
  618. echo '
  619. </table>';
  620. }
  621. echo '
  622. <br class="clear">
  623. </div>
  624. </div>';
  625. }
  626. function template_inline_permissions()
  627. {
  628. global $context, $txt, $modSettings;
  629. // This looks really weird, but it keeps things nested properly...
  630. echo '
  631. <fieldset id="', $context['current_permission'], '">
  632. <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>';
  633. if (empty($modSettings['permission_enable_deny']))
  634. echo '
  635. <ul class="permission_groups">';
  636. else
  637. echo '
  638. <div class="information">', $txt['permissions_option_desc'], '</div>
  639. <dl class="settings">
  640. <dt>
  641. <span class="perms"><strong>', $txt['permissions_option_on'], '</strong></span>
  642. <span class="perms"><strong>', $txt['permissions_option_off'], '</strong></span>
  643. <span class="perms" style="color: red;"><strong>', $txt['permissions_option_deny'], '</strong></span>
  644. </dt>
  645. <dd>
  646. </dd>';
  647. foreach ($context['member_groups'] as $group)
  648. {
  649. if (!empty($modSettings['permission_enable_deny']))
  650. echo '
  651. <dt>';
  652. else
  653. echo '
  654. <li>';
  655. if (empty($modSettings['permission_enable_deny']))
  656. echo '
  657. <input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', ' class="input_check">';
  658. else
  659. echo '
  660. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', ' class="input_radio"></span>
  661. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked' : '', ' class="input_radio"></span>
  662. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked' : '', ' class="input_radio"></span>';
  663. if (!empty($modSettings['permission_enable_deny']))
  664. echo '
  665. </dt>
  666. <dd>
  667. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  668. </dd>';
  669. else
  670. echo '
  671. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  672. </li>';
  673. }
  674. if (empty($modSettings['permission_enable_deny']))
  675. echo '
  676. </ul>';
  677. else
  678. echo '
  679. </dl>';
  680. echo '
  681. </fieldset>
  682. <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>
  683. <script><!-- // --><![CDATA[
  684. document.getElementById("', $context['current_permission'], '").style.display = "none";
  685. document.getElementById("', $context['current_permission'], '_groups_link").style.display = "";
  686. // ]]></script>';
  687. }
  688. // Edit post moderation permissions.
  689. function template_postmod_permissions()
  690. {
  691. global $context, $settings, $scripturl, $txt, $modSettings;
  692. echo '
  693. <div id="admin_form_wrapper">
  694. <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'], '">
  695. <div class="cat_bar">
  696. <h3 class="catbg">', $txt['permissions_post_moderation'], '</h3>
  697. </div>';
  698. // First, we have the bit where we can enable or disable this bad boy.
  699. echo '
  700. <div class="windowbg2">
  701. <div class="content">
  702. <dl class="settings">
  703. <dt>', $txt['permissions_post_moderation_enable'], '</dt>
  704. <dd><input type="checkbox" name="postmod_active"', !empty($modSettings['postmod_active']) ? ' checked' : '', '></dd>
  705. </dl>
  706. <hr class="hrcolor clear">
  707. </div>
  708. </div>';
  709. // If we're not active, there's a bunch of stuff we don't need to show.
  710. if (!empty($modSettings['postmod_active']))
  711. {
  712. // Got advanced permissions - if so warn!
  713. if (!empty($modSettings['permission_enable_deny']))
  714. echo '
  715. <div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>';
  716. echo '
  717. <div class="padding">
  718. <p class="smalltext" style="padding-left: 10px; padding-bottom: 10px; float: left;">
  719. <strong>', $txt['permissions_post_moderation_legend'], ':</strong><br>
  720. <img src="', $settings['default_images_url'], '/admin/post_moderation_allow.png" alt="', $txt['permissions_post_moderation_allow'], '"> - ', $txt['permissions_post_moderation_allow'], '<br>
  721. <img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.png" alt="', $txt['permissions_post_moderation_moderate'], '"> - ', $txt['permissions_post_moderation_moderate'], '<br>
  722. <img src="', $settings['default_images_url'], '/admin/post_moderation_deny.png" alt="', $txt['permissions_post_moderation_disallow'], '"> - ', $txt['permissions_post_moderation_disallow'], '
  723. </p>
  724. <span class="righttext" style="float: right">
  725. <br><br><br>
  726. ', $txt['permissions_post_moderation_select'], ':
  727. <select name="pid" onchange="document.forms.postmodForm.submit();">';
  728. foreach ($context['profiles'] as $profile)
  729. if ($profile['can_modify'])
  730. echo '
  731. <option value="', $profile['id'], '"', $profile['id'] == $context['current_profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
  732. echo '
  733. </select>
  734. <input type="submit" value="', $txt['go'], '" class="button_submit">
  735. </span>
  736. </div>
  737. <table class="table_grid">
  738. <thead>
  739. <tr class="catbg">
  740. <th class="first_th"></th>
  741. <th class="centercol" colspan="3">
  742. ', $txt['permissions_post_moderation_new_topics'], '
  743. </th>
  744. <th class="centercol" colspan="3">
  745. ', $txt['permissions_post_moderation_replies_own'], '
  746. </th>
  747. <th class="centercol" colspan="3">
  748. ', $txt['permissions_post_moderation_replies_any'], '
  749. </th>';
  750. if ($modSettings['attachmentEnable'] == 1)
  751. echo '
  752. <th class="last_th centercol" colspan="3">
  753. ', $txt['permissions_post_moderation_attachments'], '
  754. </th>';
  755. echo '
  756. </tr>
  757. <tr class="titlebg">
  758. <th width="30%">
  759. ', $txt['permissions_post_moderation_group'], '
  760. </th>
  761. <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>
  762. <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>
  763. <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>
  764. <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>
  765. <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>
  766. <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>
  767. <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>
  768. <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>
  769. <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>';
  770. if ($modSettings['attachmentEnable'] == 1)
  771. echo '
  772. <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>
  773. <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>
  774. <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>';
  775. echo '
  776. </tr>
  777. </thead>
  778. <tbody>';
  779. foreach ($context['profile_groups'] as $group)
  780. {
  781. echo '
  782. <tr>
  783. <td width="40%" class="windowbg">
  784. <span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>';
  785. if (!empty($group['children']))
  786. echo '
  787. <br><span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
  788. echo '
  789. </td>
  790. <td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="allow"', $group['new_topic'] == 'allow' ? ' checked' : '', ' class="input_radio"></td>
  791. <td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="moderate"', $group['new_topic'] == 'moderate' ? ' checked' : '', ' class="input_radio"></td>
  792. <td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="disallow"', $group['new_topic'] == 'disallow' ? ' checked' : '', ' class="input_radio"></td>';
  793. // Guests can't have "own" permissions
  794. if ($group['id'] == '-1')
  795. {
  796. echo '
  797. <td align="center" class="windowbg" colspan="3"></td>';
  798. }
  799. else
  800. {
  801. echo '
  802. <td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="allow"', $group['replies_own'] == 'allow' ? ' checked' : '', ' class="input_radio"></td>
  803. <td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="moderate"', $group['replies_own'] == 'moderate' ? ' checked' : '', ' class="input_radio"></td>
  804. <td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="disallow"', $group['replies_own'] == 'disallow' ? ' checked' : '', ' class="input_radio"></td>';
  805. }
  806. echo '
  807. <td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="allow"', $group['replies_any'] == 'allow' ? ' checked' : '', ' class="input_radio"></td>
  808. <td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="moderate"', $group['replies_any'] == 'moderate' ? ' checked' : '', ' class="input_radio"></td>
  809. <td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="disallow"', $group['replies_any'] == 'disallow' ? ' checked' : '', ' class="input_radio"></td>';
  810. if ($modSettings['attachmentEnable'] == 1)
  811. {
  812. echo '
  813. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="allow"', $group['attachment'] == 'allow' ? ' checked' : '', ' class="input_radio"></td>
  814. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="moderate"', $group['attachment'] == 'moderate' ? ' checked' : '', ' class="input_radio"></td>
  815. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="disallow"', $group['attachment'] == 'disallow' ? ' checked' : '', ' class="input_radio"></td>';
  816. }
  817. echo '
  818. </tr>';
  819. }
  820. echo '
  821. </tbody>
  822. </table>';
  823. }
  824. echo '
  825. <div class="righttext padding">
  826. <input type="submit" name="save_changes" value="', $txt['permissions_commit'], '" class="button_submit">
  827. <input type="hidden" name="', $context['admin-mppm_token_var'], '" value="', $context['admin-mppm_token'], '">
  828. </div>
  829. </form>';
  830. echo '
  831. </div>';
  832. }
  833. ?>