[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_tmpl/ -> message.subscribers.tmpl.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  
  31  $_userInfo = array();
  32  
  33  // delete all duplicate addresses
  34  if(isset($_GET['duplicate']) && $_GET['duplicate'] == 'remove') {
  35      $data = _dbQuery('SELECT COUNT(*) AS address_count, address_email FROM '.DB_PREPEND.'phpwcms_address GROUP BY address_email');
  36      if($data) {
  37      
  38          foreach($data as $value) {
  39              
  40              // check for multiple entries
  41              if($value['address_count'] > 1) {
  42              
  43                  $sql  = 'SELECT address_id FROM '.DB_PREPEND.'phpwcms_address ';
  44                  $sql .= "WHERE address_email='".aporeplace($value['address_email'])."' ";
  45                  $sql .= 'ORDER BY address_verified DESC, address_name DESC LIMIT 1';
  46                  $dataID = _dbQuery($sql);
  47                  
  48                  if(!empty($dataID[0]['address_id'])) {
  49                      $sql  = 'DELETE FROM '.DB_PREPEND.'phpwcms_address ';
  50                      $sql .= "WHERE address_email='".aporeplace($value['address_email'])."' ";
  51                      $sql .= "AND address_id != ".intval($dataID[0]['address_id']);
  52                      @_dbQuery($sql, 'DELETE');
  53                  }
  54      
  55              }
  56          }
  57      }
  58      headerRedirect(PHPWCMS_URL.'phpwcms.php?do=messages&p=4');
  59  }
  60  
  61  
  62  // delete susbcriber
  63  if(isset($_GET["del"]) && isset($_GET["s"]) && $_GET["del"] == $_GET["s"]) {
  64      _dbQuery("DELETE FROM ".DB_PREPEND."phpwcms_address WHERE address_id=".intval($_GET["del"])." LIMIT 1", 'DELETE');
  65  }
  66  // change verification
  67  if(isset($_GET["verify"]) && isset($_GET["s"])) {
  68      $sql  = "UPDATE ".DB_PREPEND."phpwcms_address SET address_verified=";
  69      $sql .= intval($_GET["verify"]) ? 1 : 0;
  70      $sql .= " WHERE address_id=".intval($_GET["s"])." LIMIT 1";
  71      _dbQuery($sql, 'UPDATE');
  72  }
  73  
  74  
  75  
  76  
  77  
  78  echo '<div class="title" style="margin-bottom:10px">'.$BL['be_subnav_msg_subscribers'].'</div>';
  79  ?>
  80  
  81  <div class="navBar imgButton chatlist">
  82      <a href="phpwcms.php?do=messages&amp;p=4&amp;s=0&amp;edit=1"><img src="img/famfamfam/vcard_add.gif" alt="Add" border="0" /><span><?php echo $BL['be_cnt_new_recipient'] ?></span></a>
  83      &nbsp;
  84      <a href="phpwcms.php?do=messages&amp;p=4&amp;duplicate=remove" onclick="return confirm('Delete all duplicate subscribers?');"><img src="img/famfamfam/vcard_delete.gif" alt="Delete" border="0" /><span><?php echo $BL['be_cnt_delete_duplicates'] ?></span></a>
  85      &nbsp;
  86      <a href="phpwcms.php?do=messages&amp;p=4&amp;import=1"><img src="img/famfamfam/table_add.gif" alt="Import" border="0" /><span><?php echo $BL['be_newsletter_newimport'] ?></span></a>
  87      &nbsp;
  88      <a href="include/inc_act/act_export.php?action=exportsubscriber" target="_blank" onclick="return confirm('Export all subscribers based on current selection?');"><img src="img/famfamfam/icon_download.gif" alt="Download" border="0" /><span><?php echo $BL['be_cnt_export_selection'] ?></span></a>
  89  </div>
  90  
  91  
  92  <?php
  93  
  94  // recipient edit form
  95  if(isset($_GET["s"]) && isset($_GET["edit"])) {
  96  
  97      $_userInfo['subscriber_id'] = intval($_GET["s"]);
  98  
  99      if($_userInfo['subscriber_id'] === 0) {
 100          
 101          $_userInfo['subscriber_data']['address_email']            = '';
 102          $_userInfo['subscriber_data']['address_name']            = '';
 103          $_userInfo['subscriber_data']['address_id']                = 0;
 104          $_userInfo['subscriber_data']['address_subscription']    = '';
 105          $_userInfo['subscriber_data']['address_tstamp']            = date('Y-m-d H:i:s');
 106          $_userInfo['subscriber_data']['address_verified']        = 0;
 107          
 108      } else {
 109          $_userInfo['subscriber_data']    = _dbQuery("SELECT * FROM ".DB_PREPEND."phpwcms_address WHERE address_id=".$_userInfo['subscriber_id']." LIMIT 1");
 110          if($_userInfo['subscriber_data']) {
 111              $_userInfo['subscriber_data']  = $_userInfo['subscriber_data'][0];
 112          }
 113      }
 114      
 115      if(isset($_POST['subscribe_email'])) {
 116          include_once (PHPWCMS_ROOT.'/include/inc_lib/subscriber.form.inc.php');
 117      }
 118      
 119      if($_userInfo['subscriber_data']) {
 120          include_once (PHPWCMS_ROOT.'/include/inc_tmpl/subscriber.form.tmpl.php');
 121      }
 122  }
 123  
 124  
 125  // import form
 126  if(isset($_GET['import']) && $_GET['import'] === '1') {
 127  
 128      $_userInfo['delimeter']            = ';';
 129      $_userInfo['subscribe_active']    = 1;
 130      $_userInfo['subscribe_all']        = 1;
 131      $_userInfo['subscribe_select']    = array();
 132  
 133      if(isset($_POST['delimeter'])) {
 134      
 135          include_once (PHPWCMS_ROOT.'/include/inc_lib/subscriberimport.form.inc.php');
 136          
 137          if(isset($_userInfo['csvError'])) {
 138              include_once (PHPWCMS_ROOT.'/include/inc_tmpl/subscriberimport.form.tmpl.php');
 139          } else {
 140              include_once (PHPWCMS_ROOT.'/include/inc_tmpl/subscriberimport.result.tmpl.php');
 141          }
 142      
 143      } else {
 144  
 145          include_once (PHPWCMS_ROOT.'/include/inc_tmpl/subscriberimport.form.tmpl.php');
 146  
 147      }
 148  
 149  }
 150  
 151  
 152  // create paginating for users
 153  if(isset($_GET['c'])) {
 154      $_SESSION['list_user_count'] = (trim($_GET['c']) == 'all') ? '99999' : intval($_GET['c']);
 155  }
 156  if(isset($_GET['page'])) {
 157      $_SESSION['subscriber_page'] = intval($_GET['page']);
 158  }
 159  
 160  
 161  // set default values for paginating
 162  if(empty($_SESSION['list_user_count'])) {
 163      $_SESSION['list_user_count'] = 25;
 164  }
 165  
 166  // get filter and paginating form values
 167  if(isset($_POST['do_pagination'])) {
 168  
 169      $_SESSION['list_active']    = empty($_POST['showactive']) ? 0 : 1;
 170      $_SESSION['list_inactive']    = empty($_POST['showinactive']) ? 0 : 1;
 171      $_SESSION['list_channel']    = empty($_POST['showchannel']) ? 0 : 1;
 172      
 173      $_SESSION['subscriber_page']    = intval($_POST['page']);
 174      $_SESSION['filter_subscriber']    = clean_slweg($_POST['filter']);
 175      if(empty($_SESSION['filter_subscriber'])) {
 176          unset($_SESSION['filter_subscriber']);
 177      } else {
 178          $_SESSION['filter_subscriber']    = convertStringToArray($_SESSION['filter_subscriber'], ' ');
 179      }
 180  }
 181  
 182  if(empty($_SESSION['subscriber_page'])) {
 183      $_SESSION['subscriber_page'] = 1;
 184  }
 185  
 186  // default settings for listing selected users
 187  $_userInfo['list_active']        = isset($_SESSION['list_active'])    ? $_SESSION['list_active']        : 1;
 188  $_userInfo['list_inactive']        = isset($_SESSION['list_inactive'])    ? $_SESSION['list_inactive']    : 1;
 189  $_userInfo['list_channel']        = isset($_SESSION['list_channel'])    ? $_SESSION['list_channel']        : 0;
 190  
 191  if($_userInfo['list_channel'] && isset($_POST['showchannel'])) {
 192      $_userInfo['channel'] = empty($_POST['subscribe_select']) ? false : $_POST['subscribe_select'];
 193      $_SESSION['channel'] = $_userInfo['channel'];
 194  } elseif($_userInfo['list_channel'] && isset($_SESSION['channel'])) {
 195      $_userInfo['channel'] = $_SESSION['channel'];
 196  } else {
 197      $_userInfo['channel'] = false;
 198  }
 199  
 200  $_userInfo['list']            = array();
 201  // if admin user should be listed
 202  $_userInfo['where_query']    = '';
 203  if($_userInfo['list_active'] != $_userInfo['list_inactive'] && $_userInfo['list_active']) {
 204      $_userInfo['where_query']    = ' WHERE address_verified=1';
 205  } elseif($_userInfo['list_active'] != $_userInfo['list_inactive'] && $_userInfo['list_inactive']) {
 206      $_userInfo['where_query']    = ' WHERE address_verified=0';
 207  }
 208  
 209  if(isset($_SESSION['filter_subscriber']) && count($_SESSION['filter_subscriber'])) {
 210      
 211      $_userInfo['filter_array'] = array();
 212  
 213      foreach($_SESSION['filter_subscriber'] as $_userInfo['filter']) {
 214          //usr_name, usr_login, usr_email
 215          $_userInfo['filter_array'][] = "CONCAT(address_email, address_name) LIKE '%".aporeplace($_userInfo['filter'])."%'";
 216      }
 217      if(count($_userInfo['filter_array'])) {
 218          
 219          $_userInfo['where_query'] .= $_userInfo['where_query'] ? ' AND ' : ' WHERE ';
 220          $_userInfo['where_query'] .= '('.implode(' OR ', $_userInfo['filter_array']).')';
 221      
 222      }
 223  
 224  }
 225  
 226  // paginating values
 227  $_userInfo['count_total'] = _dbQuery("SELECT COUNT(*) FROM ".DB_PREPEND."phpwcms_address".$_userInfo['where_query'], 'COUNT');
 228  $_userInfo['pages_total'] = ceil($_userInfo['count_total'] / $_SESSION['list_user_count']);
 229  if($_SESSION['subscriber_page'] > $_userInfo['pages_total']) {
 230      $_SESSION['subscriber_page'] = empty($_userInfo['pages_total']) ? 1 : $_userInfo['pages_total'];
 231  }
 232  
 233  
 234  ?>
 235  <form action="phpwcms.php?do=messages&amp;p=4" method="post" name="paginate" id="paginate"><input type="hidden" name="do_pagination" value="1" />
 236  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="paginate" summary="">
 237          <tr>
 238              <td><table border="0" cellpadding="0" cellspacing="0" summary="">
 239                  <tr>
 240                      
 241                      <td><input type="checkbox" name="showactive" id="showactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_userInfo['list_active'], 1) ?> /></td>
 242                      <td><label for="showactive"><img src="img/button/aktiv_12x13_1.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td>
 243                      <td><input type="checkbox" name="showinactive" id="showinactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_userInfo['list_inactive'], 1) ?> /></td>
 244                      <td><label for="showinactive"><img src="img/button/aktiv_12x13_0.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td>
 245                      
 246                      <td<?php if($_userInfo['list_channel']) echo ' class="channelSelectTd"' ?>><input type="checkbox" name="showchannel" id="showchannel" value="1" onclick="this.form.submit();"<?php is_checked(1, $_userInfo['list_channel'], 1) ?> /></td>
 247                      <td<?php if($_userInfo['list_channel']) echo ' class="channelSelectTd"' ?>><label for="showchannel"><img src="img/symbole/newsletter_susbcription.gif" alt="Subscription" style="margin:1px 0 0 1px;" /></label></td>
 248                      
 249                      
 250                      
 251  <?php 
 252  if($_userInfo['pages_total'] > 1) {
 253  
 254      echo '<td class="chatlist">|&nbsp;</td>';
 255      echo '<td>';
 256      if($_SESSION['subscriber_page'] > 1) {
 257          echo '<a href="phpwcms.php?do=messages&amp;p=4&amp;page='.($_SESSION['subscriber_page']-1).'">';
 258          echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" /></a>';
 259      } else {
 260          echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" class="inactive" />';
 261      }
 262      echo '</td>';
 263      echo '<td><input type="text" name="page" id="page" maxlength="4" size="4" value="'.$_SESSION['subscriber_page'];
 264      echo '"  class="textinput" style="margin:0 3px 0 5px;width:30px;font-weight:bold;" /></td>';
 265      echo '<td class="chatlist">/'.$_userInfo['pages_total'].'&nbsp;</td>';
 266      echo '<td>';
 267      if($_SESSION['subscriber_page'] < $_userInfo['pages_total']) {
 268          echo '<a href="phpwcms.php?do=messages&amp;p=4&amp;page='.($_SESSION['subscriber_page']+1).'">';
 269          echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" /></a>';
 270      } else {
 271          echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" class="inactive" />';
 272      }
 273      echo '</td><td class="chatlist">&nbsp;|&nbsp;</td>';
 274  
 275  } else {
 276  
 277      echo '<td class="chatlist">|&nbsp;<input type="hidden" name="page" id="page" value="1" /></td>';
 278  
 279  }
 280  ?>    
 281  
 282      <td><input type="text" name="filter" id="filter" size="10" value="<?php 
 283      
 284      if(isset($_SESSION['filter_subscriber']) && count($_SESSION['filter_subscriber']) ) {
 285          echo html_specialchars(implode(' ', $_SESSION['filter_subscriber']));
 286      }
 287      
 288      ?>" class="textinput" style="margin:0 2px 0 0;width:110px;text-align:left;" title="filter results by username, name or email" /></td>
 289      <td><input type="image" name="gofilter" src="img/famfamfam/action_go.gif" style="margin-right:3px;" /></td>
 290  
 291      </tr>
 292      </table></td>
 293  
 294  
 295  
 296      <td class="chatlist" align="right">
 297          <a href="phpwcms.php?do=messages&amp;p=4&amp;c=10">10</a>
 298          <a href="phpwcms.php?do=messages&amp;p=4&amp;c=25">25</a>
 299          <a href="phpwcms.php?do=messages&amp;p=4&amp;c=50">50</a>
 300          <a href="phpwcms.php?do=messages&amp;p=4&amp;c=100">100</a>
 301          <a href="phpwcms.php?do=messages&amp;p=4&amp;c=250">250</a>
 302          <a href="phpwcms.php?do=messages&amp;p=4&amp;c=all"><?php echo $BL['be_ftptakeover_all'] ?></a>
 303      </td>
 304  
 305      </tr>
 306  </table>
 307  <?php 
 308  
 309  // set filter select by channel
 310  if($_userInfo['list_channel']) { 
 311  
 312      
 313      
 314      $_userInfo['subscriptions'] = _dbQuery("SELECT * FROM ".DB_PREPEND."phpwcms_subscription ORDER BY subscription_name");
 315  
 316      if($_userInfo['subscriptions']) {
 317      
 318          $_userInfo['select_subscr'] = '';
 319              
 320          foreach($_userInfo['subscriptions'] as $value) {
 321          
 322              $_userInfo['select_subscr'] .= '        <tr>
 323                  <td><input type="checkbox" name="subscribe_select['.$value['subscription_id'].
 324                  ']" id="subscribe_select'.$value['subscription_id'].'" value="'.$value['subscription_id'].'"';
 325              
 326              if(!empty($_userInfo['channel'][$value['subscription_id']]) && $_userInfo['channel'][$value['subscription_id']]==$value['subscription_id']) {                
 327                  $_userInfo['select_subscr'] .= ' checked="checked"';
 328              }
 329              
 330              $_userInfo['select_subscr'] .= ' /></td>
 331                  <td><label for="subscribe_select'.$value['subscription_id'].'">'.
 332                  html_specialchars($value['subscription_name']).
 333                  '</label></td>
 334              </tr>
 335              ';
 336          }
 337          
 338          if($_userInfo['select_subscr']) {
 339  
 340              echo '<div id="channelSelect">'.LF;
 341              echo '<table cellpadding="0" cellspacing="0" border="0">'.LF;
 342              echo $_userInfo['select_subscr'];
 343              echo '</table>'.LF;
 344              //echo '<input type="image" name="gofilter" src="img/famfamfam/action_go.gif" class="channelSelectSubmit" />';
 345              echo '</div>';
 346  
 347          }
 348      
 349      }
 350  
 351  
 352      
 353  
 354  }
 355  
 356  ?>
 357  </form>
 358  <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
 359          
 360      <tr><td colspan="4"><img src="img/leer.gif" alt="" width="1" height="3"></td></tr>
 361      <tr><td colspan="4" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1"></td></tr>
 362  
 363  <?php
 364  // loop listing available newsletters
 365  $row_count = 0;                
 366  
 367  $sql  = "SELECT * FROM ".DB_PREPEND."phpwcms_address".$_userInfo['where_query']." ";
 368  $sql .= "LIMIT ".(($_SESSION['subscriber_page']-1) * $_SESSION['list_user_count']).','.$_SESSION['list_user_count'];
 369  $data = _dbQuery($sql);
 370  
 371  foreach($data as $row) {
 372  
 373      // mark selected channel
 374      if($_userInfo['channel'] !== false) {
 375      
 376          $_userInfo['channel_select'] = ' class="inactive"';
 377      
 378          $row['channel'] = unserialize($row['address_subscription']);
 379          if(is_array($row['channel']) && count($row['channel'])) {
 380          
 381              foreach($row['channel'] as $channel) {
 382              
 383                  if(isset($_userInfo['channel'][$channel])) {
 384                      $_userInfo['channel_select'] = '';
 385                      break;
 386                  }
 387              
 388              }
 389      
 390          }
 391  
 392      } else {
 393      
 394          $_userInfo['channel_select'] = '';
 395      
 396      }
 397  
 398      $row["address_email"] = html_specialchars($row["address_email"]);
 399      echo '<tr'.( ($row_count % 2) ? ' bgcolor="#F3F5F8"' : '' ).$_userInfo['channel_select'].">\n<td width=\"25\" style=\"padding:1px 3px 3px 4px;\">";
 400      echo '<img src="img/famfamfam/vcard.gif" alt="Recipient"></td>'."\n";
 401      echo '<td width="1%" class="dir">&nbsp;<strong>'.$row["address_email"]."</strong></td>\n";
 402      echo '<td class="dir" width="95%">&nbsp;'.html_specialchars($row["address_name"])."</td>\n";
 403      echo '<td align="right" nowrap="nowrap" class="button_td">';
 404      
 405      echo '<a href="phpwcms.php?do=messages&amp;p=4&amp;s='.$row["address_id"].'&amp;edit=1">';        
 406      echo '<img src="img/button/edit_22x13.gif" border="0" alt=""></a>';
 407      
 408      echo '<a href="phpwcms.php?do=messages&amp;p=4&amp;s='.$row["address_id"].'&amp;verify=';
 409      echo ($row["address_verified"]) ? '0' : '1';
 410      echo '" title="set '.$row["address_email"].' verified/not verified">';        
 411      echo '<img src="img/button/aktiv_12x13_'.$row["address_verified"].'.gif" border="0" alt=""></a>';
 412      
 413      echo '<a href="phpwcms.php?do=messages&amp;p=4&amp;s='.$row["address_id"].'&amp;del='.$row["address_id"];
 414      echo '" title="delete: '.$row["address_email"].'"';
 415      echo ' onclick="return confirm(\'Delete subscriber '.js_singlequote($row["address_email"]).'\');">';
 416      echo '<img src="img/button/trash_13x13_1.gif" border="0" alt=""></a>';
 417  
 418      echo "</td>\n</tr>\n";
 419  
 420      $row_count++;
 421  }
 422  
 423  if($row_count) {
 424      echo '<tr><td colspan="4" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1"></td></tr>';
 425  }
 426  
 427  ?>
 428      <tr><td colspan="4"><img src="img/leer.gif" alt="" width="1" height="15"></td></tr>
 429  </table>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7