2001-05-02 10:02:32 +02:00
|
|
|
<?php
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
|
|
|
* eGW's application configuration in a centralized location
|
|
|
|
*
|
|
|
|
* @link www.egroupware.org
|
2008-10-27 16:11:15 +01:00
|
|
|
* @author Joseph Engo <jengo@phpgroupware.org> original class Copyright (C) 2000, 2001 Joseph Engo
|
2008-01-19 06:25:37 +01:00
|
|
|
* @author Ralf Becker <ralfbecker@outdoor-training.de>
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* eGW's application configuration in a centralized location
|
|
|
|
*/
|
|
|
|
class config
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Name of the config table
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
const TABLE = 'egw_config';
|
|
|
|
/**
|
2008-03-06 12:43:45 +01:00
|
|
|
* Reference to the global db class
|
2008-01-19 06:25:37 +01:00
|
|
|
*
|
|
|
|
* @var egw_db
|
|
|
|
*/
|
|
|
|
static private $db;
|
|
|
|
/**
|
|
|
|
* Cache for the config data shared by all instances of this class
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2011-08-26 15:50:20 +02:00
|
|
|
static private $configs;
|
2008-10-27 16:11:15 +01:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
|
|
|
* app the particular config class is instanciated for
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $appname;
|
|
|
|
/**
|
|
|
|
* actual config-data of the instanciated class
|
|
|
|
*
|
|
|
|
* @deprecated dont use direct
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $config_data;
|
|
|
|
|
2008-03-06 12:43:45 +01:00
|
|
|
/**
|
|
|
|
* Constructor for the old non-static use
|
|
|
|
*
|
|
|
|
* @param string $appname
|
|
|
|
*/
|
2008-01-19 06:25:37 +01:00
|
|
|
function __construct($appname = '')
|
2001-05-02 10:02:32 +02:00
|
|
|
{
|
2008-01-19 06:25:37 +01:00
|
|
|
if (!$appname)
|
|
|
|
{
|
|
|
|
$appname = $GLOBALS['egw_info']['flags']['currentapp'];
|
|
|
|
}
|
|
|
|
$this->appname = $appname;
|
|
|
|
}
|
2001-05-02 10:02:32 +02:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
|
|
|
* reads the whole repository for $this->appname, appname has to be set via the constructor
|
2008-10-27 16:11:15 +01:00
|
|
|
*
|
2008-01-19 06:25:37 +01:00
|
|
|
* You can also use the static config::read($app) method, without instanciating the class.
|
|
|
|
*
|
|
|
|
* @return array the whole config-array for that app
|
|
|
|
*/
|
|
|
|
function read_repository()
|
|
|
|
{
|
|
|
|
$this->config_data = self::read($this->appname);
|
2008-10-27 16:11:15 +01:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
//echo __CLASS__.'::'.__METHOD__."() this->appname=$this->appname\n"; _debug_array($this->config_data);
|
2008-10-27 16:11:15 +01:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
return $this->config_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* updates the whole repository for $this->appname, you have to call read_repository() before (!)
|
|
|
|
*/
|
|
|
|
function save_repository()
|
|
|
|
{
|
|
|
|
if (is_array($this->config_data))
|
2001-05-02 10:02:32 +02:00
|
|
|
{
|
2008-01-19 06:25:37 +01:00
|
|
|
self::$db->lock(array(config::TABLE));
|
|
|
|
foreach($this->config_data as $name => $value)
|
2001-05-02 10:02:32 +02:00
|
|
|
{
|
2012-07-14 10:53:44 +02:00
|
|
|
self::save_value($name, $value, $this->appname, false);
|
2005-07-22 11:05:01 +02:00
|
|
|
}
|
2008-01-19 06:25:37 +01:00
|
|
|
foreach(self::$configs[$this->appname] as $name => $value)
|
2005-07-22 11:05:01 +02:00
|
|
|
{
|
2008-01-19 06:25:37 +01:00
|
|
|
if (!isset($this->config_data[$name])) // has been deleted
|
|
|
|
{
|
2012-07-14 10:53:44 +02:00
|
|
|
self::save_value($name, null, $this->appname, false);
|
2011-09-13 11:25:25 +02:00
|
|
|
//self::$db->delete(config::TABLE,array('config_app'=>$this->appname,'config_name'=>$name),__LINE__,__FILE__);
|
2008-01-19 06:25:37 +01:00
|
|
|
}
|
2005-07-22 11:05:01 +02:00
|
|
|
}
|
2008-01-19 06:25:37 +01:00
|
|
|
self::$db->unlock();
|
|
|
|
|
|
|
|
if ($this->appname == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited
|
2005-07-22 11:05:01 +02:00
|
|
|
{
|
2008-01-19 06:25:37 +01:00
|
|
|
$GLOBALS['egw']->invalidate_session_cache(); // in case egw_info is cached in the session (phpgwapi is in egw_info[server])
|
2001-05-02 10:02:32 +02:00
|
|
|
}
|
2008-01-19 06:25:37 +01:00
|
|
|
self::$configs[$this->appname] = $this->config_data;
|
2011-08-26 15:50:20 +02:00
|
|
|
|
|
|
|
egw_cache::setInstance(__CLASS__, 'configs', self::$configs);
|
2001-05-02 10:02:32 +02:00
|
|
|
}
|
2008-01-19 06:25:37 +01:00
|
|
|
}
|
2001-05-02 10:02:32 +02:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
|
|
|
* updates or insert a single config-value direct into the database
|
|
|
|
*
|
2012-07-14 10:53:44 +02:00
|
|
|
* Can (under recent PHP version) only be used static!
|
|
|
|
* Use $this->value() or $this->delete_value() together with $this->save_repository() for non-static usage.
|
2008-10-27 16:11:15 +01:00
|
|
|
*
|
2008-03-13 20:28:44 +01:00
|
|
|
* @param string $name name of the config-value
|
|
|
|
* @param mixed $value content, empty or null values are not saved, but deleted
|
2012-07-14 10:53:44 +02:00
|
|
|
* @param string $app app-name (depreacted to use default of $this->appname set via the constructor!)
|
|
|
|
* @param boolean $update_cache=true update instance cache and for phpgwapi invalidate session-cache
|
|
|
|
* @throws egw_exception_wrong_parameter if no $app parameter given for static call
|
|
|
|
* @return boolean|int true if no change, else number of affected rows
|
2008-01-19 06:25:37 +01:00
|
|
|
*/
|
2012-07-14 10:53:44 +02:00
|
|
|
static function save_value($name, $value, $app, $update_cache=true)
|
2008-01-19 06:25:37 +01:00
|
|
|
{
|
2010-06-16 13:02:24 +02:00
|
|
|
if (!$app && (!isset($this) || !is_a($this,__CLASS__)))
|
2008-01-19 06:25:37 +01:00
|
|
|
{
|
2012-07-14 10:53:44 +02:00
|
|
|
throw new egw_exception_wrong_parameter('$app parameter required for static call of config::save_value($name,$value,$app)!');
|
2008-01-19 06:25:37 +01:00
|
|
|
}
|
|
|
|
//echo "<p>config::save_value('$name','".print_r($value,True)."','$app')</p>\n";
|
2010-06-16 13:02:24 +02:00
|
|
|
if (!$app || isset($this) && is_a($this,__CLASS__) && $app == $this->appname)
|
2001-05-02 10:02:32 +02:00
|
|
|
{
|
2010-06-16 13:02:24 +02:00
|
|
|
$app = $this->appname;
|
2008-01-19 06:25:37 +01:00
|
|
|
$this->config_data[$name] = $value;
|
|
|
|
}
|
2011-08-26 15:50:20 +02:00
|
|
|
if (!isset(self::$configs))
|
|
|
|
{
|
|
|
|
self::init_static();
|
|
|
|
}
|
2008-01-19 06:25:37 +01:00
|
|
|
//echo "<p>config::save_value('$name','".print_r($value,True)."','$app')</p>\n";
|
|
|
|
if (isset(self::$configs[$app][$name]) && self::$configs[$app][$name] === $value)
|
|
|
|
{
|
|
|
|
return True; // no change ==> exit
|
|
|
|
}
|
2003-11-08 23:30:06 +01:00
|
|
|
|
2008-10-27 16:11:15 +01:00
|
|
|
if (!isset($value) || $value === '')
|
2008-03-13 20:28:44 +01:00
|
|
|
{
|
|
|
|
if (isset(self::$configs[$app])) unset(self::$configs[$app][$name]);
|
2012-07-14 10:53:44 +02:00
|
|
|
self::$db->delete(config::TABLE,array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__);
|
2011-08-26 15:50:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-10-13 08:19:14 +02:00
|
|
|
self::$configs[$app][$name] = $value;
|
2011-10-20 13:41:20 +02:00
|
|
|
if(is_array($value)) $value = serialize($value);
|
2012-07-14 10:53:44 +02:00
|
|
|
self::$db->insert(config::TABLE,array('config_value'=>$value),array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__);
|
2008-03-13 20:28:44 +01:00
|
|
|
}
|
2012-07-14 10:53:44 +02:00
|
|
|
if ($update_cache)
|
|
|
|
{
|
|
|
|
if ($app == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited
|
|
|
|
{
|
|
|
|
$GLOBALS['egw']->invalidate_session_cache(); // in case egw_info is cached in the session (phpgwapi is in egw_info[server])
|
|
|
|
}
|
|
|
|
egw_cache::setInstance(__CLASS__, 'configs', self::$configs);
|
|
|
|
}
|
|
|
|
return self::$db->affected_rows();
|
2008-01-19 06:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* deletes the whole repository for $this->appname, appname has to be set via the constructor
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function delete_repository()
|
|
|
|
{
|
2011-08-26 15:50:20 +02:00
|
|
|
if (!isset(self::$configs))
|
2008-03-06 12:43:45 +01:00
|
|
|
{
|
2011-08-26 15:50:20 +02:00
|
|
|
self::init_static();
|
2008-03-06 12:43:45 +01:00
|
|
|
}
|
2008-01-19 06:25:37 +01:00
|
|
|
self::$db->delete(config::TABLE,array('config_app' => $this->appname),__LINE__,__FILE__);
|
|
|
|
|
|
|
|
unset(self::$configs[$this->appname]);
|
2011-08-26 15:50:20 +02:00
|
|
|
egw_cache::setInstance(__CLASS__, 'configs', self::$configs);
|
2008-01-19 06:25:37 +01:00
|
|
|
}
|
2001-05-02 10:02:32 +02:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
|
|
|
* deletes a single value from the repository, you need to call save_repository after
|
|
|
|
*
|
|
|
|
* @param $variable_name string name of the config
|
|
|
|
*/
|
|
|
|
function delete_value($variable_name)
|
|
|
|
{
|
|
|
|
unset($this->config_data[$variable_name]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets a single value in the repositry, you need to call save_repository after
|
|
|
|
*
|
|
|
|
* @param $variable_name string name of the config
|
|
|
|
* @param $variable_data mixed the content
|
|
|
|
*/
|
|
|
|
function value($variable_name,$variable_data)
|
|
|
|
{
|
|
|
|
$this->config_data[$variable_name] = $variable_data;
|
|
|
|
}
|
2008-10-27 16:11:15 +01:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
|
|
|
* Reads the configuration for an applications
|
2008-10-27 16:11:15 +01:00
|
|
|
*
|
2008-01-19 06:25:37 +01:00
|
|
|
* Does some caching to not read it twice (in the same request)
|
|
|
|
*
|
|
|
|
* @param string $app
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
static function read($app)
|
|
|
|
{
|
2011-08-26 15:50:20 +02:00
|
|
|
if (!isset(self::$configs))
|
2001-05-02 10:02:32 +02:00
|
|
|
{
|
2011-08-26 15:50:20 +02:00
|
|
|
self::init_static();
|
2001-05-02 10:02:32 +02:00
|
|
|
}
|
2011-08-26 15:50:20 +02:00
|
|
|
return self::$configs[$app];
|
2008-01-19 06:25:37 +01:00
|
|
|
}
|
2008-10-27 16:11:15 +01:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
|
|
|
* get customfield array of an application
|
|
|
|
*
|
2008-10-27 16:11:15 +01:00
|
|
|
* @param string $app
|
2008-01-19 06:25:37 +01:00
|
|
|
* @param boolean $all_private_too=false should all the private fields be returned too, default no
|
2011-10-14 15:54:02 +02:00
|
|
|
* @param string $only_type2=null if given only return fields of type2 == $only_type2
|
2008-01-19 06:25:37 +01:00
|
|
|
* @return array with customfields
|
|
|
|
*/
|
2011-10-14 15:54:02 +02:00
|
|
|
static function get_customfields($app,$all_private_too=false, $only_type2=null)
|
2008-01-19 06:25:37 +01:00
|
|
|
{
|
|
|
|
$config = self::read($app);
|
|
|
|
$config_name = isset($config['customfields']) ? 'customfields' : 'custom_fields';
|
2008-10-27 16:11:15 +01:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
$cfs = is_array($config[$config_name]) ? $config[$config_name] : array();
|
2001-05-02 10:02:32 +02:00
|
|
|
|
2011-10-14 15:54:02 +02:00
|
|
|
foreach($cfs as $name => $field)
|
2003-11-03 15:25:50 +01:00
|
|
|
{
|
2011-10-14 15:54:02 +02:00
|
|
|
if (!$all_private_too && $field['private'] && !self::_check_private_cf($field['private']) ||
|
|
|
|
$only_type2 && $field['type2'] && !in_array($only_type2, explode(',', $field['type2'])))
|
2003-11-08 23:30:06 +01:00
|
|
|
{
|
2011-10-14 15:54:02 +02:00
|
|
|
unset($cfs[$name]);
|
2003-11-03 15:25:50 +01:00
|
|
|
}
|
|
|
|
}
|
2011-10-14 15:54:02 +02:00
|
|
|
//error_log(__METHOD__."('$app', $all_private_too, '$only_type2') returning fields: ".implode(', ', array_keys($cfs)));
|
2008-01-19 06:25:37 +01:00
|
|
|
return $cfs;
|
|
|
|
}
|
2003-11-03 15:25:50 +01:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
|
|
|
* Check if user is allowed to see a certain private cf
|
|
|
|
*
|
|
|
|
* @param string $private comma-separated list of user- or group-id's
|
|
|
|
* @return boolean true if user has access, false otherwise
|
|
|
|
*/
|
|
|
|
private static function _check_private_cf($private)
|
|
|
|
{
|
2014-05-13 11:32:21 +02:00
|
|
|
static $user_and_memberships = null;
|
2008-10-27 16:11:15 +01:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
if (!$private)
|
2001-05-02 10:02:32 +02:00
|
|
|
{
|
2008-01-19 06:25:37 +01:00
|
|
|
return true;
|
2001-05-02 10:02:32 +02:00
|
|
|
}
|
2008-01-19 06:25:37 +01:00
|
|
|
if (is_null($user_and_memberships))
|
2003-11-08 23:30:06 +01:00
|
|
|
{
|
2008-01-19 06:25:37 +01:00
|
|
|
$user_and_memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true);
|
|
|
|
$user_and_memberships[] = $GLOBALS['egw_info']['user']['account_id'];
|
2003-11-08 23:30:06 +01:00
|
|
|
}
|
2008-01-19 06:25:37 +01:00
|
|
|
if (!is_array($private)) $private = explode(',',$private);
|
2005-11-02 12:45:52 +01:00
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
return (boolean) array_intersect($private,$user_and_memberships);
|
|
|
|
}
|
2008-10-27 16:11:15 +01:00
|
|
|
|
2013-06-12 18:57:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Change account_id's of private custom-fields
|
|
|
|
*
|
|
|
|
* @param string $app
|
|
|
|
* @param array $ids2change from-id => to-id pairs
|
|
|
|
* @return int number of changed ids
|
|
|
|
*/
|
|
|
|
static function change_account_ids($app, array $ids2change)
|
|
|
|
{
|
|
|
|
$changed = 0;
|
|
|
|
if (($cfs = self::get_customfields($app, true)))
|
|
|
|
{
|
2014-05-13 11:32:21 +02:00
|
|
|
foreach($cfs as &$data)
|
2013-06-12 18:57:44 +02:00
|
|
|
{
|
|
|
|
if ($data['private'])
|
|
|
|
{
|
|
|
|
foreach($data['private'] as &$id)
|
|
|
|
{
|
|
|
|
if (isset($ids2change[$id]))
|
|
|
|
{
|
|
|
|
$id = $ids2change[$id];
|
|
|
|
++$changed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($changed)
|
|
|
|
{
|
|
|
|
self::save_value('customfields', $cfs, $app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return names of custom fields containing account-ids
|
|
|
|
*
|
|
|
|
* @param string $app
|
|
|
|
* @return array account[-commasep] => array of name(s) pairs
|
|
|
|
*/
|
|
|
|
static function get_account_cfs($app)
|
|
|
|
{
|
|
|
|
$types = array();
|
|
|
|
if (($cfs = self::get_customfields($app, true)))
|
|
|
|
{
|
|
|
|
foreach($cfs as $name => $data)
|
|
|
|
{
|
|
|
|
if ($data['type'] == 'select-account' || $data['type'] == 'home-accounts')
|
|
|
|
{
|
|
|
|
$types['account'.($data['rows'] > 1 ? '-commasep' : '')][] = $name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $types;
|
|
|
|
}
|
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
|
|
|
* get_content_types of using application
|
|
|
|
*
|
2008-10-27 16:11:15 +01:00
|
|
|
* @param string $app
|
2008-01-19 06:25:37 +01:00
|
|
|
* @return array with content-types
|
|
|
|
*/
|
2008-03-06 12:43:45 +01:00
|
|
|
static function get_content_types($app)
|
2008-01-19 06:25:37 +01:00
|
|
|
{
|
|
|
|
$config = self::read($app);
|
|
|
|
|
|
|
|
return is_array($config['types']) ? $config['types'] : array();
|
|
|
|
}
|
|
|
|
|
2011-08-26 18:27:57 +02:00
|
|
|
/**
|
|
|
|
* Return configuration for all apps, save to be transmitted to browser
|
|
|
|
*
|
|
|
|
* You can add further values to the white-list, but keep in mind they are publicly visible (eg. via anon user of sitemgr)!!!
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
static public function clientConfigs()
|
|
|
|
{
|
|
|
|
static $white_list = array(
|
|
|
|
'all' => array('customfields', 'types'),
|
|
|
|
'phpgwapi' => array('webserver_url','server_timezone','enforce_ssl','system_charset',
|
|
|
|
'checkfornewversion','checkappversions','email_address_format', // admin >> site config
|
|
|
|
'site_title','login_logo_file','login_logo_url','login_logo_title','favicon_file',
|
2014-05-13 11:32:21 +02:00
|
|
|
'markuntranslated','link_list_thumbnail','enabled_spellcheck','debug_minify',
|
2011-08-26 18:27:57 +02:00
|
|
|
'call_link','call_popup', // addressbook
|
|
|
|
'hide_birthdays'), // calendar
|
|
|
|
'projectmanager' => array('hours_per_workday', 'duration_units'),
|
|
|
|
'manual' => array('manual_remote_egw_url'),
|
|
|
|
'infolog' => array('status'),
|
|
|
|
'timesheet' => array('status_labels'),
|
|
|
|
);
|
|
|
|
if (!isset(self::$configs))
|
|
|
|
{
|
|
|
|
self::init_static();
|
|
|
|
}
|
|
|
|
$client_config = array();
|
|
|
|
foreach(self::$configs as $app => $config)
|
|
|
|
{
|
|
|
|
foreach($config as $name => $value)
|
|
|
|
{
|
|
|
|
if (strpos($name, 'pass') !== false) continue;
|
|
|
|
|
|
|
|
if (in_array($name, $white_list['all']) || isset($white_list[$app]) && in_array($name, $white_list[$app]))
|
|
|
|
{
|
|
|
|
$client_config[$app][$name] = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-09 16:32:07 +01:00
|
|
|
// some things need on client-side which are not direct configs
|
2014-02-21 12:10:11 +01:00
|
|
|
$client_config['phpgwapi']['max_lang_time'] = translation::max_lang_time();
|
2014-01-09 16:32:07 +01:00
|
|
|
|
2011-08-26 18:27:57 +02:00
|
|
|
return $client_config;
|
|
|
|
}
|
|
|
|
|
2008-01-19 06:25:37 +01:00
|
|
|
/**
|
2014-05-13 11:32:21 +02:00
|
|
|
* Initialise class: reference to db and self::$configs cache
|
2008-01-19 06:25:37 +01:00
|
|
|
*/
|
2014-05-13 11:32:21 +02:00
|
|
|
public static function init_static()
|
2008-01-19 06:25:37 +01:00
|
|
|
{
|
2014-05-13 11:32:21 +02:00
|
|
|
// we use a reference here (no clone), as we no longer use egw_db::row() or egw_db::next_record()!
|
2014-05-13 17:53:35 +02:00
|
|
|
if (isset($GLOBALS['egw_setup']) && is_a($GLOBALS['egw_setup']->db, 'egw_db'))
|
2008-01-19 06:25:37 +01:00
|
|
|
{
|
2014-05-13 17:53:35 +02:00
|
|
|
self::$db = $GLOBALS['egw_setup']->db;
|
2008-01-19 06:25:37 +01:00
|
|
|
}
|
|
|
|
else
|
2001-05-02 10:02:32 +02:00
|
|
|
{
|
2014-05-13 17:53:35 +02:00
|
|
|
self::$db = $GLOBALS['egw']->db;
|
2001-05-02 10:02:32 +02:00
|
|
|
}
|
2012-10-01 11:23:51 +02:00
|
|
|
// if item is not cached or cache is not looking alright --> query config from database
|
|
|
|
if (!(self::$configs = egw_cache::getInstance(__CLASS__, 'configs')) || !is_array(self::$configs['phpgwapi']))
|
2011-08-26 15:50:20 +02:00
|
|
|
{
|
|
|
|
self::$configs = array();
|
|
|
|
foreach(self::$db->select(config::TABLE,'*',false,__LINE__,__FILE__) as $row)
|
|
|
|
{
|
|
|
|
$app = $row['config_app'];
|
|
|
|
$name = $row['config_name'];
|
|
|
|
$value = $row['config_value'];
|
|
|
|
|
|
|
|
$test = @unserialize($value);
|
|
|
|
if($test === false)
|
|
|
|
{
|
|
|
|
// manually retrieve the string lengths of the serialized array if unserialize failed
|
|
|
|
$test = @unserialize(preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.mb_strlen('$2','8bit').':\"$2\";'", $value));
|
|
|
|
}
|
|
|
|
self::$configs[$app][$name] = is_array($test) ? $test : $value;
|
|
|
|
}
|
|
|
|
egw_cache::setInstance(__CLASS__, 'configs', self::$configs);
|
|
|
|
}
|
2001-05-21 19:18:39 +02:00
|
|
|
}
|
2008-01-19 06:25:37 +01:00
|
|
|
}
|