ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 public More...
 
 getAll ()
 read all values from settingstable public More...
 
 set ($a_key, $a_val)
 write one value to db-table settings 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.

Constructor & Destructor Documentation

◆ __construct()

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

Initialize settings.

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

References $ilDB, and read().

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.
global $ilDB
+ 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 293 of file class.ilSetting.php.

References $ilDB, and array.

Referenced by ilSetupGUI\changeSettingsType().

294  {
295  global $ilDB;
296 
297  $old_type = self::_getValueType();
298 
299  if ($a_new_type == $old_type)
300  {
301  return false;
302  }
303  elseif ($a_new_type == 'clob')
304  {
305  $ilDB->addTableColumn('settings','value2',
306  array( "type" => "clob",
307  "notnull" => false,
308  "default" => NULL));
309 
310  $ilDB->query("UPDATE settings SET value2 = value");
311  $ilDB->dropTableColumn('settings','value');
312  $ilDB->renameTableColumn('settings','value2','value');
313 
314  return true;
315  }
316  elseif ($a_new_type == 'text')
317  {
318  $ilDB->addTableColumn('settings','value2',
319  array( "type" => "text",
320  "length" => 4000,
321  "notnull" => false,
322  "default" => NULL));
323 
324  $ilDB->query("UPDATE settings SET value2 = value");
325  $ilDB->dropTableColumn('settings','value');
326  $ilDB->renameTableColumn('settings','value2','value');
327 
328  return true;
329  }
330  else
331  {
332  return false;
333  }
334  }
Create styles array
The data for the language used.
global $ilDB
+ 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 343 of file class.ilSetting.php.

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

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

344  {
345  global $ilDB;
346 
347  $settings = array();
348 
349  $query = "SELECT * FROM settings WHERE LENGTH(value) > "
350  . $ilDB->quote($a_limit, 'integer');
351 
352  $result = $ilDB->query($query);
353 
354  while ($row = $ilDB->fetchAssoc($result))
355  {
356  $settings[] = $row;
357  }
358 
359  return $settings;
360  }
$result
Create styles array
The data for the language used.
global $ilDB
+ 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 270 of file class.ilSetting.php.

References $info.

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

271  {
272  include_once ('./Services/Database/classes/class.ilDBAnalyzer.php');
273  $analyzer = new ilDBAnalyzer();
274  $info = $analyzer->getFieldInformation('settings');
275 
276  if ($info['value']['type'] == 'clob')
277  {
278  return 'clob';
279  }
280  else
281  {
282  return 'text';
283  }
284  }
$info
Definition: example_052.php:80
This class gives all kind of DB information using the MDB2 manager and reverse module.
+ 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.

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

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  }
Create styles array
The data for the language used.
global $ilDB

◆ delete()

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.

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  }
global $ilDB

◆ deleteAll()

ilSetting::deleteAll ( )

Delete all settings of a current module.

public

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

References $ilDB, $query, and array.

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  }
Create styles array
The data for the language used.
global $ilDB

◆ deleteLike()

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.

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  }
global $ilDB

◆ get()

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.

Referenced by ilObjStudyProgrammeTreeGUI\create(), ilLanguage\getUserLanguage(), ilObjStudyProgrammeAdminGUI\initFormSettings(), and ilOnScreenChatGUI\isOnScreenChatAccessible().

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
+ Here is the caller graph for this function:

◆ getAll()

ilSetting::getAll ( )

read all values from settingstable public

Returns
array keyword/value pairs

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

References $setting.

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

◆ getModule()

ilSetting::getModule ( )

Get currernt module.

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

References $module.

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

◆ read()

ilSetting::read ( )

Read settings data.

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

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

Referenced by __construct().

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  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ set()

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, array, and ilUtil\sendFailure().

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

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  }
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
global $ilDB
+ 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.

References $ilDB, and set().

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 public
global $ilDB
+ 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: