b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (CVS HEAD) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Source for file _currency.class.php

Documentation is available at _currency.class.php

  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 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: _currency.class.php,v 1.13 2010/01/17 04:14:40 fplanque Exp $
  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.  * Currency Class
  39.  */
  40. class Currency extends DataObject
  41. {
  42.     var $code = '';
  43.     var $shortcut = '';
  44.     var $name = '';
  45.     var $enabled = 1;
  46.  
  47.     /**
  48.      * Constructor
  49.      *
  50.      * @param object database row
  51.      */
  52.     function Currency$db_row NULL )
  53.     {
  54.         // Call parent constructor:
  55.         parent::DataObject'T_currency''curr_''curr_ID' );
  56.  
  57.         $this->delete_restrictions = array(
  58.                 array'table'=>'T_country''fk'=>'ctry_curr_ID''msg'=>T_('%d related countries') ),
  59.             );
  60.  
  61.         $this->delete_cascades = array();
  62.  
  63.          if$db_row )
  64.         {
  65.             $this->ID            = $db_row->curr_ID;
  66.             $this->code          = $db_row->curr_code;
  67.             $this->shortcut      = $db_row->curr_shortcut;
  68.             $this->name          = $db_row->curr_name;
  69.             $this->enabled       = $db_row->curr_enabled;
  70.         }
  71.     }
  72.  
  73.  
  74.     /**
  75.      * Load data from Request form fields.
  76.      *
  77.      * @return boolean true if loaded data seems valid.
  78.      */
  79.     function load_from_Request()
  80.     {
  81.         // Name
  82.         $this->set_string_from_param'name'true );
  83.  
  84.         // Shortcut
  85.         $this->set_string_from_param'shortcut'true );
  86.  
  87.         // Code
  88.         param'curr_code''string' );
  89.         param_check_regexp'curr_code''#^[A-Za-z]{3}$#'T_('Currency code must be 3 letters parameter.') );
  90.         $this->set_from_Request'code''curr_code'true  );
  91.  
  92.         return param_errors_detected();
  93.     }
  94.  
  95.  
  96.     /**
  97.      * Set param value
  98.      *
  99.      * By default, all values will be considered strings
  100.      *
  101.      * @param string parameter name
  102.      * @param mixed parameter value
  103.      * @param boolean true to set to NULL if empty value
  104.      * @return boolean true, if a value has been set; false if it has not changed
  105.      */
  106.     function set$parname$parvalue$make_null false )
  107.     {
  108.         switch$parname )
  109.         {
  110.             case 'code':
  111.                 $parvalue strtoupper($parvalue);
  112.             case 'shortcut':
  113.             case 'name':
  114.             case 'enabled':
  115.             default:
  116.                 return $this->set_param$parname'string'$parvalue$make_null );
  117.         }
  118.     }
  119.  
  120.  
  121.     /**
  122.      * Check existence of specified currency code in curr_code unique field.
  123.      *
  124.      * @return int ID if currency code exists otherwise NULL/false
  125.      */
  126.     function dbexists()
  127.     {
  128.         return parent::dbexists('curr_code'$this->code);
  129.     }
  130.  
  131.  
  132.     /**
  133.      * Get currency unique name (code).
  134.      *
  135.      * @return string currency code
  136.      */
  137.     function get_name()
  138.     {
  139.         return $this->code;
  140.     }
  141. }
  142.  
  143.  
  144. /*
  145.  * $Log: _currency.class.php,v $
  146.  * Revision 1.13  2010/01/17 04:14:40  fplanque
  147.  * minor / fixes
  148.  *
  149.  * Revision 1.12  2010/01/15 17:27:28  efy-asimo
  150.  * Global Settings > Currencies - Add Enable/Disable column
  151.  *
  152.  * Revision 1.11  2009/09/20 20:07:18  blueyed
  153.  *  - DataObject::dbexists quotes always
  154.  *  - phpdoc fixes
  155.  *  - style fixes
  156.  *
  157.  * Revision 1.10  2009/09/14 13:31:36  efy-arrin
  158.  * Included the ClassName in load_class() call with proper UpperCase
  159.  *
  160.  * Revision 1.9  2009/09/07 12:40:57  efy-maxim
  161.  * Ability to select the default currency when editing a country
  162.  *
  163.  * Revision 1.8  2009/09/05 14:39:48  efy-maxim
  164.  * Delete Restrictions for currency
  165.  *
  166.  * Revision 1.7  2009/09/04 19:00:05  efy-maxim
  167.  * currency/country codes validators have been improved using param_check_regexp() function
  168.  *
  169.  * Revision 1.6  2009/09/03 18:29:29  efy-maxim
  170.  * currency/country code validators
  171.  *
  172.  * Revision 1.5  2009/09/03 07:24:58  efy-maxim
  173.  * 1. Show edit screen again if current currency/goal exists in database.
  174.  * 2. Convert currency code to uppercase
  175.  *
  176.  * Revision 1.4  2009/09/02 23:29:34  fplanque
  177.  * doc
  178.  *
  179.  */
  180. ?>

Documentation generated on Sat, 06 Mar 2010 04:07:18 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).