00001 <?php 00004 # Copyright (C) 2004 Brion Vibber <brion@pobox.com> 00005 # http://www.mediawiki.org/ 00006 # 00007 # This program is free software; you can redistribute it and/or modify 00008 # it under the terms of the GNU General Public License as published by 00009 # the Free Software Foundation; either version 2 of the License, or 00010 # (at your option) any later version. 00011 # 00012 # This program is distributed in the hope that it will be useful, 00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 # GNU General Public License for more details. 00016 # 00017 # You should have received a copy of the GNU General Public License along 00018 # with this program; if not, write to the Free Software Foundation, Inc., 00019 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 # http://www.gnu.org/copyleft/gpl.html 00021 00032 class AuthPlugin { 00042 public function userExists( $username ) { 00043 # Override this! 00044 return false; 00045 } 00046 00057 public function authenticate( $username, $password ) { 00058 # Override this! 00059 return false; 00060 } 00061 00068 public function modifyUITemplate( &$template, &$type ) { 00069 # Override this! 00070 $template->set( 'usedomain', false ); 00071 } 00072 00078 public function setDomain( $domain ) { 00079 $this->domain = $domain; 00080 } 00081 00088 public function validDomain( $domain ) { 00089 # Override this! 00090 return true; 00091 } 00092 00103 public function updateUser( &$user ) { 00104 # Override this and do something 00105 return true; 00106 } 00107 00108 00122 public function autoCreate() { 00123 return false; 00124 } 00125 00133 public function allowPropChange( $prop = '' ) { 00134 if( $prop == 'realname' && is_callable( array( $this, 'allowRealNameChange' ) ) ) { 00135 return $this->allowRealNameChange(); 00136 } elseif( $prop == 'emailaddress' && is_callable( array( $this, 'allowEmailChange' ) ) ) { 00137 return $this->allowEmailChange(); 00138 } elseif( $prop == 'nickname' && is_callable( array( $this, 'allowNickChange' ) ) ) { 00139 return $this->allowNickChange(); 00140 } else { 00141 return true; 00142 } 00143 } 00144 00150 public function allowPasswordChange() { 00151 return true; 00152 } 00153 00166 public function setPassword( $user, $password ) { 00167 return true; 00168 } 00169 00177 public function updateExternalDB( $user ) { 00178 return true; 00179 } 00180 00186 public function canCreateAccounts() { 00187 return false; 00188 } 00189 00200 public function addUser( $user, $password, $email='', $realname='' ) { 00201 return true; 00202 } 00203 00204 00213 public function strict() { 00214 return false; 00215 } 00216 00224 public function strictUserAuth( $username ) { 00225 return false; 00226 } 00227 00239 public function initUser( &$user, $autocreate=false ) { 00240 # Override this to do something. 00241 } 00242 00247 public function getCanonicalName( $username ) { 00248 return $username; 00249 } 00250 00256 public function getUserInstance( User &$user ) { 00257 return new AuthPluginUser( $user ); 00258 } 00259 } 00260 00261 class AuthPluginUser { 00262 function __construct( $user ) { 00263 # Override this! 00264 } 00265 00266 public function getId() { 00267 # Override this! 00268 return -1; 00269 } 00270 00271 public function isLocked() { 00272 # Override this! 00273 return false; 00274 } 00275 00276 public function isHidden() { 00277 # Override this! 00278 return false; 00279 } 00280 00281 public function resetAuthToken() { 00282 # Override this! 00283 return true; 00284 } 00285 }