ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSetting Class Reference

ILIAS Setting Class. More...

+ Collaboration diagram for ilSetting:

Public Member Functions

 ilSetting ($a_module="common", $a_disabled_cache=false)
 Initialize settings.
 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 30830 2011-09-27 09:33:38Z akill

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 280 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 330 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 257 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 242 of file class.ilSetting.php.

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

Referenced by ilObjSAHSLearningModuleAccess\_lookupCertificate().

{
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'];
}

+ Here is the caller graph for this function:

ilSetting::delete (   $a_keyword)

delete one value from settingstable public

Parameters
stringkeyword
Returns
string value

Definition at line 173 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 137 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 155 of file class.ilSetting.php.

References $ilDB, $query, and read().

{
global $ilDB;
$query = "DELETE FROM settings WHERE module = ".$ilDB->quote($this->module, "text").
" AND ".$ilDB->like("keyword", "text", $a_like);
$ilDB->manipulate($query);
$this->read();
return true;
}

+ Here is the call graph for this function:

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 114 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 193 of file class.ilSetting.php.

References $setting.

{
}
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 72 of file class.ilSetting.php.

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

Referenced by deleteLike(), and 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 205 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 232 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 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: