ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
64 {
65 $this->__read();
66 }
67
69 {
71 }
72 function setRegistrationType($a_type)
73 {
74 $this->registration_type = $a_type;
75 }
76
78 {
79 global $ilias;
80
81 $ret = (int)$ilias->getSetting('new_registration_type',IL_REG_DISABLED);
82
83 if($ret < 1 or $ret > 5)
84 {
85 //data is corrupted and should be processed like "No Registration possible" (#18261)
87 }
88
89 return $ret;
90 }
91
92 function enabled()
93 {
94 return $this->registration_type != IL_REG_DISABLED;
95 }
96 function directEnabled()
97 {
98 return $this->registration_type == IL_REG_DIRECT;
99 }
100 function approveEnabled()
101 {
102 return $this->registration_type == IL_REG_APPROVE;
103 }
104 public function activationEnabled()
105 {
106 return $this->registration_type == IL_REG_ACTIVATION;
107 }
109 {
110 return $this->registration_type == IL_REG_CODES;
111 }
112
114 {
116 }
117 function setPasswordGenerationStatus($a_status)
118 {
119 $this->password_generation_enabled = $a_status;
120 }
121
123 {
125 }
126
127 function setAccessLimitation($a_access_limitation)
128 {
129 $this->access_limitation = $a_access_limitation;
130 }
131
132 function setApproveRecipientLogins($a_rec_string)
133 {
134 $this->approve_recipient_logins = $a_rec_string;
135 $this->approve_recipient_ids = array();
136
137 // convert logins to array of ids
138 foreach(explode(',',trim($this->approve_recipient_logins)) as $login)
139 {
140 if($uid = ilObjUser::_lookupId(trim($login)))
141 {
142 $this->approve_recipient_ids[] = $uid;
143 }
144 }
145 }
147 {
149 }
151 {
152 return $this->approve_recipient_ids ? $this->approve_recipient_ids : array();
153 }
154 function getUnknown()
155 {
156 return implode(',',$this->unknown);
157 }
158
160 {
161 return $this->role_type == IL_REG_ROLES_FIXED;
162 }
164 {
165 return $this->role_type == IL_REG_ROLES_EMAIL;
166 }
167 function setRoleType($a_type)
168 {
169 $this->role_type = $a_type;
170 }
171
172 public function setRegistrationHashLifetime($a_lifetime)
173 {
174 $this->reg_hash_life_time = $a_lifetime;
175
176 return $this;
177 }
178
180 {
181 return max($this->reg_hash_life_time, self::REG_HASH_LIFETIME_MIN_VALUE);
182 }
183
184 public function setAllowCodes($a_allow_codes)
185 {
186 $this->reg_allow_codes = (bool)$a_allow_codes;
187
188 return $this;
189 }
190
191 public function getAllowCodes()
192 {
194 }
195
196 public function setAllowedDomains($a_value)
197 {
198 $a_value = explode(";", trim($a_value));
199 $this->allowed_domains = $a_value;
200 }
201
202 public function getAllowedDomains()
203 {
204 return (array)$this->allowed_domains;
205 }
206
207 function validate()
208 {
209 $this->unknown = array();
210 $this->mail_perm = array();
211
212 $login_arr = explode(',',$this->getApproveRecipientLogins());
213 $login_arr = $login_arr ? $login_arr : array();
214 foreach($login_arr as $recipient)
215 {
216 if(!$recipient = trim($recipient))
217 {
218 continue;
219 }
220 if(!ilObjUser::_lookupId($recipient))
221 {
222 $this->unknown[] = $recipient;
223 continue;
224 }
225 else
226 {
227 $valid = $recipient;
228 }
229 }
230 if(count($this->unknown))
231 {
233 }
234 if($this->getRegistrationType() == IL_REG_APPROVE and !count((array) $valid))
235 {
237 }
238 return 0;
239 }
240
241
242 function save()
243 {
244 global $ilias;
245
246 $ilias->setSetting('reg_role_assignment',$this->role_type);
247 $ilias->setSetting('new_registration_type',$this->registration_type);
248 $ilias->setSetting('passwd_reg_auto_generate',$this->password_generation_enabled);
249 $ilias->setSetting('approve_recipient',addslashes(serialize($this->approve_recipient_ids)));
250 $ilias->setSetting('reg_access_limitation',$this->access_limitation);
251 $ilias->setSetting('reg_hash_life_time',$this->reg_hash_life_time);
252 $ilias->setSetting('reg_allow_codes',$this->reg_allow_codes);
253 $ilias->setSetting('reg_allowed_domains',implode(';', $this->allowed_domains));
254
255 return true;
256 }
257
258 function __read()
259 {
260 global $ilias;
261
262 //static method validates value
263 $this->registration_type = self::_lookupRegistrationType();
264
265 $this->role_type = $ilias->getSetting('reg_role_assignment',1);
266 $this->password_generation_enabled = $ilias->getSetting('passwd_reg_auto_generate');
267 $this->access_limitation = $ilias->getSetting('reg_access_limitation');
268 $this->reg_hash_life_time = $ilias->getSetting('reg_hash_life_time');
269 $this->reg_allow_codes = (bool)$ilias->getSetting('reg_allow_codes');
270
271 $this->approve_recipient_ids = unserialize(stripslashes($ilias->getSetting('approve_recipient')));
272 $this->approve_recipient_ids = $this->approve_recipient_ids ?
273 $this->approve_recipient_ids :
274 array();
275
276 // create login array
277 $tmp_logins = array();
278 foreach($this->approve_recipient_ids as $id)
279 {
280 if($login = ilObjUser::_lookupLogin($id))
281 {
282 $tmp_logins[] = $login;
283 }
284 }
285 $this->approve_recipient_logins = implode(',',$tmp_logins);
286
287 $this->setAllowedDomains($ilias->getSetting('reg_allowed_domains'));
288 }
289}
290?>
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)
$valid