ManagePermissions.template.php 53 KB

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