|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00029 defined('MOODLE_INTERNAL') || die(); 00030 00034 define('AUTH_OK', 0); 00035 00039 define('AUTH_FAIL', 1); 00040 00044 define('AUTH_DENIED', 2); 00045 00049 define('AUTH_ERROR', 4); 00050 00054 define('AUTH_CONFIRM_FAIL', 0); 00055 define('AUTH_CONFIRM_OK', 1); 00056 define('AUTH_CONFIRM_ALREADY', 2); 00057 define('AUTH_CONFIRM_ERROR', 3); 00058 00059 # MDL-14055 00060 define('AUTH_REMOVEUSER_KEEP', 0); 00061 define('AUTH_REMOVEUSER_SUSPEND', 1); 00062 define('AUTH_REMOVEUSER_FULLDELETE', 2); 00063 00070 class auth_plugin_base { 00071 00076 var $config; 00077 00082 var $authtype; 00083 /* 00084 * The fields we can lock and update from/to external authentication backends 00085 * @var array 00086 */ 00087 var $userfields = array( 00088 'firstname', 00089 'lastname', 00090 'email', 00091 'city', 00092 'country', 00093 'lang', 00094 'description', 00095 'url', 00096 'idnumber', 00097 'institution', 00098 'department', 00099 'phone1', 00100 'phone2', 00101 'address' 00102 ); 00103 00120 function user_login($username, $password) { 00121 print_error('mustbeoveride', 'debug', '', 'user_login()' ); 00122 } 00123 00130 function can_change_password() { 00131 //override if needed 00132 return false; 00133 } 00134 00144 function change_password_url() { 00145 //override if needed 00146 return null; 00147 } 00148 00155 function can_edit_profile() { 00156 //override if needed 00157 return true; 00158 } 00159 00169 function edit_profile_url() { 00170 //override if needed 00171 return null; 00172 } 00173 00181 function is_internal() { 00182 //override if needed 00183 return true; 00184 } 00185 00190 function prevent_local_passwords() { 00191 return !$this->is_internal(); 00192 } 00193 00201 function is_synchronised_with_external() { 00202 return !$this->is_internal(); 00203 } 00204 00217 function user_update_password($user, $newpassword) { 00218 //override if needed 00219 return true; 00220 } 00221 00232 function user_update($olduser, $newuser) { 00233 //override if needed 00234 return true; 00235 } 00236 00245 function user_delete($olduser) { 00246 //override if needed 00247 return; 00248 } 00249 00255 function can_reset_password() { 00256 //override if needed 00257 return false; 00258 } 00259 00265 function can_signup() { 00266 //override if needed 00267 return false; 00268 } 00269 00277 function user_signup($user, $notify=true) { 00278 //override when can signup 00279 print_error('mustbeoveride', 'debug', '', 'user_signup()' ); 00280 } 00281 00287 function can_confirm() { 00288 //override if needed 00289 return false; 00290 } 00291 00298 function user_confirm($username, $confirmsecret) { 00299 //override when can confirm 00300 print_error('mustbeoveride', 'debug', '', 'user_confirm()' ); 00301 } 00302 00309 function user_exists($username) { 00310 //override if needed 00311 return false; 00312 } 00313 00323 function password_expire($username) { 00324 return 0; 00325 } 00331 function sync_roles($user) { 00332 //override if needed 00333 } 00334 00344 function get_userinfo($username) { 00345 //override if needed 00346 return array(); 00347 } 00348 00359 function config_form($config, $err, $user_fields) { 00360 //override if needed 00361 } 00362 00369 function validate_form(&$form, &$err) { 00370 //override if needed 00371 } 00372 00378 function process_config($config) { 00379 //override if needed 00380 return true; 00381 } 00382 00390 function loginpage_hook() { 00391 global $frm; // can be used to override submitted login form 00392 global $user; // can be used to replace authenticate_user_login() 00393 00394 //override if needed 00395 } 00396 00405 function user_authenticated_hook(&$user, $username, $password) { 00406 //override if needed 00407 } 00408 00415 function prelogout_hook() { 00416 global $USER; // use $USER->auth to find the plugin used for login 00417 00418 //override if needed 00419 } 00420 00428 function logoutpage_hook() { 00429 global $USER; // use $USER->auth to find the plugin used for login 00430 global $redirect; // can be used to override redirect after logout 00431 00432 //override if needed 00433 } 00434 00445 function ignore_timeout_hook($user, $sid, $timecreated, $timemodified) { 00446 return false; 00447 } 00448 00454 function get_title() { 00455 return get_string('pluginname', "auth_{$this->authtype}"); 00456 } 00457 00463 function get_description() { 00464 $authdescription = get_string("auth_{$this->authtype}description", "auth_{$this->authtype}"); 00465 return $authdescription; 00466 } 00467 00474 function is_captcha_enabled() { 00475 return false; 00476 } 00477 00493 function loginpage_idp_list($wantsurl) { 00494 return array(); 00495 } 00496 00497 }