ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilCASSettings.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  public const SYNC_DISABLED = 0;
27  public const SYNC_CAS = 1;
28  public const SYNC_LDAP = 2;
29 
30  private static ?ilCASSettings $instance = null;
31 
33  private string $server = '';
34  private int $port = 0;
35  private string $uri = '';
36  private string $login_instructions = '';
37  private bool $active = false;
38  private bool $create_users = false;
39  private bool $allow_local = false;
40  private int $user_default_role = 0;
41  private int $default_role = 0;
42 
46  protected function __construct()
47  {
48  global $DIC;
49 
50  $this->storage = $DIC->settings();
51  $this->read();
52  }
53 
57  public static function getInstance(): ilCASSettings
58  {
59  if (self::$instance) {
60  return self::$instance;
61  }
62  return self::$instance = new ilCASSettings();
63  }
64 
65  public function setServer(string $a_server): void
66  {
67  $this->server = $a_server;
68  }
69 
70  public function getServer(): string
71  {
72  return $this->server;
73  }
74 
75  public function setPort(int $a_port): void
76  {
77  $this->port = $a_port;
78  }
79 
80  public function getPort(): int
81  {
82  return $this->port;
83  }
84 
85  public function setUri(string $a_uri): void
86  {
87  $this->uri = $a_uri;
88  }
89 
90  public function getUri(): string
91  {
92  return $this->uri;
93  }
94 
95  public function setLoginInstruction(string $a_inst): void
96  {
97  $this->login_instructions = $a_inst;
98  }
99 
100  public function getLoginInstruction(): string
101  {
103  }
104 
105  public function setActive($a_active): void
106  {
107  $this->active = $a_active;
108  }
109 
110  public function isActive(): bool
111  {
112  return $this->active;
113  }
114 
115  public function enableUserCreation($a_uc): void
116  {
117  $this->create_users = $a_uc;
118  }
119 
120  public function isUserCreationEnabled(): bool
121  {
122  return $this->create_users;
123  }
124 
125  public function enableLocalAuthentication($a_local): void
126  {
127  $this->allow_local = $a_local;
128  }
129 
130  public function isLocalAuthenticationEnabled(): bool
131  {
132  return $this->allow_local;
133  }
134 
135  public function setDefaultRole($a_role): void
136  {
137  $this->default_role = $a_role;
138  }
139 
140  public function getDefaultRole(): int
141  {
142  return $this->default_role;
143  }
144 
145  public function save(): void
146  {
147  $this->getStorage()->set('cas_server', $this->getServer());
148  $this->getStorage()->set('cas_port', (string) $this->getPort());
149  $this->getStorage()->set('cas_uri', $this->getUri());
150  $this->getStorage()->set('cas_login_instructions', $this->getLoginInstruction());
151  $this->getStorage()->set('cas_active', (string) $this->isActive());
152  $this->getStorage()->set('cas_create_users', (string) $this->isUserCreationEnabled());
153  $this->getStorage()->set('cas_allow_local', (string) $this->isLocalAuthenticationEnabled());
154  $this->getStorage()->set('cas_user_default_role', (string) $this->getDefaultRole());
155  }
156 
157  private function read(): void
158  {
159  $this->setServer($this->getStorage()->get('cas_server', $this->server));
160  $this->setPort((int) $this->getStorage()->get('cas_port', (string) $this->port));
161  $this->setUri($this->getStorage()->get('cas_uri', $this->uri));
162  $this->setActive((bool) $this->getStorage()->get('cas_active', (string) $this->active));
163  $this->setDefaultRole((int) $this->getStorage()->get('cas_user_default_role', (string) $this->user_default_role));
164  $this->setLoginInstruction($this->getStorage()->get('cas_login_instructions', $this->login_instructions));
165  $this->enableLocalAuthentication((bool) $this->getStorage()->get('cas_allow_local', (string) $this->allow_local));
166  $this->enableUserCreation((bool) $this->getStorage()->get('cas_create_users', (string) $this->create_users));
167  }
168 
169  private function getStorage(): ilSetting
170  {
171  return $this->storage;
172  }
173 }
static ilCASSettings $instance
server()
description: > This example shows how a Progress Bar can be rendered and updated by the server...
Definition: server.php:43
setLoginInstruction(string $a_inst)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct()
Singleton constructor.
global $DIC
Definition: shib_login.php:22
enableLocalAuthentication($a_local)
setUri(string $a_uri)
setPort(int $a_port)
setServer(string $a_server)
static getInstance()
Get singleton instance.