1 | <?php |
||
34 | class auth_plugin_ws extends auth_plugin_base { |
||
35 | |||
36 | /** |
||
37 | * Constructor. |
||
38 | */ |
||
39 | public function __construct() { |
||
55 | |||
56 | /** |
||
57 | * Returns true if the username and password work and false if they are |
||
58 | * wrong or don't exist. |
||
59 | * |
||
60 | * @param string $username The username |
||
61 | * @param string $password The password |
||
62 | * @return bool Authentication success or failure. |
||
63 | */ |
||
64 | public function user_login($username, $password) { |
||
74 | |||
75 | /** |
||
76 | * This plugin is intended only to authenticate users. |
||
77 | * User synchronization must be done by external service, |
||
78 | * using Moodle's webservices. |
||
79 | * |
||
80 | * @param progress_trace $trace |
||
81 | * @param bool $do_updates Optional: set to true to force an update of existing accounts |
||
82 | * @return int 0 means success, 1 means failure |
||
83 | */ |
||
84 | public function sync_users(progress_trace $trace, $do_updates=false) { |
||
87 | |||
88 | public function get_userinfo($username) { |
||
91 | |||
92 | private function call_ws($serverurl, $functionname, $params = array()) { |
||
110 | |||
111 | public function prevent_local_passwords() { |
||
114 | |||
115 | /** |
||
116 | * Returns true if this authentication plugin is "internal". |
||
117 | * |
||
118 | * Internal plugins use password hashes from Moodle user table for authentication. |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | public function is_internal() { |
||
125 | |||
126 | /** |
||
127 | * Indicates if moodle should automatically update internal user |
||
128 | * records with data from external sources using the information |
||
129 | * from auth_plugin_base::get_userinfo(). |
||
130 | * The external service is responsible to update user records. |
||
131 | * |
||
132 | * @return bool true means automatically copy data from ext to user table |
||
133 | */ |
||
134 | public function is_synchronised_with_external() { |
||
137 | |||
138 | /** |
||
139 | * Returns true if this authentication plugin can change the user's |
||
140 | * password. |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | public function can_change_password() { |
||
147 | |||
148 | /** |
||
149 | * Returns the URL for changing the user's pw, or empty if the default can |
||
150 | * be used. |
||
151 | * |
||
152 | * @return moodle_url |
||
153 | */ |
||
154 | public function change_password_url() { |
||
161 | |||
162 | /** |
||
163 | * Returns true if plugin allows resetting of internal password. |
||
164 | * |
||
165 | * @return bool |
||
166 | */ |
||
167 | public function can_reset_password() { |
||
170 | } |
||
171 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.