ManagePermissions.template.php 51 KB

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