ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPublicSectionSettings.php
Go to the documentation of this file.
1<?php
2
24{
28 protected static $instance = null;
29
31
32 private bool $enabled = false;
33
37 private array $domains = array();
38
42 private function __construct()
43 {
44 global $DIC;
45
46 $this->settings = $DIC->settings();
47 $this->read();
48 }
49
50 public static function getInstance(): ilPublicSectionSettings
51 {
52 if (!self::$instance) {
53 self::$instance = new self();
54 }
55 return self::$instance;
56 }
57
61 public function setDomains(array $domains): void
62 {
63 $this->domains = $domains;
64 }
65
70 public function getDomains(): array
71 {
72 return $this->domains;
73 }
74
75 public function isEnabled(): bool
76 {
77 return $this->enabled;
78 }
79
80 public function isEnabledForDomain(string $a_domain): bool
81 {
82 if (!$this->enabled) {
83 return false;
84 }
85 if (count($this->domains)) {
86 if (in_array(trim($a_domain), $this->getDomains())) {
87 return true;
88 } else {
89 return false;
90 }
91 }
92 return true;
93 }
94
95 public function setEnabled(bool $stat): void
96 {
97 $this->enabled = $stat;
98 }
99
100 public function save(): void
101 {
102 $this->settings->set('pub_section', (string) $this->isEnabled());
103 $this->settings->set('pub_section_domains', serialize($this->getDomains()));
104 }
105
109 protected function read(): void
110 {
111 $this->enabled = (bool) $this->settings->get('pub_section', (string) $this->enabled);
112 $domains = $this->settings->get('pub_section_domains', serialize($this->domains));
113 $this->domains = (array) unserialize($domains);
114 }
115}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Setting Class.
global $DIC
Definition: shib_login.php:26