ManagePermissions.template.php 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2011 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.0
  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 reqWin(this.href);">?</a>)' : ($group['id'] == 0 ? ' (<a href="' . $scripturl . '?action=helpadmin;help=membergroup_regular_members" onclick="return reqWin(this.href);">?</a>)' : ($group['id'] == 1 ? ' (<a href="' . $scripturl . '?action=helpadmin;help=membergroup_administrator" onclick="return reqWin(this.href);">?</a>)' : ($group['id'] == 3 ? ' (<a href="' . $scripturl . '?action=helpadmin;help=membergroup_moderator" onclick="return reqWin(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. <span class="ie6_header floatleft">
  87. <img src="', $settings['images_url'], '/', empty($context['show_advanced_options']) ? 'selected' : 'sort_down', '.gif" id="permissions_panel_toggle" alt="*" /> ', $txt['permissions_advanced_options'], '
  88. </span>
  89. </h3>
  90. </div>
  91. <div id="permissions_panel_advanced" class="windowbg">
  92. <span class="topslice"><span></span></span>
  93. <div class="content">
  94. <fieldset>
  95. <legend>', $txt['permissions_with_selection'], '</legend>
  96. <dl class="settings admin_permissions">
  97. <dt>
  98. ', $txt['permissions_apply_pre_defined'], ' <a href="', $scripturl, '?action=helpadmin;help=permissions_quickgroups" onclick="return reqWin(this.href);">(?)</a>:
  99. </dt>
  100. <dd>
  101. <select name="predefined">
  102. <option value="">(', $txt['permissions_select_pre_defined'], ')</option>
  103. <option value="restrict">', $txt['permitgroups_restrict'], '</option>
  104. <option value="standard">', $txt['permitgroups_standard'], '</option>
  105. <option value="moderator">', $txt['permitgroups_moderator'], '</option>
  106. <option value="maintenance">', $txt['permitgroups_maintenance'], '</option>
  107. </select>
  108. </dd>
  109. <dt>
  110. ', $txt['permissions_like_group'], ':
  111. </dt>
  112. <dd>
  113. <select name="copy_from">
  114. <option value="empty">(', $txt['permissions_select_membergroup'], ')</option>';
  115. foreach ($context['groups'] as $group)
  116. {
  117. if ($group['id'] != 1)
  118. echo '
  119. <option value="', $group['id'], '">', $group['name'], '</option>';
  120. }
  121. echo '
  122. </select>
  123. </dd>
  124. <dt>
  125. <select name="add_remove">
  126. <option value="add">', $txt['permissions_add'], '...</option>
  127. <option value="clear">', $txt['permissions_remove'], '...</option>';
  128. if (!empty($modSettings['permission_enable_deny']))
  129. echo '
  130. <option value="deny">', $txt['permissions_deny'], '...</option>';
  131. echo '
  132. </select>
  133. </dt>
  134. <dd style="overflow:auto;">
  135. <select name="permissions">
  136. <option value="">(', $txt['permissions_select_permission'], ')</option>';
  137. foreach ($context['permissions'] as $permissionType)
  138. {
  139. if ($permissionType['id'] == 'membergroup' && !empty($context['profile']))
  140. continue;
  141. foreach ($permissionType['columns'] as $column)
  142. {
  143. foreach ($column as $permissionGroup)
  144. {
  145. if ($permissionGroup['hidden'])
  146. continue;
  147. echo '
  148. <option value="" disabled="disabled">[', $permissionGroup['name'], ']</option>';
  149. foreach ($permissionGroup['permissions'] as $perm)
  150. {
  151. if ($perm['hidden'])
  152. continue;
  153. if ($perm['has_own_any'])
  154. echo '
  155. <option value="', $permissionType['id'], '/', $perm['own']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['own']['name'], ')</option>
  156. <option value="', $permissionType['id'], '/', $perm['any']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['any']['name'], ')</option>';
  157. else
  158. echo '
  159. <option value="', $permissionType['id'], '/', $perm['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], '</option>';
  160. }
  161. }
  162. }
  163. }
  164. echo '
  165. </select>
  166. </dd>
  167. </dl>
  168. </fieldset>
  169. <div class="righttext">
  170. <input type="submit" value="', $txt['permissions_set_permissions'], '" onclick="return checkSubmit();" class="button_submit" />
  171. </div>
  172. </div>
  173. <span class="botslice"><span></span></span>
  174. </div>';
  175. // Javascript for the advanced stuff.
  176. echo '
  177. <script type="text/javascript"><!-- // --><![CDATA[
  178. var oPermissionsPanelToggle = new smc_Toggle({
  179. bToggleEnabled: true,
  180. bCurrentlyCollapsed: ', empty($context['show_advanced_options']) ? 'true' : 'false', ',
  181. aSwappableContainers: [
  182. \'permissions_panel_advanced\'
  183. ],
  184. aSwapImages: [
  185. {
  186. sId: \'permissions_panel_toggle\',
  187. srcExpanded: smf_images_url + \'/sort_down.gif\',
  188. altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
  189. srcCollapsed: smf_images_url + \'/selected.gif\',
  190. altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
  191. }
  192. ],
  193. oThemeOptions: {
  194. bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
  195. sOptionName: \'admin_preferences\',
  196. sSessionVar: ', JavaScriptEscape($context['session_var']), ',
  197. sSessionId: ', JavaScriptEscape($context['session_id']), ',
  198. sThemeId: \'1\',
  199. sAdditionalVars: \';admin_key=app\'
  200. }
  201. });';
  202. echo '
  203. function checkSubmit()
  204. {
  205. 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 != ""))
  206. {
  207. alert("', $txt['permissions_only_one_option'], '");
  208. return false;
  209. }
  210. if (document.forms.permissionForm.predefined.value == "" && document.forms.permissionForm.copy_from.value == "" && document.forms.permissionForm.permissions.value == "")
  211. {
  212. alert("', $txt['permissions_no_action'], '");
  213. return false;
  214. }
  215. if (document.forms.permissionForm.permissions.value != "" && document.forms.permissionForm.add_remove.value == "deny")
  216. return confirm("', $txt['permissions_deny_dangerous'], '");
  217. return true;
  218. }
  219. // ]]></script>';
  220. if (!empty($context['profile']))
  221. echo '
  222. <input type="hidden" name="pid" value="', $context['profile']['id'], '" />';
  223. echo '
  224. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />';
  225. }
  226. else
  227. echo '
  228. </table>';
  229. echo '
  230. </form>
  231. </div>
  232. <br class="clear" />';
  233. }
  234. function template_by_board()
  235. {
  236. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  237. echo '
  238. <form id="admincenter" action="', $scripturl, '?action=admin;area=permissions;sa=board" method="post" accept-charset="', $context['character_set'], '">
  239. <div class="cat_bar">
  240. <h3 class="catbg">', $txt['permissions_boards'], '</h3>
  241. </div>
  242. <div class="information">
  243. ', $txt['permissions_boards_desc'], '
  244. </div>
  245. <div class="title_bar">
  246. <h3 id="board_permissions" class="titlebg flow_hidden">
  247. <span class="perm_name floatleft">', $txt['board_name'], '</span>
  248. <span class="perm_profile floatleft">', $txt['permission_profile'], '</span>
  249. </h3>
  250. </div>';
  251. if (!$context['edit_all'])
  252. echo '
  253. <div class="righttext">
  254. <a href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">[', $txt['permissions_board_all'], ']</a>
  255. </div>';
  256. foreach ($context['categories'] as $category)
  257. {
  258. echo '
  259. <div class="cat_bar">
  260. <h3 class="catbg"><strong>', $category['name'], '</strong></h3>
  261. </div>';
  262. if (!empty($category['boards']))
  263. echo '
  264. <div class="windowbg">
  265. <span class="topslice"><span></span></span>
  266. <div class="content">
  267. <ul class="perm_boards flow_hidden">';
  268. $alternate = false;
  269. foreach ($category['boards'] as $board)
  270. {
  271. $alternate = !$alternate;
  272. echo '
  273. <li class="flow_hidden' ,' windowbg', $alternate ? '' : '2','">
  274. <span class="perm_board floatleft">
  275. <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>
  276. </span>
  277. <span class="perm_boardprofile floatleft">';
  278. if ($context['edit_all'])
  279. {
  280. echo '
  281. <select name="boardprofile[', $board['id'], ']">';
  282. foreach ($context['profiles'] as $id => $profile)
  283. echo '
  284. <option value="', $id, '" ', $id == $board['profile'] ? 'selected="selected"' : '', '>', $profile['name'], '</option>';
  285. echo '
  286. </select>';
  287. }
  288. else
  289. echo '
  290. <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $board['profile'], ';', $context['session_var'], '=', $context['session_id'], '"> [', $board['profile_name'], ']</a>';
  291. echo '
  292. </span>
  293. </li>';
  294. }
  295. if (!empty($category['boards']))
  296. echo '
  297. </ul>
  298. </div>
  299. <span class="botslice"><span></span></span>
  300. </div>';
  301. }
  302. echo '
  303. <div class="righttext">';
  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 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. </div>
  313. </form>
  314. <br class="clear" />';
  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="righttext padding">
  362. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />';
  363. if ($context['can_edit_something'])
  364. echo '
  365. <input type="submit" name="rename" value="', empty($context['show_rename_boxes']) ? $txt['permissions_profile_rename'] : $txt['permissions_commit'], '" class="button_submit" />';
  366. echo '
  367. <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" class="button_submit" />
  368. </div>
  369. </form>
  370. <br />
  371. <form action="', $scripturl, '?action=admin;area=permissions;sa=profiles" method="post" accept-charset="', $context['character_set'], '">
  372. <div class="cat_bar">
  373. <h3 class="catbg">', $txt['permissions_profile_new'], '</h3>
  374. </div>
  375. <div class="windowbg">
  376. <span class="topslice"><span></span></span>
  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. <div class="righttext">
  398. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  399. <input type="submit" name="create" value="', $txt['permissions_profile_new_create'], '" class="button_submit" />
  400. </div>
  401. </div>
  402. <span class="botslice"><span></span></span>
  403. </div>
  404. </form>
  405. </div>
  406. <br class="clear" />';
  407. }
  408. function template_modify_group()
  409. {
  410. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  411. // Cannot be edited?
  412. if (!$context['profile']['can_modify'])
  413. {
  414. echo '
  415. <div class="errorbox">
  416. ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
  417. </div>';
  418. }
  419. else
  420. {
  421. echo '
  422. <script type="text/javascript"><!-- // --><![CDATA[
  423. window.smf_usedDeny = false;
  424. function warnAboutDeny()
  425. {
  426. if (window.smf_usedDeny)
  427. return confirm("', $txt['permissions_deny_dangerous'], '");
  428. else
  429. return true;
  430. }
  431. // ]]></script>';
  432. }
  433. echo '
  434. <div id="admincenter">
  435. <form 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();">';
  436. if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1)
  437. echo '
  438. <div class="information">
  439. ', $txt['permissions_option_desc'], '
  440. </div>';
  441. echo '
  442. <div class="cat_bar">
  443. <h3 class="catbg">';
  444. if ($context['permission_type'] == 'board')
  445. echo '
  446. ', $txt['permissions_local_for'], ' &quot;', $context['group']['name'], '&quot; ', $txt['permissions_on'], ' &quot;', $context['profile']['name'], '&quot;';
  447. else
  448. echo '
  449. ', $context['permission_type'] == 'membergroup' ? $txt['permissions_general'] : $txt['permissions_board'], ' - &quot;', $context['group']['name'], '&quot;';
  450. echo '
  451. </h3>
  452. </div>
  453. <div class="windowbg">
  454. <span class="topslice"><span></span></span>
  455. <div class="content">
  456. ', $txt['permissions_change_view'], ': ', ($context['view_type'] == 'simple' ? '<img src="' . $settings['images_url'] . '/selected.gif" 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> |
  457. ', ($context['view_type'] == 'classic' ? '<img src="' . $settings['images_url'] . '/selected.gif" 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>
  458. </div>
  459. <span class="botslice"><span></span></span>
  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="righttext 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. </form>
  495. </div>
  496. <br class="clear" />';
  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'], '/sort_down.gif" 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 reqWin(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.gif" 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. // Manually toggle the breakdown.
  621. echo '
  622. function toggleBreakdown(id_group, forcedisplayType)
  623. {
  624. displayType = document.getElementById("group_hr_div_" + id_group).style.display == "none" ? "" : "none";
  625. if (typeof(forcedisplayType) != "undefined")
  626. displayType = forcedisplayType;
  627. for (i = 0; i < groupPermissions[id_group].length; i++)
  628. {
  629. document.getElementById("perm_div_" + id_group + "_" + groupPermissions[id_group][i]).style.display = displayType
  630. }
  631. document.getElementById("group_hr_div_" + id_group).style.display = displayType
  632. document.getElementById("group_toggle_img_" + id_group).src = "', $settings['images_url'], '/" + (displayType == "none" ? "selected" : "sort_down") + ".gif";
  633. return false;
  634. }';
  635. // This function decides what to do when ANYTHING is touched!
  636. echo '
  637. var groupPermissions = new Array();
  638. function determineGroupState(id_group, forceState)
  639. {
  640. if (typeof(forceState) != "undefined")
  641. thisState = forceState;
  642. // Cycle through this groups elements.
  643. var curState = false, thisState;
  644. for (var i = 0; i < groupPermissions[id_group].length; i++)
  645. {';
  646. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  647. echo '
  648. if (typeof(forceState) != "undefined")
  649. {
  650. document.getElementById(\'select_\' + groupPermissions[id_group][i]).checked = forceState == \'on\' ? 1 : 0;
  651. }
  652. thisState = document.getElementById(\'select_\' + groupPermissions[id_group][i]).checked ? \'on\' : \'off\';';
  653. else
  654. echo '
  655. if (typeof(forceState) != "undefined")
  656. {
  657. document.getElementById(\'select_on_\' + groupPermissions[id_group][i]).checked = forceState == \'on\' ? 1 : 0;
  658. document.getElementById(\'select_off_\' + groupPermissions[id_group][i]).checked = forceState == \'off\' ? 1 : 0;
  659. document.getElementById(\'select_deny_\' + groupPermissions[id_group][i]).checked = forceState == \'deny\' ? 1 : 0;
  660. }
  661. if (document.getElementById(\'select_on_\' + groupPermissions[id_group][i]).checked)
  662. thisState = \'on\';
  663. else if (document.getElementById(\'select_off_\' + groupPermissions[id_group][i]).checked)
  664. thisState = \'off\';
  665. else
  666. thisState = \'deny\';';
  667. echo '
  668. // Unless this is the first element, or it\'s the same state as the last we\'re buggered.
  669. if (curState == false || thisState == curState)
  670. {
  671. curState = thisState;
  672. }
  673. else
  674. {
  675. curState = \'fudged\';
  676. i = 999;
  677. }
  678. }
  679. // First check the right master is selected!';
  680. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  681. echo '
  682. document.getElementById("group_select_" + id_group).checked = curState == \'on\' ? 1 : 0;';
  683. else
  684. echo '
  685. document.getElementById("group_select_on_" + id_group).checked = curState == \'on\' ? 1 : 0;
  686. document.getElementById("group_select_off_" + id_group).checked = curState == \'off\' ? 1 : 0;
  687. document.getElementById("group_select_deny_" + id_group).checked = curState == \'deny\' ? 1 : 0;';
  688. // Force the display?
  689. echo '
  690. if (curState != \'fudged\')
  691. toggleBreakdown(id_group, "none");';
  692. echo '
  693. }';
  694. }
  695. // Some more javascript to be displayed as long as we are editing.
  696. if ($context['profile']['can_modify'])
  697. {
  698. foreach ($permission_data as $id_group => $permissionGroup)
  699. {
  700. if (empty($permissionGroup['permissions']))
  701. continue;
  702. // As before...
  703. $has_display_content = false;
  704. if (!$permissionGroup['hidden'])
  705. {
  706. // Make sure we can show it.
  707. foreach ($permissionGroup['permissions'] as $permission)
  708. if (!$permission['hidden'])
  709. $has_display_content = true;
  710. // Make all the group indicators visible on JS only.
  711. if ($has_display_content)
  712. {
  713. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  714. echo '
  715. document.getElementById("group_select_div_', $id_group, '").parentNode.className = "lockedbg";
  716. document.getElementById("group_select_', $id_group, '").style.display = "";';
  717. else
  718. echo '
  719. document.getElementById("group_select_div_on_', $id_group, '").parentNode.className = "lockedbg";
  720. document.getElementById("group_select_div_off_', $id_group, '").parentNode.className = "lockedbg";
  721. document.getElementById("group_select_div_deny_', $id_group, '").parentNode.className = "lockedbg";
  722. document.getElementById("group_select_on_', $id_group, '").style.display = "";
  723. document.getElementById("group_select_off_', $id_group, '").style.display = "";
  724. document.getElementById("group_select_deny_', $id_group, '").style.display = "";';
  725. }
  726. $perm_ids = array();
  727. $count = 0;
  728. foreach ($permissionGroup['permissions'] as $permission)
  729. {
  730. if (!$permission['hidden'])
  731. {
  732. // Need this for knowing what can be tweaked.
  733. $perm_ids[] = "'$permission[id]'";
  734. }
  735. }
  736. // Declare this groups permissions into an array.
  737. if (!empty($perm_ids))
  738. echo '
  739. groupPermissions[\'', $id_group, '\'] = new Array(', count($perm_ids), ');';
  740. foreach ($perm_ids as $count => $id)
  741. echo '
  742. groupPermissions[\'', $id_group, '\'][', $count, '] = ', $id, ';';
  743. // Show the group as required.
  744. if ($has_display_content)
  745. echo '
  746. determineGroupState(\'', $id_group, '\');';
  747. }
  748. }
  749. }
  750. echo '
  751. // ]]></script>';
  752. }
  753. // The SMF 1.x way of looking at permissions.
  754. function template_modify_group_classic($type)
  755. {
  756. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  757. $permission_type = &$context['permissions'][$type];
  758. $disable_field = $context['profile']['can_modify'] ? '' : 'disabled="disabled" ';
  759. echo '
  760. <div class="windowbg2">
  761. <span class="topslice"><span></span></span>
  762. <div class="content">';
  763. foreach ($permission_type['columns'] as $column)
  764. {
  765. echo '
  766. <table width="49%" class="table_grid perm_classic floatleft">';
  767. foreach ($column as $permissionGroup)
  768. {
  769. if (empty($permissionGroup['permissions']))
  770. continue;
  771. // Are we likely to have something in this group to display or is it all hidden?
  772. $has_display_content = false;
  773. if (!$permissionGroup['hidden'])
  774. {
  775. // Before we go any further check we are going to have some data to print otherwise we just have a silly heading.
  776. foreach ($permissionGroup['permissions'] as $permission)
  777. if (!$permission['hidden'])
  778. $has_display_content = true;
  779. if ($has_display_content)
  780. {
  781. echo '
  782. <tr class="catbg">
  783. <th colspan="2" width="100%" align="left"><strong class="smalltext">', $permissionGroup['name'], '</strong></th>';
  784. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  785. echo '
  786. <th colspan="3" width="10"></th>';
  787. else
  788. echo '
  789. <th align="center"><div>', $txt['permissions_option_on'], '</div></th>
  790. <th align="center"><div>', $txt['permissions_option_off'], '</div></th>
  791. <th align="center"><div>', $txt['permissions_option_deny'], '</div></th>';
  792. echo '
  793. </tr>';
  794. }
  795. }
  796. $alternate = false;
  797. foreach ($permissionGroup['permissions'] as $permission)
  798. {
  799. // If it's hidden keep the last value.
  800. if ($permission['hidden'] || $permissionGroup['hidden'])
  801. {
  802. echo '
  803. <tr style="display: none;">
  804. <td>';
  805. if ($permission['has_own_any'])
  806. {
  807. // Guests can't have own permissions.
  808. if ($context['group']['id'] != -1)
  809. echo '
  810. <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'], '" />';
  811. echo '
  812. <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'], '" />';
  813. }
  814. else
  815. echo '
  816. <input type="hidden" name="perm[', $permission_type['id'], '][', $permission['id'], ']" value="', $permission['select'] == 'denied' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $permission['select'], '" />';
  817. echo '
  818. </td>
  819. </tr>';
  820. }
  821. else
  822. {
  823. echo '
  824. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
  825. <td width="10">
  826. ', $permission['show_help'] ? '<a href="' . $scripturl . '?action=helpadmin;help=permissionhelp_' . $permission['id'] . '" onclick="return reqWin(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.gif" alt="' . $txt['help'] . '" /></a>' : '', '
  827. </td>';
  828. if ($permission['has_own_any'])
  829. {
  830. echo '
  831. <td colspan="4" width="100%" align="left">', $permission['name'], '</td>
  832. </tr><tr class="', $alternate ? 'windowbg' : 'windowbg2', '">';
  833. // Guests can't do their own thing.
  834. if ($context['group']['id'] != -1)
  835. {
  836. echo '
  837. <td></td>
  838. <td width="100%" class="smalltext" align="right">', $permission['own']['name'], ':</td>';
  839. if (empty($modSettings['permission_enable_deny']))
  840. echo '
  841. <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>';
  842. else
  843. echo '
  844. <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>
  845. <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>
  846. <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>';
  847. echo '
  848. </tr><tr class="', $alternate ? 'windowbg' : 'windowbg2', '">';
  849. }
  850. echo '
  851. <td></td>
  852. <td width="100%" class="smalltext" align="right">', $permission['any']['name'], ':</td>';
  853. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  854. echo '
  855. <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>';
  856. else
  857. echo '
  858. <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>
  859. <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>
  860. <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>';
  861. echo '
  862. </tr>';
  863. }
  864. else
  865. {
  866. echo '
  867. <td width="100%" align="left">', $permission['name'], '</td>';
  868. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  869. echo '
  870. <td><input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_check" ', $disable_field, '/></td>';
  871. else
  872. echo '
  873. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_radio" ', $disable_field, '/></td>
  874. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'off' ? ' checked="checked"' : '', ' value="off" class="input_radio" ', $disable_field, '/></td>
  875. <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>';
  876. echo '
  877. </tr>';
  878. }
  879. }
  880. $alternate = !$alternate;
  881. }
  882. if (!$permissionGroup['hidden'] && $has_display_content)
  883. echo '
  884. <tr class="windowbg2">
  885. <td colspan="5" width="100%"><!--separator--></td>
  886. </tr>';
  887. }
  888. echo '
  889. </table>';
  890. }
  891. echo '
  892. <br class="clear" />
  893. </div>
  894. <span class="botslice"><span></span></span>
  895. </div>';
  896. }
  897. function template_inline_permissions()
  898. {
  899. global $context, $settings, $options, $txt, $modSettings;
  900. echo '
  901. <fieldset id="', $context['current_permission'], '">
  902. <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>';
  903. if (empty($modSettings['permission_enable_deny']))
  904. echo '
  905. <ul class="permission_groups">';
  906. else
  907. echo '
  908. <div class="information">', $txt['permissions_option_desc'], '</div>
  909. <dl class="settings">
  910. <dt>
  911. <span class="perms"><strong>', $txt['permissions_option_on'], '</strong></span>
  912. <span class="perms"><strong>', $txt['permissions_option_off'], '</strong></span>
  913. <span class="perms" style="color: red;"><strong>', $txt['permissions_option_deny'], '</strong></span>
  914. </dt>
  915. <dd>
  916. </dd>';
  917. foreach ($context['member_groups'] as $group)
  918. {
  919. if (!empty($modSettings['permission_enable_deny']))
  920. echo '
  921. <dt>';
  922. else
  923. echo '
  924. <li>';
  925. if (empty($modSettings['permission_enable_deny']))
  926. echo '
  927. <input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked="checked"' : '', ' class="input_check" />';
  928. else
  929. echo '
  930. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked="checked"' : '', ' class="input_radio" /></span>
  931. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked="checked"' : '', ' class="input_radio" /></span>
  932. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked="checked"' : '', ' class="input_radio" /></span>';
  933. if (!empty($modSettings['permission_enable_deny']))
  934. echo '
  935. </dt>
  936. <dd>
  937. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  938. </dd>';
  939. else
  940. echo '
  941. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  942. </li>';
  943. }
  944. if (empty($modSettings['permission_enable_deny']))
  945. echo '
  946. </ul>';
  947. else
  948. echo '
  949. </dl>';
  950. echo '
  951. </fieldset>
  952. <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>
  953. <script type="text/javascript"><!-- // --><![CDATA[
  954. document.getElementById("', $context['current_permission'], '").style.display = "none";
  955. document.getElementById("', $context['current_permission'], '_groups_link").style.display = "";
  956. // ]]></script>';
  957. }
  958. // Edit post moderation permissions.
  959. function template_postmod_permissions()
  960. {
  961. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  962. echo '
  963. <div id="admincenter">
  964. <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'], '">
  965. <div class="title_bar">
  966. <h3 class="titlebg">', $txt['permissions_post_moderation'], '</h3>
  967. </div>';
  968. // Got advanced permissions - if so warn!
  969. if (!empty($modSettings['permission_enable_deny']))
  970. echo '
  971. <div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>';
  972. echo '
  973. <div class="righttext padding">
  974. ', $txt['permissions_post_moderation_select'], ':
  975. <select name="pid" onchange="document.forms.postmodForm.submit();">';
  976. foreach ($context['profiles'] as $profile)
  977. if ($profile['can_modify'])
  978. echo '
  979. <option value="', $profile['id'], '" ', $profile['id'] == $context['current_profile'] ? 'selected="selected"' : '', '>', $profile['name'], '</option>';
  980. echo '
  981. </select>
  982. <input type="submit" value="', $txt['go'], '" class="button_submit" />
  983. </div>
  984. <table width="100%" class="table_grid">
  985. <thead>
  986. <tr class="catbg">
  987. <th class="first_th"></th>
  988. <th align="center" colspan="3">
  989. ', $txt['permissions_post_moderation_new_topics'], '
  990. </th>
  991. <th align="center" colspan="3">
  992. ', $txt['permissions_post_moderation_replies_own'], '
  993. </th>
  994. <th align="center" colspan="3">
  995. ', $txt['permissions_post_moderation_replies_any'], '
  996. </th>
  997. <th class="last_th" align="center" colspan="3">
  998. ', $txt['permissions_post_moderation_attachments'], '
  999. </th>
  1000. </tr>
  1001. <tr class="titlebg">
  1002. <th width="30%">
  1003. ', $txt['permissions_post_moderation_group'], '
  1004. </th>
  1005. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_allow.gif" alt="', $txt['permissions_post_moderation_allow'], '" title="', $txt['permissions_post_moderation_allow'], '" /></th>
  1006. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.gif" alt="', $txt['permissions_post_moderation_moderate'], '" title="', $txt['permissions_post_moderation_moderate'], '" /></th>
  1007. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_deny.gif" alt="', $txt['permissions_post_moderation_disallow'], '" title="', $txt['permissions_post_moderation_disallow'], '" /></th>
  1008. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_allow.gif" alt="', $txt['permissions_post_moderation_allow'], '" title="', $txt['permissions_post_moderation_allow'], '" /></th>
  1009. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.gif" alt="', $txt['permissions_post_moderation_moderate'], '" title="', $txt['permissions_post_moderation_moderate'], '" /></th>
  1010. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_deny.gif" alt="', $txt['permissions_post_moderation_disallow'], '" title="', $txt['permissions_post_moderation_disallow'], '" /></th>
  1011. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_allow.gif" alt="', $txt['permissions_post_moderation_allow'], '" title="', $txt['permissions_post_moderation_allow'], '" /></th>
  1012. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.gif" alt="', $txt['permissions_post_moderation_moderate'], '" title="', $txt['permissions_post_moderation_moderate'], '" /></th>
  1013. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_deny.gif" alt="', $txt['permissions_post_moderation_disallow'], '" title="', $txt['permissions_post_moderation_disallow'], '" /></th>
  1014. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_allow.gif" alt="', $txt['permissions_post_moderation_allow'], '" title="', $txt['permissions_post_moderation_allow'], '" /></th>
  1015. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.gif" alt="', $txt['permissions_post_moderation_moderate'], '" title="', $txt['permissions_post_moderation_moderate'], '" /></th>
  1016. <th align="center"><img src="', $settings['default_images_url'], '/admin/post_moderation_deny.gif" alt="', $txt['permissions_post_moderation_disallow'], '" title="', $txt['permissions_post_moderation_disallow'], '" /></th>
  1017. </tr>
  1018. </thead>
  1019. <tbody>';
  1020. foreach ($context['profile_groups'] as $group)
  1021. {
  1022. echo '
  1023. <tr>
  1024. <td width="40%" class="windowbg">
  1025. <span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>';
  1026. if (!empty($group['children']))
  1027. echo '
  1028. <br /><span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
  1029. echo '
  1030. </td>
  1031. <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>
  1032. <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>
  1033. <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>
  1034. <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>
  1035. <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>
  1036. <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>
  1037. <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>
  1038. <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>
  1039. <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>
  1040. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="allow" ', $group['attachment'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1041. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="moderate" ', $group['attachment'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1042. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="disallow" ', $group['attachment'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1043. </tr>';
  1044. }
  1045. echo '
  1046. </tbody>
  1047. </table>
  1048. <div class="righttext padding">
  1049. <input type="submit" name="save_changes" value="', $txt['permissions_commit'], '" class="button_submit" />
  1050. </div>
  1051. </form>
  1052. <p class="smalltext" style="padding-left: 10px;">
  1053. <strong>', $txt['permissions_post_moderation_legend'], ':</strong><br />
  1054. <img src="', $settings['default_images_url'], '/admin/post_moderation_allow.gif" alt="', $txt['permissions_post_moderation_allow'], '" /> - ', $txt['permissions_post_moderation_allow'], '<br />
  1055. <img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.gif" alt="', $txt['permissions_post_moderation_moderate'], '" /> - ', $txt['permissions_post_moderation_moderate'], '<br />
  1056. <img src="', $settings['default_images_url'], '/admin/post_moderation_deny.gif" alt="', $txt['permissions_post_moderation_disallow'], '" /> - ', $txt['permissions_post_moderation_disallow'], '
  1057. </p>
  1058. </div>
  1059. <br class="clear" />';
  1060. }
  1061. ?>