ILIAS  release_8 Revision v8.23
ilSettingsTemplate Class Reference

Settings template application class. More...

+ Collaboration diagram for ilSettingsTemplate:

Public Member Functions

 __construct (int $a_id=0, ?ilSettingsTemplateConfig $config=null)
 
 setId (int $a_val)
 
 getId ()
 
 setAutoGenerated (bool $a_status)
 
 getAutoGenerated ()
 
 setTitle (string $a_val)
 
 getTitle ()
 
 setType (string $a_val)
 
 getType ()
 
 setDescription (string $a_val)
 
 getDescription ()
 
 isAvailable ()
 
 setSetting (string $a_setting, $a_value, bool $a_hide=false)
 Set setting. More...
 
 removeSetting (string $a_setting)
 
 removeAllSettings ()
 
 getSettings ()
 
 addHiddenTab (string $a_tab_id)
 
 removeAllHiddenTabs ()
 
 getHiddenTabs ()
 
 getConfig ()
 Returns the template config associated with this template or NULL if none is given. More...
 
 setConfig (ilSettingsTemplateConfig $config)
 Sets the template config for this template. More...
 
 read ()
 
 create ()
 
 update ()
 
 insertHiddenTabs ()
 
 delete ()
 

Static Public Member Functions

static getAllSettingsTemplates (string $a_type, bool $a_include_auto_generated=false)
 Get all settings templates of type. More...
 
static lookupTitle (int $a_id)
 
static lookupDescription (int $a_id)
 
static translate (string $a_title_desc)
 

Static Protected Member Functions

static lookupProperty (int $a_id, string $a_prop)
 

Protected Attributes

ilDBInterface $db
 

Private Member Functions

 insertSettings ()
 

Private Attributes

int $id
 
string $type = ''
 
string $title = ''
 
string $description = ''
 
array $setting = []
 
array $hidden_tab = []
 
bool $auto_generated = false
 
ilSettingsTemplateConfig $config = null
 
bool $available = true
 

Detailed Description

Settings template application class.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de
Deprecated:

Definition at line 27 of file class.ilSettingsTemplate.php.

Constructor & Destructor Documentation

◆ __construct()

ilSettingsTemplate::__construct ( int  $a_id = 0,
?ilSettingsTemplateConfig  $config = null 
)

Definition at line 41 of file class.ilSettingsTemplate.php.

References $DIC, read(), setConfig(), and setId().

44  {
45  global $DIC;
46 
47  $this->db = $DIC->database();
48  if ($a_id > 0) {
49  if ($config) {
50  $this->setConfig($config);
51  }
52  $this->setId($a_id);
53  $this->read();
54  }
55  }
setConfig(ilSettingsTemplateConfig $config)
Sets the template config for this template.
global $DIC
Definition: feed.php:28
ilSettingsTemplateConfig $config
+ Here is the call graph for this function:

Member Function Documentation

◆ addHiddenTab()

ilSettingsTemplate::addHiddenTab ( string  $a_tab_id)

Definition at line 155 of file class.ilSettingsTemplate.php.

Referenced by read(), and ilSettingsTemplateGUI\setValuesFromForm().

155  : void
156  {
157  $this->hidden_tab[$a_tab_id] = $a_tab_id;
158  }
+ Here is the caller graph for this function:

◆ create()

ilSettingsTemplate::create ( )

Definition at line 233 of file class.ilSettingsTemplate.php.

References $db, $ilDB, getAutoGenerated(), getDescription(), getId(), getTitle(), getType(), insertHiddenTabs(), insertSettings(), and setId().

Referenced by ilSettingsTemplateGUI\saveSettingsTemplate().

233  : void
234  {
235  $ilDB = $this->db;
236 
237  $this->setId($ilDB->nextId("adm_settings_template"));
238 
239  // write template
240  $ilDB->insert("adm_settings_template", [
241  "id" => ["integer", $this->getId()],
242  "title" => ["text", $this->getTitle()],
243  "type" => ["text", $this->getType()],
244  // begin-patch lok
245  "description" => ["clob", $this->getDescription()],
246  'auto_generated' => ['integer', $this->getAutoGenerated()]
247  // end-patch lok
248  ]);
249 
250  // write settings
251  $this->insertSettings();
252 
253  // write hidden tabs
254  $this->insertHiddenTabs();
255  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilSettingsTemplate::delete ( )

Definition at line 315 of file class.ilSettingsTemplate.php.

References $db, and $ilDB.

315  : void
316  {
317  $ilDB = $this->db;
318 
319  $ilDB->manipulate(
320  "DELETE FROM adm_settings_template WHERE "
321  . " id = " . $ilDB->quote($this->getId(), "integer")
322  );
323  $ilDB->manipulate(
324  "DELETE FROM adm_set_templ_value WHERE "
325  . " template_id = " . $ilDB->quote($this->getId(), "integer")
326  );
327  $ilDB->manipulate(
328  "DELETE FROM adm_set_templ_hide_tab WHERE "
329  . " template_id = " . $ilDB->quote($this->getId(), "integer")
330  );
331  }

◆ getAllSettingsTemplates()

static ilSettingsTemplate::getAllSettingsTemplates ( string  $a_type,
bool  $a_include_auto_generated = false 
)
static

Get all settings templates of type.

Definition at line 336 of file class.ilSettingsTemplate.php.

References $DIC, and $ilDB.

Referenced by ilSettingsTemplateTableGUI\__construct(), ilObjSurveyGUI\addDidacticTemplateOptions(), ilObjTestGUI\addDidacticTemplateOptions(), ilLOEditorGUI\applySettingsTemplate(), and ilObjSurveyGUI\importSurveyObject().

339  : array {
340  global $DIC;
341 
342  $ilDB = $DIC->database();
343 
344  if ($a_include_auto_generated) {
345  $set = $ilDB->query("SELECT * FROM adm_settings_template " .
346  " WHERE type = " . $ilDB->quote($a_type, "text") .
347  " ORDER BY title");
348  } else {
349  $set = $ilDB->query("SELECT * FROM adm_settings_template " .
350  " WHERE type = " . $ilDB->quote($a_type, "text") .
351  'AND auto_generated = ' . $ilDB->quote(0, 'integer') . ' ' .
352  " ORDER BY title");
353  }
354 
355  $settings_template = [];
356  while ($rec = $ilDB->fetchAssoc($set)) {
357  $settings_template[] = $rec;
358  }
359  return $settings_template;
360  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getAutoGenerated()

ilSettingsTemplate::getAutoGenerated ( )

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

References $auto_generated.

Referenced by create(), and update().

72  : bool
73  {
74  return $this->auto_generated;
75  }
+ Here is the caller graph for this function:

◆ getConfig()

ilSettingsTemplate::getConfig ( )

Returns the template config associated with this template or NULL if none is given.

Definition at line 174 of file class.ilSettingsTemplate.php.

References $config.

Referenced by setSetting().

175  {
176  return $this->config;
177  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilSettingsTemplateConfig $config
+ Here is the caller graph for this function:

◆ getDescription()

ilSettingsTemplate::getDescription ( )

Definition at line 102 of file class.ilSettingsTemplate.php.

References $description.

Referenced by create(), and update().

102  : string
103  {
104  return $this->description;
105  }
+ Here is the caller graph for this function:

◆ getHiddenTabs()

ilSettingsTemplate::getHiddenTabs ( )

Definition at line 165 of file class.ilSettingsTemplate.php.

References $hidden_tab.

Referenced by insertHiddenTabs().

165  : array
166  {
167  return $this->hidden_tab;
168  }
+ Here is the caller graph for this function:

◆ getId()

ilSettingsTemplate::getId ( )

Definition at line 62 of file class.ilSettingsTemplate.php.

References $id.

Referenced by create(), and update().

62  : int
63  {
64  return $this->id;
65  }
+ Here is the caller graph for this function:

◆ getSettings()

ilSettingsTemplate::getSettings ( )

Definition at line 150 of file class.ilSettingsTemplate.php.

References $setting.

Referenced by insertSettings().

150  : array
151  {
152  return $this->setting;
153  }
+ Here is the caller graph for this function:

◆ getTitle()

ilSettingsTemplate::getTitle ( )

Definition at line 82 of file class.ilSettingsTemplate.php.

References $title.

Referenced by create(), and update().

82  : string
83  {
84  return $this->title;
85  }
+ Here is the caller graph for this function:

◆ getType()

ilSettingsTemplate::getType ( )

Definition at line 92 of file class.ilSettingsTemplate.php.

References $type.

Referenced by create(), and update().

92  : string
93  {
94  return $this->type;
95  }
+ Here is the caller graph for this function:

◆ insertHiddenTabs()

ilSettingsTemplate::insertHiddenTabs ( )

Definition at line 302 of file class.ilSettingsTemplate.php.

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

Referenced by create(), and update().

302  : void
303  {
304  $ilDB = $this->db;
305 
306  foreach ($this->getHiddenTabs() as $tab_id) {
307  $ilDB->manipulate("INSERT INTO adm_set_templ_hide_tab " .
308  "(template_id, tab_id) VALUES (" .
309  $ilDB->quote($this->getId(), "integer") . "," .
310  $ilDB->quote($tab_id, "text") .
311  ")");
312  }
313  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertSettings()

ilSettingsTemplate::insertSettings ( )
private

Definition at line 287 of file class.ilSettingsTemplate.php.

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

Referenced by create(), and update().

287  : void
288  {
289  $ilDB = $this->db;
290 
291  foreach ($this->getSettings() as $s => $set) {
292  $ilDB->manipulate("INSERT INTO adm_set_templ_value " .
293  "(template_id, setting, value, hide) VALUES (" .
294  $ilDB->quote($this->getId(), "integer") . "," .
295  $ilDB->quote($s, "text") . "," .
296  $ilDB->quote($set["value"], "text") . "," .
297  $ilDB->quote($set["hide"], "integer") .
298  ")");
299  }
300  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAvailable()

ilSettingsTemplate::isAvailable ( )

Definition at line 107 of file class.ilSettingsTemplate.php.

References $available.

107  : bool
108  {
109  return $this->available;
110  }

◆ lookupDescription()

static ilSettingsTemplate::lookupDescription ( int  $a_id)
static

Definition at line 383 of file class.ilSettingsTemplate.php.

383  : string
384  {
385  return self::lookupProperty($a_id, 'description');
386  }

◆ lookupProperty()

static ilSettingsTemplate::lookupProperty ( int  $a_id,
string  $a_prop 
)
staticprotected

Definition at line 362 of file class.ilSettingsTemplate.php.

References $DIC, and $ilDB.

365  : string {
366  global $DIC;
367 
368  $ilDB = $DIC->database();
369 
370  $set = $ilDB->query(
371  "SELECT $a_prop FROM adm_settings_template WHERE " .
372  " id = " . $ilDB->quote($a_id, "integer")
373  );
374  $rec = $ilDB->fetchAssoc($set);
375  return $rec[$a_prop];
376  }
global $DIC
Definition: feed.php:28

◆ lookupTitle()

static ilSettingsTemplate::lookupTitle ( int  $a_id)
static

Definition at line 378 of file class.ilSettingsTemplate.php.

Referenced by ilSettingsTemplateGUI\confirmSettingsTemplateDeletion().

378  : string
379  {
380  return self::lookupProperty($a_id, 'title');
381  }
+ Here is the caller graph for this function:

◆ read()

ilSettingsTemplate::read ( )

Definition at line 187 of file class.ilSettingsTemplate.php.

References $db, $ilDB, addHiddenTab(), setAutoGenerated(), setDescription(), setSetting(), setTitle(), and setType().

Referenced by __construct().

187  : void
188  {
189  $ilDB = $this->db;
190 
191  // read template
192  $set = $ilDB->query(
193  "SELECT * FROM adm_settings_template WHERE " .
194  " id = " . $ilDB->quote($this->getId(), "integer")
195  );
196  if ($ilDB->numRows($set) === 0) {
197  $this->available = false;
198  return;
199  }
200 
201  $rec = $ilDB->fetchAssoc($set);
202  $this->setTitle($rec["title"]);
203  $this->setType($rec["type"]);
204  $this->setDescription($rec["description"] ?? '');
205  // begin-patch lok
206  $this->setAutoGenerated((bool) $rec['auto_generated']);
207  // end-patch lok
208 
209  // read template setttings
210  $set = $ilDB->query(
211  "SELECT * FROM adm_set_templ_value WHERE " .
212  " template_id = " . $ilDB->quote($this->getId(), "integer")
213  );
214  while ($rec = $ilDB->fetchAssoc($set)) {
215  $this->setSetting(
216  $rec["setting"],
217  $rec["value"],
218  (bool) $rec["hide"]
219  );
220  }
221 
222  // read hidden tabs
223  $set = $ilDB->query(
224  "SELECT * FROM adm_set_templ_hide_tab WHERE " .
225  " template_id = " . $ilDB->quote($this->getId(), "integer")
226  );
227  while ($rec = $ilDB->fetchAssoc($set)) {
228  $this->addHiddenTab($rec["tab_id"]);
229  }
230  $this->available = true;
231  }
setAutoGenerated(bool $a_status)
setSetting(string $a_setting, $a_value, bool $a_hide=false)
Set setting.
addHiddenTab(string $a_tab_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAllHiddenTabs()

ilSettingsTemplate::removeAllHiddenTabs ( )

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

Referenced by ilSettingsTemplateGUI\setValuesFromForm().

160  : void
161  {
162  $this->hidden_tab = [];
163  }
+ Here is the caller graph for this function:

◆ removeAllSettings()

ilSettingsTemplate::removeAllSettings ( )

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

Referenced by ilSettingsTemplateGUI\setValuesFromForm().

145  : void
146  {
147  $this->setting = [];
148  }
+ Here is the caller graph for this function:

◆ removeSetting()

ilSettingsTemplate::removeSetting ( string  $a_setting)

Definition at line 140 of file class.ilSettingsTemplate.php.

140  : void
141  {
142  unset($this->setting[$a_setting]);
143  }

◆ setAutoGenerated()

ilSettingsTemplate::setAutoGenerated ( bool  $a_status)

Definition at line 67 of file class.ilSettingsTemplate.php.

Referenced by read().

67  : void
68  {
69  $this->auto_generated = $a_status;
70  }
+ Here is the caller graph for this function:

◆ setConfig()

ilSettingsTemplate::setConfig ( ilSettingsTemplateConfig  $config)

Sets the template config for this template.

Definition at line 182 of file class.ilSettingsTemplate.php.

References $config.

Referenced by __construct().

182  : void
183  {
184  $this->config = $config;
185  }
ilSettingsTemplateConfig $config
+ Here is the caller graph for this function:

◆ setDescription()

ilSettingsTemplate::setDescription ( string  $a_val)

Definition at line 97 of file class.ilSettingsTemplate.php.

Referenced by read(), and ilSettingsTemplateGUI\setValuesFromForm().

97  : void
98  {
99  $this->description = $a_val;
100  }
+ Here is the caller graph for this function:

◆ setId()

ilSettingsTemplate::setId ( int  $a_val)

Definition at line 57 of file class.ilSettingsTemplate.php.

Referenced by __construct(), and create().

57  : void
58  {
59  $this->id = $a_val;
60  }
+ Here is the caller graph for this function:

◆ setSetting()

ilSettingsTemplate::setSetting ( string  $a_setting,
  $a_value,
bool  $a_hide = false 
)

Set setting.

Parameters
array | string$a_value

Definition at line 116 of file class.ilSettingsTemplate.php.

References ILIAS\LTI\ToolProvider\$settings, ilSettingsTemplateConfig\CHECKBOX, and getConfig().

Referenced by read(), and ilSettingsTemplateGUI\setValuesFromForm().

120  : void {
121  if ($this->getConfig()) {
122  $settings = $this->getConfig()->getSettings();
123 
124  if (isset($settings[$a_setting]['type']) &&
125  $settings[$a_setting]['type'] === ilSettingsTemplateConfig::CHECKBOX) {
126  if (is_array($a_value)) {
127  $a_value = serialize($a_value);
128  } else {
129  $a_value = unserialize($a_value, ['allowed_classes' => false]);
130  }
131  }
132  }
133 
134  $this->setting[$a_setting] = [
135  "value" => $a_value,
136  "hide" => $a_hide
137  ];
138  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
getConfig()
Returns the template config associated with this template or NULL if none is given.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTitle()

ilSettingsTemplate::setTitle ( string  $a_val)

Definition at line 77 of file class.ilSettingsTemplate.php.

Referenced by read(), and ilSettingsTemplateGUI\setValuesFromForm().

77  : void
78  {
79  $this->title = $a_val;
80  }
+ Here is the caller graph for this function:

◆ setType()

ilSettingsTemplate::setType ( string  $a_val)

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

Referenced by read(), and ilSettingsTemplateGUI\saveSettingsTemplate().

87  : void
88  {
89  $this->type = $a_val;
90  }
+ Here is the caller graph for this function:

◆ translate()

static ilSettingsTemplate::translate ( string  $a_title_desc)
static

Definition at line 388 of file class.ilSettingsTemplate.php.

References $DIC.

Referenced by ilSettingsTemplateTableGUI\fillRow().

388  : string
389  {
390  global $DIC;
391 
392  if (str_starts_with($a_title_desc, 'il_')) {
393  return $DIC->language()->txt($a_title_desc);
394  }
395  return $a_title_desc;
396  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ update()

ilSettingsTemplate::update ( )

Definition at line 257 of file class.ilSettingsTemplate.php.

References $db, $ilDB, getAutoGenerated(), getDescription(), getId(), getTitle(), getType(), insertHiddenTabs(), and insertSettings().

257  : void
258  {
259  $ilDB = $this->db;
260 
261  // update template
262  $ilDB->update("adm_settings_template", [
263  "title" => ["text", $this->getTitle()],
264  "type" => ["text", $this->getType()],
265  // begin-patch lok
266  "description" => ["clob", $this->getDescription()],
267  'auto_generated' => ['integer', $this->getAutoGenerated()]
268  ], [
269  "id" => ["integer", $this->getId()],
270  ]);
271 
272  // delete settings and hidden tabs
273  $ilDB->manipulate(
274  "DELETE FROM adm_set_templ_value WHERE "
275  . " template_id = " . $ilDB->quote($this->getId(), "integer")
276  );
277  $ilDB->manipulate(
278  "DELETE FROM adm_set_templ_hide_tab WHERE "
279  . " template_id = " . $ilDB->quote($this->getId(), "integer")
280  );
281 
282  // insert settings and hidden tabs
283  $this->insertSettings();
284  $this->insertHiddenTabs();
285  }
+ Here is the call graph for this function:

Field Documentation

◆ $auto_generated

bool ilSettingsTemplate::$auto_generated = false
private

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

Referenced by getAutoGenerated().

◆ $available

bool ilSettingsTemplate::$available = true
private

Definition at line 39 of file class.ilSettingsTemplate.php.

Referenced by isAvailable().

◆ $config

ilSettingsTemplateConfig ilSettingsTemplate::$config = null
private

Definition at line 38 of file class.ilSettingsTemplate.php.

Referenced by getConfig(), and setConfig().

◆ $db

ilDBInterface ilSettingsTemplate::$db
protected

◆ $description

string ilSettingsTemplate::$description = ''
private

Definition at line 33 of file class.ilSettingsTemplate.php.

Referenced by getDescription().

◆ $hidden_tab

array ilSettingsTemplate::$hidden_tab = []
private

Definition at line 36 of file class.ilSettingsTemplate.php.

Referenced by getHiddenTabs().

◆ $id

int ilSettingsTemplate::$id
private

Definition at line 30 of file class.ilSettingsTemplate.php.

Referenced by getId().

◆ $setting

array ilSettingsTemplate::$setting = []
private

Definition at line 34 of file class.ilSettingsTemplate.php.

Referenced by getSettings().

◆ $title

string ilSettingsTemplate::$title = ''
private

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

Referenced by getTitle().

◆ $type

string ilSettingsTemplate::$type = ''
private

Definition at line 31 of file class.ilSettingsTemplate.php.

Referenced by getType().


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