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