ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSetting Class Reference

ILIAS Setting Class. More...

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

Public Member Functions

 __construct ($a_module="common", $a_disabled_cache=false)
 Initialize settings. More...
 
 getModule ()
 Get currernt module. More...
 
 read ()
 Read settings data. More...
 
 get ($a_keyword, $a_default_value=false)
 get setting More...
 
 deleteAll ()
 Delete all settings of a current module. More...
 
 deleteLike ($a_like)
 Delete all settings corresponding to a like string. More...
 
 delete ($a_keyword)
 delete one value from settingstable @access public More...
 
 getAll ()
 read all values from settingstable @access public More...
 
 set ($a_key, $a_val)
 write one value to db-table settings @access public More...
 
 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. More...
 
static _changeValueType ($a_new_type='text')
 change the type of the value column in the database More...
 
static _getLongerSettings ($a_limit='4000')
 get a list of setting records with values loger than a limit More...
 

Data Fields

 $setting = array()
 
 $module = ""
 

Protected Attributes

 $db
 

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 More...
 
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 More...
 

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$

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

Constructor & Destructor Documentation

◆ __construct()

ilSetting::__construct (   $a_module = "common",
  $a_disabled_cache = false 
)

Initialize settings.

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

61 {
62 global $DIC;
63
64 $this->db = $DIC->database();
65 $ilDB = $DIC->database();
66
67 $this->cache_disabled = $a_disabled_cache;
68 $this->module = $a_module;
69 // check whether ini file object exists
70 if (!is_object($ilDB)) {
71 die("Fatal Error: ilSettings object instantiated without DB initialisation.");
72 }
73 $this->read();
74 }
read()
Read settings data.
global $DIC
Definition: saml.php:7
global $ilDB

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

+ Here is the call graph for this function:

Member Function Documentation

◆ _changeValueType()

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

290 {
291 global $DIC;
292
293 $ilDB = $DIC->database();
294
295 $old_type = self::_getValueType();
296
297 if ($a_new_type == $old_type) {
298 return false;
299 } elseif ($a_new_type == 'clob') {
300 $ilDB->addTableColumn(
301 'settings',
302 'value2',
303 array( "type" => "clob",
304 "notnull" => false,
305 "default" => null)
306 );
307
308 $ilDB->query("UPDATE settings SET value2 = value");
309 $ilDB->dropTableColumn('settings', 'value');
310 $ilDB->renameTableColumn('settings', 'value2', 'value');
311
312 return true;
313 } elseif ($a_new_type == 'text') {
314 $ilDB->addTableColumn(
315 'settings',
316 'value2',
317 array( "type" => "text",
318 "length" => 4000,
319 "notnull" => false,
320 "default" => null)
321 );
322
323 $ilDB->query("UPDATE settings SET value2 = value");
324 $ilDB->dropTableColumn('settings', 'value');
325 $ilDB->renameTableColumn('settings', 'value2', 'value');
326
327 return true;
328 } else {
329 return false;
330 }
331 }
static _getValueType()
Get the type of the value column in the database.

References $DIC, $ilDB, and _getValueType().

Referenced by ilSetupGUI\changeSettingsType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getLongerSettings()

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

341 {
342 global $DIC;
343
344 $ilDB = $DIC->database();
345
346 $settings = array();
347
348 $query = "SELECT * FROM settings WHERE LENGTH(value) > "
349 . $ilDB->quote($a_limit, 'integer');
350
351 $result = $ilDB->query($query);
352
353 while ($row = $ilDB->fetchAssoc($result)) {
354 $settings[] = $row;
355 }
356
357 return $settings;
358 }
$result
$query

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

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

+ Here is the caller graph for this function:

◆ _getValueType()

static ilSetting::_getValueType ( )
static

Get the type of the value column in the database.

Returns
string 'text' or 'clob'
Exceptions
ilDatabaseException

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

270 {
271 include_once('./Services/Database/classes/class.ilDBAnalyzer.php');
272 $analyzer = new ilDBAnalyzer();
273 $info = $analyzer->getFieldInformation('settings');
274
275 if ($info['value']['type'] == 'clob') {
276 return 'clob';
277 } else {
278 return 'text';
279 }
280 }
This class gives all kind of DB information using the MDB2 manager and reverse module.
$info
Definition: index.php:5

References $info.

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

+ Here is the caller graph for this function:

◆ _lookupValue()

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

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

252 {
253 global $DIC;
254
255 $ilDB = $DIC->database();
256
257 $query = "SELECT value FROM settings WHERE module = %s AND keyword = %s";
258 $res = $ilDB->queryF($query, array('text', 'text'), array($a_module, $a_keyword));
259 $data = $ilDB->fetchAssoc($res);
260 return $data['value'];
261 }
foreach($_POST as $key=> $value) $res

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

Referenced by ilCronManager\runActiveJobs().

+ Here is the caller graph for this function:

◆ delete()

ilSetting::delete (   $a_keyword)

delete one value from settingstable @access public

Parameters
stringkeyword
Returns
string value

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

182 {
184
185 $st = $ilDB->manipulate("DELETE FROM settings WHERE keyword = " .
186 $ilDB->quote($a_keyword, "text") . " AND module = " .
187 $ilDB->quote($this->module, "text"));
188
189 unset($this->setting[$a_keyword]);
190
191 return true;
192 }

References $db, and $ilDB.

◆ deleteAll()

ilSetting::deleteAll ( )

Delete all settings of a current module.

@access public

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

143 {
145
146 $query = "DELETE FROM settings WHERE module = " . $ilDB->quote($this->module, "text");
147 $ilDB->manipulate($query);
148
149 $this->setting = array();
150
151 return true;
152 }

References $db, $ilDB, and $query.

◆ deleteLike()

ilSetting::deleteLike (   $a_like)

Delete all settings corresponding to a like string.

@access public

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

161 {
163
164 $query = "SELECT keyword FROM settings" .
165 " WHERE module = " . $ilDB->quote($this->module, "text") .
166 " AND " . $ilDB->like("keyword", "text", $a_like);
167 $res = $ilDB->query($query);
168 while ($row = $ilDB->fetchAssoc($res)) {
169 $this->delete($row["keyword"]);
170 }
171
172 return true;
173 }

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

◆ get()

ilSetting::get (   $a_keyword,
  $a_default_value = false 
)

get setting

@access public

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

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

124 {
125 if ($a_keyword == "ilias_version") {
126 return ILIAS_VERSION;
127 }
128
129 if (isset($this->setting[$a_keyword])) {
130 return $this->setting[$a_keyword];
131 } else {
132 return $a_default_value;
133 }
134 }
const ILIAS_VERSION

References ILIAS_VERSION.

Referenced by ilObjStudyProgrammeAdminGUI\initFormSettings(), and ilOnScreenChatGUI\isOnScreenChatAccessible().

+ Here is the caller graph for this function:

◆ getAll()

ilSetting::getAll ( )

read all values from settingstable @access public

Returns
array keyword/value pairs

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

202 {
203 return $this->setting;
204 }

References $setting.

◆ getModule()

ilSetting::getModule ( )

Get currernt module.

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

80 {
81 return $this->module;
82 }

References $module.

◆ read()

ilSetting::read ( )

Read settings data.

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

88 {
90
91 // get the settings from the cache if they exist.
92 // The setting array of the class is a reference to the cache.
93 // So changing settings in one instance will change them in all.
94 // This is the same behaviour as if the are read from the DB.
95 if (!$this->cache_disabled) {
96 if (isset(self::$settings_cache[$this->module])) {
97 $this->setting =&self::$settings_cache[$this->module];
98 return;
99 } else {
100 $this->setting = array();
101 self::$settings_cache[$this->module] =&$this->setting;
102 }
103 }
104
105 $query = "SELECT * FROM settings WHERE module=" . $ilDB->quote($this->module, "text");
106 $res = $ilDB->query($query);
107
108 while ($row = $ilDB->fetchAssoc($res)) {
109 $this->setting[$row["keyword"]] = $row["value"];
110 }
111 }

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

Referenced by __construct().

+ Here is the caller graph for this function:

◆ set()

ilSetting::set (   $a_key,
  $a_val 
)

write one value to db-table settings @access public

Parameters
stringkeyword
stringvalue
Returns
boolean true on success

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

214 {
215 global $DIC;
216
217 $lng = $DIC["lng"];
219
220 $this->delete($a_key);
221
222 if (!isset(self::$value_type)) {
223 self::$value_type = self::_getValueType();
224 }
225
226 if (self::$value_type == 'text' and strlen($a_val) >= 4000) {
227 ilUtil::sendFailure($lng->txt('setting_value_truncated'), true);
228 $a_val = substr($a_val, 0, 4000);
229 }
230
231 $ilDB->insert("settings", array(
232 "module" => array("text", $this->module),
233 "keyword" => array("text", $a_key),
234 "value" => array(self::$value_type, $a_val)));
235
236 $this->setting[$a_key] = $a_val;
237
238 return true;
239 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17

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

Referenced by ilObjStudyProgrammeAdminGUI\saveSettings(), and setScormDebug().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setScormDebug()

ilSetting::setScormDebug (   $a_key,
  $a_val 
)

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

242 {
244 if ($a_val != "1") {
245 $ilDB->query("UPDATE sahs_lm SET debug = 'n'");
246 }
247 $setreturn = ilSetting::set($a_key, $a_val);
248 return $setreturn;
249 }
set($a_key, $a_val)
write one value to db-table settings @access public

References $db, $ilDB, and set().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilSetting::$db
protected

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

Referenced by delete(), deleteAll(), deleteLike(), read(), set(), and setScormDebug().

◆ $module

ilSetting::$module = ""

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

Referenced by getModule(), and read().

◆ $setting

ilSetting::$setting = array()

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

Referenced by getAll(), and read().

◆ $settings_cache

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

◆ $value_type

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


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