ManagePermissions.template.php 52 KB

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