Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/auth/manual/auth.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 require_once($CFG->libdir.'/authlib.php');
00030 
00039 class auth_plugin_manual extends auth_plugin_base {
00040 
00044     function auth_plugin_manual() {
00045         $this->authtype = 'manual';
00046         $this->config = get_config('auth/manual');
00047     }
00048 
00057     function user_login($username, $password) {
00058         global $CFG, $DB, $USER;
00059         if (!$user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
00060             return false;
00061         }
00062         if (!validate_internal_user_password($user, $password)) {
00063             return false;
00064         }
00065         if ($password === 'changeme') {
00066             // force the change - this is deprecated and it makes sense only for manual auth,
00067             // because most other plugins can not change password easily or
00068             // passwords are always specified by users
00069             set_user_preference('auth_forcepasswordchange', true, $user->id);
00070         }
00071         return true;
00072     }
00073 
00083     function user_update_password($user, $newpassword) {
00084         $user = get_complete_user_data('id', $user->id);
00085         return update_internal_user_password($user, $newpassword);
00086     }
00087 
00088     function prevent_local_passwords() {
00089         return false;
00090     }
00091 
00097     function is_internal() {
00098         return true;
00099     }
00100 
00107     function can_change_password() {
00108         return true;
00109     }
00110 
00117     function change_password_url() {
00118         return null;
00119     }
00120 
00126     function can_reset_password() {
00127         return true;
00128     }
00129 
00141     function config_form($config, $err, $user_fields) {
00142         include 'config.html';
00143     }
00144 
00151     function process_config($config) {
00152         return true;
00153     }
00154 
00163     function user_confirm($username, $confirmsecret = null) {
00164         global $DB;
00165 
00166         $user = get_complete_user_data('username', $username);
00167 
00168         if (!empty($user)) {
00169             if ($user->confirmed) {
00170                 return AUTH_CONFIRM_ALREADY;
00171             } else {
00172                 $DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
00173                 $DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
00174                 return AUTH_CONFIRM_OK;
00175             }
00176         } else  {
00177             return AUTH_CONFIRM_ERROR;
00178         }
00179     }
00180 
00181 }
00182 
00183 
 All Data Structures Namespaces Files Functions Variables Enumerations