ManagePermissions.template.php 51 KB

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