ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSetting Class Reference

ILIAS Setting Class. More...

+ Inheritance diagram for ilSetting:
+ Collaboration diagram for ilSetting:

Public Member Functions

 ilSetting ($a_module="common", $a_disabled_cache=false)
 Initialize settings.
 getModule ()
 Get currernt module.
 read ()
 Read settings data.
 get ($a_keyword, $a_default_value=false)
 get setting
 deleteAll ()
 Delete all settings of a current module.
 deleteLike ($a_like)
 Delete all settings corresponding to a like string.
 delete ($a_keyword)
 delete one value from settingstable public
 getAll ()
 read all values from settingstable public
 set ($a_key, $a_val)
 write one value to db-table settings public
 setScormDebug ($a_key, $a_val)

Static Public Member Functions

static _lookupValue ($a_module, $a_keyword)
static _getValueType ()
 get the type of the value column in the database
static _changeValueType ($a_new_type= 'text')
 change the type of the value column in the database
static _getLongerSettings ($a_limit= '4000')
 get a list of setting records with values loger than a limit

Data Fields

 $setting = array()
 $module = ""

Static Private Attributes

static $settings_cache = array()
 cache for the read settings ilSetting is instantiated more than once per request for some modules The cache avoids reading them from the DB with each instance
static $value_type = NULL
 the type of settings value field in database This is determined in the set method to get a correct DB insert Don't set the value type to force a detection at first access

Detailed Description

ILIAS Setting Class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@d.nosp@m.atab.nosp@m.ay.de
Version
Id:
class.ilSetting.php 46023 2013-11-05 15:33:10Z smeyer

Definition at line 32 of file class.ilSetting.php.

Member Function Documentation

static ilSetting::_changeValueType (   $a_new_type = 'text')
static

change the type of the value column in the database

Parameters
string'text' or 'clob'
Returns
bolean type changed or not

Definition at line 292 of file class.ilSetting.php.

References $ilDB, and _getValueType().

Referenced by ilSetupGUI\changeSettingsType().

{
global $ilDB;
$old_type = self::_getValueType();
if ($a_new_type == $old_type)
{
return false;
}
elseif ($a_new_type == 'clob')
{
$ilDB->addTableColumn('settings','value2',
array( "type" => "clob",
"notnull" => false,
"default" => NULL));
$ilDB->query("UPDATE settings SET value2 = value");
$ilDB->dropTableColumn('settings','value');
$ilDB->renameTableColumn('settings','value2','value');
return true;
}
elseif ($a_new_type == 'text')
{
$ilDB->addTableColumn('settings','value2',
array( "type" => "text",
"length" => 4000,
"notnull" => false,
"default" => NULL));
$ilDB->query("UPDATE settings SET value2 = value");
$ilDB->dropTableColumn('settings','value');
$ilDB->renameTableColumn('settings','value2','value');
return true;
}
else
{
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSetting::_getLongerSettings (   $a_limit = '4000')
static

get a list of setting records with values loger than a limit

Parameters
intcharacter limit (default: 4000)
Returns
array records with longer values

Definition at line 342 of file class.ilSetting.php.

References $ilDB, $query, $result, and $row.

Referenced by ilSetupGUI\changeSettingsType(), and ilSetupGUI\showLongerSettings().

{
global $ilDB;
$settings = array();
$query = "SELECT * FROM settings WHERE LENGTH(value) > "
. $ilDB->quote($a_limit, 'integer');
$result = $ilDB->query($query);
while ($row = $ilDB->fetchAssoc($result))
{
$settings[] = $row;
}
return $settings;
}

+ Here is the caller graph for this function:

static ilSetting::_getValueType ( )
static

get the type of the value column in the database

Returns
string 'text' or 'clob'

Definition at line 269 of file class.ilSetting.php.

References ilDBAnalyzer\getFieldInformation().

Referenced by _changeValueType(), ilSetupGUI\changeSettingsType(), ilSetupGUI\initSettingsTypeForm(), and set().

{
include_once ('./Services/Database/classes/class.ilDBAnalyzer.php');
$analyzer = new ilDBAnalyzer;
$info = $analyzer->getFieldInformation('settings');
if ($info['value']['type'] == 'clob')
{
return 'clob';
}
else
{
return 'text';
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSetting::_lookupValue (   $a_module,
  $a_keyword 
)
static

Definition at line 254 of file class.ilSetting.php.

References $ilDB, $query, and $res.

{
global $ilDB;
$query = "SELECT value FROM settings WHERE module = %s AND keyword = %s";
$res = $ilDB->queryF($query, array('text', 'text'), array($a_module, $a_keyword));
$data = $ilDB->fetchAssoc($res);
return $data['value'];
}
ilSetting::delete (   $a_keyword)

delete one value from settingstable public

Parameters
stringkeyword
Returns
string value

Definition at line 185 of file class.ilSetting.php.

References $ilDB.

{
global $ilDB;
$st = $ilDB->manipulate("DELETE FROM settings WHERE keyword = ".
$ilDB->quote($a_keyword, "text")." AND module = ".
$ilDB->quote($this->module, "text"));
unset($this->setting[$a_keyword]);
return true;
}
ilSetting::deleteAll ( )

Delete all settings of a current module.

public

Definition at line 145 of file class.ilSetting.php.

References $ilDB, and $query.

{
global $ilDB;
$query = "DELETE FROM settings WHERE module = ".$ilDB->quote($this->module, "text");
$ilDB->manipulate($query);
$this->setting = array();
return true;
}
ilSetting::deleteLike (   $a_like)

Delete all settings corresponding to a like string.

public

Definition at line 163 of file class.ilSetting.php.

References $ilDB, $query, $res, and $row.

{
global $ilDB;
$query = "SELECT keyword FROM settings".
" WHERE module = ".$ilDB->quote($this->module, "text").
" AND ".$ilDB->like("keyword", "text", $a_like);
$res = $ilDB->query($query);
while($row = $ilDB->fetchAssoc($res))
{
$this->delete($row["keyword"]);
}
return true;
}
ilSetting::get (   $a_keyword,
  $a_default_value = false 
)

get setting

public

Parameters
stringkeyword
stringdefault_value This value is returned, when no setting has been found for the keyword.
Returns
string value

Definition at line 122 of file class.ilSetting.php.

References ILIAS_VERSION.

{
if ($a_keyword == "ilias_version")
{
return ILIAS_VERSION;
}
if (isset($this->setting[$a_keyword]))
{
return $this->setting[$a_keyword];
}
else
{
return $a_default_value;
}
}
ilSetting::getAll ( )

read all values from settingstable public

Returns
array keyword/value pairs

Definition at line 205 of file class.ilSetting.php.

References $setting.

{
}
ilSetting::getModule ( )

Get currernt module.

Definition at line 72 of file class.ilSetting.php.

References $module.

{
return $this->module;
}
ilSetting::ilSetting (   $a_module = "common",
  $a_disabled_cache = false 
)

Initialize settings.

Definition at line 55 of file class.ilSetting.php.

References $ilDB, and read().

{
global $ilDB;
$this->cache_disabled = $a_disabled_cache;
$this->module = $a_module;
// check whether ini file object exists
if (!is_object($ilDB))
{
die ("Fatal Error: ilSettings object instantiated without DB initialisation.");
}
$this->read();
}

+ Here is the call graph for this function:

ilSetting::read ( )

Read settings data.

Definition at line 80 of file class.ilSetting.php.

References $ilDB, $module, $query, $res, $row, and $setting.

Referenced by ilSetting().

{
global $ilDB;
// get the settings from the cache if they exist.
// The setting array of the class is a reference to the cache.
// So changing settings in one instance will change them in all.
// This is the same behaviour as if the are read from the DB.
if (!$this->cache_disabled)
{
if (isset(self::$settings_cache[$this->module]))
{
$this->setting =& self::$settings_cache[$this->module];
return;
}
else
{
$this->setting = array();
self::$settings_cache[$this->module] =& $this->setting;
}
}
$query = "SELECT * FROM settings WHERE module=".$ilDB->quote($this->module, "text");
$res = $ilDB->query($query);
while ($row = $ilDB->fetchAssoc($res))
{
$this->setting[$row["keyword"]] = $row["value"];
}
}

+ Here is the caller graph for this function:

ilSetting::set (   $a_key,
  $a_val 
)

write one value to db-table settings public

Parameters
stringkeyword
stringvalue
Returns
boolean true on success

Definition at line 217 of file class.ilSetting.php.

References $ilDB, $lng, _getValueType(), and ilUtil\sendFailure().

Referenced by setScormDebug().

{
global $lng, $ilDB;
$this->delete($a_key);
if (!isset(self::$value_type))
{
self::$value_type = self::_getValueType();
}
if (self::$value_type == 'text' and strlen($a_val) >= 4000)
{
ilUtil::sendFailure($lng->txt('setting_value_truncated'), true);
$a_val = substr($a_val, 0, 4000);
}
$ilDB->insert("settings", array(
"module" => array("text", $this->module),
"keyword" => array("text", $a_key),
"value" => array(self::$value_type, $a_val)));
$this->setting[$a_key] = $a_val;
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilSetting::setScormDebug (   $a_key,
  $a_val 
)

Definition at line 244 of file class.ilSetting.php.

References $ilDB, and set().

{
global $ilDB;
if ($a_val != "1") {
$ilDB->query("UPDATE sahs_lm SET debug = 'n'");
}
$setreturn = ilSetting::set($a_key, $a_val);
return $setreturn;
}

+ Here is the call graph for this function:

Field Documentation

ilSetting::$module = ""

Definition at line 50 of file class.ilSetting.php.

Referenced by getModule(), and read().

ilSetting::$setting = array()

Definition at line 49 of file class.ilSetting.php.

Referenced by getAll(), and read().

ilSetting::$settings_cache = array()
staticprivate

cache for the read settings ilSetting is instantiated more than once per request for some modules The cache avoids reading them from the DB with each instance

Definition at line 39 of file class.ilSetting.php.

ilSetting::$value_type = NULL
staticprivate

the type of settings value field in database This is determined in the set method to get a correct DB insert Don't set the value type to force a detection at first access

Definition at line 46 of file class.ilSetting.php.


The documentation for this class was generated from the following file: