ManagePermissions.template.php 51 KB

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