ManagePermissions.template.php 51 KB

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