2012-05-07 21:54:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class representing a user from OATH's perspective
|
|
|
|
*
|
|
|
|
* @ingroup Extensions
|
|
|
|
*/
|
|
|
|
class OATHUser {
|
2014-05-19 00:05:59 +00:00
|
|
|
/** @var User */
|
|
|
|
private $user;
|
2014-05-11 08:16:03 +00:00
|
|
|
|
2014-05-19 00:05:59 +00:00
|
|
|
/** @var OATHAuthKey|null */
|
|
|
|
private $key;
|
2012-05-07 21:54:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor. Can't be called directly. Call one of the static NewFrom* methods
|
2014-05-19 00:05:59 +00:00
|
|
|
* @param User $user
|
|
|
|
* @param OATHAuthKey $key
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-19 00:05:59 +00:00
|
|
|
public function __construct( User $user, OATHAuthKey $key = null ) {
|
|
|
|
$this->user = $user;
|
|
|
|
$this->key = $key;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
2014-05-19 00:05:59 +00:00
|
|
|
public function getUser() {
|
|
|
|
return $this->user;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
public function getAccount() {
|
|
|
|
global $wgSitename;
|
|
|
|
|
2014-05-19 00:05:59 +00:00
|
|
|
return "$wgSitename:{$this->user->getName()}";
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-19 00:05:59 +00:00
|
|
|
* Get the key associated with this user.
|
|
|
|
*
|
|
|
|
* @return null|OATHAuthKey
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-19 00:05:59 +00:00
|
|
|
public function getKey() {
|
|
|
|
return $this->key;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-19 00:05:59 +00:00
|
|
|
* Set the key associated with this user.
|
|
|
|
*
|
|
|
|
* @param OATHAuthKey|null $key
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-19 00:05:59 +00:00
|
|
|
public function setKey( OATHAuthKey $key = null ) {
|
|
|
|
$this->key = $key;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
}
|