19declare(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]);
152 return $this->setting;
157 $this->hidden_tab[$a_tab_id] = $a_tab_id;
162 $this->hidden_tab = [];
167 return $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);
202 $this->setTitle($rec[
"title"]);
203 $this->setType($rec[
"type"]);
204 $this->setDescription($rec[
"description"] ??
'');
206 $this->setAutoGenerated((
bool) $rec[
'auto_generated']);
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)) {
228 $this->addHiddenTab($rec[
"tab_id"]);
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()],
245 "description" => [
"clob", $this->getDescription()],
246 'auto_generated' => [
'integer', $this->getAutoGenerated()]
251 $this->insertSettings();
254 $this->insertHiddenTabs();
262 $ilDB->update(
"adm_settings_template", [
263 "title" => [
"text", $this->getTitle()],
264 "type" => [
"text", $this->getType()],
266 "description" => [
"clob", $this->getDescription()],
267 'auto_generated' => [
'integer', $this->getAutoGenerated()]
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")
283 $this->insertSettings();
284 $this->insertHiddenTabs();
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") .
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") .
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
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;
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;
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Settings template application class.
static lookupTitle(int $a_id)
setDescription(string $a_val)
setSetting(string $a_setting, $a_value, bool $a_hide=false)
Set setting.
setAutoGenerated(bool $a_status)
getConfig()
Returns the template config associated with this template or NULL if none is given.
__construct(int $a_id=0, ?ilSettingsTemplateConfig $config=null)
static translate(string $a_title_desc)
static lookupDescription(int $a_id)
static lookupProperty(int $a_id, string $a_prop)
addHiddenTab(string $a_tab_id)
removeSetting(string $a_setting)
ilSettingsTemplateConfig $config
static getAllSettingsTemplates(string $a_type, bool $a_include_auto_generated=false)
Get all settings templates of type.
setConfig(ilSettingsTemplateConfig $config)
Sets the template config for this template.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...