ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilShibbolethSettings.php
Go to the documentation of this file.
1 <?php
2 
21 
28 {
29  private const PREFIX = 'shib_';
30  private const DEFAULT_IDP_LIST = "urn:mace:organization1:providerID, Example Organization 1\nurn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/SWITCHaai";
31  private const DEFAULT_LOGIN_BUTTON = "templates/default/images/shib_login_button.svg";
32  private const DEFAULT_ORGANISATION_SELECTION = "external_wayf";
33 
34  protected ilSetting $settings;
35  protected array $data = [];
36 
38  protected array $user_fields = [
39  'firstname' => true,
40  'lastname' => true,
41  'email' => true,
42  'title' => false,
43  'gender' => false,
44  'institution' => false,
45  'department' => false,
46  'zipcode' => false,
47  'city' => false,
48  'country' => false,
49  'street' => false,
50  'phone_office' => false,
51  'phone_home' => false,
52  'phone_mobile' => false,
53  'language' => false,
54  'matriculation' => false,
55  ];
56 
57  public function __construct()
58  {
59  global $DIC;
60 
61  $this->settings = $DIC->settings();
62  $this->read();
63  }
64 
68  public function getUserFields(): array
69  {
70  return $this->user_fields;
71  }
72 
73  public function read(): void
74  {
75  $filtered_data = array_filter(
76  $this->settings->getAll(),
77  static fn ($value, string $key): bool => strpos($key, self::PREFIX) === 0,
78  ARRAY_FILTER_USE_BOTH
79  );
80 
81  array_walk($filtered_data, function ($v, string $k): void {
82  $this->data[str_replace(self::PREFIX, '', $k)] = $v === '' ? null : $v;
83  });
84  }
85 
86  public function get(string $a_keyword, ?string $a_default_value = null): string
87  {
88  $a_keyword = str_replace(self::PREFIX, '', $a_keyword);
89 
90  return (string) ($this->data[$a_keyword] ?? $a_default_value);
91  }
92 
93 
97  public function getAll(): array
98  {
99  return $this->data;
100  }
101 
102  public function set(string $a_key, string $a_val): void
103  {
104  $a_key = str_replace(self::PREFIX, '', $a_key);
105  $this->data[$a_key] = $a_val;
106  }
107 
108  public function store(): void
109  {
110  foreach ($this->data as $key => $value) {
111  $this->settings->set(self::PREFIX . $key, (string) $value);
112  }
113  }
114 
115  public function getDefaultRole(): int
116  {
117  return $this->data['user_default_role'] ?? 4;
118  }
119 
120  public function setDefaultRole(int $role_id): void
121  {
122  $this->data['user_default_role'] = $role_id;
123  }
124 
125  public function getIdPList(): string
126  {
127  return $this->data['idp_list'] ?? self::DEFAULT_IDP_LIST;
128  }
129 
130  public function setIdPList(string $list): void
131  {
132  $this->data['idp_list'] = $list;
133  }
134 
135  public function getLoginButton(): string
136  {
137  return $this->data['login_button'] ?? self::DEFAULT_LOGIN_BUTTON;
138  }
139 
140  public function setLoginButton(string $login_button): void
141  {
142  $this->data['login_button'] = $login_button;
143  }
144 
145  public function getOrganisationSelectionType(): string
146  {
147  return $this->data['hos_type'] ?? self::DEFAULT_ORGANISATION_SELECTION;
148  }
149 
150  public function setOrganisationSelectionType(string $type): void
151  {
152  $this->data['hos_type'] = $type;
153  }
154 
155  public function isActive(): bool
156  {
157  return (bool) ($this->data['active'] ?? false);
158  }
159 
160  public function setActive(bool $status): void
161  {
162  $this->data['active'] = $status ? '1' : '0';
163  }
164 
165  public function isLocalAuthAllowed(): bool
166  {
167  return (bool) ($this->data['auth_allow_local'] ?? false);
168  }
169 
170  public function setAllowLocalAuth(bool $status): void
171  {
172  $this->data['auth_allow_local'] = $status ? '1' : '0';
173  }
174 
175  public function adminMustActivate(): bool
176  {
177  return (bool) ($this->data['activate_new'] ?? false);
178  }
179 
180  public function setAdminMustActivate(bool $status): void
181  {
182  $this->data['activate_new'] = $status ? '1' : '0';
183  }
184 
185  public function getFederationName(): string
186  {
187  return ($this->data['federation_name'] ?? '');
188  }
189 
190  public function setFederationName(string $federation): void
191  {
192  $this->data['federation_name'] = $federation;
193  }
194 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$type
global $DIC
Definition: feed.php:28
setFederationName(string $federation)
string $key
Consumer key/client ID value.
Definition: System.php:193
setLoginButton(string $login_button)
Class ilShibbolethSettings.