2
0

ManagePermissions.template.php 52 KB

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