b2evolution PHP Cross Reference Blogging Systems

Source: /inc/plugins/model/_pluginusersettings.class.php - 133 lines - 4369 bytes - Summary - Text - Print

Description: This file implements the PluginUserSettings class, to handle plugin/user/name/value "pairs". 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 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-2014 by Francois Planque - {@link http://fplanque.com/}
   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 plugins
  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 6136 2014-03-08 07:59:48Z manuel $
  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', 'AbstractSettings' );
  37  
  38  /**
  39   * Class to handle settings for plugins
  40   *
  41   * @package plugins
  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  ?>

title

Description

title

Description

title

Description

title

title

Body