b2evolution PHP Cross Reference Blogging Systems

Source: /inc/tools/model/_emailblocked.class.php - 203 lines - 6543 bytes - Summary - Text - Print

Description: This file implements the (blocked) email address class. This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}. See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**

   3   * This file implements the (blocked) email address class.

   4   *

   5   * This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}.

   6   * See also {@link http://sourceforge.net/projects/evocms/}.

   7   *

   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}.

   9  *

  10   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)

  11   *

  12   * {@internal Open Source relicensing agreement:

  13   * EVO FACTORY grants Francois PLANQUE the right to license

  14   * EVO FACTORY contributions to this file and the b2evolution project

  15   * under any OSI approved OSS license (http://www.opensource.org/licenses/).

  16   * }}

  17   *

  18   * @package evocore

  19   *

  20   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}

  21   * @author fplanque: Francois PLANQUE.

  22   *

  23   * @version $Id: _emailblocked.class.php 849 2012-02-16 09:09:09Z yura $

  24   */
  25  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  26  
  27  load_class( '_core/model/dataobjects/_dataobject.class.php', 'DataObject' );
  28  load_funcs( 'tools/model/_email.funcs.php' );
  29  
  30  
  31  /**

  32   * Email Blcoked Class

  33   *

  34   * @package evocore

  35   */
  36  class EmailBlocked extends DataObject
  37  {
  38      var $address;
  39  
  40      var $status = 'unknown';
  41  
  42      var $sent_count = 0;
  43  
  44      var $sent_last_returnerror = 0;
  45  
  46      var $prmerror_count = 0;
  47  
  48      var $tmperror_count = 0;
  49  
  50      var $spamerror_count = 0;
  51  
  52      var $othererror_count = 0;
  53  
  54      var $last_sent_ts;
  55  
  56      var $last_error_ts;
  57  
  58      /**

  59       * Constructor

  60       *

  61       * @param object table Database row

  62       */
  63  	function EmailBlocked( $db_row = NULL )
  64      {
  65          // Call parent constructor:

  66          parent::DataObject( 'T_email__blocked', 'emblk_', 'emblk_ID' );
  67  
  68          if( $db_row != NULL )
  69          {
  70              $this->ID = $db_row->emblk_ID;
  71              $this->address = $db_row->emblk_address;
  72              $this->status = $db_row->emblk_status;
  73              $this->sent_count = $db_row->emblk_sent_count;
  74              $this->sent_last_returnerror = $db_row->emblk_sent_last_returnerror;
  75              $this->prmerror_count = $db_row->emblk_prmerror_count;
  76              $this->tmperror_count = $db_row->emblk_tmperror_count;
  77              $this->spamerror_count = $db_row->emblk_spamerror_count;
  78              $this->othererror_count = $db_row->emblk_othererror_count;
  79              $this->last_sent_ts = $db_row->emblk_last_sent_ts;
  80              $this->last_error_ts = $db_row->emblk_last_error_ts;
  81          }
  82      }
  83  
  84  
  85      /**

  86       * Set param value

  87       *

  88       * @param string parameter name

  89       * @param mixed parameter value

  90       * @param boolean true to set to NULL if empty value

  91       * @return boolean true, if a value has been set; false if it has not changed

  92       */
  93  	function set( $parname, $parvalue, $make_null = false )
  94      {
  95          return $this->set_param( $parname, 'string', $parvalue, $make_null );
  96      }
  97  
  98  
  99      /**

 100       * Load data from Request form fields.

 101       *

 102       * @return boolean true if loaded data seems valid.

 103       */
 104  	function load_from_Request()
 105      {
 106          // Address

 107          param_string_not_empty( 'emblk_address', T_('Please enter email address.') );
 108          param_check_email( 'emblk_address', true );
 109          if( $existing_emblk_ID = $this->dbexists( 'emblk_address', get_param( 'emblk_address' ) ) )
 110          {    // Check if a email address already exists with the same address
 111              global $admin_url;
 112              param_error( 'emblk_address', sprintf( T_('This email address already exists. Do you want to <a %s>edit the existing email address</a>?'),
 113                  'href="'.$admin_url.'?ctrl=email&amp;tab=blocked&amp;emblk_ID='.$existing_emblk_ID.'"' ) );
 114          }
 115          $this->set_from_Request( 'address' );
 116  
 117          // Status

 118          $emblk_status = param( 'emblk_status', 'string', true );
 119          if( !empty( $emblk_status ) )
 120          {
 121              $this->set( 'status', $emblk_status );
 122          }
 123  
 124          // Sent count

 125          param( 'emblk_sent_count', 'integer', '' );
 126          param_check_number( 'emblk_sent_count', T_('The count must be a number.'), true );
 127          $this->set_from_Request( 'sent_count', 'emblk_sent_count', true );
 128  
 129          // Sent count since last error

 130          param( 'emblk_sent_last_returnerror', 'integer', '' );
 131          param_check_number( 'emblk_sent_last_returnerror', T_('The count must be a number.'), true );
 132          $this->set_from_Request( 'sent_last_returnerror', 'emblk_sent_last_returnerror', true );
 133  
 134          // Permanent errors count

 135          param( 'emblk_prmerror_count', 'integer', '' );
 136          param_check_number( 'emblk_prmerror_count', T_('The count must be a number.'), true );
 137          $this->set_from_Request( 'prmerror_count', 'emblk_prmerror_count', true );
 138  
 139          // Permanent errors count

 140          param( 'emblk_tmperror_count', 'integer', '' );
 141          param_check_number( 'emblk_tmperror_count', T_('The count must be a number.'), true );
 142          $this->set_from_Request( 'tmperror_count', 'emblk_tmperror_count', true );
 143  
 144          // Permanent errors count

 145          param( 'emblk_spamerror_count', 'integer', '' );
 146          param_check_number( 'emblk_spamerror_count', T_('The count must be a number.'), true );
 147          $this->set_from_Request( 'spamerror_count', 'emblk_spamerror_count', true );
 148  
 149          // Permanent errors count

 150          param( 'emblk_othererror_count', 'integer', '' );
 151          param_check_number( 'emblk_othererror_count', T_('The count must be a number.'), true );
 152          $this->set_from_Request( 'othererror_count', 'emblk_othererror_count', true );
 153  
 154          return ! param_errors_detected();
 155      }
 156  
 157      /**

 158       * Increase a counter field

 159       *

 160       * @param string Counter name ( 'prmerror', 'tmperror', 'spamerror', 'othererror' )

 161       */
 162  	function increase_counter( $counter_name )
 163      {
 164          $counter_name .= '_count';
 165          if( isset( $this->$counter_name ) )
 166          {
 167              $this->set( $counter_name, $this->get( $counter_name ) + 1 );
 168              if( $counter_name != 'sent_count' )
 169              {    // Update last error date when we increase an error counter
 170                  global $servertimenow;
 171                  $this->set( 'last_error_ts', date( 'Y-m-d H:i:s', $servertimenow ) );
 172                  $this->set( 'sent_last_returnerror', '0' );
 173              }
 174          }
 175      }
 176  
 177  
 178      /**

 179       * Set status

 180       *

 181       * @param string New status value

 182       */
 183  	function set_status( $new_status )
 184      {
 185          if( $this->ID == 0 )
 186          {    // New record is creating, we can assign any status without level restrictions
 187              $this->set( 'status', $new_status );
 188          }
 189          else
 190          {    // The record is updating, we should update only status which has hight level then old status
 191  
 192              // Get statuses which we can update depending on levels of the statuses

 193              $available_statuses = emblk_get_statuses_less_level( $new_status );
 194  
 195              if( in_array( $this->get( 'status' ), $available_statuses ) )
 196              {    // Check if we can update this status
 197                  $this->set( 'status', $new_status );
 198              }
 199          }
 200      }
 201  }
 202  
 203  ?>

title

Description

title

Description

title

Description

title

title

Body