b2evolution

Multilingual multiuser multiblog engine

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

Source for file _genericordered.class.php

Documentation is available at _genericordered.class.php

  1. <?php
  2. /**
  3.  * This file implements the generic ordered 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-2010 by Francois PLANQUE - {@link http://fplanque.net/}
  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.  *
  26.  * @package evocore
  27.  *
  28.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  29.  * @author fplanque: Francois PLANQUE.
  30.  * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
  31.  *
  32.  * @version $Id: _genericordered.class.php,v 1.7 2010/02/08 17:53:03 efy-yury Exp $
  33.  */
  34. if!defined('EVO_MAIN_INIT') ) die'Please, do not access this page directly.' );
  35.  
  36. load_class('generic/model/_genericelement.class.php''GenericElement' );
  37.  
  38. /**
  39.  * User property;
  40.  *
  41.  * Generic Ordered of users with specific permissions.
  42.  *
  43.  * @package evocore
  44.  */
  45. {
  46.     // Order object
  47.     var $order;
  48.  
  49.  
  50.     /**
  51.      * Constructor
  52.      *
  53.      * @param string Name of table in database
  54.      * @param string Prefix of fields in the table
  55.      * @param string Name of the ID field (including prefix)
  56.      * @param object DB row
  57.      */
  58.     function GenericOrdered$tablename$prefix ''$dbIDname 'ID'$db_row NULL )
  59.     {
  60.         global $Debuglog;
  61.  
  62.         // Call parent constructor:
  63.         parent::GenericElement$tablename$prefix$dbIDname$db_row );
  64.  
  65.         if$db_row != NULL )
  66.         {
  67.             $this->order = $db_row->{$prefix.'order'};
  68.         }
  69.  
  70.         $Debuglog->add"Created element <strong>$this->name</strong>"'dataobjects' );
  71.     }
  72.  
  73.  
  74.     /**
  75.      * Set param value
  76.      *
  77.      * By default, all values will be considered strings
  78.      *
  79.      * {@internal Contact::set(-)}}
  80.      *
  81.      * @param string parameter name
  82.      * @param mixed parameter value
  83.      * @param boolean true to set to NULL if empty value
  84.      * @return boolean true, if a value has been set; false if it has not changed
  85.      */
  86.     function set$parname$parvalue$make_null false )
  87.     {
  88.         switch$parname )
  89.         {
  90.              case 'order':
  91.                 return $this->set_param$parname'number'$parvalue$make_null );
  92.  
  93.             case 'name':
  94.             default:
  95.                 return $this->set_param$parname'string'$parvalue$make_null );
  96.         }
  97.     }
  98.  
  99.  
  100.     /**
  101.      * Insert object into DB based on previously recorded changes
  102.      */
  103.     function dbinsert()
  104.     {
  105.         global $DB;
  106.  
  107.         $DB->begin();
  108.  
  109.         if$max_order $DB->get_var'SELECT MAX('.$this->dbprefix.'order)
  110.                                                                             FROM '.$this->dbtablename ) )
  111.         {    // The new element order must be the lastest
  112.             $max_order++;
  113.         }
  114.         else
  115.         // There are no elements in the database yet, so his order is set to 1.
  116.             $max_order 1;
  117.         }
  118.  
  119.         // Set Object order:
  120.         $this->set'order'$max_order );
  121.  
  122.         parent::dbinsert();
  123.  
  124.         $DB->commit();
  125.     }
  126.  
  127. }
  128.  
  129.  
  130. /*
  131.  * $Log: _genericordered.class.php,v $
  132.  * Revision 1.7  2010/02/08 17:53:03  efy-yury
  133.  * copyright 2009 -> 2010
  134.  *
  135.  * Revision 1.6  2009/09/14 12:25:47  efy-arrin
  136.  * Included the ClassName in load_class() call with proper UpperCase
  137.  *
  138.  * Revision 1.5  2009/08/30 17:27:03  fplanque
  139.  * better NULL param handling all over the app
  140.  *
  141.  * Revision 1.4  2009/07/18 18:43:50  tblue246
  142.  * DataObject::set_param() does not accept "integer" as the 2nd param (has to be "number").
  143.  *
  144.  * Revision 1.3  2009/03/08 23:57:43  fplanque
  145.  * 2009
  146.  *
  147.  * Revision 1.2  2008/01/21 09:35:30  fplanque
  148.  * (c) 2008
  149.  *
  150.  * Revision 1.1  2007/06/25 11:00:17  fplanque
  151.  * MODULES (refactored MVC)
  152.  *
  153.  * Revision 1.8  2007/04/26 00:11:11  fplanque
  154.  * (c) 2007
  155.  *
  156.  * Revision 1.7  2006/11/26 01:42:09  fplanque
  157.  * doc
  158.  */
  159. ?>

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