00001 <?php
00002
00003 # Copyright (C) 2009 Aryeh Gregor
00004 #
00005 # This program 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 2 of the License, or
00008 # (at your option) any later version.
00009 #
00010 # This program 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 along
00016 # with this program; if not, write to the Free Software Foundation, Inc.,
00017 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 # http://www.gnu.org/copyleft/gpl.html
00019
00037 class ExternalUser_Hardcoded extends ExternalUser {
00038 private $mName;
00039
00040 protected function initFromName( $name ) {
00041 global $wgExternalAuthConf;
00042
00043 if ( isset( $wgExternalAuthConf[$name] ) ) {
00044 $this->mName = $name;
00045 return true;
00046 }
00047 return false;
00048 }
00049
00050 protected function initFromId( $id ) {
00051 return $this->initFromName( $id );
00052 }
00053
00054 public function getId() {
00055 return $this->mName;
00056 }
00057
00058 public function getName() {
00059 return $this->mName;
00060 }
00061
00062 public function authenticate( $password ) {
00063 global $wgExternalAuthConf;
00064
00065 return isset( $wgExternalAuthConf[$this->mName]['password'] )
00066 && $wgExternalAuthConf[$this->mName]['password'] == $password;
00067 }
00068
00069 public function getPref( $pref ) {
00070 global $wgExternalAuthConf;
00071
00072 if ( isset( $wgExternalAuthConf[$this->mName][$pref] ) ) {
00073 return $wgExternalAuthConf[$this->mName][$pref];
00074 }
00075 return null;
00076 }
00077
00078 # TODO: Implement setPref() via regex on LocalSettings. (Just kidding.)
00079 }