* @ingroup ExternalUser
*/
class ExternalUser_MediaWiki extends ExternalUser {
- private $mRow, $mDb;
+ private $mRow;
+ /**
+ * @var DatabaseBase
+ */
+ private $mDb;
+
+ /**
+ * @param $name string
+ * @return bool
+ */
protected function initFromName( $name ) {
# We might not need the 'usable' bit, but let's be safe. Theoretically
# this might return wrong results for old versions, but it's probably
return $this->initFromCond( array( 'user_name' => $name ) );
}
+ /**
+ * @param $id int
+ * @return bool
+ */
protected function initFromId( $id ) {
return $this->initFromCond( array( 'user_id' => $id ) );
}
+ /**
+ * @param $cond array
+ * @return bool
+ */
private function initFromCond( $cond ) {
global $wgExternalAuthConf;
- $class = 'Database' . $wgExternalAuthConf['DBtype'];
- $this->mDb = new $class(
- $wgExternalAuthConf['DBserver'],
- $wgExternalAuthConf['DBuser'],
- $wgExternalAuthConf['DBpassword'],
- $wgExternalAuthConf['DBname'],
- false,
- 0,
- $wgExternalAuthConf['DBprefix']
+ $this->mDb = DatabaseBase::factory( $wgExternalAuthConf['DBtype'],
+ array(
+ 'host' => $wgExternalAuthConf['DBserver'],
+ 'user' => $wgExternalAuthConf['DBuser'],
+ 'password' => $wgExternalAuthConf['DBpassword'],
+ 'dbname' => $wgExternalAuthConf['DBname'],
+ 'tablePrefix' => $wgExternalAuthConf['DBprefix'],
+ )
);
$row = $this->mDb->selectRow(
return $this->mRow->user_id;
}
+ /**
+ * @return string
+ */
public function getName() {
return $this->mRow->user_name;
}
}
public function getPref( $pref ) {
- # FIXME: Return other prefs too. Lots of global-riddled code that does
+ # @todo FIXME: Return other prefs too. Lots of global-riddled code that does
# this normally.
if ( $pref === 'emailaddress'
&& $this->row->user_email_authenticated !== null ) {
return null;
}
+ /**
+ * @return array
+ */
public function getGroups() {
- # FIXME: Untested.
+ # @todo FIXME: Untested.
$groups = array();
$res = $this->mDb->select(
'user_groups',