ManageNews.template.php 19 KB

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