ModerationCenter.template.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2014 Simple Machines and individual contributors
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. function template_moderation_center()
  13. {
  14. global $settings, $context, $txt, $scripturl;
  15. // Show moderators notes.
  16. template_notes();
  17. // Show a welcome message to the user.
  18. echo '
  19. <div id="modcenter">';
  20. $alternate = true;
  21. // Show all the blocks they want to see.
  22. foreach ($context['mod_blocks'] as $block)
  23. {
  24. $block_function = 'template_' . $block;
  25. echo '
  26. <div class="modblock_', $alternate ? 'left' : 'right', '">', function_exists($block_function) ? $block_function() : '', '</div>';
  27. if (!$alternate)
  28. echo '
  29. <br class="clear">';
  30. $alternate = !$alternate;
  31. }
  32. echo '
  33. </div>
  34. <br class="clear">';
  35. }
  36. // Show all the group requests the user can see.
  37. function template_group_requests_block()
  38. {
  39. global $context, $txt, $scripturl;
  40. echo '
  41. <div class="cat_bar">
  42. <h3 class="catbg">
  43. <span id="group_requests_toggle" class="', !empty($context['admin_prefs']['mcgr']) ? 'toggle_down' : 'toggle_up', ' floatright" style="display: none;"></span>
  44. <a href="', $scripturl, '?action=groups;sa=requests" id="group_requests_link">', $txt['mc_group_requests'], '</a>
  45. </h3>
  46. </div>
  47. <div class="windowbg" id="group_requests_panel">
  48. <div class="content modbox">
  49. <ul class="reset">';
  50. foreach ($context['group_requests'] as $request)
  51. echo '
  52. <li class="smalltext">
  53. <a href="', $request['request_href'], '">', $request['group']['name'], '</a> ', $txt['mc_groupr_by'], ' ', $request['member']['link'], '
  54. </li>';
  55. // Don't have any watched users right now?
  56. if (empty($context['group_requests']))
  57. echo '
  58. <li>
  59. <strong class="smalltext">', $txt['mc_group_requests_none'], '</strong>
  60. </li>';
  61. echo '
  62. </ul>
  63. </div>
  64. </div>
  65. <script><!-- // --><![CDATA[
  66. var oGroupRequestsPanelToggle = new smc_Toggle({
  67. bToggleEnabled: true,
  68. bCurrentlyCollapsed: ', !empty($context['admin_prefs']['mcgr']) ? 'true' : 'false', ',
  69. aSwappableContainers: [
  70. \'group_requests_panel\'
  71. ],
  72. aSwapImages: [
  73. {
  74. sId: \'group_requests_toggle\',
  75. altExpanded: ', JavaScriptEscape($txt['hide']), ',
  76. altCollapsed: ', JavaScriptEscape($txt['show']), '
  77. }
  78. ],
  79. aSwapLinks: [
  80. {
  81. sId: \'group_requests_link\',
  82. msgExpanded: ', JavaScriptEscape($txt['mc_group_requests']), ',
  83. msgCollapsed: ', JavaScriptEscape($txt['mc_group_requests']), '
  84. }
  85. ],
  86. oThemeOptions: {
  87. bUseThemeSettings: true,
  88. sOptionName: \'admin_preferences\',
  89. sSessionVar: smf_session_var,
  90. sSessionId: smf_session_id,
  91. sThemeId: \'1\',
  92. sAdditionalVars: \';admin_key=mcgr\'
  93. }
  94. });
  95. // ]]></script>';
  96. }
  97. function template_watched_users()
  98. {
  99. global $context, $txt, $scripturl;
  100. echo '
  101. <div class="cat_bar">
  102. <h3 class="catbg">
  103. <span id="watched_users_toggle" class="', !empty($context['admin_prefs']['mcwu']) ? 'toggle_down' : 'toggle_up', ' floatright" style="display: none;"></span>
  104. <a href="', $scripturl, '?action=moderate;area=userwatch" id="watched_users_link">', $txt['mc_watched_users'], '</a>
  105. </h3>
  106. </div>
  107. <div class="windowbg" id="watched_users_panel">
  108. <div class="content modbox">
  109. <ul class="reset">';
  110. foreach ($context['watched_users'] as $user)
  111. echo '
  112. <li>
  113. <span class="smalltext">', sprintf(!empty($user['last_login']) ? $txt['mc_seen'] : $txt['mc_seen_never'], $user['link'], $user['last_login']), '</span>
  114. </li>';
  115. // Don't have any watched users right now?
  116. if (empty($context['watched_users']))
  117. echo '
  118. <li>
  119. <strong class="smalltext">', $txt['mc_watched_users_none'], '</strong>
  120. </li>';
  121. echo '
  122. </ul>
  123. </div>
  124. </div>
  125. <script><!-- // --><![CDATA[
  126. var oWatchedUsersToggle = new smc_Toggle({
  127. bToggleEnabled: true,
  128. bCurrentlyCollapsed: ', !empty($context['admin_prefs']['mcwu']) ? 'true' : 'false', ',
  129. aSwappableContainers: [
  130. \'watched_users_panel\'
  131. ],
  132. aSwapImages: [
  133. {
  134. sId: \'watched_users_toggle\',
  135. altExpanded: ', JavaScriptEscape($txt['hide']), ',
  136. altCollapsed: ', JavaScriptEscape($txt['show']), '
  137. }
  138. ],
  139. aSwapLinks: [
  140. {
  141. sId: \'watched_users_link\',
  142. msgExpanded: ', JavaScriptEscape($txt['mc_watched_users']), ',
  143. msgCollapsed: ', JavaScriptEscape($txt['mc_watched_users']), '
  144. }
  145. ],
  146. oThemeOptions: {
  147. bUseThemeSettings: true,
  148. sOptionName: \'admin_preferences\',
  149. sSessionVar: smf_session_var,
  150. sSessionId: smf_session_id,
  151. sThemeId: \'1\',
  152. sAdditionalVars: \';admin_key=mcwu\'
  153. }
  154. });
  155. // ]]></script>';
  156. }
  157. // Little section for making... notes.
  158. function template_notes()
  159. {
  160. global $context, $txt, $scripturl;
  161. // Let them know the action was a success.
  162. if (!empty($context['report_post_action']))
  163. {
  164. echo '
  165. <div class="infobox">
  166. ', $txt['report_action_'. $context['report_post_action']], '
  167. </div>';
  168. }
  169. echo '
  170. <div class="modnotes">
  171. <form action="', $scripturl, '?action=moderate;area=index;modnote" method="post">
  172. <div class="cat_bar">
  173. <h3 class="catbg">', $txt['mc_notes'], '</h3>
  174. </div>
  175. <div class="windowbg">
  176. <div class="content modbox">';
  177. if (!empty($context['notes']))
  178. {
  179. echo '
  180. <ul class="reset moderation_notes">';
  181. // Cycle through the notes.
  182. foreach ($context['notes'] as $note)
  183. echo '
  184. <li class="smalltext"><a href="', $note['delete_href'], ';', $context['mod-modnote-del_token_var'], '=', $context['mod-modnote-del_token'], '" class="delete_modnote"><span class="generic_icons del_small"></span></a>', $note['time'] ,' <strong>', $note['author']['link'], ':</strong> ', $note['text'], '</li>';
  185. echo '
  186. </ul>
  187. <div class="pagesection notes">
  188. <span class="smalltext">', $context['page_index'], '</span>
  189. </div>';
  190. }
  191. echo '
  192. <div class="floatleft post_note">
  193. <input type="text" name="new_note" value="', $txt['mc_click_add_note'], '" style="width: 95%;" onclick="if (this.value == \'', $txt['mc_click_add_note'], '\') this.value = \'\';" class="input_text">
  194. </div>
  195. <input type="hidden" name="', $context['mod-modnote-add_token_var'], '" value="', $context['mod-modnote-add_token'], '">
  196. <input type="submit" name="makenote" value="', $txt['mc_add_note'], '" class="button_submit">
  197. </div>
  198. </div>
  199. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  200. </form>
  201. </div>';
  202. }
  203. // Show a list of all the unapproved posts
  204. function template_unapproved_posts()
  205. {
  206. global $options, $context, $txt, $scripturl;
  207. // Just a big table of it all really...
  208. echo '
  209. <div id="modcenter">
  210. <form action="', $scripturl, '?action=moderate;area=postmod;start=', $context['start'], ';sa=', $context['current_view'], '" method="post" accept-charset="', $context['character_set'], '">
  211. <div class="cat_bar">
  212. <h3 class="catbg">', $txt['mc_unapproved_posts'], '</h3>
  213. </div>';
  214. // Make up some buttons
  215. $approve_button = create_button('approve.png', 'approve', 'approve', 'class="centericon"');
  216. $remove_button = create_button('delete.png', 'remove_message', 'remove', 'class="centericon"');
  217. // No posts?
  218. if (empty($context['unapproved_items']))
  219. echo '
  220. <div class="windowbg2">
  221. <div class="content">
  222. <p class="centertext">', $txt['mc_unapproved_' . $context['current_view'] . '_none_found'], '</p>
  223. </div>
  224. </div>';
  225. else
  226. echo '
  227. <div class="pagesection floatleft">
  228. ', $context['page_index'], '
  229. </div>';
  230. foreach ($context['unapproved_items'] as $item)
  231. {
  232. echo '
  233. <div class="topic clear">
  234. <div class="', $item['alternate'] == 0 ? 'windowbg2' : 'windowbg', ' core_posts">
  235. <div class="content">
  236. <div class="counter">', $item['counter'], '</div>
  237. <div class="topic_details">
  238. <h5><strong>', $item['category']['link'], ' / ', $item['board']['link'], ' / ', $item['link'], '</strong></h5>
  239. <span class="smalltext"><strong>', $txt['mc_unapproved_by'], ' ', $item['poster']['link'], ' ', $txt['on'], ':</strong> ', $item['time'], '</span>
  240. </div>
  241. <div class="list_posts">
  242. <div class="post">', $item['body'], '</div>
  243. </div>
  244. <span class="floatright">
  245. <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';approve=', $item['id'], '">', $approve_button, '</a>';
  246. if ($item['can_delete'])
  247. echo '
  248. ', $context['menu_separator'], '
  249. <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';delete=', $item['id'], '">', $remove_button, '</a>';
  250. if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
  251. echo '
  252. <input type="checkbox" name="item[]" value="', $item['id'], '" checked class="input_check"> ';
  253. echo '
  254. </span>
  255. </div>
  256. </div>
  257. </div>';
  258. }
  259. echo '
  260. <div class="pagesection">';
  261. if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
  262. echo '
  263. <div class="floatright">
  264. <select name="do" onchange="if (this.value != 0 &amp;&amp; confirm(\'', $txt['mc_unapproved_sure'], '\')) submit();">
  265. <option value="0">', $txt['with_selected'], ':</option>
  266. <option value="0">-------------------</option>
  267. <option value="approve">&nbsp;--&nbsp;', $txt['approve'], '</option>
  268. <option value="delete">&nbsp;--&nbsp;', $txt['delete'], '</option>
  269. </select>
  270. <noscript><input type="submit" name="mc_go" value="', $txt['go'], '" class="button_submit"></noscript>
  271. </div>';
  272. if (!empty($context['unapproved_items']))
  273. echo '
  274. <div class="floatleft">
  275. <div class="pagelinks">', $context['page_index'], '</div>
  276. </div>';
  277. echo '
  278. </div>
  279. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  280. </form>
  281. </div>';
  282. }
  283. // Callback function for showing a watched users post in the table.
  284. function template_user_watch_post_callback($post)
  285. {
  286. global $scripturl, $context, $txt, $delete_button;
  287. // We'll have a delete please bob.
  288. if (empty($delete_button))
  289. $delete_button = create_button('delete.png', 'remove_message', 'remove', 'class="centericon"');
  290. $output_html = '
  291. <div>
  292. <div class="floatleft">
  293. <strong><a href="' . $scripturl . '?topic=' . $post['id_topic'] . '.' . $post['id'] . '#msg' . $post['id'] . '">' . $post['subject'] . '</a></strong> ' . $txt['mc_reportedp_by'] . ' <strong>' . $post['author_link'] . '</strong>
  294. </div>
  295. <div class="floatright">';
  296. if ($post['can_delete'])
  297. $output_html .= '
  298. <a href="' . $scripturl . '?action=moderate;area=userwatch;sa=post;delete=' . $post['id'] . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'' . $txt['mc_watched_users_delete_post'] . '\');">' . $delete_button . '</a>
  299. <input type="checkbox" name="delete[]" value="' . $post['id'] . '" class="input_check">';
  300. $output_html .= '
  301. </div>
  302. </div><br>
  303. <div class="smalltext">
  304. &#171; ' . $txt['mc_watched_users_posted'] . ': ' . $post['poster_time'] . ' &#187;
  305. </div>
  306. <hr>
  307. ' . $post['body'];
  308. return $output_html;
  309. }
  310. // Moderation settings
  311. function template_moderation_settings()
  312. {
  313. global $context, $txt, $scripturl;
  314. echo '
  315. <div id="modcenter">
  316. <form action="', $scripturl, '?action=moderate;area=settings" method="post" accept-charset="', $context['character_set'], '">
  317. <div class="windowbg2">
  318. <div class="content">
  319. <dl class="settings">';
  320. if ($context['can_moderate_approvals'])
  321. {
  322. echo '
  323. <dt>
  324. <strong><label for="mod_notify_approval">', $txt['mc_prefs_notify_approval'], '</label>:</strong>
  325. </dt>
  326. <dd>
  327. <input type="checkbox" id="mod_notify_approval" name="mod_notify_approval"', $context['mod_settings']['notify_approval'] ? ' checked' : '', ' class="input_check">
  328. </dd>';
  329. }
  330. echo '
  331. </dl>
  332. <hr class="hrcolor">
  333. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  334. <input type="hidden" name="', $context['mod-set_token_var'], '" value="', $context['mod-set_token'], '">
  335. <input type="submit" name="save" value="', $txt['save'], '" class="button_submit">
  336. </div>
  337. </div>
  338. </form>
  339. </div>';
  340. }
  341. // Show a notice sent to a user.
  342. function template_show_notice()
  343. {
  344. global $txt, $settings, $context, $modSettings;
  345. // We do all the HTML for this one!
  346. echo '<!DOCTYPE html>
  347. <html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
  348. <head>
  349. <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '">
  350. <title>', $context['page_title'], '</title>
  351. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'">
  352. </head>
  353. <body>
  354. <div class="cat_bar">
  355. <h3 class="catbg">', $txt['show_notice'], '</h3>
  356. </div>
  357. <div class="title_bar">
  358. <h3 class="titlebg">', $txt['show_notice_subject'], ': ', $context['notice_subject'], '</h3>
  359. </div>
  360. <div class="windowbg">
  361. <div class="content">
  362. <dl>
  363. <dt>
  364. <strong>', $txt['show_notice_text'], ':</strong>
  365. </dt>
  366. <dd>
  367. ', $context['notice_body'], '
  368. </dd>
  369. </dl>
  370. </div>
  371. </div>
  372. </body>
  373. </html>';
  374. }
  375. // Add or edit a warning template.
  376. function template_warn_template()
  377. {
  378. global $context, $txt, $scripturl;
  379. echo '
  380. <div id="modcenter">
  381. <form action="', $scripturl, '?action=moderate;area=warnings;sa=templateedit;tid=', $context['id_template'], '" method="post" accept-charset="', $context['character_set'], '">
  382. <div class="cat_bar">
  383. <h3 class="catbg">', $context['page_title'], '</h3>
  384. </div>
  385. <div class="information">
  386. ', $txt['mc_warning_template_desc'], '
  387. </div>
  388. <div class="windowbg">
  389. <div class="content">
  390. <div class="errorbox"', empty($context['warning_errors']) ? ' style="display: none"' : '', ' id="errors">
  391. <dl>
  392. <dt>
  393. <strong id="error_serious">', $txt['error_while_submitting'] , '</strong>
  394. </dt>
  395. <dd class="error" id="error_list">
  396. ', empty($context['warning_errors']) ? '' : implode('<br>', $context['warning_errors']), '
  397. </dd>
  398. </dl>
  399. </div>
  400. <div id="box_preview"', !empty($context['template_preview']) ? '' : ' style="display:none"', '>
  401. <dl class="settings">
  402. <dt>
  403. <strong>', $txt['preview'] , '</strong>
  404. </dt>
  405. <dd id="template_preview">
  406. ', !empty($context['template_preview']) ? $context['template_preview'] : '', '
  407. </dd>
  408. </dl>
  409. </div>
  410. <dl class="settings">
  411. <dt>
  412. <strong><label for="template_title">', $txt['mc_warning_template_title'], '</label>:</strong>
  413. </dt>
  414. <dd>
  415. <input type="text" id="template_title" name="template_title" value="', $context['template_data']['title'], '" size="30" class="input_text">
  416. </dd>
  417. <dt>
  418. <strong><label for="template_body">', $txt['profile_warning_notify_body'], '</label>:</strong><br>
  419. <span class="smalltext">', $txt['mc_warning_template_body_desc'], '</span>
  420. </dt>
  421. <dd>
  422. <textarea id="template_body" name="template_body" rows="10" cols="45" class="smalltext">', $context['template_data']['body'], '</textarea>
  423. </dd>
  424. </dl>';
  425. if ($context['template_data']['can_edit_personal'])
  426. echo '
  427. <input type="checkbox" name="make_personal" id="make_personal"', $context['template_data']['personal'] ? ' checked' : '', ' class="input_check">
  428. <label for="make_personal">
  429. <strong>', $txt['mc_warning_template_personal'], '</strong>
  430. </label>
  431. <br>
  432. <span class="smalltext">', $txt['mc_warning_template_personal_desc'], '</span>
  433. <br>';
  434. echo '
  435. <hr class="hrcolor">
  436. <input type="submit" name="preview" id="preview_button" value="', $txt['preview'], '" class="button_submit">
  437. <input type="submit" name="save" value="', $context['page_title'], '" class="button_submit">
  438. </div>
  439. </div>
  440. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  441. <input type="hidden" name="', $context['mod-wt_token_var'], '" value="', $context['mod-wt_token'], '">
  442. </form>
  443. </div>
  444. <script><!-- // --><![CDATA[
  445. $(document).ready(function() {
  446. $("#preview_button").click(function() {
  447. return ajax_getTemplatePreview();
  448. });
  449. });
  450. function ajax_getTemplatePreview ()
  451. {
  452. $.ajax({
  453. type: "POST",
  454. url: "' . $scripturl . '?action=xmlhttp;sa=previews;xml",
  455. data: {item: "warning_preview", title: $("#template_title").val(), body: $("#template_body").val(), user: $(\'input[name="u"]\').attr("value")},
  456. context: document.body,
  457. success: function(request){
  458. $("#box_preview").css({display:""});
  459. $("#template_preview").html($(request).find(\'body\').text());
  460. if ($(request).find("error").text() != \'\')
  461. {
  462. $("#errors").css({display:""});
  463. var errors_html = \'\';
  464. var errors = $(request).find(\'error\').each(function() {
  465. errors_html += $(this).text() + \'<br>\';
  466. });
  467. $(document).find("#error_list").html(errors_html);
  468. }
  469. else
  470. {
  471. $("#errors").css({display:"none"});
  472. $("#error_list").html(\'\');
  473. }
  474. return false;
  475. },
  476. });
  477. return false;
  478. }
  479. // ]]></script>';
  480. }
  481. ?>