b2evolution PHP Cross Reference Blogging Systems

Source: /inc/generic/model/_genericelement.class.php - 151 lines - 4366 bytes - Summary - Text - Print

Description: This file implements the Generic Element class, which manages user groups. 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 Generic Element class, which manages user groups.
   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   *
  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: _genericelement.class.php 6136 2014-03-08 07:59:48Z manuel $
  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  load_class( '_core/model/dataobjects/_dataobject.class.php', 'DataObject' );
  37  
  38  /**
  39   * User Element
  40   *
  41   * Generic Element of users with specific permissions.
  42   *
  43   * @package evocore
  44   */
  45  class GenericElement extends DataObject
  46  {
  47      /**
  48       * Name of Generic Element
  49       *
  50       * @var string
  51       * @access protected
  52       */
  53      var $name;
  54  
  55  
  56      /**
  57       * Constructor
  58       *
  59       * @param string Name of table in database
  60       * @param string Prefix of fields in the table
  61       * @param string Name of the ID field (including prefix)
  62       * @param object DB row
  63       */
  64  	function GenericElement( $tablename, $prefix = '', $dbIDname = 'ID', $db_row = NULL )
  65      {
  66          global $Debuglog;
  67  
  68          // Call parent constructor:
  69          parent::DataObject( $tablename, $prefix, $dbIDname );
  70  
  71          if( $db_row != NULL )
  72          {
  73              // echo 'Instanciating existing group';
  74              $this->ID = $db_row->$dbIDname;
  75              $this->name = $db_row->{$prefix.'name'};
  76          }
  77  
  78          $Debuglog->add( "Created element <strong>$this->name</strong>", 'dataobjects' );
  79      }
  80  
  81  
  82      /**
  83       * Load data from Request form fields.
  84       *
  85       * @return boolean true if loaded data seems valid.
  86       */
  87  	function load_from_Request()
  88      {
  89          param_string_not_empty( $this->dbprefix.'name', T_('Please enter a name.') );
  90          $this->set_from_Request( 'name' );
  91  
  92          return ! param_errors_detected();
  93      }
  94  
  95  
  96      /**
  97       * TODO
  98       *
  99       */
 100  	function disp_form()
 101      {
 102          global $ctrl, $action, $edited_name_maxlen, $form_below_list;
 103  
 104          // Determine if we are creating or updating...
 105          $creating = is_create_action( $action );
 106  
 107          $Form = new Form( NULL, 'form' );
 108  
 109          if( !$form_below_list )
 110          { // We need to display a link to cancel editing:
 111              $Form->global_icon( T_('Cancel editing!'), 'close', regenerate_url( 'action' ) );
 112          }
 113  
 114          $Form->begin_form( 'fform', $creating ?  T_('New element') : T_('Element') );
 115  
 116          $Form->add_crumb( 'element' );
 117          $Form->hidden( 'action', $creating ? 'create' : 'update' );
 118          $Form->hidden( 'ctrl', $ctrl );
 119          $Form->hiddens_by_key( get_memorized( 'action, ctrl' ) );
 120  
 121          $Form->text_input( $this->dbprefix.'name', $this->name, $edited_name_maxlen, T_('name'), '', array( 'required' => true ) );
 122  
 123          if( ! $creating ) $Form->hidden( $this->dbIDname, $this->ID );
 124  
 125          if( $creating )
 126          {
 127              $Form->end_form( array( array( 'submit', 'submit', T_('Record'), 'SaveButton' ),
 128                                                              array( 'reset', '', T_('Reset'), 'ResetButton' ) ) );
 129          }
 130          else
 131          {
 132              $Form->end_form( array( array( 'submit', 'submit', T_('Update'), 'SaveButton' ),
 133                                                              array( 'reset', '', T_('Reset'), 'ResetButton' ) ) );
 134          }
 135      }
 136  
 137  
 138      /**
 139       * Template function: return name of item
 140       *
 141       * @param string Output format, see {@link format_to_output()}
 142       * @return string
 143       */
 144  	function get_name( $format = 'htmlbody' )
 145      {
 146          return $this->dget( 'name', $format );
 147      }
 148  
 149  }
 150  
 151  ?>

title

Description

title

Description

title

Description

title

title

Body