ManagePermissions.template.php 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  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: ', 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. <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. // Manually toggle the breakdown.
  626. echo '
  627. function toggleBreakdown(id_group, forcedisplayType)
  628. {
  629. displayType = document.getElementById("group_hr_div_" + id_group).style.display == "none" ? "" : "none";
  630. if (typeof(forcedisplayType) != "undefined")
  631. displayType = forcedisplayType;
  632. for (i = 0; i < groupPermissions[id_group].length; i++)
  633. {
  634. document.getElementById("perm_div_" + id_group + "_" + groupPermissions[id_group][i]).style.display = displayType
  635. }
  636. document.getElementById("group_hr_div_" + id_group).style.display = displayType
  637. document.getElementById("group_toggle_img_" + id_group).src = "', $settings['images_url'], '/" + (displayType == "none" ? "selected" : "sort_down") + ".gif";
  638. return false;
  639. }';
  640. // This function decides what to do when ANYTHING is touched!
  641. echo '
  642. var groupPermissions = new Array();
  643. function determineGroupState(id_group, forceState)
  644. {
  645. if (typeof(forceState) != "undefined")
  646. thisState = forceState;
  647. // Cycle through this groups elements.
  648. var curState = false, thisState;
  649. for (var i = 0; i < groupPermissions[id_group].length; i++)
  650. {';
  651. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  652. echo '
  653. if (typeof(forceState) != "undefined")
  654. {
  655. document.getElementById(\'select_\' + groupPermissions[id_group][i]).checked = forceState == \'on\' ? 1 : 0;
  656. }
  657. thisState = document.getElementById(\'select_\' + groupPermissions[id_group][i]).checked ? \'on\' : \'off\';';
  658. else
  659. echo '
  660. if (typeof(forceState) != "undefined")
  661. {
  662. document.getElementById(\'select_on_\' + groupPermissions[id_group][i]).checked = forceState == \'on\' ? 1 : 0;
  663. document.getElementById(\'select_off_\' + groupPermissions[id_group][i]).checked = forceState == \'off\' ? 1 : 0;
  664. document.getElementById(\'select_deny_\' + groupPermissions[id_group][i]).checked = forceState == \'deny\' ? 1 : 0;
  665. }
  666. if (document.getElementById(\'select_on_\' + groupPermissions[id_group][i]).checked)
  667. thisState = \'on\';
  668. else if (document.getElementById(\'select_off_\' + groupPermissions[id_group][i]).checked)
  669. thisState = \'off\';
  670. else
  671. thisState = \'deny\';';
  672. echo '
  673. // Unless this is the first element, or it\'s the same state as the last we\'re buggered.
  674. if (curState == false || thisState == curState)
  675. {
  676. curState = thisState;
  677. }
  678. else
  679. {
  680. curState = \'fudged\';
  681. i = 999;
  682. }
  683. }
  684. // First check the right master is selected!';
  685. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  686. echo '
  687. document.getElementById("group_select_" + id_group).checked = curState == \'on\' ? 1 : 0;';
  688. else
  689. echo '
  690. document.getElementById("group_select_on_" + id_group).checked = curState == \'on\' ? 1 : 0;
  691. document.getElementById("group_select_off_" + id_group).checked = curState == \'off\' ? 1 : 0;
  692. document.getElementById("group_select_deny_" + id_group).checked = curState == \'deny\' ? 1 : 0;';
  693. // Force the display?
  694. echo '
  695. if (curState != \'fudged\')
  696. toggleBreakdown(id_group, "none");';
  697. echo '
  698. }';
  699. }
  700. // Some more javascript to be displayed as long as we are editing.
  701. if ($context['profile']['can_modify'])
  702. {
  703. foreach ($permission_data as $id_group => $permissionGroup)
  704. {
  705. if (empty($permissionGroup['permissions']))
  706. continue;
  707. // As before...
  708. $has_display_content = false;
  709. if (!$permissionGroup['hidden'])
  710. {
  711. // Make sure we can show it.
  712. foreach ($permissionGroup['permissions'] as $permission)
  713. if (!$permission['hidden'])
  714. $has_display_content = true;
  715. // Make all the group indicators visible on JS only.
  716. if ($has_display_content)
  717. {
  718. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  719. echo '
  720. document.getElementById("group_select_div_', $id_group, '").parentNode.className = "lockedbg";
  721. document.getElementById("group_select_', $id_group, '").style.display = "";';
  722. else
  723. echo '
  724. document.getElementById("group_select_div_on_', $id_group, '").parentNode.className = "lockedbg";
  725. document.getElementById("group_select_div_off_', $id_group, '").parentNode.className = "lockedbg";
  726. document.getElementById("group_select_div_deny_', $id_group, '").parentNode.className = "lockedbg";
  727. document.getElementById("group_select_on_', $id_group, '").style.display = "";
  728. document.getElementById("group_select_off_', $id_group, '").style.display = "";
  729. document.getElementById("group_select_deny_', $id_group, '").style.display = "";';
  730. }
  731. $perm_ids = array();
  732. $count = 0;
  733. foreach ($permissionGroup['permissions'] as $permission)
  734. {
  735. if (!$permission['hidden'])
  736. {
  737. // Need this for knowing what can be tweaked.
  738. $perm_ids[] = "'$permission[id]'";
  739. }
  740. }
  741. // Declare this groups permissions into an array.
  742. if (!empty($perm_ids))
  743. echo '
  744. groupPermissions[\'', $id_group, '\'] = new Array(', count($perm_ids), ');';
  745. foreach ($perm_ids as $count => $id)
  746. echo '
  747. groupPermissions[\'', $id_group, '\'][', $count, '] = ', $id, ';';
  748. // Show the group as required.
  749. if ($has_display_content)
  750. echo '
  751. determineGroupState(\'', $id_group, '\');';
  752. }
  753. }
  754. }
  755. echo '
  756. // ]]></script>';
  757. }
  758. // The SMF 1.x way of looking at permissions.
  759. function template_modify_group_classic($type)
  760. {
  761. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  762. $permission_type = &$context['permissions'][$type];
  763. $disable_field = $context['profile']['can_modify'] ? '' : 'disabled="disabled" ';
  764. echo '
  765. <div class="windowbg2">
  766. <span class="topslice"><span></span></span>
  767. <div class="content">';
  768. foreach ($permission_type['columns'] as $column)
  769. {
  770. echo '
  771. <table width="49%" class="table_grid perm_classic floatleft">';
  772. foreach ($column as $permissionGroup)
  773. {
  774. if (empty($permissionGroup['permissions']))
  775. continue;
  776. // Are we likely to have something in this group to display or is it all hidden?
  777. $has_display_content = false;
  778. if (!$permissionGroup['hidden'])
  779. {
  780. // Before we go any further check we are going to have some data to print otherwise we just have a silly heading.
  781. foreach ($permissionGroup['permissions'] as $permission)
  782. if (!$permission['hidden'])
  783. $has_display_content = true;
  784. if ($has_display_content)
  785. {
  786. echo '
  787. <tr class="catbg">
  788. <th colspan="2" width="100%" align="left"><strong class="smalltext">', $permissionGroup['name'], '</strong></th>';
  789. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  790. echo '
  791. <th colspan="3" width="10"></th>';
  792. else
  793. echo '
  794. <th align="center"><div>', $txt['permissions_option_on'], '</div></th>
  795. <th align="center"><div>', $txt['permissions_option_off'], '</div></th>
  796. <th align="center"><div>', $txt['permissions_option_deny'], '</div></th>';
  797. echo '
  798. </tr>';
  799. }
  800. }
  801. $alternate = false;
  802. foreach ($permissionGroup['permissions'] as $permission)
  803. {
  804. // If it's hidden keep the last value.
  805. if ($permission['hidden'] || $permissionGroup['hidden'])
  806. {
  807. echo '
  808. <tr style="display: none;">
  809. <td>';
  810. if ($permission['has_own_any'])
  811. {
  812. // Guests can't have own permissions.
  813. if ($context['group']['id'] != -1)
  814. echo '
  815. <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'], '" />';
  816. echo '
  817. <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'], '" />';
  818. }
  819. else
  820. echo '
  821. <input type="hidden" name="perm[', $permission_type['id'], '][', $permission['id'], ']" value="', $permission['select'] == 'denied' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $permission['select'], '" />';
  822. echo '
  823. </td>
  824. </tr>';
  825. }
  826. else
  827. {
  828. echo '
  829. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
  830. <td width="10">
  831. ', $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>' : '', '
  832. </td>';
  833. if ($permission['has_own_any'])
  834. {
  835. echo '
  836. <td colspan="4" width="100%" align="left">', $permission['name'], '</td>
  837. </tr><tr class="', $alternate ? 'windowbg' : 'windowbg2', '">';
  838. // Guests can't do their own thing.
  839. if ($context['group']['id'] != -1)
  840. {
  841. echo '
  842. <td></td>
  843. <td width="100%" class="smalltext" align="right">', $permission['own']['name'], ':</td>';
  844. if (empty($modSettings['permission_enable_deny']))
  845. echo '
  846. <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>';
  847. else
  848. echo '
  849. <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>
  850. <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>
  851. <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>';
  852. echo '
  853. </tr><tr class="', $alternate ? 'windowbg' : 'windowbg2', '">';
  854. }
  855. echo '
  856. <td></td>
  857. <td width="100%" class="smalltext" align="right">', $permission['any']['name'], ':</td>';
  858. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  859. echo '
  860. <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>';
  861. else
  862. echo '
  863. <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>
  864. <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>
  865. <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>';
  866. echo '
  867. </tr>';
  868. }
  869. else
  870. {
  871. echo '
  872. <td width="100%" align="left">', $permission['name'], '</td>';
  873. if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
  874. echo '
  875. <td><input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_check" ', $disable_field, '/></td>';
  876. else
  877. echo '
  878. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" class="input_radio" ', $disable_field, '/></td>
  879. <td><input type="radio" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'off' ? ' checked="checked"' : '', ' value="off" class="input_radio" ', $disable_field, '/></td>
  880. <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>';
  881. echo '
  882. </tr>';
  883. }
  884. }
  885. $alternate = !$alternate;
  886. }
  887. if (!$permissionGroup['hidden'] && $has_display_content)
  888. echo '
  889. <tr class="windowbg2">
  890. <td colspan="5" width="100%"><!--separator--></td>
  891. </tr>';
  892. }
  893. echo '
  894. </table>';
  895. }
  896. echo '
  897. <br class="clear" />
  898. </div>
  899. <span class="botslice"><span></span></span>
  900. </div>';
  901. }
  902. function template_inline_permissions()
  903. {
  904. global $context, $settings, $options, $txt, $modSettings;
  905. echo '
  906. <fieldset id="', $context['current_permission'], '">
  907. <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>';
  908. if (empty($modSettings['permission_enable_deny']))
  909. echo '
  910. <ul class="permission_groups">';
  911. else
  912. echo '
  913. <div class="information">', $txt['permissions_option_desc'], '</div>
  914. <dl class="settings">
  915. <dt>
  916. <span class="perms"><strong>', $txt['permissions_option_on'], '</strong></span>
  917. <span class="perms"><strong>', $txt['permissions_option_off'], '</strong></span>
  918. <span class="perms" style="color: red;"><strong>', $txt['permissions_option_deny'], '</strong></span>
  919. </dt>
  920. <dd>
  921. </dd>';
  922. foreach ($context['member_groups'] as $group)
  923. {
  924. if (!empty($modSettings['permission_enable_deny']))
  925. echo '
  926. <dt>';
  927. else
  928. echo '
  929. <li>';
  930. if (empty($modSettings['permission_enable_deny']))
  931. echo '
  932. <input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked="checked"' : '', ' class="input_check" />';
  933. else
  934. echo '
  935. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked="checked"' : '', ' class="input_radio" /></span>
  936. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked="checked"' : '', ' class="input_radio" /></span>
  937. <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked="checked"' : '', ' class="input_radio" /></span>';
  938. if (!empty($modSettings['permission_enable_deny']))
  939. echo '
  940. </dt>
  941. <dd>
  942. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  943. </dd>';
  944. else
  945. echo '
  946. <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
  947. </li>';
  948. }
  949. if (empty($modSettings['permission_enable_deny']))
  950. echo '
  951. </ul>';
  952. else
  953. echo '
  954. </dl>';
  955. echo '
  956. </fieldset>
  957. <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>
  958. <script type="text/javascript"><!-- // --><![CDATA[
  959. document.getElementById("', $context['current_permission'], '").style.display = "none";
  960. document.getElementById("', $context['current_permission'], '_groups_link").style.display = "";
  961. // ]]></script>';
  962. }
  963. // Edit post moderation permissions.
  964. function template_postmod_permissions()
  965. {
  966. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  967. echo '
  968. <div id="admincenter">
  969. <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'], '">
  970. <div class="title_bar">
  971. <h3 class="titlebg">', $txt['permissions_post_moderation'], '</h3>
  972. </div>';
  973. // Got advanced permissions - if so warn!
  974. if (!empty($modSettings['permission_enable_deny']))
  975. echo '
  976. <div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>';
  977. echo '
  978. <div class="righttext padding">
  979. ', $txt['permissions_post_moderation_select'], ':
  980. <select name="pid" onchange="document.forms.postmodForm.submit();">';
  981. foreach ($context['profiles'] as $profile)
  982. if ($profile['can_modify'])
  983. echo '
  984. <option value="', $profile['id'], '" ', $profile['id'] == $context['current_profile'] ? 'selected="selected"' : '', '>', $profile['name'], '</option>';
  985. echo '
  986. </select>
  987. <input type="submit" value="', $txt['go'], '" class="button_submit" />
  988. </div>
  989. <table width="100%" class="table_grid">
  990. <thead>
  991. <tr class="catbg">
  992. <th class="first_th"></th>
  993. <th align="center" colspan="3">
  994. ', $txt['permissions_post_moderation_new_topics'], '
  995. </th>
  996. <th align="center" colspan="3">
  997. ', $txt['permissions_post_moderation_replies_own'], '
  998. </th>
  999. <th align="center" colspan="3">
  1000. ', $txt['permissions_post_moderation_replies_any'], '
  1001. </th>
  1002. <th class="last_th" align="center" colspan="3">
  1003. ', $txt['permissions_post_moderation_attachments'], '
  1004. </th>
  1005. </tr>
  1006. <tr class="titlebg">
  1007. <th width="30%">
  1008. ', $txt['permissions_post_moderation_group'], '
  1009. </th>
  1010. <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>
  1011. <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>
  1012. <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>
  1013. <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>
  1014. <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>
  1015. <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>
  1016. <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>
  1017. <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>
  1018. <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>
  1019. <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>
  1020. <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>
  1021. <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>
  1022. </tr>
  1023. </thead>
  1024. <tbody>';
  1025. foreach ($context['profile_groups'] as $group)
  1026. {
  1027. echo '
  1028. <tr>
  1029. <td width="40%" class="windowbg">
  1030. <span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>';
  1031. if (!empty($group['children']))
  1032. echo '
  1033. <br /><span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
  1034. echo '
  1035. </td>
  1036. <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>
  1037. <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>
  1038. <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>
  1039. <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>
  1040. <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>
  1041. <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>
  1042. <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>
  1043. <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>
  1044. <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>
  1045. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="allow" ', $group['attachment'] == 'allow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1046. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="moderate" ', $group['attachment'] == 'moderate' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1047. <td align="center" class="windowbg"><input type="radio" name="attachment[', $group['id'], ']" value="disallow" ', $group['attachment'] == 'disallow' ? 'checked="checked"' : '', ' class="input_radio" /></td>
  1048. </tr>';
  1049. }
  1050. echo '
  1051. </tbody>
  1052. </table>
  1053. <div class="righttext padding">
  1054. <input type="submit" name="save_changes" value="', $txt['permissions_commit'], '" class="button_submit" />
  1055. <input type="hidden" name="', $context['admin-mppm_token_var'], '" value="', $context['admin-mppm_token'], '" />
  1056. </div>
  1057. </form>
  1058. <p class="smalltext" style="padding-left: 10px;">
  1059. <strong>', $txt['permissions_post_moderation_legend'], ':</strong><br />
  1060. <img src="', $settings['default_images_url'], '/admin/post_moderation_allow.gif" alt="', $txt['permissions_post_moderation_allow'], '" /> - ', $txt['permissions_post_moderation_allow'], '<br />
  1061. <img src="', $settings['default_images_url'], '/admin/post_moderation_moderate.gif" alt="', $txt['permissions_post_moderation_moderate'], '" /> - ', $txt['permissions_post_moderation_moderate'], '<br />
  1062. <img src="', $settings['default_images_url'], '/admin/post_moderation_deny.gif" alt="', $txt['permissions_post_moderation_disallow'], '" /> - ', $txt['permissions_post_moderation_disallow'], '
  1063. </p>
  1064. </div>
  1065. <br class="clear" />';
  1066. }
  1067. ?>