ManagePermissions.template.php 51 KB

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