phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ 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 Quam Plures - {@link http://quamplures.net/}
  6.  * See also {@link https://launchpad.net/quam-plures}.
  7.  *
  8.  * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
  9.  * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
  10.  *  Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  11.  *
  12.  *  {@internal License choice
  13.  *  - If you have received this file as part of a package, please find the license.txt file in
  14.  *    the same folder or the closest folder above for complete license terms.
  15.  *  - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  16.  *    then you must choose one of the following licenses before using the file:
  17.  *    - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  18.  *    - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  19.  *  }}}
  20.  *
  21.  *  {@internal Open Source relicensing agreement:
  22.  *  Daniel HAHLER grants Francois PLANQUE the right to license
  23.  *  Daniel HAHLER's contributions to this file and the b2evolution project
  24.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  25.  *  }}}
  26.  *
  27.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  28.  * @author blueyed: Daniel HAHLER
  29.  * @author fplanque: Francois PLANQUE
  30.  *
  31.  * @package pond
  32.  */
  33. if!defined('QP_MAIN_INIT') ) die'Please, do not access this page directly.' );
  34.  
  35. /**
  36.  * Class to handle settings in an abstract manner (to get used with either 1, 2 or 3 DB column keys).
  37.  *
  38.  * Arrays and Objects automatically get serialized and unserialized
  39.  * (in {@link AbstractSettings::get()} and {@link AbstractSettings::dbupdate()}).
  40.  *
  41.  * Note: I've evaluated splitting this into single classes for performance reasons, but only
  42.  *       get() is relevant performance-wise and we could now only get rid of the switch() therein,
  43.  *       which is not sufficient to split it into *_base + _X classes. (blueyed, 2006-08)
  44.  *
  45.  * @abstract
  46.  * @see UserSettings, GeneralSettings, PluginSettings, CollectionSettings
  47.  *
  48.  * @package pond
  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 
  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.      * false, if settings  could not be loaded or NULL if not initialized.
  89.      *
  90.       * @access protected
  91.      * @var array 
  92.      */
  93.     var $cache = NULL;
  94.  
  95.  
  96.     /**
  97.      * Do we have loaded everything?
  98.      *
  99.      * @var boolean 
  100.      */
  101.     var $all_loaded = false;
  102.  
  103.  
  104.     /**
  105.      * Default settings.
  106.      *
  107.      * Maps last colkeyname to some default setting that will be used by
  108.      * {@link get()} if no value was defined (and it is set as a default).
  109.      *
  110.      * @var array 
  111.      */
  112.     var $_defaults = array();
  113.  
  114.  
  115.     /**
  116.      * Constructor.
  117.      * @param string The name of the DB table with the settings stored.
  118.      * @param array List of names for the DB columns keys that reference a value.
  119.      * @param string The name of the DB column that holds the value.
  120.      * @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'.
  121.      */
  122.     function AbstractSettings$db_table_name$col_key_names$col_value_name$cache_by_col_keys )
  123.     {
  124.         $this->db_table_name = $db_table_name;
  125.         $this->col_key_names = $col_key_names;
  126.         $this->col_value_name = $col_value_name;
  127.         $this->cache_by_col_keys = $cache_by_col_keys;
  128.  
  129.  
  130.         /**
  131.          * internal counter for the number of column keys
  132.          * @var integer
  133.          */
  134.         $this->count_col_key_names count$this->col_key_names );
  135.  
  136.         if$this->count_col_key_names || $this->count_col_key_names )
  137.         {
  138.             debug_die'Settings keycount not supported for class '.get_class() );
  139.         }
  140.     }
  141.  
  142.  
  143.     /**
  144.      * Load all settings, disregarding the derived classes setting of
  145.      * {@link $cache_by_col_keys} - useful if you know that you want to get
  146.      * all user settings for example.
  147.      */
  148.     function load_all()
  149.     {
  150.         return $this->_load();
  151.     }
  152.  
  153.  
  154.     /**
  155.      * Loads the settings. Not meant to be called directly, but gets called
  156.      * when needed.
  157.      *
  158.      * @access protected
  159.      * @param string First column key
  160.      * @param string Second column key
  161.      * @param string Third column key
  162.      * @return boolean always true
  163.      */
  164.     function _load$arg1 NULL$arg2 NULL$arg3 NULL )
  165.     {
  166.         if$this->all_loaded )
  167.         // already all loaded
  168.             return true;
  169.         }
  170.         global $DB;
  171.  
  172.         /**
  173.          * The where clause - gets filled when {@link $cache_by_col_keys} is used.
  174.          */
  175.         $whereList array();
  176.  
  177.         if$this->cache_by_col_keys && isset($arg1) )
  178.         // The number of column keys to cache by is > 0
  179.             $testCache $this->cache;
  180.             $args array$arg1$arg2$arg3 );
  181.  
  182.             for$i 0$i $this->cache_by_col_keys$i++ )
  183.             {
  184.                 $whereList[$this->col_key_names[$i]." = '".$args[$i]."'";
  185.  
  186.                 ifis_array$testCache )
  187.                         || is_null($args[$i])
  188.                         || isset$testCache[$args[$i]] )
  189.                         || ($testCache $testCache[$args[$i]]) )
  190.                 {
  191.                     break;
  192.                 }
  193.             }
  194.  
  195.             if$i == $this->cache_by_col_keys )
  196.             // already loaded!
  197.                 return true;
  198.             }
  199.         }
  200.         else
  201.         // We cache everything at once!
  202.             $this->all_loaded = true;
  203.         }
  204.  
  205.  
  206.         $result $DB->get_results'
  207.             SELECT '.implode', '$this->col_key_names ).', '.$this->col_value_name.'
  208.             FROM '.$this->db_table_name.(
  209.                 isset$whereList[0)
  210.                 ? ' WHERE '.implode' AND '$whereList )
  211.                 : '' ) );
  212.  
  213.         switch$this->count_col_key_names )
  214.         {
  215.             case 1:
  216.                 if$result )
  217.                 // Remember that we've tried it
  218.                     $this->cache$arg1 NULL;
  219.                 }
  220.                 else foreach$result as $loop_row )
  221.                 {
  222.                     $this->cache[$loop_row->{$this->col_key_names[0]}]->value $loop_row->{$this->col_value_name};
  223.                     $this->cache[$loop_row->{$this->col_key_names[0]}]->dbUptodate true;
  224.                     $this->cache[$loop_row->{$this->col_key_names[0]}]->dbRemove false;
  225.                 }
  226.                 break;
  227.  
  228.             case 2:
  229.                 if$result )
  230.                 // Remember that we've tried it
  231.                     $this->cache$arg1 ]$arg2 NULL;
  232.                 }
  233.                 else foreach$result as $loop_row )
  234.                 {
  235.                     $this->cache[$loop_row->{$this->col_key_names[0]}][$loop_row->{$this->col_key_names[1]}]->value $loop_row->{$this->col_value_name};
  236.                     $this->cache[$loop_row->{$this->col_key_names[0]}][$loop_row->{$this->col_key_names[1]}]->dbUptodate true;
  237.                     $this->cache[$loop_row->{$this->col_key_names[0]}][$loop_row->{$this->col_key_names[1]}]->dbRemove false;
  238.                 }
  239.                 break;
  240.  
  241.             case 3:
  242.                 if$result )
  243.                 // Remember that we've tried it
  244.                     $this->cache$arg1 ]$arg2 ]$arg3 NULL;
  245.                 }
  246.                 else foreach$result as $loop_row )
  247.                 {
  248.                     $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};
  249.                     $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;
  250.                     $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;
  251.                 }
  252.                 break;
  253.         }
  254.  
  255.         return true;
  256.     }
  257.  
  258.  
  259.     /**
  260.      * Get a setting from the DB settings table.
  261.      *
  262.      * @uses get_default()
  263.      * @param string First column key
  264.      * @param string Second column key
  265.      * @param string Third column key
  266.      * @return string|false|NULLvalue as string on success; NULL if not found; false in case of error
  267.      */
  268.     function get$col_key1$col_key2 NULL$col_key3 NULL )
  269.     {
  270.         global $debug;
  271.  
  272.         if$debug )
  273.         {
  274.             global $Debuglog$Timer;
  275.             $this_class get_class($this);
  276.             $Timer->resume('abstractsettings_'.$this_class.'_get');
  277.         }
  278.  
  279.         switch$this->count_col_key_names )
  280.         {
  281.             case 1:
  282.                 $this->_load$col_key1 );
  283.                 if!empty($this->cache$col_key1 ]->unserialized) )
  284.                 {    // The value has been unserialized before:
  285.                     $r $this->cache$col_key1 ]->value;
  286.                 }
  287.                 elseifisset($this->cache$col_key1 ]->value) )
  288.                 {    // First attempt to access the value, we need to unserialize it:
  289.                     // Try to unserialize setting (once) - this is as fast as checking an array of values that should get unserialized
  290.                     if( ($r @unserialize($this->cache$col_key1 ]->value)) !== false )
  291.                     {
  292.                         $this->cache$col_key1 ]->value $r;
  293.                     }
  294.                     else
  295.                     {
  296.                         $r $this->cache$col_key1 ]->value;
  297.                     }
  298.                     $this->cache$col_key1 ]->unserialized true;
  299.                 }
  300.                 else
  301.                 {    // The value is not in the cache, we use the default:
  302.                     $r $this->get_default$col_key1 );
  303.                     $this->cache$col_key1 ]->value $r// remember in cache
  304.                     $this->cache$col_key1 ]->dbUptodate true;
  305.                     $this->cache$col_key1 ]->unserialized true;
  306.                     $from_default true// for debug
  307.                 }
  308.                 break;
  309.  
  310.             case 2:
  311.                 $this->_load$col_key1$col_key2 );
  312.  
  313.                 ifisset($this->cache$col_key1 ]$col_key2 ]->unserialized) )
  314.                 {
  315.                     $r $this->cache$col_key1 ]$col_key2 ]->value;
  316.                 }
  317.                 elseifisset($this->cache$col_key1 ]$col_key2 ]->value) )
  318.                 {
  319.                     // Try to unserialize setting (once) - this is as fast as checking an array of values that should get unserialized
  320.                     if( ($r @unserialize($this->cache$col_key1 ]$col_key2 ]->value)) !== false )
  321.                     {
  322.                         $this->cache$col_key1 ]$col_key2 ]->value $r;
  323.                     }
  324.                     else
  325.                     {
  326.                         $r $this->cache$col_key1 ]$col_key2 ]->value;
  327.                     }
  328.                     $this->cache$col_key1 ]$col_key2 ]->unserialized true;
  329.                 }
  330.                 else
  331.                 {
  332.                     $r $this->get_default$col_key2 );
  333.                     $this->cache$col_key1 ]$col_key2 ]->value $r// remember in cache
  334.                     $this->cache$col_key1 ]$col_key2 ]->dbUptodate true;
  335.                     $this->cache$col_key1 ]$col_key2 ]->unserialized true;
  336.                     $from_default true// for debug
  337.                 }
  338.                 break;
  339.  
  340.             case 3:
  341.                 $this->_load$col_key1$col_key2$col_key3 );
  342.  
  343.                 ifisset($this->cache$col_key1 ]$col_key2 ]$col_key3 ]->unserialized) )
  344.                 {
  345.                     $r $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value;
  346.                 }
  347.                 elseifisset($this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value) )
  348.                 {
  349.                     // Try to unserialize setting (once) - this is as fast as checking an array of values that should get unserialized
  350.                     if( ($r @unserialize($this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value)) !== false )
  351.                     {
  352.                         $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value $r;
  353.                     }
  354.                     else
  355.                     {
  356.                         $r $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value;
  357.                     }
  358.                     $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->unserialized true;
  359.                 }
  360.                 else
  361.                 {
  362.                     $r $this->get_default$col_key3 );
  363.                     $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->value $r// remember in cache
  364.                     $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->dbUptodate true;
  365.                     $this->cache$col_key1 ]$col_key2 ]$col_key3 ]->unserialized true;
  366.                     $from_default true// for debug
  367.                 }
  368.                 break;
  369.         }
  370.  
  371.         if$debug )
  372.         {
  373.             $Debuglog->add$this_class.'::get( '.$col_key1.'/'.$col_key2.'/'.$col_key3.' ): '
  374.                 .isset($from_default'[DEFAULT]: ' '' )
  375.                 .var_export$rtrue )'settings' );
  376.             $Timer->pause('abstractsettings_'.$this_class.'_get');
  377.         }
  378.  
  379.         return $r;
  380.     }
  381.  
  382.  
  383.     /**
  384.      * Get the default for the last key of {@link $col_key_names}
  385.      *
  386.      * @param string The last column key
  387.      * @return NULL|mixedNULL if no default is set, otherwise the value (should be string).
  388.      */
  389.     function get_default$last_key )
  390.     {
  391.         ifisset($this->_defaults$last_key ]) )
  392.         {
  393.             return $this->_defaults$last_key ];
  394.         }
  395.  
  396.         return NULL;
  397.     }
  398.  
  399.  
  400.     /**
  401.      * Only set the first variable (passed by reference) if we could retrieve a
  402.      * setting.
  403.      *
  404.      * @param mixed variable to set maybe (by reference)
  405.      * @param string the values for the column keys (depends on $this->col_key_names
  406.      *                and must match its count and order)
  407.      * @return boolean true on success (variable was set), false if not
  408.      */
  409.     function get_cond$toset )
  410.     {
  411.         $args func_get_args();
  412.         array_shift$args );
  413.  
  414.         $result call_user_func_arrayarray$this'get' )$args );
  415.  
  416.         if$result !== NULL && $result !== false )
  417.         // No error and value retrieved
  418.             $toset $result;
  419.             return true;
  420.         }
  421.         else
  422.         {
  423.             return false;
  424.         }
  425.     }
  426.  
  427.  
  428.     /**
  429.      * Temporarily sets a setting ({@link dbupdate()} writes it to DB).
  430.      *
  431.      * @param string $args,... the values for the {@link $col_key_names column keys}
  432.      *                          and {@link $col_value_name column value}. Must match order and count!
  433.      * @return boolean true, if the value has been set, false if it has not changed.
  434.      */
  435.     function set()
  436.     {
  437.         global $Debuglog;
  438.  
  439.         $args func_get_args();
  440.         $value array_pop($args);
  441.  
  442.         call_user_func_arrayarray(&$this'_load')$args );
  443.  
  444.         $debugMsg get_class($this).'::set( '.implode(', '$args ).' ): ';
  445.  
  446.         switch$this->count_col_key_names )
  447.         {
  448.             case 1:
  449.                 $atCache $this->cache$args[0] ];
  450.                 break;
  451.  
  452.             case 2:
  453.                 $atCache $this->cache$args[0] ]$args[1] ];
  454.                 break;
  455.  
  456.             case 3:
  457.                 $atCache $this->cache$args[0] ]$args[1] ]$args[2] ];
  458.                 break;
  459.  
  460.             default:
  461.                 return false;
  462.         }
  463.  
  464.         $atCache->dbRemove false;
  465.  
  466.         ifisset($atCache->value) )
  467.         {
  468.             if$atCache->value == $value )
  469.             // already set
  470.                 $Debuglog->add$debugMsg.' Already set to the same value.''settings' );
  471.                 return false;
  472.             }
  473.         }
  474.  
  475.         $atCache->value $value;
  476.         $atCache->dbUptodate false;
  477.         $atCache->unserialized false// We haven't tried to unserialize the value yet
  478.  
  479.         $Debuglog->add$debugMsg.' SET!''settings' );
  480.  
  481.         return true;
  482.     }
  483.  
  484.  
  485.     /**
  486.      * Set an array of values.
  487.      *
  488.      * @param array Array of parameters for {@link set()}
  489.      */
  490.     function set_array$array )
  491.     {
  492.         foreach$array as $lSet )
  493.         {
  494.             call_user_func_arrayarray$this'set' )$lSet );
  495.         }
  496.     }
  497.  
  498.  
  499.     /**
  500.      * Remove a setting.
  501.      *
  502.      * @param array List of {@link $col_key_names}
  503.      * @return boolean 
  504.      */
  505.     function delete$args )
  506.     {
  507.         $args func_get_args();
  508.  
  509.         switch$this->count_col_key_names )
  510.         {
  511.             case 1:
  512.                 $atCache $this->cache$args[0] ];
  513.                 break;
  514.  
  515.             case 2:
  516.                 $atCache $this->cache$args[0] ]$args[1] ];
  517.                 break;
  518.  
  519.             case 3:
  520.                 $atCache $this->cache$args[0] ]$args[1] ]$args[2] ];
  521.                 break;
  522.  
  523.             default:
  524.                 return false;
  525.         }
  526.  
  527.         $atCache->dbRemove true;
  528.         unset($atCache->unserialized);
  529.         unset($atCache->value);
  530.  
  531.         return true;
  532.     }
  533.  
  534.  
  535.     /**
  536.      * Delete an array of values.
  537.      *
  538.      * @param array Array of parameters for {@link delete()}
  539.      */
  540.     function delete_array$array )
  541.     {
  542.         foreach$array as $lDel )
  543.         {
  544.             call_user_func_arrayarray$this'delete' )$lDel );
  545.         }
  546.     }
  547.  
  548.  
  549.     /**
  550.      * Delete values for {@link $_defaults default settings} in DB.
  551.      *
  552.      * This will use the default settings on the next {@link get()}
  553.      * again.
  554.      *
  555.      * @return boolean true, if settings have been updated; false otherwise
  556.      */
  557.     function restore_defaults()
  558.     {
  559.         $this->delete_arrayarray_keys$this->_defaults ) );
  560.  
  561.         return $this->dbupdate();
  562.     }
  563.  
  564.  
  565.     /**
  566.      * Commit changed settings to DB.
  567.      *
  568.      * @return boolean true, if settings have been updated; false otherwise
  569.      */
  570.     function dbupdate()
  571.     {
  572.         ifempty($this->cache) )
  573.         {
  574.             return false;
  575.         }
  576.  
  577.         global $DB;
  578.  
  579.         $query_insert array();
  580.         $query_where_delete array();
  581.  
  582.         switch$this->count_col_key_names )
  583.         {
  584.             case 1:
  585.                 foreach$this->cache as $key => $value )
  586.                 {
  587.                     if$value === NULL )
  588.                     // Remembered as not existing
  589.                         continue;
  590.                     }
  591.                     ifempty($value->dbRemove) )
  592.                     {
  593.                         $query_where_delete["{$this->col_key_names[0]} = '$key'";
  594.                         unset$this->cache[$key);
  595.                     }
  596.                     elseifisset($value->dbUptodate&& !$value->dbUptodate )
  597.                     {
  598.                         $value $value->value;
  599.                         ifis_array$value || is_object$value ) )
  600.                         {
  601.                             $value serialize($value);
  602.                         }
  603.                         $query_insert["('$key', '".$DB->escape$value )."')";
  604.                         $this->cache[$key]->dbUptodate true;
  605.                     }
  606.                 }
  607.                 break;
  608.  
  609.             case 2:
  610.                 foreach$this->cache as $key => $value )
  611.                 {
  612.                     foreach$value as $key2 => $value2 )
  613.                     {
  614.                         if$value2 === NULL )
  615.                         // Remembered as not existing
  616.                             continue;
  617.                         }
  618.                         ifempty($value2->dbRemove) )
  619.                         {
  620.                             $query_where_delete["{$this->col_key_names[0]} = '$key' AND {$this->col_key_names[1]} = '$key2'";
  621.                             unset$this->cache[$key][$key2);
  622.                         }
  623.                         elseifisset($value2->dbUptodate&& !$value2->dbUptodate )
  624.                         {
  625.                             $value2 $value2->value;
  626.                             ifis_array$value2 || is_object$value2 ) )
  627.                             {
  628.                                 $value2 serialize($value2);
  629.                             }
  630.                             $query_insert["('$key', '$key2', '".$DB->escape$value2 )."')";
  631.                             $this->cache[$key][$key2]->dbUptodate true;
  632.                         }
  633.                     }
  634.                 }
  635.                 break;
  636.  
  637.             case 3:
  638.                 foreach$this->cache as $key => $value )
  639.                 {
  640.                     foreach$value as $key2 => $value2 )
  641.                     {
  642.                         foreach$value2 as $key3 => $value3 )
  643.                         {
  644.                             if$value3 === NULL )
  645.                             // Remembered as not existing
  646.                                 continue;
  647.                             }
  648.                             ifempty($value3->dbRemove) )
  649.                             {
  650.                                 $query_where_delete["{$this->col_key_names[0]} = '$key' AND {$this->col_key_names[1]} = '$key2' AND {$this->col_key_names[2]} = '$key3'";
  651.                                 unset$this->cache[$key][$key2][$key3);
  652.                             }
  653.                             elseifisset($value3->dbUptodate&& !$value3->dbUptodate )
  654.                             {
  655.                                 $value3 $value3->value;
  656.                                 ifis_array($value3|| is_object($value3) )
  657.                                 {
  658.                                     $value3 serialize($value3);
  659.                                 }
  660.                                 $query_insert["('$key', '$key2', '$key3', '".$DB->escape$value3 )."')";
  661.                                 $this->cache[$key][$key2][$key3]->dbUptodate true;
  662.                             }
  663.                         }
  664.                     }
  665.                 }
  666.                 break;
  667.  
  668.             default:
  669.                 return false;
  670.         }
  671.  
  672.  
  673.         $r false;
  674.  
  675.         ifempty($query_where_delete) )
  676.         {
  677.             $query 'DELETE FROM '.$this->db_table_name." WHERE\n(".implode")\nOR ("$query_where_delete ).')';
  678.             $r = (boolean)$DB->query$query );
  679.         }
  680.  
  681.  
  682.         ifempty($query_insert) )
  683.         {
  684.             $query 'REPLACE INTO '.$this->db_table_name.' ('.implode', '$this->col_key_names ).', '.$this->col_value_name
  685.                                 .') VALUES '.implode(', '$query_insert);
  686.             $r $DB->query$query || $r;
  687.         }
  688.  
  689.         return $r;
  690.     }
  691.  
  692.  
  693.     /**
  694.      * Reset cache (includes settings to be written to DB).
  695.      *
  696.      * This is useful, to rollback settings that have been made, e.g. when a Plugin
  697.      * decides that his settings should not get updated.
  698.      */
  699.     function reset()
  700.     {
  701.         $this->cache NULL;
  702.         $this->all_loaded false;
  703.     }
  704.  
  705. }
  706.  
  707.  
  708. ?>