ManagePermissions.template.php 51 KB

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