ManagePermissions.template.php 51 KB

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