ILIAS  release_8 Revision v8.24
class.ilPublicSectionSettings.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
10{
14 protected static $instance = null;
15
17
18 private bool $enabled = false;
19
23 private array $domains = array();
24
28 private function __construct()
29 {
30 global $DIC;
31
32 $this->settings = $DIC->settings();
33 $this->read();
34 }
35
36 public static function getInstance(): ilPublicSectionSettings
37 {
38 if (!self::$instance) {
39 self::$instance = new self();
40 }
41 return self::$instance;
42 }
43
47 public function setDomains(array $domains): void
48 {
49 $this->domains = $domains;
50 }
51
56 public function getDomains(): array
57 {
58 return $this->domains;
59 }
60
61 public function isEnabled(): bool
62 {
63 return $this->enabled;
64 }
65
66 public function isEnabledForDomain(string $a_domain): bool
67 {
68 if (!$this->enabled) {
69 return false;
70 }
71 if (count($this->domains)) {
72 if (in_array(trim($a_domain), $this->getDomains())) {
73 return true;
74 } else {
75 return false;
76 }
77 }
78 return true;
79 }
80
81 public function setEnabled(bool $stat): void
82 {
83 $this->enabled = $stat;
84 }
85
86 public function save(): void
87 {
88 $this->settings->set('pub_section', (string) $this->isEnabled());
89 $this->settings->set('pub_section_domains', serialize($this->getDomains()));
90 }
91
95 protected function read(): void
96 {
97 $this->enabled = (bool) $this->settings->get('pub_section', (string) $this->enabled);
98 $domains = $this->settings->get('pub_section_domains', serialize($this->domains));
99 $this->domains = (array) unserialize($domains);
100 }
101}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28