b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 1.9) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Source for file _abstractsettings.class.php

Documentation is available at _abstractsettings.class.php

  1. <?php
  2. /**
  3.  * This file implements the AbstractSettings class designed to handle any kind of settings.
  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-2006 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://cvs.sourceforge.net/viewcvs.py/evocms/)
  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.  * @author fplanque: Francois PLANQUE
  31.  *
  32.  * @version $Id: _abstractsettings.class.php,v 1.12.2.6 2006/11/15 21:05:24 blueyed Exp $
  33.  */
  34. if!defined('EVO_MAIN_INIT') ) die'Please, do not access this page directly.' );
  35.  
  36. /**
  37.  * Class to handle settings in an abstract manner (to get used with either 1, 2 or 3 DB column keys).
  38.  *
  39.  * Arrays and Objects automatically get serialized and unserialized
  40.  * (in {@link AbstractSettings::get()} and {@link AbstractSettings::dbupdate()}).
  41.  *
  42.  * Note: I've evaluated splitting this into single classes for performance reasons, but only
  43.  *       get() is relevant performance-wise and we could now only get rid of the switch() therein,
  44.  *       which is not sufficient to split it into *_base + _X classes. (blueyed, 2006-08)
  45.  *
  46.  * @package evocore
  47.  * @abstract
  48.  * @see UserSettings, GeneralSettings, PluginSettings, CollectionSettings
  49.  */
  50. {
  51.     /**
  52.      * The DB table which stores the settings.
  53.      *
  54.      * @var string 
  55.      * @access protected
  56.      */
  57.     var $db_table_name;
  58.  
  59.     /**
  60.      * Array with DB column key names.
  61.      *
  62.      * @var array of strings
  63.      * @access protected
  64.      */
  65.     var $col_key_names = array();
  66.  
  67.     /**
  68.      * DB column name for the value.
  69.      *
  70.      * @var string 
  71.      * @access protected
  72.      */
  73.     var $col_value_name;
  74.  
  75.  
  76.     /**
  77.      * The number of column keys to cache by. This are the first x keys of
  78.      * {@link $col_key_names}. 0 means 'load all'.
  79.      *
  80.      * @var integer 
  81.      */
  82.     var $cache_by_col_keys;
  83.  
  84.  
  85.     /**
  86.      * The internal cache.
  87.      *
  88.      * @access protected
  89.      * @var array|NULL|falseContains the loaded settings or false, if settings
  90.      *                        could not be loaded or NULL if not initialized.
  91.      */
  92.     var $cache = NULL;
  93.  
  94.  
  95.     /**
  96.      * Do we have loaded everything?
  97.      *
  98.      * @var boolean 
  99.      */
  100.     var $all_loaded = false;
  101.  
  102.  
  103.     /**
  104.      * Default settings.
  105.      *
  106.      * Maps last colkeyname to some default setting that will be used by
  107.      * {@link get()} if no value was defined (and it is set as a default).
  108.      *
  109.      * @var array 
  110.      */
  111.     var $_defaults = array();
  112.  
  113.  
  114.     /**
  115.      * Constructor.
  116.      * @param string The name of the DB table with the settings stored.
  117.      * @param array List of names for the DB columns keys that reference a value.
  118.      * @param string The name of the DB column that holds the value.
  119.      * @param integer The number of column keys to cache by. This are the first x keys of {@link $col_key_names}. 0 means 'load all'.
  120.      */
  121.     function AbstractSettings$db_table_name$col_key_names$col_value_name$cache_by_col_keys )
  122.     {
  123.         $this->db_table_name = $db_table_name;
  124.         $this->col_key_names = $col_key_names;
  125.         $this->col_value_name = $col_value_name;
  126.         $this->cache_by_col_keys = $cache_by_col_keys;
  127.  
  128.  
  129.         /**
  130.          * @var integer internal counter for the number of column keys
  131.          */
  132.         $this->count_col_key_names count$this->col_key_names );
  133.  
  134.         if$this->count_col_key_names || $this->count_col_key_names )
  135.         {
  136.             debug_die'Settings keycount not supported for class '.get_class() );
  137.         }
  138.     }
  139.  
  140.  
  141.     /**
  142.      * Load all settings, disregarding the derived classes setting of
  143.      * {@link $cache_by_col_keys} - useful if you know that you want to get
  144.      * all user settings for example.
  145.      */
  146.     function load_all()
  147.     {
  148.         return $this->_load();
  149.     }
  150.  
  151.  
  152.     /**
  153.      * Loads the settings. Not meant to be called directly, but gets called
  154.      * when needed.
  155.      *
  156.      * @access protected
  157.      * @param string First column key
  158.      * @param string Second column key
  159.      * @param string Third column key
  160.      * @return boolean always true
  161.      */
  162.     function _load$arg1 NULL$arg2 NULL$arg3 NULL )
  163.     {
  164.         if$this->all_loaded )
  165.         // already all loaded
  166.             return true;
  167.         }
  168.         global $DB;
  169.  
  170.         /**
  171.          * The where clause - gets filled when {@link $cache_by_col_keys} is used.
  172.          */
  173.         $whereList array();
  174.  
  175.         if$this->cache_by_col_keys && isset($arg1) )
  176.         {
  177.             $testCache $this->cache;
  178.             $args array$arg1$arg2$arg3 );
  179.  
  180.             for$i 0$i $this->cache_by_col_keys$i++ )
  181.             {
  182.                 $whereList[$this->col_key_names[$i].' = "'.$args[$i].'"';
  183.  
  184.                 ifis_array$testCache )
  185.                         || is_null($args[$i])
  186.                         || isset$testCache[$args[$i]] )
  187.                         || ($testCache $testCache[$args[$i]]) )
  188.                 {
  189.                     break;
  190.                 }
  191.             }
  192.  
  193.             if$i == $this->cache_by_col_keys )
  194.             // already loaded!
  195.                 return true;
  196.             }
  197.         }
  198.         else
  199.         // we're about to load everything
  200.             $this->all_loaded = true;
  201.         }
  202.  
  203.  
  204.         $result $DB->get_results'
  205.             SELECT '.implode', '$this->col_key_names ).', '.$this->col_value_name.'
  206.             FROM '.$this->db_table_name.(
  207.                 isset$whereList[0)
  208.                 ? ' WHERE '.implode' AND '$whereList )
  209.                 : '' ) );
  210.  
  211.         switch$this->count_col_key_names )
  212.         {
  213.             case 1:
  214.                 if$result )
  215.                 // Remember that we've tried it
  216.                     $this->cache$arg1 NULL;
  217.                 }
  218.                 else foreach$result as $loop_row )
  219.                 {
  220.                     $this->cache[$loop_row->{$this->col_key_names[0]}]->value $loop_row->{$this->col_value_name};
  221.                     $this->cache[$loop_row->{$this->col_key_names[0]}]->dbUptodate true;
  222.                     $this->cache[$loop_row->{$this->col_key_names[0]}]->dbRemove false;
  223.                 }
  224.                 break;
  225.  
  226.             case 2:
  227.                 if$result )
  228.                 // Remember that we've tried it
  229.                     $this->cache$arg1 ]$arg2 NULL;
  230.                 }
  231.                 else foreach$result as $loop_row )
  232.                 {
  233.                     $this->cache[$loop_row->{$this->col_key_names[0]}][$loop_row->{$this->col_key_names[1]}]->value $loop_row->{$this->col_value_name};
  234.                     $this->cache[$loop_row->{$this->col_key_names[0]}][$loop_row->{$this->col_key_names[1]}]->dbUptodate true;
  235.                     $this->cache[$loop_row->{$this->col_key_names[0]}][$loop_row->{$this->col_key_names[1]}]->dbRemove false;
  236.                 }
  237.                 break;
  238.  
  239.             case 3:
  240.                 if$result )
  241.                 // Remember that we've tried it
  242.                     $this->cache$arg1 ]$arg2 ]$arg3 NULL;
  243.                 }
  244.                 else foreach$result as $loop_row )
  245.                 {
  246.                     $this->cache[$loop_row->{$this->col_key_names[0]}][$loop_row->{$this->col_key_names[1]}][$loop_row->{$this->col_key_names[2]}]->value $loop_row->{$this->col_value_name};
  247.                     $this->cache[$loop_row->{$this->col_key_names[0]}][$loop_row->{$this->col_key_names[1]}][$loop_row->{$this->col_key_names[2]}]->dbUptodate true;
  248.                     $this->cache[$loop_row->{$this->col_key_names[0]}][$loop_row->{$this->col_key_names[1]}][$loop_row->{$this->col_key_names[2]}]->dbRemove false;
  249.                 }
  250.                 break;
  251.         }
  252.  
  253.         return true;
  254.     }
  255.  
  256.  
  257.     /**
  258.      * Get a setting from the DB settings table.
  259.      *
  260.      * @uses get_default()
  261.      * @param string First column key
  262.      * @param string Second column key
  263.      * @param string Third column key
  264.      * @return string|false|NULLvalue as string on success; NULL if not found; false in case of error
  265.      */
  266.     function get$col_key1$col_key2 NULL$col_key3 NULL )
  267.     {
  268.         global $debug;
  269.  
  270.         if$debug )
  271.         {
  272.             global $Debuglog$Timer;
  273.             $this_class get_class($this);
  274.             $Timer->resume('abstractsettings_'.$this_class.'_get');
  275.         }
  276.  
  277.         switch$this->count_col_key_names )
  278.         {
  279.             case 1:
  280.                 $this->_load$col_key1 );
  281.  
  282.                 ifisset($this->cache$col_key1 ]->unserialized) )
  283.                 {    // The value has been unserialized before:
  284.                     $r $this->cache$col_key1 ]->value;
  285.                 }
  286.                 elseifisset($this->cache$col_key1 ]->value) )
  287.                 {    // First attempt to access the value, we need to unserialize it:
  288.                     // Try to unserialize setting (once) - this is as fast as checking an array of values that should get unserialized
  289.                     if( ($r @unserialize($this->cache$col_key1 ]->value)) !== false )
  290.                     {
  291.                         $this->cache$col_key1 ]->value $r;
  292.                     }
  293.                     else
  294.                     {
  295.                         $r $this->cache$col_key1 ]->value;
  296.                     }
  297.                     $this->cache$col_key1 ]->unserialized true;
  298.                 }
  299.                 else
  300.                 {    // The value is not in the cache, we use the default:
  301.                     $r $this->get_default$col_key1 );
  302.                     $this->cache$col_key1 ]->value $r// remember in cache
  303.                     $this->cache$col_key1 ]->dbUptodate true;
  304.                     $this->cache$col_key1 ]->unserialized true;
  305.                     $from_default true// for debug
  306.                 }
  307.                 break;
  308.  
  309.             case 2:
  310.                 $this->_load$col_key1$col_key2 );
  311.  
  312.                 ifisset($this->cache$col_key1 ]$col_key2 ]->unserialized) )
  313.                 {
  314.                     $r $this->cache$col_key1 ]$col_key2 ]->value;
  315.                 }
  316.                 elseifisset($this->cache$col_key1 ]$col_key2 ]->value) )
  317.                 {
  318.                     // Try to unserialize setting (once) - this is as fast as checking an array of values that should get unserialized
  319.                     if( ($r @unserialize($this->cache$col_key1 ]$col_key2 ]->value)) !== false )
  320.                     {
  321.                         $this->cache$col_key1 ]$col_key2 ]->value $r;
  322.                     }
  323.                     else
  324.                     {
  325.                         $r $this->cache$col_key1 ]$col_key2 ]->value;
  326.                     }
  327.                     $this->cache$col_key1 ]$col_key2 ]->unserialized true;
  328.                 }
  329.                 else
  330.                 {
  331.                     $r $this->get_default$col_key2 );
  332.                     $this->cache$col_key1 ]$col_key2 ]->value $r// remember in cache
  333.                     $this->cache$col_key1 ]$col_key2 ]->dbUptodate true;
  334.                     $this->cache$col_key1 ]$col_key2 ]->unserialized true;
  335.                     $from_default true// for debug
  336.                 }
  337.                 break;
  338.  
  339.             case 3:
  340.                 $this->_load$col_key1$col_key2$col_key3 );
  341.  
  342.                 ifisset($this->cache$col_key1 ]$col_key2 ]$col_key3 ]->unserialized) )
  343.                 {
  344.                     $r $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value;
  345.                 }
  346.                 elseifisset($this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value) )
  347.                 {
  348.                     // Try to unserialize setting (once) - this is as fast as checking an array of values that should get unserialized
  349.                     if( ($r @unserialize($this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value)) !== false )
  350.                     {
  351.                         $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value $r;
  352.                     }
  353.                     else
  354.                     {
  355.                         $r $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value;
  356.                     }
  357.                     $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->unserialized true;
  358.                 }
  359.                 else
  360.                 {
  361.                     $r $this->get_default$col_key3 );
  362.                     $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value $r// remember in cache
  363.                     $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->dbUptodate true;
  364.                     $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->unserialized true;
  365.                     $from_default true// for debug
  366.                 }
  367.                 break;
  368.         }
  369.  
  370.         if$debug )
  371.         {
  372.             $Debuglog->add$this_class.'::get( '.$col_key1.'/'.$col_key2.'/'.$col_key3.' ): '
  373.                 .isset($from_default'[DEFAULT]: ' '' )
  374.                 .var_export$rtrue )'settings' );
  375.             $Timer->pause('abstractsettings_'.$this_class.'_get');
  376.         }
  377.  
  378.         return $r;
  379.     }
  380.  
  381.  
  382.     /**
  383.      * Get the default for the last key of {@link $col_key_names}
  384.      *
  385.      * @param string The last column key
  386.      * @return NULL|mixedNULL if no default is set, otherwise the value (should be string).
  387.      */
  388.     function get_default$last_key )
  389.     {
  390.         ifisset($this->_defaults$last_key ]) )
  391.         {
  392.             return $this->_defaults$last_key ];
  393.         }
  394.  
  395.         return NULL;
  396.     }
  397.  
  398.  
  399.     /**
  400.      * Only set the first variable (passed by reference) if we could retrieve a
  401.      * setting.
  402.      *
  403.      * @param mixed variable to set maybe (by reference)
  404.      * @param string the values for the column keys (depends on $this->col_key_names
  405.      *                and must match its count and order)
  406.      * @return boolean true on success (variable was set), false if not
  407.      */
  408.     function get_cond$toset )
  409.     {
  410.         $args func_get_args();
  411.         array_shift$args );
  412.  
  413.         $result call_user_func_arrayarray$this'get' )$args );
  414.  
  415.         if$result !== NULL && $result !== false )
  416.         // No error and value retrieved
  417.             $toset $result;
  418.             return true;
  419.         }
  420.         else
  421.         {
  422.             return false;
  423.         }
  424.     }
  425.  
  426.  
  427.     /**
  428.      * Temporarily sets a setting ({@link dbupdate()} writes it to DB).
  429.      *
  430.      * @param string $args,... the values for the {@link $col_key_names column keys}
  431.      *                          and {@link $col_value_name column value}. Must match order and count!
  432.      * @return boolean true, if the value has been set, false if it has not changed.
  433.      */
  434.     function set()
  435.     {
  436.         global $Debuglog;
  437.  
  438.         $args func_get_args();
  439.         $value array_pop($args);
  440.  
  441.         call_user_func_arrayarray(&$this'_load')$args );
  442.  
  443.         $debugMsg get_class($this).'::set( '.implode(', '$args ).' ): ';
  444.  
  445.         switch$this->count_col_key_names )
  446.         {
  447.             case 1:
  448.                 $atCache $this->cache$args[0] ];
  449.                 break;
  450.  
  451.             case 2:
  452.                 $atCache $this->cache$args[0] ]$args[1] ];
  453.                 break;
  454.  
  455.             case 3:
  456.                 $atCache $this->cache$args[0] ]$args[1] ]$args[2] ];
  457.                 break;
  458.  
  459.             default:
  460.                 return false;
  461.         }
  462.  
  463.         $atCache->dbRemove false;
  464.  
  465.         ifisset($atCache->value) )
  466.         {
  467.             if$atCache->value == $value )
  468.             // already set
  469.                 $Debuglog->add$debugMsg.' Already set to the same value.''settings' );
  470.                 return false;
  471.             }
  472.         }
  473.  
  474.         $atCache->value $value;
  475.         $atCache->dbUptodate false;
  476.         $atCache->unserialized true;
  477.  
  478.         $Debuglog->add$debugMsg.' SET!''settings' );
  479.  
  480.         return true;
  481.     }
  482.  
  483.  
  484.     /**
  485.      * Set an array of values.
  486.      *
  487.      * @param array Array of parameters for {@link set()}
  488.      */
  489.     function set_array$array )
  490.     {
  491.         foreach$array as $lSet )
  492.         {
  493.             call_user_func_arrayarray$this'set' )$lSet );
  494.         }
  495.     }
  496.  
  497.  
  498.     /**
  499.      * Remove a setting.
  500.      *
  501.      * @param array List of {@link $col_key_names}
  502.      * @return boolean 
  503.      */
  504.     function delete$args )
  505.     {
  506.         $args func_get_args();
  507.  
  508.         switch$this->count_col_key_names )
  509.         {
  510.             case 1:
  511.                 $atCache $this->cache$args[0] ];
  512.                 break;
  513.  
  514.             case 2:
  515.                 $atCache $this->cache$args[0] ]$args[1] ];
  516.                 break;
  517.  
  518.             case 3:
  519.                 $atCache $this->cache$args[0] ]$args[1] ]$args[2] ];
  520.                 break;
  521.  
  522.             default:
  523.                 return false;
  524.         }
  525.  
  526.         $atCache->dbRemove true;
  527.         unset($atCache->unserialized);
  528.         unset($atCache->value);
  529.  
  530.         return true;
  531.     }
  532.  
  533.  
  534.     /**
  535.      * Delete an array of values.
  536.      *
  537.      * @param array Array of parameters for {@link delete()}
  538.      */
  539.     function delete_array$array )
  540.     {
  541.         foreach$array as $lDel )
  542.         {
  543.             call_user_func_arrayarray$this'delete' )$lDel );
  544.         }
  545.     }
  546.  
  547.  
  548.     /**
  549.      * Delete values for {@link $_defaults default settings} in DB.
  550.      *
  551.      * This will use the default settings on the next {@link get()}
  552.      * again.
  553.      *
  554.      * @return boolean true, if settings have been updated; false otherwise
  555.      */
  556.     function restore_defaults()
  557.     {
  558.         $this->delete_arrayarray_keys$this->_defaults ) );
  559.  
  560.         return $this->dbupdate();
  561.     }
  562.  
  563.  
  564.     /**
  565.      * Commit changed settings to DB.
  566.      *
  567.      * @return boolean true, if settings have been updated; false otherwise
  568.      */
  569.     function dbupdate()
  570.     {
  571.         ifempty($this->cache) )
  572.         {
  573.             return false;
  574.         }
  575.  
  576.         global $DB;
  577.  
  578.         $query_insert array();
  579.         $query_where_delete array();
  580.  
  581.         switch$this->count_col_key_names )
  582.         {
  583.             case 1:
  584.                 foreach$this->cache as $key => $value )
  585.                 {
  586.                     if$value === NULL )
  587.                     // Remembered as not existing
  588.                         continue;
  589.                     }
  590.                     ifempty($value->dbRemove) )
  591.                     {
  592.                         $query_where_delete["{$this->col_key_names[0]} = '$key'";
  593.                         unset$this->cache[$key);
  594.                     }
  595.                     elseifisset($value->dbUptodate&& !$value->dbUptodate )
  596.                     {
  597.                         $value $value->value;
  598.                         ifis_array$value || is_object$value ) )
  599.                         {
  600.                             $value serialize($value);
  601.                         }
  602.                         $query_insert["('$key', '".$DB->escape$value )."')";
  603.                         $this->cache[$key]->dbUptodate true;
  604.                     }
  605.                 }
  606.                 break;
  607.  
  608.             case 2:
  609.                 foreach$this->cache as $key => $value )
  610.                 {
  611.                     foreach$value as $key2 => $value2 )
  612.                     {
  613.                         if$value2 === NULL )
  614.                         // Remembered as not existing
  615.                             continue;
  616.                         }
  617.                         ifempty($value2->dbRemove) )
  618.                         {
  619.                             $query_where_delete["{$this->col_key_names[0]} = '$key' AND {$this->col_key_names[1]} = '$key2'";
  620.                             unset$this->cache[$key][$key2);
  621.                         }
  622.                         elseifisset($value2->dbUptodate&& !$value2->dbUptodate )
  623.                         {
  624.                             $value2 $value2->value;
  625.                             ifis_array$value2 || is_object$value2 ) )
  626.                             {
  627.                                 $value2 serialize($value2);
  628.                             }
  629.                             $query_insert["('$key', '$key2', '".$DB->escape$value2 )."')";
  630.                             $this->cache[$key][$key2]->dbUptodate true;
  631.                         }
  632.                     }
  633.                 }
  634.                 break;
  635.  
  636.             case 3:
  637.                 foreach$this->cache as $key => $value )
  638.                 {
  639.                     foreach$value as $key2 => $value2 )
  640.                     {
  641.                         foreach$value2 as $key3 => $value3 )
  642.                         {
  643.                             if$value3 === NULL )
  644.                             // Remembered as not existing
  645.                                 continue;
  646.                             }
  647.                             ifempty($value3->dbRemove) )
  648.                             {
  649.                                 $query_where_delete["{$this->col_key_names[0]} = '$key' AND {$this->col_key_names[1]} = '$key2' AND {$this->col_key_names[2]} = '$key3'";
  650.                                 unset$this->cache[$key][$key2][$key3);
  651.                             }
  652.                             elseifisset($value3->dbUptodate&& !$value3->dbUptodate )
  653.                             {
  654.                                 $value3 $value3->value;
  655.                                 ifis_array($value3|| is_object($value3) )
  656.                                 {
  657.                                     $value3 serialize($value3);
  658.                                 }
  659.                                 $query_insert["('$key', '$key2', '$key3', '".$DB->escape$value3 )."')";
  660.                                 $this->cache[$key][$key2][$key3]->dbUptodate true;
  661.                             }
  662.                         }
  663.                     }
  664.                 }
  665.                 break;
  666.  
  667.             default:
  668.                 return false;
  669.         }
  670.  
  671.  
  672.         $r false;
  673.  
  674.         ifempty($query_where_delete) )
  675.         {
  676.             $query 'DELETE FROM '.$this->db_table_name." WHERE\n(".implode")\nOR ("$query_where_delete ).')';
  677.             $r = (boolean)$DB->query$query );
  678.         }
  679.  
  680.  
  681.         ifempty($query_insert) )
  682.         {
  683.             $query 'REPLACE INTO '.$this->db_table_name.' ('.implode', '$this->col_key_names ).', '.$this->col_value_name
  684.                                 .') VALUES '.implode(', '$query_insert);
  685.             $r $DB->query$query || $r;
  686.         }
  687.  
  688.         return $r;
  689.     }
  690.  
  691.  
  692.     /**
  693.      * Reset cache (includes settings to be written to DB).
  694.      *
  695.      * This is useful, to rollback settings that have been made, e.g. when a Plugin
  696.      * decides that his settings should not get updated.
  697.      */
  698.     function reset()
  699.     {
  700.         $this->cache NULL;
  701.         $this->all_loaded false;
  702.     }
  703.  
  704. }
  705.  
  706.  
  707. /*
  708.  * $Log: _abstractsettings.class.php,v $
  709.  * Revision 1.12.2.6  2006/11/15 21:05:24  blueyed
  710.  * MFH: - Fixed removing setting after delete() and get() (from defaults) (When getting value from default do not reset $dbRemove property)
  711.  * - Opt: default settings are already unserialized
  712.  *
  713.  * Revision 1.12.2.5  2006/11/15 20:19:35  blueyed
  714.  * MFH: Fixed AbstractSettings::delete(): unset properties in cache
  715.  *
  716.  * Revision 1.12.2.4  2006/11/04 19:54:54  fplanque
  717.  * Reinjected old Log blocks. Removing them from CVS was a bad idea -- especially since Daniel has decided branch 1.9 was his HEAD...
  718.  *
  719.  * Revision 1.12  2006/08/04 23:27:03  blueyed
  720.  * Fixed getting default values.
  721.  *
  722.  * Revision 1.11  2006/08/02 22:05:37  blueyed
  723.  * Optimized performance of (Abstract)Settings, especially get().
  724.  *
  725.  * Revision 1.10  2006/05/19 18:15:05  blueyed
  726.  * Merged from v-1-8 branch
  727.  *
  728.  * Revision 1.9.2.1  2006/05/19 15:06:24  fplanque
  729.  * dirty sync
  730.  *
  731.  * Revision 1.9  2006/05/12 21:53:38  blueyed
  732.  * Fixes, cleanup, translation for plugins
  733.  *
  734.  * Revision 1.8  2006/05/02 22:17:10  blueyed
  735.  * use global DB object instead of property, so it does not get serialized with the object
  736.  *
  737.  * Revision 1.7  2006/04/20 17:30:53  blueyed
  738.  * doc
  739.  *
  740.  * Revision 1.6  2006/04/20 16:31:30  fplanque
  741.  * comment moderation (finished for 1.8)
  742.  *
  743.  * Revision 1.5  2006/04/19 20:13:50  fplanque
  744.  * do not restrict to :// (does not catch subdomains, not even www.)
  745.  *
  746.  * Revision 1.4  2006/03/12 23:08:59  fplanque
  747.  * doc cleanup
  748.  *
  749.  * Revision 1.3  2006/03/11 15:49:48  blueyed
  750.  * Allow a plugin to not update his settings at all.
  751.  *
  752.  * Revision 1.2  2006/02/24 15:09:31  blueyed
  753.  * Decent support for serialized settings through get() and dbupdate().
  754.  *
  755.  * Revision 1.1  2006/02/23 21:11:58  fplanque
  756.  * File reorganization to MVC (Model View Controller) architecture.
  757.  * See index.hml files in folders.
  758.  * (Sorry for all the remaining bugs induced by the reorg... :/)
  759.  *
  760.  * Revision 1.30  2006/01/26 20:27:45  blueyed
  761.  * minor
  762.  *
  763.  * Revision 1.28  2006/01/22 22:41:12  blueyed
  764.  * Added get_unserialized().
  765.  *
  766.  * Revision 1.27  2005/12/30 04:34:04  blueyed
  767.  * Small performance enhancements.
  768.  *
  769.  * Revision 1.26  2005/12/19 17:39:56  fplanque
  770.  * Remember prefered browing tab for each user.
  771.  *
  772.  * Revision 1.25  2005/12/12 19:21:21  fplanque
  773.  * big merge; lots of small mods; hope I didn't make to many mistakes :]
  774.  *
  775.  * Revision 1.24  2005/12/08 22:26:31  blueyed
  776.  * added restore_defaults(), use debug_die()
  777.  *
  778.  * Revision 1.23  2005/12/07 18:04:17  blueyed
  779.  * Normalization
  780.  *
  781.  * Revision 1.19  2005/11/01 23:03:22  blueyed
  782.  * Fix notice on rare occasion (a setting was remembered as not existing [set to NULL in cache], not changed/set and dbupdate()) called
  783.  *
  784.  * Revision 1.18  2005/10/28 02:37:37  blueyed
  785.  * Normalized AbstractSettings API
  786.  *
  787.  * Revision 1.17  2005/09/06 17:13:54  fplanque
  788.  * stop processing early if referer spam has been detected
  789.  *
  790.  * Revision 1.16  2005/07/12 22:54:14  blueyed
  791.  * Fixed get_cond(): respect NULL and false return value of get()
  792.  *
  793.  * Revision 1.15  2005/06/06 17:59:39  fplanque
  794.  * user dialog enhancements
  795.  *
  796.  * Revision 1.14  2005/05/04 19:40:41  fplanque
  797.  * cleaned up file settings a little bit
  798.  *
  799.  * Revision 1.13  2005/04/28 20:44:19  fplanque
  800.  * normalizing, doc
  801.  *
  802.  * Revision 1.12  2005/02/28 09:06:31  blueyed
  803.  * removed constants for DB config (allows to override it from _config_TEST.php), introduced EVO_CONFIG_LOADED
  804.  *
  805.  * Revision 1.11  2005/01/10 20:29:26  blueyed
  806.  * Defaults / Refactored AbstractSettings
  807.  *
  808.  * Revision 1.10  2005/01/06 11:35:00  blueyed
  809.  * Debuglog changed
  810.  *
  811.  * Revision 1.9  2005/01/06 05:20:14  blueyed
  812.  * refactored (constructor), getDefaults()
  813.  *
  814.  * Revision 1.8  2005/01/03 06:23:47  blueyed
  815.  * minor refactoring
  816.  *
  817.  * Revision 1.7  2004/12/30 14:29:42  fplanque
  818.  * comments
  819.  *
  820.  * Revision 1.5  2004/11/08 02:48:26  blueyed
  821.  * doc updated
  822.  *
  823.  * Revision 1.4  2004/11/08 02:23:44  blueyed
  824.  * allow caching by column keys (e.g. user ID)
  825.  *
  826.  * Revision 1.3  2004/10/23 21:32:42  blueyed
  827.  * documentation, return value
  828.  *
  829.  * Revision 1.2  2004/10/16 01:31:22  blueyed
  830.  * documentation changes
  831.  *
  832.  * Revision 1.1  2004/10/13 22:46:32  fplanque
  833.  * renamed [b2]evocore/*
  834.  *
  835.  * Revision 1.13  2004/10/11 19:02:04  fplanque
  836.  * Edited code documentation.
  837.  *
  838.  */
  839. ?>

Documentation generated on Tue, 18 Dec 2007 19:09:53 +0100 by phpDocumentor 1.4.0