b2evolution PHP Cross Reference Blogging Systems

Source: /inc/regional/model/_city.class.php - 155 lines - 4287 bytes - Summary - Text - Print

Description: 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 is part of the evoCore framework - {@link http://evocore.net/}

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

   5   *

   6   * @copyright (c)2009-2014 by Francois PLANQUE - {@link http://fplanque.net/}

   7   * Parts of this file are copyright (c)2009 by The Evo Factory - {@link http://www.evofactory.com/}.

   8   *

   9   * {@internal License choice

  10   * - If you have received this file as part of a package, please find the license.txt file in

  11   *   the same folder or the closest folder above for complete license terms.

  12   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)

  13   *   then you must choose one of the following licenses before using the file:

  14   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php

  15   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php

  16   * }}

  17   *

  18   * {@internal Open Source relicensing agreement:

  19   * The Evo Factory grants Francois PLANQUE the right to license

  20   * The Evo Factory's contributions to this file and the b2evolution project

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

  22   * }}

  23   *

  24   * @package evocore

  25   *

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

  27   * @author efy-maxim: Evo Factory / Maxim.

  28   * @author fplanque: Francois Planque.

  29   *

  30   * @version $Id: _city.class.php 13 2011-10-24 23:42:53Z fplanque $

  31   */
  32  
  33  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  34  
  35  load_class( '_core/model/dataobjects/_dataobject.class.php', 'DataObject' );
  36  
  37  /**

  38   * City Class

  39   */
  40  class City extends DataObject
  41  {
  42      var $ctry_ID = '';
  43      var $rgn_ID = '';
  44      var $subrg_ID = '';
  45      var $postcode = '';
  46      var $name = '';
  47      var $enabled = 1;
  48      var $preferred = 0;
  49  
  50      /**

  51       * Constructor

  52       *

  53       * @param object database row

  54       */
  55  	function City( $db_row = NULL )
  56      {
  57          // Call parent constructor:

  58          parent::DataObject( 'T_regional__city', 'city_', 'city_ID' );
  59  
  60          $this->delete_restrictions = array(
  61                  array( 'table'=>'T_users', 'fk'=>'user_city_ID', 'msg'=>T_('%d related users') ),
  62              );
  63  
  64          $this->delete_cascades = array();
  65  
  66          if( $db_row )
  67          {
  68              $this->ID            = $db_row->city_ID;
  69              $this->ctry_ID       = $db_row->city_ctry_ID;
  70              $this->rgn_ID        = $db_row->city_rgn_ID;
  71              $this->subrg_ID      = $db_row->city_subrg_ID;
  72              $this->postcode      = $db_row->city_postcode;
  73              $this->name          = $db_row->city_name;
  74              $this->enabled       = $db_row->city_enabled;
  75              $this->preferred     = $db_row->city_preferred;
  76          }
  77      }
  78  
  79  
  80      /**

  81       * Load data from Request form fields.

  82       *

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

  84       */
  85  	function load_from_Request()
  86      {
  87          // Country Id

  88          param( 'city_ctry_ID', 'integer', true );
  89          param_check_number( 'city_ctry_ID', T_('Please select a country'), true );
  90          $this->set_from_Request( 'ctry_ID', 'city_ctry_ID', true );
  91  
  92          // Region Id

  93          $this->set_string_from_param( 'rgn_ID' );
  94  
  95          // Subregion Id

  96          $this->set_string_from_param( 'subrg_ID' );
  97  
  98          // Name

  99          $this->set_string_from_param( 'name', true );
 100  
 101          // Code

 102          param( 'city_postcode', 'string' );
 103          param_check_regexp( 'city_postcode', '#^[A-Za-z0-9]{1,12}$#', T_('City code must be from 1 to 12 letters.') );
 104          $this->set_from_Request( 'postcode', 'city_postcode' );
 105  
 106          return ! param_errors_detected();
 107      }
 108  
 109  
 110      /**

 111       * Set param value

 112       *

 113       * By default, all values will be considered strings

 114       *

 115       * @param string parameter name

 116       * @param mixed parameter value

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

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

 119       */
 120  	function set( $parname, $parvalue, $make_null = false )
 121      {
 122          switch( $parname )
 123          {
 124              case 'postcode':
 125              case 'name':
 126              case 'enabled':
 127              default:
 128                  return $this->set_param( $parname, 'string', $parvalue, $make_null );
 129          }
 130      }
 131  
 132  
 133      /**

 134       * Get city name.

 135       *

 136       * @return string city name

 137       */
 138  	function get_name()
 139      {
 140          return $this->name;
 141      }
 142  
 143  
 144      /**

 145       * Get postcode.

 146       *

 147       * @return string postcode

 148       */
 149  	function get_postcode()
 150      {
 151          return $this->postcode;
 152      }
 153  }
 154  
 155  ?>

title

Description

title

Description

title

Description

title

title

Body