ILIAS  release_8 Revision v8.24
class.ilCASSettings.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/******************************************************************************
6 *
7 * This file is part of ILIAS, a powerful learning management system.
8 *
9 * ILIAS is licensed with the GPL-3.0, you should have received a copy
10 * of said license along with the source code.
11 *
12 * If this is not the case or you just want to try ILIAS, you'll find
13 * us at:
14 * https://www.ilias.de
15 * https://github.com/ILIAS-eLearning
16 *
17 *****************************************************************************/
18
23{
24 public const SYNC_DISABLED = 0;
25 public const SYNC_CAS = 1;
26 public const SYNC_LDAP = 2;
27
28 private static ?ilCASSettings $instance = null;
29
31 private string $server = '';
32 private int $port = 0;
33 private string $uri = '';
34 private string $login_instructions = '';
35 private bool $active = false;
36 private bool $create_users = false;
37 private bool $allow_local = false;
38 private int $user_default_role = 0;
39 private int $default_role = 0;
40
44 protected function __construct()
45 {
46 global $DIC;
47
48 $this->storage = $DIC->settings();
49 $this->read();
50 }
51
55 public static function getInstance(): ilCASSettings
56 {
57 if (self::$instance) {
58 return self::$instance;
59 }
60 return self::$instance = new ilCASSettings();
61 }
62
63 public function setServer(string $a_server): void
64 {
65 $this->server = $a_server;
66 }
67
68 public function getServer(): string
69 {
70 return $this->server;
71 }
72
73 public function setPort(int $a_port): void
74 {
75 $this->port = $a_port;
76 }
77
78 public function getPort(): int
79 {
80 return $this->port;
81 }
82
83 public function setUri(string $a_uri): void
84 {
85 $this->uri = $a_uri;
86 }
87
88 public function getUri(): string
89 {
90 return $this->uri;
91 }
92
93 public function setLoginInstruction(string $a_inst): void
94 {
95 $this->login_instructions = $a_inst;
96 }
97
98 public function getLoginInstruction(): string
99 {
101 }
102
103 public function setActive($a_active): void
104 {
105 $this->active = $a_active;
106 }
107
108 public function isActive(): bool
109 {
110 return $this->active;
111 }
112
113 public function enableUserCreation($a_uc): void
114 {
115 $this->create_users = $a_uc;
116 }
117
118 public function isUserCreationEnabled(): bool
119 {
120 return $this->create_users;
121 }
122
123 public function enableLocalAuthentication($a_local): void
124 {
125 $this->allow_local = $a_local;
126 }
127
128 public function isLocalAuthenticationEnabled(): bool
129 {
130 return $this->allow_local;
131 }
132
133 public function setDefaultRole($a_role): void
134 {
135 $this->default_role = $a_role;
136 }
137
138 public function getDefaultRole(): int
139 {
140 return $this->default_role;
141 }
142
143 public function save(): void
144 {
145 $this->getStorage()->set('cas_server', $this->getServer());
146 $this->getStorage()->set('cas_port', (string) $this->getPort());
147 $this->getStorage()->set('cas_uri', $this->getUri());
148 $this->getStorage()->set('cas_login_instructions', $this->getLoginInstruction());
149 $this->getStorage()->set('cas_active', (string) $this->isActive());
150 $this->getStorage()->set('cas_create_users', (string) $this->isUserCreationEnabled());
151 $this->getStorage()->set('cas_allow_local', (string) $this->isLocalAuthenticationEnabled());
152 $this->getStorage()->set('cas_user_default_role', (string) $this->getDefaultRole());
153 }
154
155 private function read(): void
156 {
157 $this->setServer($this->getStorage()->get('cas_server', $this->server));
158 $this->setPort((int) $this->getStorage()->get('cas_port', (string) $this->port));
159 $this->setUri($this->getStorage()->get('cas_uri', $this->uri));
160 $this->setActive((bool) $this->getStorage()->get('cas_active', (string) $this->active));
161 $this->setDefaultRole((int) $this->getStorage()->get('cas_user_default_role', (string) $this->user_default_role));
162 $this->setLoginInstruction($this->getStorage()->get('cas_login_instructions', $this->login_instructions));
163 $this->enableLocalAuthentication((bool) $this->getStorage()->get('cas_allow_local', (string) $this->allow_local));
164 $this->enableUserCreation((bool) $this->getStorage()->get('cas_create_users', (string) $this->create_users));
165 }
166
167 private function getStorage(): ilSetting
168 {
169 return $this->storage;
170 }
171}
__construct()
Singleton constructor.
static getInstance()
Get singleton instance.
setUri(string $a_uri)
setLoginInstruction(string $a_inst)
setServer(string $a_server)
setPort(int $a_port)
enableLocalAuthentication($a_local)
static ilCASSettings $instance
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28