ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
12{
16 protected static $instance = null;
17
18
22 private $settings = null;
23
24 private $enabled = false;
25 private $domains = array();
26
30 private function __construct()
31 {
32 $this->settings = $GLOBALS['DIC']->settings();
33 $this->read();
34 }
35
40 public static function getInstance()
41 {
42 if (!self::$instance) {
43 self::$instance = new self();
44 }
45 return self::$instance;
46 }
47
48 public function setDomains(array $domains)
49 {
50 $this->domains = $domains;
51 }
52
53 public function getDomains()
54 {
55 return (array) $this->domains;
56 }
57
58 public function isEnabled()
59 {
60 return $this->enabled;
61 }
62
68 public function isEnabledForDomain($a_domain)
69 {
70 if (!$this->enabled) {
71 return false;
72 }
73 if (count($this->domains)) {
74 if (in_array(trim($a_domain), $this->getDomains())) {
75 return true;
76 } else {
77 return false;
78 }
79 }
80 return true;
81 }
82
83 public function setEnabled($stat)
84 {
85 $this->enabled = $stat;
86 }
87
88 public function save()
89 {
90 $this->settings->set('pub_section', $this->isEnabled());
91 $this->settings->set('pub_section_domains', serialize($this->getDomains()));
92 }
93
97 protected function read()
98 {
99 $this->enabled = $this->settings->get('pub_section', $this->enabled);
100
101 $domains = $this->settings->get('pub_section_domains', serialize($this->domains));
102 $this->domains = unserialize($domains);
103 }
104}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
isEnabledForDomain($a_domain)
Check if public section.
settings()
Definition: settings.php:2