ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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. 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 = ""
 

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.

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

293 {
294 global $ilDB;
295
296 $old_type = self::_getValueType();
297
298 if ($a_new_type == $old_type)
299 {
300 return false;
301 }
302 elseif ($a_new_type == 'clob')
303 {
304 $ilDB->addTableColumn('settings','value2',
305 array( "type" => "clob",
306 "notnull" => false,
307 "default" => NULL));
308
309 $ilDB->query("UPDATE settings SET value2 = value");
310 $ilDB->dropTableColumn('settings','value');
311 $ilDB->renameTableColumn('settings','value2','value');
312
313 return true;
314 }
315 elseif ($a_new_type == 'text')
316 {
317 $ilDB->addTableColumn('settings','value2',
318 array( "type" => "text",
319 "length" => 4000,
320 "notnull" => false,
321 "default" => NULL));
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 }
329 else
330 {
331 return false;
332 }
333 }
static _getValueType()
get the type of the value column in the database
global $ilDB

References $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 342 of file class.ilSetting.php.

343 {
344 global $ilDB;
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 {
355 $settings[] = $row;
356 }
357
358 return $settings;
359 }
$result

References $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'

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 {
277 return 'clob';
278 }
279 else
280 {
281 return 'text';
282 }
283 }
This class gives all kind of DB information using the MDB2 manager and reverse module.
$info
Definition: example_052.php:80

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

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

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

◆ delete()

ilSetting::delete (   $a_keyword)

delete one value from settingstable @access public

Parameters
stringkeyword
Returns
string value

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

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

References $ilDB.

◆ deleteAll()

ilSetting::deleteAll ( )

Delete all settings of a current module.

@access public

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

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

References $ilDB, and $query.

◆ deleteLike()

ilSetting::deleteLike (   $a_like)

Delete all settings corresponding to a like string.

@access public

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

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

References $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 122 of file class.ilSetting.php.

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

References ILIAS_VERSION.

Referenced by ilObjStudyProgrammeAdminGUI\initFormSettings().

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

206 {
207 return $this->setting;
208 }

References $setting.

◆ getModule()

ilSetting::getModule ( )

Get currernt module.

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

73 {
74 return $this->module;
75 }

References $module.

◆ ilSetting()

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

Initialize settings.

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

56 {
57 global $ilDB;
58
59 $this->cache_disabled = $a_disabled_cache;
60 $this->module = $a_module;
61 // check whether ini file object exists
62 if (!is_object($ilDB))
63 {
64 die ("Fatal Error: ilSettings object instantiated without DB initialisation.");
65 }
66 $this->read();
67 }
read()
Read settings data.

References $ilDB, and read().

+ Here is the call graph for this function:

◆ read()

ilSetting::read ( )

Read settings data.

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

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

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

Referenced by ilSetting().

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

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

References $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 244 of file class.ilSetting.php.

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

References $ilDB, and set().

+ Here is the call graph for this function:

Field Documentation

◆ $module

ilSetting::$module = ""

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

Referenced by getModule(), and read().

◆ $setting

ilSetting::$setting = array()

Definition at line 49 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 39 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 46 of file class.ilSetting.php.


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