[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/inc/generic/model/ -> _genericordered.class.php (source)

   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-2007 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.1 2007/06/25 11:00:17 fplanque 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');
  37  
  38  /**

  39   * User property;

  40   *

  41   * Generic Ordered of users with specific permissions.

  42   *

  43   * @package evocore

  44   */
  45  class GenericOrdered extends GenericElement
  46  {
  47      // Order object

  48      var $order;
  49  
  50  
  51      /**

  52       * Constructor

  53       *

  54       * @param string Name of table in database

  55       * @param string Prefix of fields in the table

  56       * @param string Name of the ID field (including prefix)

  57       * @param object DB row

  58       */
  59  	function GenericOrdered( $tablename, $prefix = '', $dbIDname = 'ID', $db_row = NULL )
  60      {
  61          global $Debuglog;
  62  
  63          // Call parent constructor:

  64          parent::GenericElement( $tablename, $prefix, $dbIDname, $db_row );
  65  
  66          if( $db_row != NULL )
  67          {
  68              $this->order = $db_row->{$prefix.'order'};
  69          }
  70  
  71          $Debuglog->add( "Created element <strong>$this->name</strong>", 'dataobjects' );
  72      }
  73  
  74  
  75      /**

  76       * Set param value

  77       *

  78       * By default, all values will be considered strings

  79       *

  80       * {@internal Contact::set(-)}}

  81       *

  82       * @param string parameter name

  83       * @param mixed parameter value

  84       */
  85  	function set( $parname, $parvalue )
  86      {
  87          switch( $parname )
  88          {
  89               case 'order':
  90                  $this->set_param( $parname, 'integer', $parvalue );
  91                  break;
  92  
  93              case 'name':
  94              default:
  95                  $this->set_param( $parname, 'string', $parvalue );
  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.1  2007/06/25 11:00:17  fplanque

 133   * MODULES (refactored MVC)

 134   *

 135   * Revision 1.8  2007/04/26 00:11:11  fplanque

 136   * (c) 2007

 137   *

 138   * Revision 1.7  2006/11/26 01:42:09  fplanque

 139   * doc

 140   */
 141  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics