Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 define('IL_REG_DISABLED',1);
00026 define('IL_REG_DIRECT',2);
00027 define('IL_REG_APPROVE',3);
00028
00029 define('IL_REG_ROLES_FIXED',1);
00030 define('IL_REG_ROLES_EMAIL',2);
00031
00032 define('IL_REG_ERROR_UNKNOWN',1);
00033 define('IL_REG_ERROR_NO_PERM',2);
00034
00043 class ilRegistrationSettings
00044 {
00045 function ilRegistrationSettings()
00046 {
00047 $this->__read();
00048 }
00049
00050 function getRegistrationType()
00051 {
00052 return $this->registration_type;
00053 }
00054 function setRegistrationType($a_type)
00055 {
00056 $this->registration_type = $a_type;
00057 }
00058
00059 function _lookupRegistrationType()
00060 {
00061 global $ilias;
00062
00063 return $ilias->getSetting('new_registration_type',IL_REG_DISABLED);
00064 }
00065
00066 function enabled()
00067 {
00068 return $this->registration_type != IL_REG_DISABLED;
00069 }
00070 function directEnabled()
00071 {
00072 return $this->registration_type == IL_REG_DIRECT;
00073 }
00074 function approveEnabled()
00075 {
00076 return $this->registration_type == IL_REG_APPROVE;
00077 }
00078
00079 function passwordGenerationEnabled()
00080 {
00081 return $this->password_generation_enabled;
00082 }
00083 function setPasswordGenerationStatus($a_status)
00084 {
00085 $this->password_generation_enabled = $a_status;
00086 }
00087
00088 function getAccessLimitation()
00089 {
00090 return $this->access_limitation;
00091 }
00092
00093 function setAccessLimitation($a_access_limitation)
00094 {
00095 $this->access_limitation = $a_access_limitation;
00096 }
00097
00098 function setApproveRecipientLogins($a_rec_string)
00099 {
00100 $this->approve_recipient_logins = $a_rec_string;
00101 $this->approve_recipient_ids = array();
00102
00103
00104 foreach(explode(',',trim($this->approve_recipient_logins)) as $login)
00105 {
00106 if($uid = ilObjUser::_lookupId(trim($login)))
00107 {
00108 $this->approve_recipient_ids[] = $uid;
00109 }
00110 }
00111 }
00112 function getApproveRecipientLogins()
00113 {
00114 return $this->approve_recipient_logins;
00115 }
00116 function getApproveRecipients()
00117 {
00118 return $this->approve_recipient_ids ? $this->approve_recipient_ids : array();
00119 }
00120 function getUnknown()
00121 {
00122 return implode(',',$this->unknown);
00123 }
00124
00125 function roleSelectionEnabled()
00126 {
00127 return $this->role_type == IL_REG_ROLES_FIXED;
00128 }
00129 function automaticRoleAssignmentEnabled()
00130 {
00131 return $this->role_type == IL_REG_ROLES_EMAIL;
00132 }
00133 function setRoleType($a_type)
00134 {
00135 $this->role_type = $a_type;
00136 }
00137
00138
00139 function validate()
00140 {
00141 global $ilAccess;
00142
00143 $this->unknown = array();
00144 $this->mail_perm = array();
00145
00146 $login_arr = explode(',',$this->getApproveRecipientLogins());
00147 $login_arr = $login_arr ? $login_arr : array();
00148 foreach($login_arr as $recipient)
00149 {
00150 if(!$recipient = trim($recipient))
00151 {
00152 continue;
00153 }
00154 if(!ilObjUser::_lookupId($recipient))
00155 {
00156 $this->unknown[] = $recipient;
00157 continue;
00158 }
00159 }
00160 return count($this->unknown) ? 1 : 0;
00161 }
00162
00163
00164 function save()
00165 {
00166 global $ilias;
00167
00168 $ilias->setSetting('reg_role_assignment',$this->role_type);
00169 $ilias->setSetting('new_registration_type',$this->registration_type);
00170 $ilias->setSetting('passwd_reg_auto_generate',$this->password_generation_enabled);
00171 $ilias->setSetting('approve_recipient',addslashes(serialize($this->approve_recipient_ids)));
00172 $ilias->setSetting('reg_access_limitation',$this->access_limitation);
00173
00174 return true;
00175 }
00176
00177 function __read()
00178 {
00179 global $ilias;
00180
00181 $this->registration_type = $ilias->getSetting('new_registration_type');
00182 $this->role_type = $ilias->getSetting('reg_role_assignment',1);
00183 $this->password_generation_enabled = $ilias->getSetting('passwd_reg_auto_generate');
00184 $this->access_limitation = $ilias->getSetting('reg_access_limitation');
00185
00186 $this->approve_recipient_ids = unserialize(stripslashes($ilias->getSetting('approve_recipient')));
00187 $this->approve_recipient_ids = $this->approve_recipient_ids ?
00188 $this->approve_recipient_ids :
00189 array();
00190
00191
00192 $tmp_logins = array();
00193 foreach($this->approve_recipient_ids as $id)
00194 {
00195 if($login = ilObjUser::_lookupLogin($id))
00196 {
00197 $tmp_logins[] = $login;
00198 }
00199 }
00200 $this->approve_recipient_logins = implode(',',$tmp_logins);
00201 }
00202 }
00203 ?>