ManagePermissions.template.php 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2012 Simple Machines
  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, $options, $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="admincenter">
  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. echo '
  30. <table width="100%" class="table_grid">
  31. <thead>
  32. <tr class="catbg">
  33. <th class="first_th">', $txt['membergroups_name'], '</th>
  34. <th width="10%" align="center" valign="middle">', $txt['membergroups_members_top'], '</th>';
  35. if (empty($modSettings['permission_enable_deny']))
  36. echo '
  37. <th width="16%" align="center">', $txt['membergroups_permissions'], '</th>';
  38. else
  39. echo '
  40. <th width="8%" align="center">', $txt['permissions_allowed'], '</th>
  41. <th width="8%" align="center">', $txt['permissions_denied'], '</th>';
  42. echo '
  43. <th width="10%" align="center" valign="middle">', $context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view'], '</th>
  44. <th class="last_th" width="4%" align="center" valign="middle">
  45. ', $context['can_modify'] ? '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \'group\');" />' : '', '
  46. </th>
  47. </tr>
  48. </thead>
  49. <tbody>';
  50. $alternate = false;
  51. foreach ($context['groups'] as $group)
  52. {
  53. $alternate = !$alternate;
  54. echo '
  55. <tr class="windowbg', $alternate ? '2' : '', '">
  56. <td>
  57. ', $group['name'], $group['id'] == -1 ? ' (<a href="' . $scripturl . '?action=helpadmin;help=membergroup_guests" onclick="return reqOverlayDiv(this.href);">?</a>)' : ($group['id'] == 0 ? ' (<a href="' . $scripturl . '?action=helpadmin;help=membergroup_regular_members" onclick="return reqOverlayDiv(this.href);">?</a>)' : ($group['id'] == 1 ? ' (<a href="' . $scripturl . '?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)' : ($group['id'] == 3 ? ' (<a href="' . $scripturl . '?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)' : '')));
  58. if (!empty($group['children']))
  59. echo '
  60. <br /><span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
  61. echo '
  62. </td>
  63. <td align="center">', $group['can_search'] ? $group['link'] : $group['num_members'], '</td>';
  64. if (empty($modSettings['permission_enable_deny']))
  65. echo '
  66. <td width="16%" align="center">', $group['num_permissions']['allowed'], '</td>';
  67. else
  68. echo '
  69. <td width="8%" align="center"', $group['id'] == 1 ? ' style="font-style: italic;"' : '', '>', $group['num_permissions']['allowed'], '</td>
  70. <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>';
  71. echo '
  72. <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>
  73. <td align="center">', $group['allow_modify'] && $context['can_modify'] ? '<input type="checkbox" name="group[]" value="' . $group['id'] . '" class="input_check" />' : '', '</td>
  74. </tr>';
  75. }
  76. echo '
  77. </tbody>
  78. </table>
  79. <br />';
  80. // Advanced stuff...
  81. if ($context['can_modify'])
  82. {
  83. echo '
  84. <div class="cat_bar">
  85. <h3 class="catbg">
  86. <img id="permissions_panel_toggle" class="panel_toggle" style="display: none;" src="', $settings['images_url'], '/', empty($context['show_advanced_options']) ? 'collapse' : 'expand', '.png" alt="*" />
  87. <a href="#" id="permissions_panel_link">', $txt['permissions_advanced_options'], '</a>
  88. </h3>
  89. </div>
  90. <div id="permissions_panel_advanced" class="windowbg">
  91. <div class="content">
  92. <fieldset>
  93. <legend>', $txt['permissions_with_selection'], '</legend>
  94. <dl class="settings admin_permissions">
  95. <dt>
  96. ', $txt['permissions_apply_pre_defined'], ' <a href="', $scripturl, '?action=helpadmin;help=permissions_quickgroups" onclick="return reqOverlayDiv(this.href);">(?)</a>:
  97. </dt>
  98. <dd>
  99. <select name="predefined">
  100. <option value="">(', $txt['permissions_select_pre_defined'], ')</option>
  101. <option value="restrict">', $txt['permitgroups_restrict'], '</option>
  102. <option value="standard">', $txt['permitgroups_standard'], '</option>
  103. <option value="moderator">', $txt['permitgroups_moderator'], '</option>
  104. <option value="maintenance">', $txt['permitgroups_maintenance'], '</option>
  105. </select>
  106. </dd>
  107. <dt>
  108. ', $txt['permissions_like_group'], ':
  109. </dt>
  110. <dd>
  111. <select name="copy_from">
  112. <option value="empty">(', $txt['permissions_select_membergroup'], ')</option>';
  113. foreach ($context['groups'] as $group)
  114. {
  115. if ($group['id'] != 1)
  116. echo '
  117. <option value="', $group['id'], '">', $group['name'], '</option>';
  118. }
  119. echo '
  120. </select>
  121. </dd>
  122. <dt>
  123. <select name="add_remove">
  124. <option value="add">', $txt['permissions_add'], '...</option>
  125. <option value="clear">', $txt['permissions_remove'], '...</option>';
  126. if (!empty($modSettings['permission_enable_deny']))
  127. echo '
  128. <option value="deny">', $txt['permissions_deny'], '...</option>';
  129. echo '
  130. </select>
  131. </dt>
  132. <dd style="overflow:auto;">
  133. <select name="permissions">
  134. <option value="">(', $txt['permissions_select_permission'], ')</option>';
  135. foreach ($context['permissions'] as $permissionType)
  136. {
  137. if ($permissionType['id'] == 'membergroup' && !empty($context['profile']))
  138. continue;
  139. foreach ($permissionType['columns'] as $column)
  140. {
  141. foreach ($column as $permissionGroup)
  142. {
  143. if ($permissionGroup['hidden'])
  144. continue;
  145. echo '
  146. <option value="" disabled="disabled">[', $permissionGroup['name'], ']</option>';
  147. foreach ($permissionGroup['permissions'] as $perm)
  148. {
  149. if ($perm['hidden'])
  150. continue;
  151. if ($perm['has_own_any'])
  152. echo '
  153. <option value="', $permissionType['id'], '/', $perm['own']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['own']['name'], ')</option>
  154. <option value="', $permissionType['id'], '/', $perm['any']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['any']['name'], ')</option>';
  155. else
  156. echo '
  157. <option value="', $permissionType['id'], '/', $perm['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], '</option>';
  158. }
  159. }
  160. }
  161. }
  162. echo '
  163. </select>
  164. </dd>
  165. </dl>
  166. </fieldset>
  167. <input type="submit" value="', $txt['permissions_set_permissions'], '" onclick="return checkSubmit();" class="button_submit" />
  168. </div>
  169. </div>';
  170. // Javascript for the advanced stuff.
  171. echo '
  172. <script type="text/javascript"><!-- // --><![CDATA[
  173. var oPermissionsPanelToggle = new smc_Toggle({
  174. bToggleEnabled: true,
  175. bCurrentlyCollapsed: ', empty($context['show_advanced_options']) ? 'true' : 'false', ',
  176. aSwappableContainers: [
  177. \'permissions_panel_advanced\'
  178. ],
  179. aSwapImages: [
  180. {
  181. sId: \'permissions_panel_toggle\',
  182. srcExpanded: smf_images_url + \'/collapse.png\',
  183. altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
  184. srcCollapsed: smf_images_url + \'/expand.png\',
  185. altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
  186. }
  187. ],
  188. aSwapLinks: [
  189. {
  190. sId: \'permissions_panel_link\',
  191. msgExpanded: ', JavaScriptEscape($txt['advanced']), ',
  192. msgCollapsed: ', JavaScriptEscape($txt['advanced']), '
  193. }
  194. ],
  195. oThemeOptions: {
  196. bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
  197. sOptionName: \'admin_preferences\',
  198. sSessionVar: smf_session_var,
  199. sSessionId: smf_session_id,
  200. sThemeId: \'1\',
  201. sAdditionalVars: \';admin_key=app\'
  202. }
  203. });';
  204. echo '
  205. function checkSubmit()
  206. {
  207. 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 != ""))
  208. {
  209. alert("', $txt['permissions_only_one_option'], '");
  210. return false;
  211. }
  212. if (document.forms.permissionForm.predefined.value == "" && document.forms.permissionForm.copy_from.value == "" && document.forms.permissionForm.permissions.value == "")
  213. {
  214. alert("', $txt['permissions_no_action'], '");
  215. return false;
  216. }
  217. if (document.forms.permissionForm.permissions.value != "" && document.forms.permissionForm.add_remove.value == "deny")
  218. return confirm("', $txt['permissions_deny_dangerous'], '");
  219. return true;
  220. }
  221. // ]]></script>';
  222. if (!empty($context['profile']))
  223. echo '
  224. <input type="hidden" name="pid" value="', $context['profile']['id'], '" />';
  225. echo '
  226. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  227. <input type="hidden" name="', $context['admin-mpq_token_var'], '" value="', $context['admin-mpq_token'], '" />';
  228. }
  229. else
  230. echo '
  231. </table>';
  232. echo '
  233. </form>
  234. </div>';
  235. }
  236. function template_by_board()
  237. {
  238. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  239. echo '
  240. <form id="admincenter" action="', $scripturl, '?action=admin;area=permissions;sa=board" method="post" accept-charset="', $context['character_set'], '">
  241. <div class="cat_bar">
  242. <h3 class="catbg">', $txt['permissions_boards'], '</h3>
  243. </div>
  244. <div class="information">
  245. ', $txt['permissions_boards_desc'], '
  246. </div>
  247. <div class="title_bar">
  248. <h3 id="board_permissions" class="titlebg flow_hidden">
  249. <span class="perm_name floatleft">', $txt['board_name'], '</span>
  250. <span class="perm_profile floatleft">', $txt['permission_profile'], '</span>
  251. </h3>
  252. </div>';
  253. if (!$context['edit_all'])
  254. echo '
  255. <div class="content flow_auto">
  256. <a class="button_link" href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">', $txt['permissions_board_all'], '</a>
  257. </div>';
  258. foreach ($context['categories'] as $category)
  259. {
  260. echo '
  261. <div class="cat_bar">
  262. <h3 class="catbg"><strong>', $category['name'], '</strong></h3>
  263. </div>';
  264. if (!empty($category['boards']))
  265. echo '
  266. <div class="windowbg">
  267. <div class="content">
  268. <ul class="perm_boards flow_hidden">';
  269. $alternate = false;
  270. foreach ($category['boards'] as $board)
  271. {
  272. $alternate = !$alternate;
  273. echo '
  274. <li class="flow_hidden' ,' windowbg', $alternate ? '' : '2','">
  275. <span class="perm_board floatleft">
  276. <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>
  277. </span>
  278. <span class="perm_boardprofile floatleft">';
  279. if ($context['edit_all'])
  280. {
  281. echo '
  282. <select name="boardprofile[', $board['id'], ']">';
  283. foreach ($context['profiles'] as $id => $profile)
  284. echo '
  285. <option value="', $id, '" ', $id == $board['profile'] ? 'selected="selected"' : '', '>', $profile['name'], '</option>';
  286. echo '
  287. </select>';
  288. }
  289. else
  290. echo '
  291. <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $board['profile'], ';', $context['session_var'], '=', $context['session_id'], '"> [', $board['profile_name'], ']</a>';
  292. echo '
  293. </span>
  294. </li>';
  295. }
  296. if (!empty($category['boards']))
  297. echo '
  298. </ul>
  299. </div>
  300. </div>';
  301. }
  302. echo '
  303. <div class="content">';
  304. if ($context['edit_all'])
  305. echo '
  306. <input type="submit" name="save_changes" value="', $txt['save'], '" class="button_submit" />';
  307. else
  308. echo '
  309. <a class="button_link" href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">', $txt['permissions_board_all'], '</a>';
  310. echo '
  311. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  312. <input type="hidden" name="', $context['admin-mpb_token_var'], '" value="', $context['admin-mpb_token'], '" />
  313. </div>
  314. </form>';
  315. }
  316. // Edit permission profiles (predefined).
  317. function template_edit_profiles()
  318. {
  319. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  320. echo '
  321. <div id="admincenter">
  322. <form action="', $scripturl, '?action=admin;area=permissions;sa=profiles" method="post" accept-charset="', $context['character_set'], '">
  323. <div class="title_bar">
  324. <h3 class="titlebg">', $txt['permissions_profile_edit'], '</h3>
  325. </div>
  326. <table width="100%" class="table_grid">
  327. <thead>
  328. <tr class="catbg">
  329. <th class="first_th">', $txt['permissions_profile_name'], '</th>
  330. <th>', $txt['permissions_profile_used_by'], '</th>
  331. <th class="last_th" width="5%">', $txt['delete'], '</th>
  332. </tr>
  333. </thead>
  334. <tbody>';
  335. $alternate = false;
  336. foreach ($context['profiles'] as $profile)
  337. {
  338. echo '
  339. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
  340. <td>';
  341. if (!empty($context['show_rename_boxes']) && $profile['can_edit'])
  342. echo '
  343. <input type="text" name="rename_profile[', $profile['id'], ']" value="', $profile['name'], '" class="input_text" />';
  344. else
  345. echo '
  346. <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $profile['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $profile['name'], '</a>';
  347. echo '
  348. </td>
  349. <td>
  350. ', !empty($profile['boards_text']) ? $profile['boards_text'] : $txt['permissions_profile_used_by_none'], '
  351. </td>
  352. <td align="center">
  353. <input type="checkbox" name="delete_profile[]" value="', $profile['id'], '" ', $profile['can_delete'] ? '' : 'disabled="disabled"', ' class="input_check" />
  354. </td>
  355. </tr>';
  356. $alternate = !$alternate;
  357. }
  358. echo '
  359. </tbody>
  360. </table>
  361. <div class="flow_auto righttext padding">
  362. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  363. <input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '" />';
  364. if ($context['can_edit_something'])
  365. echo '
  366. <input type="submit" name="rename" value="', empty($context['show_rename_boxes']) ? $txt['permissions_profile_rename'] : $txt['permissions_commit'], '" class="button_submit" />';
  367. echo '
  368. <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" class="button_submit" />
  369. </div>
  370. </form>
  371. <br />
  372. <form action="', $scripturl, '?action=admin;area=permissions;sa=profiles" method="post" accept-charset="', $context['character_set'], '">
  373. <div class="cat_bar">
  374. <h3 class="catbg">', $txt['permissions_profile_new'], '</h3>
  375. </div>
  376. <div class="windowbg">
  377. <div class="content">
  378. <dl class="settings">
  379. <dt>
  380. <strong>', $txt['permissions_profile_name'], ':</strong>
  381. </dt>
  382. <dd>
  383. <input type="text" name="profile_name" value="" class="input_text" />
  384. </dd>
  385. <dt>
  386. <strong>', $txt['permissions_profile_copy_from'], ':</strong>
  387. </dt>
  388. <dd>
  389. <select name="copy_from">';
  390. foreach ($context['profiles'] as $id => $profile)
  391. echo '
  392. <option value="', $id, '">', $profile['name'], '</option>';
  393. echo '
  394. </select>
  395. </dd>
  396. </dl>
  397. <hr class="hrcolor" />
  398. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  399. <input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '" />
  400. <input type="submit" name="create" value="', $txt['permissions_profile_new_create'], '" class="button_submit" />
  401. </div>
  402. </div>
  403. </form>
  404. </div>';
  405. }
  406. function template_modify_group()
  407. {
  408. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  409. // Cannot be edited?
  410. if (!$context['profile']['can_modify'])
  411. {
  412. echo '
  413. <div class="errorbox">
  414. ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
  415. </div>';
  416. }
  417. else
  418. {
  419. echo '
  420. <script type="text/javascript"><!-- // --><![CDATA[
  421. window.smf_usedDeny = false;
  422. function warnAboutDeny()
  423. {
  424. if (window.smf_usedDeny)
  425. return confirm("', $txt['permissions_deny_dangerous'], '");
  426. else
  427. return true;
  428. }
  429. // ]]></script>';
  430. }
  431. echo '
  432. <div id="admincenter">
  433. <form 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" id="permissionForm" onsubmit="return warnAboutDeny();">';
  434. if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1)
  435. echo '
  436. <div class="information">
  437. ', $txt['permissions_option_desc'], '
  438. </div>';
  439. echo '
  440. <div class="cat_bar">
  441. <h3 class="catbg">';
  442. if ($context['permission_type'] == 'board')
  443. echo '
  444. ', $txt['permissions_local_for'], ' &quot;', $context['group']['name'], '&quot; ', $txt['permissions_on'], ' &quot;', $context['profile']['name'], '&quot;';
  445. else
  446. echo '
  447. ', $context['permission_type'] == 'membergroup' ? $txt['permissions_general'] : $txt['permissions_board'], ' - &quot;', $context['group']['name'], '&quot;';
  448. echo '
  449. </h3>
  450. </div>
  451. <div class="windowbg">
  452. <div class="content">
  453. ', $txt['permissions_change_view'], ': ', ($context['view_type'] == 'simple' ? '<img src="' . $settings['images_url'] . '/selected.png" alt="*" />' : ''), '<a href="', $scripturl, '?action=admin;area=permissions;sa=modify;group=', $context['group']['id'], ($context['permission_type'] == 'board' ? ';pid=' . $context['profile']['id'] : ''), ';view=simple">', $txt['permissions_view_simple'], '</a> |
  454. ', ($context['view_type'] == 'classic' ? '<img src="' . $settings['images_url'] . '/selected.png" alt="*" />' : ''), '<a href="', $scripturl, '?action=admin;area=permissions;sa=modify;group=', $context['group']['id'], ($context['permission_type'] == 'board' ? ';pid=' . $context['profile']['id'] : ''), ';view=classic">', $txt['permissions_view_classic'], '</a>
  455. </div>
  456. </div>
  457. <div class="flow_hidden">';
  458. // Draw out the main bits.
  459. if ($context['view_type'] == 'simple')
  460. template_modify_group_simple($context['permission_type']);
  461. else
  462. template_modify_group_classic($context['permission_type']);
  463. // If this is general permissions also show the default profile.
  464. if ($context['permission_type'] == 'membergroup')
  465. {
  466. echo '
  467. </div>
  468. <br />
  469. <div class="cat_bar">
  470. <h3 class="catbg">', $txt['permissions_board'], '</h3>
  471. </div>
  472. <div class="information">
  473. ', $txt['permissions_board_desc'], '
  474. </div>
  475. <div class="flow_hidden">';
  476. if ($context['view_type'] == 'simple')
  477. template_modify_group_simple('board');
  478. else
  479. template_modify_group_classic('board');
  480. }
  481. echo '
  482. </div>';
  483. if ($context['profile']['can_modify'])
  484. echo '
  485. <div class="padding">
  486. <input type="submit" value="', $txt['permissions_commit'], '" class="button_submit" />
  487. </div>';
  488. echo '
  489. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  490. <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '" />
  491. </form>
  492. </div>';
  493. }
  494. // A javascript enabled clean permissions view.
  495. function template_modify_group_simple($type)
  496. {
  497. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  498. // Simple only has one column so we only need bother ourself with that one.
  499. $permission_data = &$context['permissions'][$type]['columns'][0];
  500. // Short cut for disabling fields we can't change.
  501. $disable_field = $context['profile']['can_modify'] ? '' : 'disabled="disabled" ';
  502. echo '
  503. <table width="100%" class="table_grid">
  504. <thead>
  505. <tr class="catbg">
  506. <th colspan="2" width="100%" align="left" class="first_th"></th>';
  507. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  508. echo '
  509. <th colspan="3" width="9" class="last_th">&nbsp;</th>';
  510. else
  511. echo '
  512. <th>', $txt['permissions_option_on'], '</th>
  513. <th>', $txt['permissions_option_off'], '</th>
  514. <th class="last_th">', $txt['permissions_option_deny'], '</th>';
  515. echo '
  516. </tr>
  517. </thead>
  518. <tbody>';
  519. foreach ($permission_data as $id_group => $permissionGroup)
  520. {
  521. if (empty($permissionGroup['permissions']))
  522. continue;
  523. // Are we likely to have something in this group to display or is it all hidden?
  524. $has_display_content = false;
  525. if (!$permissionGroup['hidden'])
  526. {
  527. // Before we go any further check we are going to have some data to print otherwise we just have a silly heading.
  528. foreach ($permissionGroup['permissions'] as $permission)
  529. if (!$permission['hidden'])
  530. $has_display_content = true;
  531. if ($has_display_content)
  532. {
  533. echo '
  534. <tr class="windowbg">
  535. <td colspan="2" width="100%" align="left">
  536. <a href="#" onclick="return toggleBreakdown(\'', $id_group, '\');">
  537. <img src="', $settings['images_url'], '/selected_open.png" id="group_toggle_img_', $id_group, '" alt="*" />&nbsp;<strong>', $permissionGroup['name'], '</strong>
  538. </a>
  539. </td>';
  540. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  541. echo '
  542. <td colspan="3" width="10">
  543. <div id="group_select_div_', $id_group, '">
  544. <input type="checkbox" id="group_select_', $id_group, '" name="group_select_', $id_group, '" class="input_check" onclick="determineGroupState(\'', $id_group, '\', this.checked ? \'on\' : \'off\');" style="display: none;" ', $disable_field, '/>
  545. </div>
  546. </td>';
  547. else
  548. echo '
  549. <td align="center">
  550. <div id="group_select_div_on_', $id_group, '">
  551. <input type="radio" id="group_select_on_', $id_group, '" name="group_select_', $id_group, '" value="on" onclick="determineGroupState(\'', $id_group, '\', \'on\');" style="display: none;" ', $disable_field, ' class="input_radio" />
  552. </div>
  553. </td>
  554. <td align="center">
  555. <div id="group_select_div_off_', $id_group, '">
  556. <input type="radio" id="group_select_off_', $id_group, '" name="group_select_', $id_group, '" value="off" onclick="determineGroupState(\'', $id_group, '\', \'off\');" style="display: none;" ', $disable_field, ' class="input_radio" />
  557. </div>
  558. </td>
  559. <td align="center">
  560. <div id="group_select_div_deny_', $id_group, '">
  561. <input type="radio" id="group_select_deny_', $id_group, '" name="group_select_', $id_group, '" value="deny" onclick="determineGroupState(\'', $id_group, '\', \'deny\');" style="display: none;" ', $disable_field, ' class="input_radio" />
  562. </div>
  563. </td>';
  564. echo '
  565. </tr>';
  566. }
  567. }
  568. $alternate = false;
  569. foreach ($permissionGroup['permissions'] as $permission)
  570. {
  571. // If it's hidden keep the last value.
  572. if ($permission['hidden'] || $permissionGroup['hidden'])
  573. {
  574. echo '
  575. <tr style="display: none;">
  576. <td>
  577. <input type="hidden" name="perm[', $type, '][', $permission['id'], ']" value="', $permission['select'] == 'denied' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $permission['select'], '" />
  578. </td>
  579. </tr>';
  580. }
  581. else
  582. {
  583. echo '
  584. <tr id="perm_div_', $id_group, '_', $permission['id'], '" class="', $alternate ? 'windowbg' : 'windowbg2', '">
  585. <td valign="top" width="10" style="padding-right: 1ex;">
  586. ', $permission['help_index'] ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $permission['help_index'] . '" onclick="return reqOverlayDiv(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.png" alt="' . $txt['help'] . '" /></a>' : '', '
  587. </td>
  588. <td valign="top" width="100%" align="left" style="padding-bottom: 2px;">', $permission['name'], '</td>';
  589. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  590. echo '
  591. <td valign="top" style="padding-bottom: 2px;"><input type="checkbox" id="select_', $permission['id'], '" name="perm[', $type, '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' onclick="determineGroupState(\'', $id_group, '\');" value="on" class="input_check" ', $disable_field, '/></td>';
  592. else
  593. echo '
  594. <td valign="top" width="10" style="padding-bottom: 2px;"><input type="radio" id="select_on_', $permission['id'], '" name="perm[', $type, '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" onclick="determineGroupState(\'', $id_group, '\');" class="input_radio" ', $disable_field, '/></td>
  595. <td valign="top" width="10" style="padding-bottom: 2px;"><input type="radio" id="select_off_', $permission['id'], '" name="perm[', $type, '][', $permission['id'], ']"', $permission['select'] == 'off' ? ' checked="checked"' : '', ' value="off" onclick="determineGroupState(\'', $id_group, '\');" class="input_radio" ', $disable_field, '/></td>
  596. <td valign="top" width="10" style="padding-bottom: 2px;"><input type="radio" id="select_deny_', $permission['id'], '" name="perm[', $type, '][', $permission['id'], ']"', $permission['select'] == 'denied' ? ' checked="checked"' : '', ' value="deny" onclick="window.smf_usedDeny = true; determineGroupState(\'', $id_group, '\');" class="input_radio" ', $disable_field, '/></td>';
  597. echo '
  598. </tr>';
  599. }
  600. $alternate = !$alternate;
  601. }
  602. if (!$permissionGroup['hidden'] && $has_display_content)
  603. echo '
  604. <tr id="group_hr_div_', $id_group, '" class="windowbg2 perm_groups">
  605. <td colspan="5" width="100%"></td>
  606. </tr>';
  607. }
  608. echo '
  609. </tbody>
  610. </table>
  611. <script type="text/javascript"><!-- // --><![CDATA[';
  612. if ($context['profile']['can_modify'] && empty($context['simple_javascript_displayed']))
  613. {
  614. // Only show this once.
  615. $context['simple_javascript_displayed'] = true;
  616. // This function decides what to do when ANYTHING is touched!
  617. echo '
  618. var groupPermissions = new Array();
  619. function determineGroupState(id_group, forceState)
  620. {
  621. if (typeof(forceState) != "undefined")
  622. thisState = forceState;
  623. // Cycle through this groups elements.
  624. var curState = false, thisState;
  625. for (var i = 0; i < groupPermissions[id_group].length; i++)
  626. {';
  627. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  628. echo '
  629. if (typeof(forceState) != "undefined")
  630. {
  631. document.getElementById(\'select_\' + groupPermissions[id_group][i]).checked = forceState == \'on\' ? 1 : 0;
  632. }
  633. thisState = document.getElementById(\'select_\' + groupPermissions[id_group][i]).checked ? \'on\' : \'off\';';
  634. else
  635. echo '
  636. if (typeof(forceState) != "undefined")
  637. {
  638. document.getElementById(\'select_on_\' + groupPermissions[id_group][i]).checked = forceState == \'on\' ? 1 : 0;
  639. document.getElementById(\'select_off_\' + groupPermissions[id_group][i]).checked = forceState == \'off\' ? 1 : 0;
  640. document.getElementById(\'select_deny_\' + groupPermissions[id_group][i]).checked = forceState == \'deny\' ? 1 : 0;
  641. }
  642. if (document.getElementById(\'select_on_\' + groupPermissions[id_group][i]).checked)
  643. thisState = \'on\';
  644. else if (document.getElementById(\'select_off_\' + groupPermissions[id_group][i]).checked)
  645. thisState = \'off\';
  646. else
  647. thisState = \'deny\';';
  648. echo '
  649. // Unless this is the first element, or it\'s the same state as the last we\'re buggered.
  650. if (curState == false || thisState == curState)
  651. {
  652. curState = thisState;
  653. }
  654. else
  655. {
  656. curState = \'fudged\';
  657. i = 999;
  658. }
  659. }
  660. // First check the right master is selected!';
  661. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  662. echo '
  663. document.getElementById("group_select_" + id_group).checked = curState == \'on\' ? 1 : 0;';
  664. else
  665. echo '
  666. document.getElementById("group_select_on_" + id_group).checked = curState == \'on\' ? 1 : 0;
  667. document.getElementById("group_select_off_" + id_group).checked = curState == \'off\' ? 1 : 0;
  668. document.getElementById("group_select_deny_" + id_group).checked = curState == \'deny\' ? 1 : 0;';
  669. // Force the display?
  670. echo '
  671. if (curState != \'fudged\')
  672. toggleBreakdown(id_group, "none");';
  673. echo '
  674. }';
  675. }
  676. // Some more javascript to be displayed as long as we are editing.
  677. if ($context['profile']['can_modify'])
  678. {
  679. foreach ($permission_data as $id_group => $permissionGroup)
  680. {
  681. if (empty($permissionGroup['permissions']))
  682. continue;
  683. // As before...
  684. $has_display_content = false;
  685. if (!$permissionGroup['hidden'])
  686. {
  687. // Make sure we can show it.
  688. foreach ($permissionGroup['permissions'] as $permission)
  689. if (!$permission['hidden'])
  690. $has_display_content = true;
  691. // Make all the group indicators visible on JS only.
  692. if ($has_display_content)
  693. {
  694. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  695. echo '
  696. document.getElementById("group_select_div_', $id_group, '").parentNode.className = "lockedbg";
  697. document.getElementById("group_select_', $id_group, '").style.display = "";';
  698. else
  699. echo '
  700. document.getElementById("group_select_div_on_', $id_group, '").parentNode.className = "lockedbg";
  701. document.getElementById("group_select_div_off_', $id_group, '").parentNode.className = "lockedbg";
  702. document.getElementById("group_select_div_deny_', $id_group, '").parentNode.className = "lockedbg";
  703. document.getElementById("group_select_on_', $id_group, '").style.display = "";
  704. document.getElementById("group_select_off_', $id_group, '").style.display = "";
  705. document.getElementById("group_select_deny_', $id_group, '").style.display = "";';
  706. }
  707. $perm_ids = array();
  708. $count = 0;
  709. foreach ($permissionGroup['permissions'] as $permission)
  710. {
  711. if (!$permission['hidden'])
  712. {
  713. // Need this for knowing what can be tweaked.
  714. $perm_ids[] = "'$permission[id]'";
  715. }
  716. }
  717. // Declare this groups permissions into an array.
  718. if (!empty($perm_ids))
  719. echo '
  720. groupPermissions[\'', $id_group, '\'] = new Array(', count($perm_ids), ');';
  721. foreach ($perm_ids as $count => $id)
  722. echo '
  723. groupPermissions[\'', $id_group, '\'][', $count, '] = ', $id, ';';
  724. // Show the group as required.
  725. if ($has_display_content)
  726. echo '
  727. determineGroupState(\'', $id_group, '\');';
  728. }
  729. }
  730. }
  731. echo '
  732. // ]]></script>';
  733. }
  734. // The SMF 1.x way of looking at permissions.
  735. function template_modify_group_classic($type)
  736. {
  737. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  738. $permission_type = &$context['permissions'][$type];
  739. $disable_field = $context['profile']['can_modify'] ? '' : 'disabled="disabled" ';
  740. echo '
  741. <div class="windowbg2">
  742. <div class="content">';
  743. foreach ($permission_type['columns'] as $column)
  744. {
  745. echo '
  746. <table width="49%" class="table_grid perm_classic floatleft">';
  747. foreach ($column as $permissionGroup)
  748. {
  749. if (empty($permissionGroup['permissions']))
  750. continue;
  751. // Are we likely to have something in this group to display or is it all hidden?
  752. $has_display_content = false;
  753. if (!$permissionGroup['hidden'])
  754. {
  755. // Before we go any further check we are going to have some data to print otherwise we just have a silly heading.
  756. foreach ($permissionGroup['permissions'] as $permission)
  757. if (!$permission['hidden'])
  758. $has_display_content = true;
  759. if ($has_display_content)
  760. {
  761. echo '
  762. <tr class="catbg">
  763. <th colspan="2" width="100%" align="left"><strong class="smalltext">', $permissionGroup['name'], '</strong></th>';
  764. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  765. echo '
  766. <th colspan="3" width="10"></th>';
  767. else
  768. echo '
  769. <th align="center"><div>', $txt['permissions_option_on'], '</div></th>
  770. <th align="center"><div>', $txt['permissions_option_off'], '</div></th>
  771. <th align="center"><div>', $txt['permissions_option_deny'], '</div></th>';
  772. echo '
  773. </tr>';
  774. }
  775. }
  776. $alternate = false;
  777. foreach ($permissionGroup['permissions'] as $permission)
  778. {
  779. // If it's hidden keep the last value.
  780. if ($permission['hidden'] || $permissionGroup['hidden'])
  781. {
  782. echo '
  783. <tr style="display: none;">
  784. <td>';
  785. if ($permission['has_own_any'])
  786. {
  787. // Guests can't have own permissions.
  788. if ($context['group']['id'] != -1)
  789. echo '
  790. <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'], '" />';
  791. echo '
  792. <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'], '" />';
  793. }
  794. else
  795. echo '
  796. <input type="hidden" name="perm[', $permission_type['id'], '][', $permission['id'], ']" value="', $permission['select'] == 'denied' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $permission['select'], '" />';
  797. echo '
  798. </td>
  799. </tr>';
  800. }
  801. else
  802. {
  803. echo '
  804. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
  805. <td width="10">
  806. ', $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>' : '', '
  807. </td>';
  808. if ($permission['has_own_any'])
  809. {
  810. echo '
  811. <td colspan="4" width="100%" align="left">', $permission['name'], '</td>
  812. </tr><tr class="', $alternate ? 'windowbg' : 'windowbg2', '">';
  813. // Guests can't do their own thing.
  814. if ($context['group']['id'] != -1)
  815. {
  816. echo '
  817. <td></td>
  818. <td width="100%" class="smalltext" align="right">', $permission['own']['name'], ':</td>';
  819. if (empty($modSettings['permission_enable_deny']))
  820. echo '
  821. <td colspan="3"><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, '/></td>';
  822. else
  823. echo '
  824. <td width="10"><input type="radio" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" id="', $permission['own']['id'], '_on" class="input_radio" ', $disable_field, '/></td>
  825. <td width="10"><input type="radio" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'off' ? ' checked="checked"' : '', ' value="off" class="input_radio" ', $disable_field, '/></td>
  826. <td width="10"><input type="radio" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'denied' ? ' checked="checked"' : '', ' value="deny" class="input_radio" ', $disable_field, '/></td>';
  827. echo '
  828. </tr><tr class="', $alternate ? 'windowbg' : 'windowbg2', '">';
  829. }
  830. echo '
  831. <td></td>
  832. <td width="100%" class="smalltext" align="right">', $permission['any']['name'], ':</td>';
  833. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  834. echo '
  835. <td colspan="3"><input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_check" ', $disable_field, '/></td>';
  836. else
  837. echo '
  838. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" onclick="document.forms.permissionForm.', $permission['own']['id'], '_on.checked = true;" class="input_radio" ', $disable_field, '/></td>
  839. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'off' ? ' checked="checked"' : '', ' value="off" class="input_radio" ', $disable_field, '/></td>
  840. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select']== 'denied' ? ' checked="checked"' : '', ' value="deny" id="', $permission['any']['id'], '_deny" onclick="window.smf_usedDeny = true;" class="input_radio" ', $disable_field, '/></td>';
  841. echo '
  842. </tr>';
  843. }
  844. else
  845. {
  846. echo '
  847. <td width="100%" align="left">', $permission['name'], '</td>';
  848. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  849. echo '
  850. <td><input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_check" ', $disable_field, '/></td>';
  851. else
  852. echo '
  853. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_radio" ', $disable_field, '/></td>
  854. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'off' ? ' checked="checked"' : '', ' value="off" class="input_radio" ', $disable_field, '/></td>
  855. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'denied' ? ' checked="checked"' : '', ' value="deny" onclick="window.smf_usedDeny = true;" class="input_radio" ', $disable_field, '/></td>';
  856. echo '
  857. </tr>';
  858. }
  859. }
  860. $alternate = !$alternate;
  861. }
  862. if (!$permissionGroup['hidden'] && $has_display_content)
  863. echo '
  864. <tr class="windowbg2">
  865. <td colspan="5" width="100%"><!--separator--></td>
  866. </tr>';
  867. }
  868. echo '
  869. </table>';
  870. }
  871. echo '
  872. <br class="clear" />
  873. </div>
  874. </div>';
  875. }
  876. function template_inline_permissions()
  877. {
  878. global $context, $settings, $options, $txt, $modSettings;
  879. echo '
  880. <fieldset id="', $context['current_permission'], '">
  881. <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>';
  882. if (empty($modSettings['permission_enable_deny']))
  883. echo '
  884. <ul class="permission_groups">';
  885. else
  886. echo '
  887. <div class="information">', $txt['permissions_option_desc'], '</div>
  888. <dl class="settings">
  889. <dt>
  890. <span class="perms"><strong>', $txt['permissions_option_on'], '</strong></span>
  891. <span class="perms"><strong>', $txt['permissions_option_off'], '</strong></span>
  892. <span class="perms" style="color: red;"><strong>', $txt['permissions_option_deny'], '</strong></span>
  893. </dt>
  894. <dd>
  895. </dd>';
  896. foreach ($context['member_groups'] as $group)
  897. {
  898. if (!empty($modSettings['permission_enable_deny']))
  899. echo '
  900. <dt>';
  901. else
  902. echo '
  903. <li>';
  904. if (empty($modSettings['permission_enable_deny']))
  905. echo '
  906. <input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked="checked"' : '', ' class="input_check" />';
  907. else
  908. echo '
  909. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked="checked"' : '', ' class="input_radio" /></span>
  910. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked="checked"' : '', ' class="input_radio" /></span>
  911. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked="checked"' : '', ' class="input_radio" /></span>';
  912. if (!empty($modSettings['permission_enable_deny']))
  913. echo '
  914. </dt>
  915. <dd>
  916. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  917. </dd>';
  918. else
  919. echo '
  920. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  921. </li>';
  922. }
  923. if (empty($modSettings['permission_enable_deny']))
  924. echo '
  925. </ul>';
  926. else
  927. echo '
  928. </dl>';
  929. echo '
  930. </fieldset>
  931. <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>
  932. <script type="text/javascript"><!-- // --><![CDATA[
  933. document.getElementById("', $context['current_permission'], '").style.display = "none";
  934. document.getElementById("', $context['current_permission'], '_groups_link").style.display = "";
  935. // ]]></script>';
  936. }
  937. // Edit post moderation permissions.
  938. function template_postmod_permissions()
  939. {
  940. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  941. echo '
  942. <div id="admincenter">
  943. <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'], '">
  944. <div class="title_bar">
  945. <h3 class="titlebg">', $txt['permissions_post_moderation'], '</h3>
  946. </div>';
  947. // Got advanced permissions - if so warn!
  948. if (!empty($modSettings['permission_enable_deny']))
  949. echo '
  950. <div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>';
  951. echo '
  952. <div class="righttext padding">
  953. ', $txt['permissions_post_moderation_select'], ':
  954. <select name="pid" onchange="document.forms.postmodForm.submit();">';
  955. foreach ($context['profiles'] as $profile)
  956. if ($profile['can_modify'])
  957. echo '
  958. <option value="', $profile['id'], '" ', $profile['id'] == $context['current_profile'] ? 'selected="selected"' : '', '>', $profile['name'], '</option>';
  959. echo '
  960. </select>
  961. <input type="submit" value="', $txt['go'], '" class="button_submit" style="margin-top: 5px;" />
  962. </div>
  963. <table width="100%" class="table_grid">
  964. <thead>
  965. <tr class="catbg">
  966. <th class="first_th"></th>
  967. <th align="center" colspan="3">
  968. ', $txt['permissions_post_moderation_new_topics'], '
  969. </th>
  970. <th align="center" colspan="3">
  971. ', $txt['permissions_post_moderation_replies_own'], '
  972. </th>
  973. <th align="center" colspan="3">
  974. ', $txt['permissions_post_moderation_replies_any'], '
  975. </th>
  976. <th class="last_th" align="center" colspan="3">
  977. ', $txt['permissions_post_moderation_attachments'], '
  978. </th>
  979. </tr>
  980. <tr class="titlebg">
  981. <th width="30%">
  982. ', $txt['permissions_post_moderation_group'], '
  983. </th>
  984. <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>
  985. <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>
  986. <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>
  987. <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>
  988. <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>
  989. <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>
  990. <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>
  991. <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>
  992. <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>
  993. <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>
  994. <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>
  995. <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>
  996. </tr>
  997. </thead>
  998. <tbody>';
  999. foreach ($context['profile_groups'] as $group)
  1000. {
  1001. echo '
  1002. <tr>
  1003. <td width="40%" class="windowbg">
  1004. <span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>';
  1005. if (!empty($group['children']))
  1006. echo '
  1007. <br /><span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
  1008. echo '
  1009. </td>
  1010. <td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="allow" ', $group['new_topic'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1011. <td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="moderate" ', $group['new_topic'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1012. <td align="center" class="windowbg2"><input type="radio" name="new_topic[', $group['id'], ']" value="disallow" ', $group['new_topic'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1013. <td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="allow" ', $group['replies_own'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1014. <td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="moderate" ', $group['replies_own'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1015. <td align="center" class="windowbg"><input type="radio" name="replies_own[', $group['id'], ']" value="disallow" ', $group['replies_own'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1016. <td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="allow" ', $group['replies_any'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1017. <td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="moderate" ', $group['replies_any'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1018. <td align="center" class="windowbg2"><input type="radio" name="replies_any[', $group['id'], ']" value="disallow" ', $group['replies_any'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1019. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="allow" ', $group['attachment'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1020. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="moderate" ', $group['attachment'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1021. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="disallow" ', $group['attachment'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1022. </tr>';
  1023. }
  1024. echo '
  1025. </tbody>
  1026. </table>
  1027. <div class="righttext padding">
  1028. <input type="submit" name="save_changes" value="', $txt['permissions_commit'], '" class="button_submit" />
  1029. <input type="hidden" name="', $context['admin-mppm_token_var'], '" value="', $context['admin-mppm_token'], '" />
  1030. </div>
  1031. </form>
  1032. <p class="smalltext" style="padding-left: 10px;">
  1033. <strong>', $txt['permissions_post_moderation_legend'], ':</strong><br />
  1034. <img src="', $settings['default_images_url'], '/admin/post_moderation_allow.png" alt="', $txt['permissions_post_moderation_allow'], '" /> - ', $txt['permissions_post_moderation_allow'], '<br />
  1035. <img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.png" alt="', $txt['permissions_post_moderation_moderate'], '" /> - ', $txt['permissions_post_moderation_moderate'], '<br />
  1036. <img src="', $settings['default_images_url'], '/admin/post_moderation_deny.png" alt="', $txt['permissions_post_moderation_disallow'], '" /> - ', $txt['permissions_post_moderation_disallow'], '
  1037. </p>
  1038. </div>';
  1039. }
  1040. ?>