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