[ 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/plugins/model/ -> _pluginusersettings.class.php (source)

   1  <?php
   2  /**

   3   * This file implements the PluginUserSettings class, to handle plugin/user/name/value "pairs".

   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)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.

  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   * Daniel HAHLER grants Francois PLANQUE the right to license

  22   * Daniel HAHLER'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 blueyed: Daniel HAHLER.

  30   *

  31   * @version $Id: _pluginusersettings.class.php,v 1.1 2007/06/25 11:00:53 fplanque Exp $

  32   *

  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  load_class('settings/model/_abstractsettings.class.php');
  37  
  38  /**

  39   * Class to handle settings for plugins

  40   *

  41   * @package evocore

  42   */
  43  class PluginUserSettings extends AbstractSettings
  44  {
  45      /**

  46       * Constructor

  47       *

  48       * @param integer plugin ID where these settings are for

  49       */
  50  	function PluginUserSettings( $plugin_ID )
  51      { // constructor
  52          parent::AbstractSettings( 'T_pluginusersettings', array( 'puset_plug_ID', 'puset_user_ID', 'puset_name' ), 'puset_value', 1 );
  53  
  54          $this->plugin_ID = $plugin_ID;
  55      }
  56  
  57  
  58      /**

  59       * Get a setting by name for the Plugin.

  60       *

  61       * @param string The settings name.

  62       * @param integer User ID (by default $current_User->ID will be used - make sure that it is available already in your event!)

  63       * @return mixed|NULL|false False in case of error, NULL if not found, the value otherwise.

  64       */
  65  	function get( $setting, $user_ID = NULL )
  66      {
  67          if( ! isset($user_ID) )
  68          {
  69              global $current_User;
  70              if( ! isset($current_User) )
  71              {
  72                  global $Debuglog;
  73                  $Debuglog->add( 'No $current_User available in PluginUserSettings::get()/[ID'.$this->plugin_ID.']!', array('errors', 'plugins') );
  74                  return false;
  75              }
  76              $user_ID = $current_User->ID;
  77          }
  78          return parent::get( $this->plugin_ID, $user_ID, $setting );
  79      }
  80  
  81  
  82      /**

  83       * Set a Plugin setting. Use {@link dbupdate()} to write it to the database.

  84       *

  85       * @param string The settings name.

  86       * @param string The settings value.

  87       * @param integer User ID (by default $current_User->ID will be used - make sure that it is available already in your event!)

  88       * @return boolean true, if the value has been set, false if it has not changed.

  89       */
  90  	function set( $setting, $value, $user_ID = NULL )
  91      {
  92          if( ! isset($user_ID) )
  93          {
  94              global $current_User;
  95              if( ! isset($current_User) )
  96              {
  97                  global $Debuglog;
  98                  $Debuglog->add( 'No $current_User available in PluginUserSettings::set()/[ID'.$this->plugin_ID.']!', array('errors', 'plugins') );
  99                  return false;
 100              }
 101              $user_ID = $current_User->ID;
 102          }
 103          return parent::set( $this->plugin_ID, $user_ID, $setting, $value );
 104      }
 105  
 106  
 107      /**

 108       * Delete a setting.

 109       *

 110       * Use {@link dbupdate()} to commit it to the database.

 111       *

 112       * @param string name of setting

 113       * @param integer User ID (by default $current_User->ID will be used - make sure that it is available already in your event!)

 114       */
 115  	function delete( $setting, $user_ID = NULL )
 116      {
 117          if( ! isset($user_ID) )
 118          {
 119              global $current_User;
 120              if( ! isset($current_User) )
 121              {
 122                  global $Debuglog;
 123                  $Debuglog->add( 'No $current_User available in PluginUserSettings::delete()/[ID'.$this->plugin_ID.']!', array('errors', 'plugins') );
 124                  return false;
 125              }
 126              $user_ID = $current_User->ID;
 127          }
 128          return parent::delete( $this->plugin_ID, $user_ID, $setting );
 129      }
 130  
 131  }
 132  
 133  /*

 134   * $Log: _pluginusersettings.class.php,v $

 135   * Revision 1.1  2007/06/25 11:00:53  fplanque

 136   * MODULES (refactored MVC)

 137   *

 138   * Revision 1.8  2007/04/26 00:11:02  fplanque

 139   * (c) 2007

 140   *

 141   * Revision 1.7  2006/11/24 18:27:25  blueyed

 142   * Fixed link to b2evo CVS browsing interface in file docblocks

 143   *

 144   * Revision 1.6  2006/04/19 20:13:50  fplanque

 145   * do not restrict to :// (does not catch subdomains, not even www.)

 146   *

 147   * Revision 1.5  2006/03/24 19:37:53  fplanque

 148   * no message

 149   *

 150   * Revision 1.4  2006/03/24 01:12:26  blueyed

 151   * Catch cases where $current_User is not set (yet) and no user_ID is given and add debuglog entries.

 152   *

 153   * Revision 1.3  2006/03/12 23:08:59  fplanque

 154   * doc cleanup

 155   *

 156   * Revision 1.2  2006/03/11 02:02:00  blueyed

 157   * Normalized t_pluginusersettings

 158   *

 159   * Revision 1.1  2006/02/27 16:57:12  blueyed

 160   * PluginUserSettings - allows a plugin to store user related settings

 161   *

 162   * Revision 1.2  2006/02/24 22:09:00  blueyed

 163   * Plugin enhancements

 164   *

 165   * Revision 1.1  2006/02/23 21:11:58  fplanque

 166   * File reorganization to MVC (Model View Controller) architecture.

 167   * See index.hml files in folders.

 168   * (Sorry for all the remaining bugs induced by the reorg... :/)

 169   *

 170   * Revision 1.3  2005/12/22 23:13:40  blueyed

 171   * Plugins' API changed and handling optimized

 172   *

 173   * Revision 1.2  2005/12/08 22:32:19  blueyed

 174   * Merged from post-phoenix; Added/fixed delete() (has to be derived to allow using it without plug_ID)

 175   *

 176   * Revision 1.1.2.2  2005/12/06 21:56:21  blueyed

 177   * Get PluginSettings straight (removing $default_keys).

 178   *

 179   * Revision 1.1.2.1  2005/11/16 22:45:32  blueyed

 180   * DNS Blacklist antispam plugin; T_pluginsettings; Backoffice editing for plugins settings; $Plugin->Settings; MERGE from HEAD;

 181   */
 182  ?>


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