ManageNews.template.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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="admincenter">
  169. <form action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="', $context['character_set'], '">
  170. <div class="cat_bar">
  171. <h3 class="catbg">
  172. <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'], '
  173. </h3>
  174. </div>
  175. <div class="information">
  176. ', $txt['email_variables'], '
  177. </div>
  178. <div class="windowbg">
  179. <span class="topslice"><span></span></span>
  180. <div class="content">
  181. <div id="preview_box" ', empty($context['preview_subject']) && empty($context['preview_message']) ? 'style="display:none"' : '', '>
  182. <div style="padding-bottom:10px"><em>', $txt['email_preview_warning'], '</em></div>
  183. <strong>', $txt['subject'], '</strong>:
  184. <div style="padding-left:10px;padding-bottom:10px" id="subject_preview">', !isset($context['preview_subject']) ? '' : $context['preview_subject'], '</div>
  185. <strong>', $txt['message'], '</strong>:
  186. <div style="padding-left:10px;padding-bottom:10px" id="message_preview">', !isset($context['preview_message']) ? '' : $context['preview_message'], '</div>
  187. </div>
  188. <p>
  189. <input type="text" name="subject" id="subject" size="60" value="', empty($context['subject']) ? $context['default_subject'] : $context['subject'], '" class="input_text" />
  190. </p>
  191. <p>
  192. <textarea cols="70" rows="9" name="message" id="message" class="editor">', empty($context['message']) ? $context['default_message'] : $context['message'], '</textarea>
  193. </p>
  194. <ul class="reset">
  195. <li><label for="send_pm"><input type="checkbox" name="send_pm" id="send_pm" ', !empty($context['send_pm']) ? 'checked="checked"' : '', 'class="input_check" onclick="if (this.checked && ', $context['total_emails'], ' != 0 && !confirm(\'', $txt['admin_news_cannot_pm_emails_js'], '\')) return false; this.form.parse_html.disabled = this.checked; this.form.send_html.disabled = this.checked; " /> ', $txt['email_as_pms'], '</label></li>
  196. <li><label for="send_html"><input type="checkbox" name="send_html" id="send_html" ', !empty($context['send_html']) ? 'checked="checked"' : '', 'class="input_check" onclick="this.form.parse_html.disabled = !this.checked;" /> ', $txt['email_as_html'], '</label></li>
  197. <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>
  198. </ul>
  199. <p>
  200. <input type="submit" onclick="make_preview(); return false;" name="preview" value="', $txt['preview'], '" class="button_submit" />
  201. <input type="submit" value="', $txt['sendtopic_send'], '" class="button_submit" />
  202. </p>
  203. </div>
  204. <span class="botslice"><span></span></span>
  205. </div>
  206. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  207. <input type="hidden" name="email_force" value="', $context['email_force'], '" />
  208. <input type="hidden" name="total_emails" value="', $context['total_emails'], '" />
  209. <input type="hidden" name="max_id_member" value="', $context['max_id_member'], '" />';
  210. foreach ($context['recipients'] as $key => $values)
  211. echo '
  212. <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '" />';
  213. echo '
  214. <script type="text/javascript"><!-- // --><![CDATA[
  215. function make_preview ()
  216. {
  217. $("#preview_box").css({display: \'\'});
  218. $("#subject_preview").html(\'', $txt['preview_fetch'], '\');
  219. $("#message_preview").html(\'', $txt['preview_fetch'], '\');
  220. $.ajax({
  221. type: "POST",
  222. url: "' . $scripturl . '?action=xmlhttp;sa=previews;xml",
  223. data: {
  224. item: "newsletterpreview",
  225. message: $("#message").val(),
  226. subject: $("#subject").val(),
  227. send_html: $("#send_html").is(\':checked\') ? 1 : 0,
  228. send_pm: $("#send_pm").is(\':checked\') ? 1 : 0,
  229. },
  230. context: document.body,
  231. success: function(request){
  232. if ($(request).find(\'[type="subject_preview"]\').text() == \'\')
  233. $("#subject_preview").html($(request).find("subject").text());
  234. else
  235. $("#subject_preview").html($(request).find(\'[type="subject_preview"]\').text()).css({color: "red"});
  236. if ($(request).find(\'[type="message_preview"]\').text() == \'\')
  237. $("#message_preview").html($(request).find("message").text());
  238. else
  239. $("#message_preview").html($(request).find(\'[type="message_preview"]\').text()).css({color: "red"});
  240. },
  241. });
  242. }
  243. // ]]></script>
  244. </form>
  245. </div>
  246. <br class="clear" />';
  247. }
  248. function template_email_members_send()
  249. {
  250. global $context, $settings, $options, $txt, $scripturl;
  251. echo '
  252. <div id="admincenter">
  253. <form action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">
  254. <div class="cat_bar">
  255. <h3 class="catbg">
  256. <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'], '
  257. </h3>
  258. </div>
  259. <div class="windowbg">
  260. <span class="topslice"><span></span></span>
  261. <div class="content">
  262. <p>
  263. <strong>', $context['percentage_done'], '% ', $txt['email_done'], '</strong>
  264. </p>
  265. <input type="submit" name="b" value="', $txt['email_continue'], '" class="button_submit" />
  266. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  267. <input type="hidden" name="subject" value="', $context['subject'], '" />
  268. <input type="hidden" name="message" value="', $context['message'], '" />
  269. <input type="hidden" name="start" value="', $context['start'], '" />
  270. <input type="hidden" name="total_emails" value="', $context['total_emails'], '" />
  271. <input type="hidden" name="max_id_member" value="', $context['max_id_member'], '" />
  272. <input type="hidden" name="send_pm" value="', $context['send_pm'], '" />
  273. <input type="hidden" name="send_html" value="', $context['send_html'], '" />
  274. <input type="hidden" name="parse_html" value="', $context['parse_html'], '" />';
  275. // All the things we must remember!
  276. foreach ($context['recipients'] as $key => $values)
  277. echo '
  278. <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '" />';
  279. echo '
  280. </div>
  281. <span class="botslice"><span></span></span>
  282. </div>
  283. </form>
  284. </div>
  285. <br class="clear" />
  286. <script type="text/javascript"><!-- // --><![CDATA[
  287. var countdown = 2;
  288. doAutoSubmit();
  289. function doAutoSubmit()
  290. {
  291. if (countdown == 0)
  292. document.forms.autoSubmit.submit();
  293. else if (countdown == -1)
  294. return;
  295. document.forms.autoSubmit.b.value = "', $txt['email_continue'], ' (" + countdown + ")";
  296. countdown--;
  297. setTimeout("doAutoSubmit();", 1000);
  298. }
  299. // ]]></script>';
  300. }
  301. ?>