19 declare(strict_types=1);
47 $this->db = $DIC->database();
57 public function setId(
int $a_val): void
69 $this->auto_generated = $a_status;
79 $this->title = $a_val;
87 public function setType(
string $a_val): void
99 $this->description = $a_val;
124 if (isset(
$settings[$a_setting][
'type']) &&
126 if (is_array($a_value)) {
127 $a_value = serialize($a_value);
129 $a_value = unserialize($a_value, [
'allowed_classes' =>
false]);
134 $this->setting[$a_setting] = [
142 unset($this->setting[$a_setting]);
157 $this->hidden_tab[$a_tab_id] = $a_tab_id;
162 $this->hidden_tab = [];
193 "SELECT * FROM adm_settings_template WHERE " .
194 " id = " .
$ilDB->quote($this->getId(),
"integer")
196 if (
$ilDB->numRows($set) === 0) {
197 $this->available =
false;
201 $rec =
$ilDB->fetchAssoc($set);
211 "SELECT * FROM adm_set_templ_value WHERE " .
212 " template_id = " .
$ilDB->quote($this->getId(),
"integer")
214 while ($rec =
$ilDB->fetchAssoc($set)) {
224 "SELECT * FROM adm_set_templ_hide_tab WHERE " .
225 " template_id = " .
$ilDB->quote($this->getId(),
"integer")
227 while ($rec =
$ilDB->fetchAssoc($set)) {
230 $this->available =
true;
237 $this->
setId(
$ilDB->nextId(
"adm_settings_template"));
240 $ilDB->insert(
"adm_settings_template", [
241 "id" => [
"integer", $this->
getId()],
242 "title" => [
"text", $this->
getTitle()],
243 "type" => [
"text", $this->
getType()],
262 $ilDB->update(
"adm_settings_template", [
263 "title" => [
"text", $this->
getTitle()],
264 "type" => [
"text", $this->
getType()],
269 "id" => [
"integer", $this->
getId()],
274 "DELETE FROM adm_set_templ_value WHERE " 275 .
" template_id = " .
$ilDB->quote($this->getId(),
"integer")
278 "DELETE FROM adm_set_templ_hide_tab WHERE " 279 .
" template_id = " .
$ilDB->quote($this->getId(),
"integer")
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") .
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") .
315 public function delete():
void 320 "DELETE FROM adm_settings_template WHERE " 321 .
" id = " .
$ilDB->quote($this->getId(),
"integer")
324 "DELETE FROM adm_set_templ_value WHERE " 325 .
" template_id = " .
$ilDB->quote($this->getId(),
"integer")
328 "DELETE FROM adm_set_templ_hide_tab WHERE " 329 .
" template_id = " .
$ilDB->quote($this->getId(),
"integer")
338 bool $a_include_auto_generated =
false 342 $ilDB = $DIC->database();
344 if ($a_include_auto_generated) {
345 $set =
$ilDB->query(
"SELECT * FROM adm_settings_template " .
346 " WHERE type = " .
$ilDB->quote($a_type,
"text") .
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') .
' ' .
355 $settings_template = [];
356 while ($rec =
$ilDB->fetchAssoc($set)) {
357 $settings_template[] = $rec;
359 return $settings_template;
368 $ilDB = $DIC->database();
371 "SELECT $a_prop FROM adm_settings_template WHERE " .
372 " id = " .
$ilDB->quote($a_id,
"integer")
374 $rec =
$ilDB->fetchAssoc($set);
375 return $rec[$a_prop];
380 return self::lookupProperty($a_id,
'title');
385 return self::lookupProperty($a_id,
'description');
388 public static function translate(
string $a_title_desc): string
392 if (str_starts_with($a_title_desc,
'il_')) {
393 return $DIC->language()->txt($a_title_desc);
395 return $a_title_desc;
setAutoGenerated(bool $a_status)
setSetting(string $a_setting, $a_value, bool $a_hide=false)
Set setting.
static translate(string $a_title_desc)
setConfig(ilSettingsTemplateConfig $config)
Sets the template config for this template.
static lookupTitle(int $a_id)
__construct(int $a_id=0, ?ilSettingsTemplateConfig $config=null)
static lookupDescription(int $a_id)
removeSetting(string $a_setting)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAllSettingsTemplates(string $a_type, bool $a_include_auto_generated=false)
Get all settings templates of type.
ilSettingsTemplateConfig $config
getConfig()
Returns the template config associated with this template or NULL if none is given.
setDescription(string $a_val)
static lookupProperty(int $a_id, string $a_prop)
Settings template application class.
addHiddenTab(string $a_tab_id)