ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
25 define('IL_REG_DISABLED',1);
26 define('IL_REG_DIRECT',2);
27 define('IL_REG_APPROVE',3);
28 
29 define('IL_REG_ROLES_FIXED',1);
30 define('IL_REG_ROLES_EMAIL',2);
31 
32 define('IL_REG_ERROR_UNKNOWN',1);
33 define('IL_REG_ERROR_NO_PERM',2);
34 
44 {
46  {
47  $this->__read();
48  }
49 
51  {
52  return $this->registration_type;
53  }
54  function setRegistrationType($a_type)
55  {
56  $this->registration_type = $a_type;
57  }
58 
60  {
61  global $ilias;
62 
63  return $ilias->getSetting('new_registration_type',IL_REG_DISABLED);
64  }
65 
66  function enabled()
67  {
68  return $this->registration_type != IL_REG_DISABLED;
69  }
70  function directEnabled()
71  {
72  return $this->registration_type == IL_REG_DIRECT;
73  }
74  function approveEnabled()
75  {
76  return $this->registration_type == IL_REG_APPROVE;
77  }
78 
80  {
81  return $this->password_generation_enabled;
82  }
83  function setPasswordGenerationStatus($a_status)
84  {
85  $this->password_generation_enabled = $a_status;
86  }
87 
89  {
90  return $this->access_limitation;
91  }
92 
93  function setAccessLimitation($a_access_limitation)
94  {
95  $this->access_limitation = $a_access_limitation;
96  }
97 
98  function setApproveRecipientLogins($a_rec_string)
99  {
100  $this->approve_recipient_logins = $a_rec_string;
101  $this->approve_recipient_ids = array();
102 
103  // convert logins to array of ids
104  foreach(explode(',',trim($this->approve_recipient_logins)) as $login)
105  {
106  if($uid = ilObjUser::_lookupId(trim($login)))
107  {
108  $this->approve_recipient_ids[] = $uid;
109  }
110  }
111  }
113  {
114  return $this->approve_recipient_logins;
115  }
117  {
118  return $this->approve_recipient_ids ? $this->approve_recipient_ids : array();
119  }
120  function getUnknown()
121  {
122  return implode(',',$this->unknown);
123  }
124 
126  {
127  return $this->role_type == IL_REG_ROLES_FIXED;
128  }
130  {
131  return $this->role_type == IL_REG_ROLES_EMAIL;
132  }
133  function setRoleType($a_type)
134  {
135  $this->role_type = $a_type;
136  }
137 
138 
139  function validate()
140  {
141  global $ilAccess;
142 
143  $this->unknown = array();
144  $this->mail_perm = array();
145 
146  $login_arr = explode(',',$this->getApproveRecipientLogins());
147  $login_arr = $login_arr ? $login_arr : array();
148  foreach($login_arr as $recipient)
149  {
150  if(!$recipient = trim($recipient))
151  {
152  continue;
153  }
154  if(!ilObjUser::_lookupId($recipient))
155  {
156  $this->unknown[] = $recipient;
157  continue;
158  }
159  }
160  return count($this->unknown) ? 1 : 0;
161  }
162 
163 
164  function save()
165  {
166  global $ilias;
167 
168  $ilias->setSetting('reg_role_assignment',$this->role_type);
169  $ilias->setSetting('new_registration_type',$this->registration_type);
170  $ilias->setSetting('passwd_reg_auto_generate',$this->password_generation_enabled);
171  $ilias->setSetting('approve_recipient',addslashes(serialize($this->approve_recipient_ids)));
172  $ilias->setSetting('reg_access_limitation',$this->access_limitation);
173 
174  return true;
175  }
176 
177  function __read()
178  {
179  global $ilias;
180 
181  $this->registration_type = $ilias->getSetting('new_registration_type');
182  $this->role_type = $ilias->getSetting('reg_role_assignment',1);
183  $this->password_generation_enabled = $ilias->getSetting('passwd_reg_auto_generate');
184  $this->access_limitation = $ilias->getSetting('reg_access_limitation');
185 
186  $this->approve_recipient_ids = unserialize(stripslashes($ilias->getSetting('approve_recipient')));
187  $this->approve_recipient_ids = $this->approve_recipient_ids ?
188  $this->approve_recipient_ids :
189  array();
190 
191  // create login array
192  $tmp_logins = array();
193  foreach($this->approve_recipient_ids as $id)
194  {
195  if($login = ilObjUser::_lookupLogin($id))
196  {
197  $tmp_logins[] = $login;
198  }
199  }
200  $this->approve_recipient_logins = implode(',',$tmp_logins);
201  }
202 }
203 ?>