6f00874c891bec44d10e0c913059cadcd812805f
3 # Copyright (C) 2009 Aryeh Gregor
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # http://www.gnu.org/copyleft/gpl.html
21 * This class supports the proprietary vBulletin forum system
22 * <http://www.vbulletin.com>, versions 3.5 and up. It calls no functions or
23 * code, only reads from the database. Example lines to put in
26 * $wgExternalAuthType = 'vB';
27 * $wgExternalAuthConf = array(
28 * 'server' => 'localhost',
29 * 'username' => 'forum',
30 * 'password' => 'udE,jSqDJ<""p=fI.K9',
31 * 'dbname' => 'forum',
35 class ExternalUser_vB
extends ExternalUser
{
38 protected function initFromName( $name ) {
39 return $this->initFromCond( array( 'username' => $name ) );
42 protected function initFromId( $id ) {
43 return $this->initFromCond( array( 'userid' => $id ) );
46 # initFromCookie() not yet implemented
48 private function initFromCond( $cond ) {
49 global $wgExternalAuthConf;
51 $this->mDb
= new Database(
52 $wgExternalAuthConf['server'],
53 $wgExternalAuthConf['username'],
54 $wgExternalAuthConf['password'],
55 $wgExternalAuthConf['dbname'],
57 $wgExternalAuthConf['tableprefix']
60 $row = $this->mDb
->selectRow(
62 array( 'userid', 'username', 'password', 'salt', 'email', 'usergroupid',
75 public function getId() { return $this->mRow
->userid
; }
76 public function getName() { return $this->mRow
->username
; }
78 public function authenticate( $password ) {
79 # vBulletin seemingly strips whitespace from passwords
80 $password = trim( $password );
81 return $this->mRow
->password
== md5( md5( $password )
82 . $this->mRow
->salt
);
85 public function getPref( $pref ) {
86 if ( $pref == 'emailaddress' && $this->mRow
->email
) {
87 # TODO: only return if validated?
88 return $this->mRow
->email
;
93 public function getGroups() {
94 $groups = array( $this->mRow
->usergroupid
);
95 $groups = array_merge( $groups, explode( ',', $this->mRow
->membergroupids
) );
96 $groups = array_unique( $groups );