[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/components/com_banners/ -> banners.class.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Banners
   5  * @author Mambo Foundation Inc see README.php
   6  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   7  * See COPYRIGHT.php for copyright notices and details.
   8  * @license GNU/GPL Version 2, see LICENSE.php
   9  *
  10  * Redistributions of files must retain the above copyright notice.
  11  *
  12  * Mambo is free software; you can redistribute it and/or
  13  * modify it under the terms of the GNU General Public License
  14  * as published by the Free Software Foundation; version 2 of the License.
  15  */
  16  
  17  /** ensure this file is being included by a parent file */
  18  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  19  
  20  class mosBannerClient extends mosDBTable {
  21      var    $cid = null;
  22      var $name = "";
  23      var $contact = "";
  24      var $email = "";
  25      var $extrainfo = "";
  26      var $checked_out = 0;
  27      var $checked_out_time = 0;
  28      var $editor    = "";
  29      
  30  	function mosBannerClient( &$_db ) {
  31          $this->mosDBTable( '#__bannerclient', 'cid', $_db );
  32      }
  33      
  34  	function check() {
  35          // check for valid client name
  36          if (trim($this->name == "")) {
  37              $this->_error = T_('You must select a name for the client.');
  38              return false;
  39          }
  40          
  41          // check for valid client contact
  42          if (trim($this->contact == "")) {
  43              $this->_error = T_('You must select a contact for the client.');
  44              return false;
  45          }
  46          
  47          // check for valid client email
  48          if ((trim($this->email == "")) || (preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email )==false)) {
  49              $this->_error = T_('You must select a valid email for the client.');
  50              return false;
  51          }
  52          return true;
  53      }
  54  }
  55  
  56  /**
  57  * @package Mambo
  58  */
  59  class mosBanner extends mosDBTable {
  60      /** @var int */
  61      var $bid                = null;
  62      /** @var int */
  63      var $cid                = null;
  64      /** @var string */
  65      var $type                = "";
  66      /** @var string */
  67      var $name                = "";
  68      /** @var int */
  69      var $imptotal            = 0;
  70      /** @var int */
  71      var $impmade            = 0;
  72      /** @var int */
  73      var $clicks                = 0;
  74      /** @var string */
  75      var $imageurl            = "";
  76      /** @var string */
  77      var $clickurl            = "";
  78      /** @var date */
  79      var $date                = null;
  80      /** @var int */
  81      var $showBanner            = 0;
  82      /** @var int */
  83      var $checked_out        = 0;
  84      /** @var date */
  85      var $checked_out_time    = 0;
  86      /** @var string */
  87      var $editor                = "";
  88      /** @var string */
  89      var $custombannercode    = "";
  90      
  91  	function mosBanner( &$_db ) {
  92          $this->mosDBTable( '#__banner', 'bid', $_db );
  93          $this->set("date",date("Y-m-d G:i:s"));
  94      }
  95      
  96  	function clicks() {
  97          $this->_db->setQuery( "UPDATE #__banner SET clicks=(clicks+1) WHERE bid=$this->bid" );
  98          $this->_db->query();
  99      }
 100      
 101  	function check() {
 102          // check for valid client id
 103          if (is_null($this->cid) || $this->cid == 0) {
 104              $this->_error = T_('You must select a client.');
 105              return false;
 106          }
 107          
 108          if(trim($this->name) == "") {
 109              $this->_error = T_('You must select a name for the banner.');
 110              return false;
 111          }
 112          
 113          if(trim($this->imageurl) == "" && trim($this->custombannercode) == "") {
 114              $this->_error = T_('You must select a image for the banner.');
 115              return false;
 116          }
 117          if(trim($this->clickurl) == "" && trim($this->custombannercode) == "") {
 118              $this->_error = T_('You must select a URL/Custom banner code for the banner.');
 119              return false;
 120          }
 121          
 122          return true;
 123      }
 124  }
 125  ?>