ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $ilDB
$DIC
Definition: xapitoken.php:46

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

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

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

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

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

269 {
270 $analyzer = new ilDBAnalyzer();
271 $info = $analyzer->getFieldInformation('settings');
272
273 if ($info['value']['type'] == 'clob') {
274 return 'clob';
275 } else {
276 return 'text';
277 }
278 }
This class gives all kind of DB information using the database manager and reverse module.

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

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

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, and $res.

◆ 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 ilObjStudyProgrammeTreeGUI\delete(), ilObjStudyProgrammeAdminGUI\initFormSettings(), ilOnScreenChatGUI\isOnScreenChatAccessible(), and ilCertificateAppEventListener\processEntry().

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

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

241 {
243 if ($a_val != "1") {
244 $ilDB->query("UPDATE sahs_lm SET debug = 'n'");
245 }
246 $setreturn = ilSetting::set($a_key, $a_val);
247 return $setreturn;
248 }
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: