PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/include/inc_tmpl/newsletter.list.tmpl.php

http://phpwcms.googlecode.com/
PHP | 229 lines | 151 code | 54 blank | 24 comment | 30 complexity | 72bd7b26cbb5fcb8eb4db1135e37a64f MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1, ISC, MIT, LGPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.0, BSD-3-Clause
  1. <?php
  2. /**
  3. * phpwcms content management system
  4. *
  5. * @author Oliver Georgi <oliver@phpwcms.de>
  6. * @copyright Copyright (c) 2002-2013, Oliver Georgi
  7. * @license http://opensource.org/licenses/GPL-2.0 GNU GPL-2
  8. * @link http://www.phpwcms.de
  9. *
  10. **/
  11. // ----------------------------------------------------------------
  12. // obligate check for phpwcms constants
  13. if (!defined('PHPWCMS_ROOT')) {
  14. die("You Cannot Access This Script Directly, Have a Nice Day.");
  15. }
  16. // ----------------------------------------------------------------
  17. if(isset($_GET["s"])) {
  18. include_once(PHPWCMS_ROOT.'/include/inc_lib/newsletter.form.inc.php');
  19. if(isset($_GET['edit'])) {
  20. include_once(PHPWCMS_ROOT.'/include/inc_tmpl/newsletter.form.tmpl.php');
  21. }
  22. if(isset($_GET['send']) && $show_nl_send) {
  23. include_once(PHPWCMS_ROOT.'/include/inc_tmpl/newsletter.send.tmpl.php');
  24. }
  25. } else {
  26. if(isset($_GET['duplicate_nl'])) {
  27. @_dbDuplicateRow( 'phpwcms_newsletter', 'newsletter_id', intval($_GET['duplicate_nl']),
  28. array('newsletter_active' => 0, 'newsletter_changed' => 'SQL:NOW()',
  29. 'newsletter_lastsending' => '0000-00-00 00:00:00', 'newsletter_created' => 'SQL:NOW()',
  30. 'newsletter_subject' => '--SELF-- (copy)'));
  31. }
  32. // check if subscription should be edited
  33. // create paginating for newsletter
  34. if(isset($_GET['c'])) {
  35. $_SESSION['list_newsletter_count'] = $_GET['c'] == 'all' ? '99999' : intval($_GET['c']);
  36. }
  37. // set default values for paginating
  38. if(empty($_SESSION['list_newsletter_count'])) {
  39. $_SESSION['list_newsletter_count'] = 10;
  40. }
  41. // set page
  42. if(isset($_GET['page'])) {
  43. $_SESSION['newsletter_page'] = intval($_GET['page']);
  44. }
  45. $_newsletter['count_total'] = _dbQuery("SELECT COUNT(*) FROM ".DB_PREPEND."phpwcms_newsletter WHERE newsletter_trashed=0", 'COUNT');
  46. $_newsletter['pages_total'] = ceil($_newsletter['count_total'] / $_SESSION['list_newsletter_count']);
  47. if(empty($_SESSION['newsletter_page'])) {
  48. $_SESSION['newsletter_page'] = 1;
  49. }
  50. if($_SESSION['newsletter_page'] > $_newsletter['pages_total']) {
  51. $_SESSION['newsletter_page'] = $_newsletter['pages_total'];
  52. }
  53. if($_SESSION['newsletter_page'] < 1) {
  54. $_SESSION['newsletter_page'] = 1;
  55. }
  56. ?>
  57. <div class="title" style="margin-bottom:10px"><?php echo $BL['be_subnav_msg_newslettersend'] ?></div>
  58. <div class="navBarLeft imgButton chatlist">
  59. &nbsp;&nbsp;
  60. <a href="phpwcms.php?do=messages&amp;p=3&amp;s=0&amp;edit=1"><img src="img/famfamfam/email_add.gif" alt="Add" border="0" /><span><?php echo $BL['be_newsletter_new'] ?></span></a>
  61. </div>
  62. <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
  63. <tr>
  64. <td><?php
  65. if($_newsletter['pages_total'] > 1) {
  66. echo '<table border="0" cellpadding="0" cellspacing="0" summary=""><tr><td>';
  67. if($_SESSION['newsletter_page'] > 1) {
  68. echo '<a href="phpwcms.php?do=messages&amp;p=3&amp;page='.($_SESSION['newsletter_page']-1).'">';
  69. echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" /></a>';
  70. } else {
  71. echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" class="inactive" />';
  72. }
  73. echo '</td>';
  74. echo '<td><input type="text" name="page" id="page" maxlength="4" size="4" value="'.$_SESSION['newsletter_page'];
  75. echo '" class="textinput" style="margin:0 3px 0 5px;width:30px;font-weight:bold;" /></td>';
  76. echo '<td class="chatlist">/'.$_newsletter['pages_total'].'&nbsp;</td>';
  77. echo '<td>';
  78. if($_SESSION['newsletter_page'] < $_newsletter['pages_total']) {
  79. echo '<a href="phpwcms.php?do=messages&amp;p=3&amp;page='.($_SESSION['newsletter_page']+1).'">';
  80. echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" /></a>';
  81. } else {
  82. echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" class="inactive" />';
  83. }
  84. echo '</td></tr></table>';
  85. } else {
  86. echo '&nbsp;';
  87. }
  88. ?>
  89. </td>
  90. <td class="chatlist" align="right">
  91. <a href="phpwcms.php?do=messages&amp;p=3&amp;c=5">5</a>
  92. <a href="phpwcms.php?do=messages&amp;p=3&amp;c=10">10</a>
  93. <a href="phpwcms.php?do=messages&amp;p=3&amp;c=25">25</a>
  94. <a href="phpwcms.php?do=messages&amp;p=3&amp;c=50">50</a>
  95. <a href="phpwcms.php?do=messages&amp;p=3&amp;c=100">100</a>
  96. <a href="phpwcms.php?do=messages&amp;p=3&amp;c=all"><?php echo $BL['be_ftptakeover_all'] ?></a>
  97. </td>
  98. </tr>
  99. </table>
  100. <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
  101. <tr class="tableHeadRow">
  102. <th>&nbsp;</th>
  103. <th style="text-align:left"><?php echo $BL['be_msg_subject'] ?></th>
  104. <th><?php echo $BL['be_newsletter_changed'] ?></th>
  105. <th><?php echo str_replace(' ', '<br />', $BL['be_last_sending']) ?></th>
  106. <th><?php echo $BL['be_total'].'/<br />'.$BL['be_cnt_queued'].'/<br />'.$BL['be_msg_senttop'] ?></th>
  107. <th>&nbsp;</th>
  108. </tr>
  109. <tr><td colspan="6" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1" /></td></tr>
  110. <?php
  111. // loop listing available newsletters
  112. $sql = "SELECT *, UNIX_TIMESTAMP(newsletter_changed) AS cdate, UNIX_TIMESTAMP(newsletter_lastsending) AS lastsend FROM ".DB_PREPEND."phpwcms_newsletter WHERE newsletter_trashed=0 ORDER BY newsletter_changed DESC";
  113. $sql .= " LIMIT ".(($_SESSION['newsletter_page']-1) * $_SESSION['list_newsletter_count']).','.$_SESSION['list_newsletter_count'];
  114. $result = _dbQuery($sql);
  115. if(isset($result[0]['newsletter_id'])) {
  116. $row_count = 0;
  117. foreach($result as $row) {
  118. $row['newsletter_vars'] = unserialize($row['newsletter_vars']);
  119. echo '<tr'.( ($row_count % 2) ? ' bgcolor="#F3F5F8"' : '' ).' class="listrow">'.LF;
  120. echo '<td width="2%" style="padding:2px 5px 2px 4px;">';
  121. // sent/queue status
  122. $count_sent = _dbQuery('SELECT COUNT(*) FROM '.DB_PREPEND.'phpwcms_newsletterqueue WHERE queue_status=1 AND queue_pid='.$row["newsletter_id"], 'COUNT');
  123. $count_queue = _dbQuery('SELECT COUNT(*) FROM '.DB_PREPEND.'phpwcms_newsletterqueue WHERE queue_status=0 AND queue_pid='.$row["newsletter_id"], 'COUNT');
  124. $count_recipient = countNewsletterRecipients($row['newsletter_vars']['subscription']);
  125. if(empty($row["newsletter_active"]) || !$count_queue) {
  126. echo '<img src="img/famfamfam/email.gif" alt="NL" title="ID:'.$row["newsletter_id"].'" />';
  127. } else {
  128. echo '<a href="phpwcms.php?do=messages&amp;p=3&amp;s='.$row["newsletter_id"];
  129. echo '&amp;send=1"><img src="img/famfamfam/email_go.gif" alt="Send" border="0" title="ID:'.$row["newsletter_id"].'"></a>';
  130. }
  131. echo '</td>'.LF;
  132. echo '<td class="dir"><strong>'.html_specialchars($row["newsletter_subject"])."</strong></td>\n";
  133. // create date
  134. echo '<td nowrap="nowrap" class="v10" align="center">&nbsp;';
  135. if($row['cdate']) {
  136. echo @date($BL['be_shortdatetime'], $row['cdate']);
  137. }
  138. echo '&nbsp;</td>';
  139. // last sending
  140. echo '<td nowrap="nowrap" class="v10" align="center">&nbsp;';
  141. if($row['lastsend']) {
  142. @date($BL['be_shortdatetime'], $row['lastsend']);
  143. }
  144. echo '&nbsp;</td>';
  145. echo '<td nowrap="nowrap" class="v10" align="center">'.$count_recipient.'/'.$count_queue.'/'.$count_sent;
  146. if($count_sent && !$count_queue && $row["newsletter_active"]) {
  147. echo '<img src="img/symbole/valid.gif" border="0" alt="valid" style="margin: 0 0 0 3px" />';
  148. }
  149. echo '&nbsp;</td>';
  150. // buttons
  151. echo '<td align="right" nowrap="nowrap" class="button_td">';
  152. // duplicate
  153. echo '<a href="phpwcms.php?do=messages&amp;p=3&amp;duplicate_nl='.$row["newsletter_id"];
  154. echo '"><img src="img/button/copy_11x11_0.gif" alt="Duplicate" border="0" style="margin:1px 3px 1px 0" /></a>';
  155. // edit
  156. echo '<a href="phpwcms.php?do=messages&amp;p=3&amp;s='.$row["newsletter_id"];
  157. echo '&amp;edit=1"><img src="img/button/edit_22x13.gif" alt="Edit" border="0" /></a>';
  158. // delete
  159. echo '<a href="phpwcms.php?do=messages&amp;p=3&amp;s='.$row["newsletter_id"].'&amp;del='.$row["newsletter_id"];
  160. echo '" title="delete: '.html_specialchars($row["newsletter_subject"]);
  161. echo '" onclick="return confirm(\'Delete newsletter: '.js_singlequote(html_specialchars($row["newsletter_subject"])).'\');">';
  162. echo '<img src="img/button/trash_13x13_1.gif" border="0" alt="Delete" /></a>';
  163. echo "</td>\n</tr>\n";
  164. $row_count++;
  165. }
  166. } else {
  167. echo '<tr><td colspan="6">&nbsp;no newsletter available</td></tr>';
  168. }
  169. ?>
  170. <tr><td colspan="6" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1" /></td></tr>
  171. <tr><td colspan="6"><img src="img/leer.gif" alt="" width="1" height="8" /></td></tr>
  172. </table>
  173. <?php
  174. }
  175. ?>