b2evolution PHP Cross Reference Blogging Systems

Source: /inc/items/model/_itemtype.class.php - 135 lines - 3723 bytes - Summary - Text - Print

Description: This file implements the Item Type class. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the Item Type class.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
  10   *
  11   * {@internal License choice
  12   * - If you have received this file as part of a package, please find the license.txt file in
  13   *   the same folder or the closest folder above for complete license terms.
  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15   *   then you must choose one of the following licenses before using the file:
  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18   * }}
  19   *
  20   * {@internal Open Source relicensing agreement:
  21   * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license
  22   * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project
  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24   *
  25   * The Evo Factory grants Francois PLANQUE the right to license
  26   * The Evo Factory's contributions to this file and the b2evolution project
  27   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  28   * }}
  29   *
  30   * @package evocore
  31   *
  32   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  33   * @author fplanque: Francois PLANQUE.
  34   * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
  35   * @author efy-sergey: Evo Factory / Sergey.
  36   *
  37   * @version $Id: _itemtype.class.php 6425 2014-04-08 09:24:40Z yura $
  38   */
  39  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  40  
  41  load_class( '_core/model/dataobjects/_dataobject.class.php', 'DataObject' );
  42  
  43  /**
  44   * ItemType Class
  45   *
  46   * @package evocore
  47   */
  48  class ItemType extends DataObject
  49  {
  50      var $name;
  51  
  52  
  53      /**
  54       * Constructor
  55       *
  56       *
  57       * @param table Database row
  58       */
  59  	function ItemType( $db_row = NULL )
  60      {
  61          // Call parent constructor:
  62          parent::DataObject( 'T_items__type', 'ptyp_', 'ptyp_ID' );
  63  
  64          // Allow inseting specific IDs
  65          $this->allow_ID_insert = true;
  66  
  67          $this->delete_restrictions = array(
  68                  array( 'table'=>'T_items__item', 'fk'=>'post_ptyp_ID', 'msg'=>T_('%d related items') ), // "Lignes de visit reports"
  69              );
  70  
  71           if( $db_row != NULL )
  72          {
  73              $this->ID               = $db_row->ptyp_ID         ;
  74              $this->name               = $db_row->ptyp_name     ;
  75          }
  76      }
  77  
  78      /**
  79       * Load data from Request form fields.
  80       *
  81       * @return boolean true if loaded data seems valid.
  82       */
  83  	function load_from_Request()
  84      {
  85          // get new ID
  86          if( param( 'new_ptyp_ID', 'string', NULL ) !== NULL )
  87          {
  88              param_check_number( 'new_ptyp_ID', T_('ID must be a number.'), true );
  89              $this->set_from_Request( 'ID', 'new_ptyp_ID' );
  90          }
  91  
  92          // Name
  93          param_string_not_empty( 'ptyp_name', T_('Please enter a name.') );
  94          $this->set_from_Request( 'name' );
  95  
  96          return ! param_errors_detected();
  97      }
  98  
  99      /**
 100       * Get the name of the ItemType
 101       * @return string
 102       */
 103  	function get_name()
 104      {
 105          return $this->name;
 106      }
 107  
 108      /**
 109       * Check existence of specified item type ID in ptyp_ID unique field.
 110       *
 111       * @return int ID if item type exists otherwise NULL/false
 112       */
 113  	function dbexists()
 114      {
 115          global $DB;
 116  
 117          $sql = "SELECT $this->dbIDname
 118                            FROM $this->dbtablename
 119                         WHERE $this->dbIDname = $this->ID";
 120  
 121          return $DB->get_var( $sql );
 122      }
 123  
 124      /**
 125       *  Returns array, which determinate the lower and upper limit of protected ID's
 126       *
 127       *  @return array
 128       */
 129  	function get_reserved_ids()
 130      {
 131          return array( 1000, 5000 );
 132      }
 133  }
 134  
 135  ?>

title

Description

title

Description

title

Description

title

title

Body