ManageNews.template.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2012 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. function template_email_members()
  13. {
  14. global $context, $settings, $options, $txt, $scripturl;
  15. echo '
  16. <div id="admincenter">
  17. <form action="', $scripturl, '?action=admin;area=news;sa=mailingcompose" method="post" id="admin_newsletters" class="flow_hidden" accept-charset="', $context['character_set'], '">
  18. <div class="cat_bar">
  19. <h3 class="catbg">', $txt['admin_newsletters'], '</h3>
  20. </div>
  21. <div class="information">
  22. ', $txt['admin_news_select_recipients'], '
  23. </div>
  24. <div class="windowbg">
  25. <div class="content">
  26. <dl class="settings">
  27. <dt>
  28. <strong>', $txt['admin_news_select_group'], ':</strong><br />
  29. <span class="smalltext">', $txt['admin_news_select_group_desc'], '</span>
  30. </dt>
  31. <dd>';
  32. foreach ($context['groups'] as $group)
  33. echo '
  34. <label for="groups_', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups_', $group['id'], '" value="', $group['id'], '" checked="checked" class="input_check" /> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br />';
  35. echo '
  36. <br />
  37. <label for="checkAllGroups"><input type="checkbox" id="checkAllGroups" checked="checked" onclick="invertAll(this, this.form, \'groups\');" class="input_check" /> <em>', $txt['check_all'], '</em></label>';
  38. echo '
  39. </dd>
  40. </dl><br class="clear" />
  41. </div>
  42. </div>
  43. <br />
  44. <div id="advanced_panel_header" class="cat_bar">
  45. <h3 class="catbg">
  46. <img id="advanced_panel_toggle" class="panel_toggle" style="display: none; src="', $settings['images_url'], '/', empty($context['show_advanced_options']) ? 'collapse' : 'expand', '.png" alt="*" />
  47. <a href="#" id="advanced_panel_link" >', $txt['advanced'], '</a>
  48. </h3>
  49. </div>
  50. <div id="advanced_panel_div" class="windowbg2">
  51. <div class="content">
  52. <dl class="settings">
  53. <dt>
  54. <strong>', $txt['admin_news_select_email'], ':</strong><br />
  55. <span class="smalltext">', $txt['admin_news_select_email_desc'], '</span>
  56. </dt>
  57. <dd>
  58. <textarea name="emails" rows="5" cols="30" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 98%; min-width: 98%' : 'width: 98%') . ';"></textarea>
  59. </dd>
  60. <dt>
  61. <strong>', $txt['admin_news_select_members'], ':</strong><br />
  62. <span class="smalltext">', $txt['admin_news_select_members_desc'], '</span>
  63. </dt>
  64. <dd>
  65. <input type="text" name="members" id="members" value="" size="30" class="input_text" />
  66. <span id="members_container"></span>
  67. </dd>
  68. </dl>
  69. <hr class="bordercolor" />
  70. <dl class="settings">
  71. <dt>
  72. <strong>', $txt['admin_news_select_excluded_groups'], ':</strong><br />
  73. <span class="smalltext">', $txt['admin_news_select_excluded_groups_desc'], '</span>
  74. </dt>
  75. <dd>';
  76. foreach ($context['groups'] as $group)
  77. echo '
  78. <label for="exclude_groups_', $group['id'], '"><input type="checkbox" name="exclude_groups[', $group['id'], ']" id="exclude_groups_', $group['id'], '" value="', $group['id'], '" class="input_check" /> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br />';
  79. echo '
  80. <br />
  81. <label for="checkAllGroupsExclude"><input type="checkbox" id="checkAllGroupsExclude" onclick="invertAll(this, this.form, \'exclude_groups\');" class="input_check" /> <em>', $txt['check_all'], '</em></label><br />
  82. </dd>
  83. <dt>
  84. <strong>', $txt['admin_news_select_excluded_members'], ':</strong><br />
  85. <span class="smalltext">', $txt['admin_news_select_excluded_members_desc'], '</span>
  86. </dt>
  87. <dd>
  88. <input type="text" name="exclude_members" id="exclude_members" value="" size="30" class="input_text" />
  89. <span id="exclude_members_container"></span>
  90. </dd>
  91. </dl>
  92. <hr class="bordercolor" />
  93. <dl class="settings">
  94. <dt>
  95. <label for="email_force"><strong>', $txt['admin_news_select_override_notify'], ':</strong></label><br />
  96. <span class="smalltext">', $txt['email_force'], '</span>
  97. </dt>
  98. <dd>
  99. <input type="checkbox" name="email_force" id="email_force" value="1" class="input_check" />
  100. </dd>
  101. </dl>
  102. </div>
  103. </div>
  104. <div class="righttext">
  105. <input type="submit" value="', $txt['admin_next'], '" class="button_submit" />
  106. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  107. </div>
  108. </form>
  109. </div>';
  110. // This is some javascript for the simple/advanced toggling and member suggest
  111. echo '
  112. <script type="text/javascript"><!-- // --><![CDATA[
  113. var oAdvancedPanelToggle = new smc_Toggle({
  114. bToggleEnabled: true,
  115. bCurrentlyCollapsed: ', empty($context['show_advanced_options']) ? 'true' : 'false', ',
  116. aSwappableContainers: [
  117. \'advanced_panel_div\'
  118. ],
  119. aSwapImages: [
  120. {
  121. sId: \'advanced_panel_toggle\',
  122. srcExpanded: smf_images_url + \'/collapse.png\',
  123. altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
  124. srcCollapsed: smf_images_url + \'/expand.png\',
  125. altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
  126. }
  127. ],
  128. aSwapLinks: [
  129. {
  130. sId: \'advanced_panel_link\',
  131. msgExpanded: ', JavaScriptEscape($txt['advanced']), ',
  132. msgCollapsed: ', JavaScriptEscape($txt['advanced']), '
  133. }
  134. ],
  135. oThemeOptions: {
  136. bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
  137. sOptionName: \'admin_preferences\',
  138. sSessionVar: smf_session_var,
  139. sSessionId: smf_session_id,
  140. sThemeId: \'1\'
  141. }
  142. });
  143. // ]]></script>
  144. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  145. <script type="text/javascript"><!-- // --><![CDATA[
  146. var oMemberSuggest = new smc_AutoSuggest({
  147. sSelf: \'oMemberSuggest\',
  148. sSessionId: smf_session_id,
  149. sSessionVar: smf_session_var,
  150. sSuggestId: \'members\',
  151. sControlId: \'members\',
  152. sSearchType: \'member\',
  153. bItemList: true,
  154. sPostName: \'member_list\',
  155. sURLMask: \'action=profile;u=%item_id%\',
  156. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  157. sItemListContainerId: \'members_container\',
  158. aListItems: []
  159. });
  160. var oExcludeMemberSuggest = new smc_AutoSuggest({
  161. sSelf: \'oExcludeMemberSuggest\',
  162. sSessionId: \'', $context['session_id'], '\',
  163. sSessionVar: \'', $context['session_var'], '\',
  164. sSuggestId: \'exclude_members\',
  165. sControlId: \'exclude_members\',
  166. sSearchType: \'member\',
  167. bItemList: true,
  168. sPostName: \'exclude_member_list\',
  169. sURLMask: \'action=profile;u=%item_id%\',
  170. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  171. sItemListContainerId: \'exclude_members_container\',
  172. aListItems: []
  173. });
  174. // ]]></script>';
  175. }
  176. function template_email_members_compose()
  177. {
  178. global $context, $settings, $options, $txt, $scripturl;
  179. echo '
  180. <div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
  181. <div class="cat_bar">
  182. <h3 class="catbg">
  183. <span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
  184. </h3>
  185. </div>
  186. <div class="windowbg">
  187. <div class="content">
  188. <div class="post" id="preview_body">
  189. ', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
  190. </div>
  191. </div>
  192. </div>
  193. </div><br />';
  194. echo '
  195. <div id="admincenter">
  196. <form name="newsmodify" action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="', $context['character_set'], '">
  197. <div class="cat_bar">
  198. <h3 class="catbg">
  199. <a href="', $scripturl, '?action=helpadmin;help=email_members" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '" class="icon" /></a> ', $txt['admin_newsletters'], '
  200. </h3>
  201. </div>
  202. <div class="information">
  203. ', $txt['email_variables'], '
  204. </div>
  205. <div class="windowbg">
  206. <div class="content">
  207. <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
  208. <dl>
  209. <dt>
  210. <strong id="error_serious">', $txt['error_while_submitting'] , '</strong>
  211. </dt>
  212. <dd class="error" id="error_list">
  213. ', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
  214. </dd>
  215. </dl>
  216. </div>
  217. <dl id="post_header">
  218. <dt class="clear_left">
  219. <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span>
  220. </dt>
  221. <dd id="pm_subject">
  222. <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="60" maxlength="60"',isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
  223. </dd>
  224. </dl><hr class="clear" />
  225. <div id="bbcBox_message"></div>';
  226. // What about smileys?
  227. if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
  228. echo '
  229. <div id="smileyBox_message"></div>';
  230. // Show BBC buttons, smileys and textbox.
  231. echo '
  232. ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
  233. echo '
  234. <ul class="reset">
  235. <li><label for="send_pm"><input type="checkbox" name="send_pm" id="send_pm" ', !empty($context['send_pm']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_pms'], '</label></li>
  236. <li><label for="send_html"><input type="checkbox" name="send_html" id="send_html" ', !empty($context['send_html']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_html'], '</label></li>
  237. <li><label for="parse_html"><input type="checkbox" name="parse_html" id="parse_html" checked="checked" disabled="disabled" class="input_check" /> ', $txt['email_parsed_html'], '</label></li>
  238. </ul>
  239. <p id="shortcuts" class="smalltext">
  240. ', isBrowser('is_firefox') ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '
  241. </p>
  242. <p id="post_confirm_strip" class="righttext">
  243. ', template_control_richedit_buttons($context['post_box_name']), '
  244. </p>
  245. </div>
  246. </div>
  247. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  248. <input type="hidden" name="email_force" value="', $context['email_force'], '" />
  249. <input type="hidden" name="total_emails" value="', $context['total_emails'], '" />
  250. <input type="hidden" name="max_id_member" value="', $context['max_id_member'], '" />';
  251. foreach ($context['recipients'] as $key => $values)
  252. echo '
  253. <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '" />';
  254. echo '
  255. <script type="text/javascript"><!-- // --><![CDATA[';
  256. // The functions used to preview a posts without loading a new page.
  257. echo '
  258. var txt_preview_title = "', $txt['preview_title'], '";
  259. var txt_preview_fetch = "', $txt['preview_fetch'], '";
  260. function previewPost()
  261. {';
  262. if (isBrowser('is_firefox'))
  263. echo '
  264. // Firefox doesn\'t render <marquee> that have been put it using javascript
  265. if (document.forms.newsmodify.elements[', JavaScriptEscape($context['post_box_name']), '].value.indexOf(\'[move]\') != -1)
  266. {
  267. return submitThisOnce(document.forms.newsmodify);
  268. }';
  269. echo '
  270. if (window.XMLHttpRequest)
  271. {
  272. // Opera didn\'t support setRequestHeader() before 8.01.
  273. // @todo Remove support for old browsers
  274. if (\'opera\' in window)
  275. {
  276. var test = new XMLHttpRequest();
  277. if (!(\'setRequestHeader\' in test))
  278. return submitThisOnce(document.forms.newsmodify);
  279. }
  280. // @todo Currently not sending poll options and option checkboxes.
  281. var x = new Array();
  282. var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), '];
  283. var checkboxFields = [\'send_html\', \'send_pm\'];
  284. for (var i = 0, n = textFields.length; i < n; i++)
  285. if (textFields[i] in document.forms.newsmodify)
  286. {
  287. // Handle the WYSIWYG editor.
  288. if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled)
  289. x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
  290. else
  291. x[x.length] = textFields[i] + \'=\' + document.forms.newsmodify[textFields[i]].value.replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
  292. }
  293. for (var i = 0, n = checkboxFields.length; i < n; i++)
  294. if (checkboxFields[i] in document.forms.newsmodify && document.forms.newsmodify.elements[checkboxFields[i]].checked)
  295. x[x.length] = checkboxFields[i] + \'=\' + document.forms.newsmodify.elements[checkboxFields[i]].value;
  296. x[x.length] = \'item=newsletterpreview\';
  297. sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=xmlhttp;sa=previews;xml\', x.join(\'&\'), onDocSent);
  298. document.getElementById(\'preview_section\').style.display = \'\';
  299. setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title);
  300. setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch);
  301. return false;
  302. }
  303. else
  304. return submitThisOnce(document.forms.newsmodify);
  305. }
  306. function onDocSent(XMLDoc)
  307. {
  308. if (!XMLDoc)
  309. {
  310. document.forms.newsmodify.preview.onclick = new function ()
  311. {
  312. return true;
  313. }
  314. document.forms.newsmodify.preview.click();
  315. }
  316. // Show the preview section.
  317. var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0];
  318. setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue);
  319. var bodyText = \'\';
  320. for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++)
  321. bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue;
  322. setInnerHTML(document.getElementById(\'preview_body\'), bodyText);
  323. document.getElementById(\'preview_body\').className = \'post\';
  324. // Show a list of errors (if any).
  325. var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0];
  326. var errorList = new Array();
  327. for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
  328. errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
  329. document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
  330. setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br />\'));
  331. // Adjust the color of captions if the given data is erroneous.
  332. var captions = errors.getElementsByTagName(\'caption\');
  333. for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++)
  334. if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')))
  335. document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\');
  336. if (errors.getElementsByTagName(\'post_error\').length == 1)
  337. document.forms.newsmodify.', $context['post_box_name'], '.style.border = \'1px solid red\';
  338. else if (document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\')
  339. {
  340. if (\'runtimeStyle\' in document.forms.newsmodify.', $context['post_box_name'], ')
  341. document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor = \'\';
  342. else
  343. document.forms.newsmodify.', $context['post_box_name'], '.style.border = null;
  344. }
  345. location.hash = \'#\' + \'preview_section\';
  346. }';
  347. echo '
  348. // ]]></script>';
  349. echo '
  350. <script type="text/javascript"><!-- // --><![CDATA[
  351. function checkboxes_status (item)
  352. {
  353. if (item.id == \'send_html\')
  354. document.getElementById(\'parse_html\').disabled = !document.getElementById(\'parse_html\').disabled;
  355. if (item.id == \'send_pm\')
  356. {
  357. if (!document.getElementById(\'send_html\').checked)
  358. document.getElementById(\'parse_html\').disabled = true;
  359. else
  360. document.getElementById(\'parse_html\').disabled = false;
  361. document.getElementById(\'send_html\').disabled = !document.getElementById(\'send_html\').disabled;
  362. }
  363. }
  364. // ]]></script>
  365. </form>
  366. </div>
  367. <br class="clear" />';
  368. }
  369. function template_email_members_send()
  370. {
  371. global $context, $settings, $options, $txt, $scripturl;
  372. echo '
  373. <div id="admincenter">
  374. <form action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">
  375. <div class="cat_bar">
  376. <h3 class="catbg">
  377. <a href="', $scripturl, '?action=helpadmin;help=email_members" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '" /></a> ', $txt['admin_newsletters'], '
  378. </h3>
  379. </div>
  380. <div class="windowbg">
  381. <div class="content">
  382. <div class="progress_bar">
  383. <div class="full_bar">', $context['percentage_done'], '% ', $txt['email_done'], '</div>
  384. <div class="green_percent" style="width: ', $context['percentage_done'], '%;">&nbsp;</div>
  385. </div>
  386. <hr class="hrcolor" />
  387. <input type="submit" name="b" value="', $txt['email_continue'], '" class="button_submit" />
  388. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  389. <input type="hidden" name="subject" value="', $context['subject'], '" />
  390. <input type="hidden" name="message" value="', $context['message'], '" />
  391. <input type="hidden" name="start" value="', $context['start'], '" />
  392. <input type="hidden" name="total_emails" value="', $context['total_emails'], '" />
  393. <input type="hidden" name="max_id_member" value="', $context['max_id_member'], '" />
  394. <input type="hidden" name="send_pm" value="', $context['send_pm'], '" />
  395. <input type="hidden" name="send_html" value="', $context['send_html'], '" />
  396. <input type="hidden" name="parse_html" value="', $context['parse_html'], '" />';
  397. // All the things we must remember!
  398. foreach ($context['recipients'] as $key => $values)
  399. echo '
  400. <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '" />';
  401. echo '
  402. <br class="clear_right" />
  403. </div>
  404. </div>
  405. </form>
  406. </div>
  407. <br class="clear" />
  408. <script type="text/javascript"><!-- // --><![CDATA[
  409. var countdown = 2;
  410. doAutoSubmit();
  411. function doAutoSubmit()
  412. {
  413. if (countdown == 0)
  414. document.forms.autoSubmit.submit();
  415. else if (countdown == -1)
  416. return;
  417. document.forms.autoSubmit.b.value = "', $txt['email_continue'], ' (" + countdown + ")";
  418. countdown--;
  419. setTimeout("doAutoSubmit();", 1000);
  420. }
  421. // ]]></script>';
  422. }
  423. ?>