MDL-52285 auth: use __construct() for constructors
[moodle.git] / auth / none / auth.php
blob110c3906036b0615f510dea30e232e501bf8b798
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Anobody can login with any password.
20 * @package auth_none
21 * @author Martin Dougiamas
22 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
25 defined('MOODLE_INTERNAL') || die();
27 require_once($CFG->libdir.'/authlib.php');
29 /**
30 * Plugin for no authentication.
32 class auth_plugin_none extends auth_plugin_base {
34 /**
35 * Constructor.
37 public function __construct() {
38 $this->authtype = 'none';
39 $this->config = get_config('auth/none');
42 /**
43 * Old syntax of class constructor for backward compatibility.
45 public function auth_plugin_none() {
46 self::__construct();
49 /**
50 * Returns true if the username and password work or don't exist and false
51 * if the user exists and the password is wrong.
53 * @param string $username The username
54 * @param string $password The password
55 * @return bool Authentication success or failure.
57 function user_login ($username, $password) {
58 global $CFG, $DB;
59 if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
60 return validate_internal_user_password($user, $password);
62 return true;
65 /**
66 * Updates the user's password.
68 * called when the user password is updated.
70 * @param object $user User table object
71 * @param string $newpassword Plaintext password
72 * @return boolean result
75 function user_update_password($user, $newpassword) {
76 $user = get_complete_user_data('id', $user->id);
77 // This will also update the stored hash to the latest algorithm
78 // if the existing hash is using an out-of-date algorithm (or the
79 // legacy md5 algorithm).
80 return update_internal_user_password($user, $newpassword);
83 function prevent_local_passwords() {
84 return false;
87 /**
88 * Returns true if this authentication plugin is 'internal'.
90 * @return bool
92 function is_internal() {
93 return true;
96 /**
97 * Returns true if this authentication plugin can change the user's
98 * password.
100 * @return bool
102 function can_change_password() {
103 return true;
107 * Returns the URL for changing the user's pw, or empty if the default can
108 * be used.
110 * @return moodle_url
112 function change_password_url() {
113 return null;
117 * Returns true if plugin allows resetting of internal password.
119 * @return bool
121 function can_reset_password() {
122 return true;
126 * Returns true if plugin can be manually set.
128 * @return bool
130 function can_be_manually_set() {
131 return true;
135 * Prints a form for configuring this authentication plugin.
137 * This function is called from admin/auth.php, and outputs a full page with
138 * a form for configuring this plugin.
140 * @param array $page An object containing all the data for this page.
142 function config_form($config, $err, $user_fields) {
143 include "config.html";
147 * Processes and stores configuration data for this authentication plugin.
149 function process_config($config) {
150 return true;