ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilRegistrationSettings.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
25define('IL_REG_DISABLED', 1);
26define('IL_REG_DIRECT', 2);
27define('IL_REG_APPROVE', 3);
28define('IL_REG_ACTIVATION', 4);
29define('IL_REG_CODES', 5);
30
31define('IL_REG_ROLES_FIXED', 1);
32define('IL_REG_ROLES_EMAIL', 2);
33
34define('IL_REG_ERROR_UNKNOWN', 1);
35define('IL_REG_ERROR_NO_PERM', 2);
36
46{
47 const ERR_UNKNOWN_RCP = 1;
48 const ERR_MISSING_RCP = 2;
49
51
57 private $role_type;
58 private $unknown;
60 private $reg_allow_codes = false;
62
63 public function __construct()
64 {
65 $this->__read();
66 }
67
68 public function getRegistrationType()
69 {
71 }
73 {
74 $this->registration_type = $a_type;
75 }
76
77 public static function _lookupRegistrationType()
78 {
79 global $DIC;
80
81 $ilSetting = $DIC['ilSetting'];
82
83 $ret = (int) $ilSetting->get('new_registration_type', IL_REG_DISABLED);
84
85 if ($ret < 1 or $ret > 5) {
86 //data is corrupted and should be processed like "No Registration possible" (#18261)
88 }
89
90 return $ret;
91 }
92
93 public function enabled()
94 {
95 return $this->registration_type != IL_REG_DISABLED;
96 }
97 public function directEnabled()
98 {
99 return $this->registration_type == IL_REG_DIRECT;
100 }
101 public function approveEnabled()
102 {
103 return $this->registration_type == IL_REG_APPROVE;
104 }
105 public function activationEnabled()
106 {
107 return $this->registration_type == IL_REG_ACTIVATION;
108 }
109 public function registrationCodeRequired()
110 {
111 return $this->registration_type == IL_REG_CODES;
112 }
113
115 {
117 }
118 public function setPasswordGenerationStatus($a_status)
119 {
120 $this->password_generation_enabled = $a_status;
121 }
122
123 public function getAccessLimitation()
124 {
126 }
127
128 public function setAccessLimitation($a_access_limitation)
129 {
130 $this->access_limitation = $a_access_limitation;
131 }
132
133 public function setApproveRecipientLogins($a_rec_string)
134 {
135 $this->approve_recipient_logins = $a_rec_string;
136 $this->approve_recipient_ids = array();
137
138 // convert logins to array of ids
139 foreach (explode(',', trim($this->approve_recipient_logins)) as $login) {
140 if ($uid = ilObjUser::_lookupId(trim($login))) {
141 $this->approve_recipient_ids[] = $uid;
142 }
143 }
144 }
146 {
148 }
149 public function getApproveRecipients()
150 {
151 return $this->approve_recipient_ids ? $this->approve_recipient_ids : array();
152 }
153 public function getUnknown()
154 {
155 return implode(',', $this->unknown);
156 }
157
158 public function roleSelectionEnabled()
159 {
160 return $this->role_type == IL_REG_ROLES_FIXED;
161 }
163 {
164 return $this->role_type == IL_REG_ROLES_EMAIL;
165 }
166 public function setRoleType($a_type)
167 {
168 $this->role_type = $a_type;
169 }
170
171 public function setRegistrationHashLifetime($a_lifetime)
172 {
173 $this->reg_hash_life_time = $a_lifetime;
174
175 return $this;
176 }
177
179 {
180 return max($this->reg_hash_life_time, self::REG_HASH_LIFETIME_MIN_VALUE);
181 }
182
183 public function setAllowCodes($a_allow_codes)
184 {
185 $this->reg_allow_codes = (bool) $a_allow_codes;
186
187 return $this;
188 }
189
190 public function getAllowCodes()
191 {
193 }
194
195 public function setAllowedDomains($a_value)
196 {
197 $a_value = explode(";", trim($a_value));
198 $this->allowed_domains = $a_value;
199 }
200
201 public function getAllowedDomains()
202 {
203 return (array) $this->allowed_domains;
204 }
205
206 public function validate()
207 {
208 $this->unknown = array();
209 $this->mail_perm = array();
210
211 $login_arr = explode(',', $this->getApproveRecipientLogins());
212 $login_arr = $login_arr ? $login_arr : array();
213 foreach ($login_arr as $recipient) {
214 if (!$recipient = trim($recipient)) {
215 continue;
216 }
217 if (!ilObjUser::_lookupId($recipient)) {
218 $this->unknown[] = $recipient;
219 continue;
220 } else {
221 $valid = $recipient;
222 }
223 }
224 if (count($this->unknown)) {
226 }
227 if ($this->getRegistrationType() == IL_REG_APPROVE and !count((array) $valid)) {
229 }
230 return 0;
231 }
232
233
234 public function save()
235 {
236 global $DIC;
237
238 $ilias = $DIC['ilias'];
239
240 $ilias->setSetting('reg_role_assignment', $this->role_type);
241 $ilias->setSetting('new_registration_type', $this->registration_type);
242 $ilias->setSetting('passwd_reg_auto_generate', $this->password_generation_enabled);
243 $ilias->setSetting('approve_recipient', addslashes(serialize($this->approve_recipient_ids)));
244 $ilias->setSetting('reg_access_limitation', $this->access_limitation);
245 $ilias->setSetting('reg_hash_life_time', $this->reg_hash_life_time);
246 $ilias->setSetting('reg_allow_codes', $this->reg_allow_codes);
247 $ilias->setSetting('reg_allowed_domains', implode(';', $this->allowed_domains));
248
249 return true;
250 }
251
252 public function __read()
253 {
254 global $DIC;
255
256 $ilias = $DIC['ilias'];
257
258 //static method validates value
259 $this->registration_type = self::_lookupRegistrationType();
260
261 $this->role_type = $ilias->getSetting('reg_role_assignment', 1);
262 $this->password_generation_enabled = $ilias->getSetting('passwd_reg_auto_generate');
263 $this->access_limitation = $ilias->getSetting('reg_access_limitation');
264 $this->reg_hash_life_time = $ilias->getSetting('reg_hash_life_time');
265 $this->reg_allow_codes = (bool) $ilias->getSetting('reg_allow_codes');
266
267 $this->approve_recipient_ids = unserialize(stripslashes($ilias->getSetting('approve_recipient')));
268 $this->approve_recipient_ids = $this->approve_recipient_ids ?
269 $this->approve_recipient_ids :
270 array();
271
272 // create login array
273 $tmp_logins = array();
274 foreach ($this->approve_recipient_ids as $id) {
276 $tmp_logins[] = $login;
277 }
278 }
279 $this->approve_recipient_logins = implode(',', $tmp_logins);
280
281 $this->setAllowedDomains($ilias->getSetting('reg_allowed_domains'));
282 }
283}
An exception for terminatinating execution or to throw for unit testing.
const IL_REG_ACTIVATION
const IL_REG_ROLES_FIXED
const IL_REG_ROLES_EMAIL
static _lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
Lookup id by login.
Class ilObjAuthSettingsGUI.
setAccessLimitation($a_access_limitation)
$login
Definition: cron.php:13
$valid
if(!array_key_exists('StateId', $_REQUEST)) $id
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92