ManagePermissions.template.php 52 KB

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