[ Index ]

PHP Cross Reference of Mambo 4.6.5

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

title

Body

[close]

/components/com_weblinks/ -> weblinks.class.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Weblinks
   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  /**
  21  * Category database table class
  22  */
  23  class mosWeblink extends mosDBTable {
  24      /** @var int Primary key */
  25      var $id=null;
  26      /** @var int */
  27      var $catid=null;
  28      /** @var int */
  29      var $sid=null;
  30      /** @var string */
  31      var $title=null;
  32      /** @var string */
  33      var $url=null;
  34      /** @var string */
  35      var $description=null;
  36      /** @var datetime */
  37      var $date=null;
  38      /** @var int */
  39      var $hits=null;
  40      /** @var int */
  41      var $published=null;
  42      /** @var boolean */
  43      var $checked_out=null;
  44      /** @var time */
  45      var $checked_out_time=null;
  46      /** @var int */
  47      var $ordering=null;
  48      /** @var int */
  49      var $archived=null;
  50      /** @var int */
  51      var $approved=null;
  52      /** @var string */
  53      var $params=null;
  54  
  55      /**
  56      * @param database A database connector object
  57      */
  58  	function mosWeblink( &$db ) {
  59          $this->mosDBTable( '#__weblinks', 'id', $db );
  60      }
  61      /** overloaded check function */
  62  	function check() {
  63          // filter malicious code
  64          $ignoreList = array( 'params' );
  65          $this->filter( $ignoreList );
  66  
  67          // specific filters        
  68          $callcheck = array('InputFilter', 'process');
  69          if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpInputFilter/class.inputfilter.php');
  70          // specific filters
  71          $iFilter =& new InputFilter();
  72          
  73          if ($iFilter->badAttributeValue( array( 'href', $this->url ))) {
  74              $this->_error = T_('Please provide a valid URL');
  75              return false;
  76          }
  77  
  78          /** check for valid name */
  79          if (trim( $this->title ) == '') {
  80              $this->_error = T_('Your web link must be given a title.');
  81              return false;
  82          }
  83  
  84          if ( !( eregi( 'http://', $this->url ) || ( eregi( 'https://',$this->url ) )  || ( eregi( 'ftp://',$this->url ) ) ) ) {
  85              $this->url = 'http://'.$this->url;
  86          }
  87  
  88          /** check for existing name */
  89          $this->title = $this->_db->getEscaped($this->title);
  90          $this->catid = $this->_db->getEscaped($this->catid);
  91          $this->_db->setQuery( "SELECT id FROM #__weblinks "
  92          . "\nWHERE title='$this->title' AND catid='$this->catid'"
  93          );
  94  
  95          $xid = intval( $this->_db->loadResult() );
  96          if ($xid && $xid != intval( $this->id )) {
  97              $this->_error = T_('There is already a web link that name, please try again.');
  98              return false;
  99          }
 100          return true;
 101      }
 102  }
 103  ?>