2012-05-07 21:54:44 +00:00
|
|
|
<?php
|
2018-04-11 01:29:26 +00:00
|
|
|
/**
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*/
|
2012-05-07 21:54:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
|
|
/**
|
2016-06-15 10:07:01 +00:00
|
|
|
* Constructor. Can't be called directly. Use OATHUserRepository::findByUser instead.
|
2014-05-19 00:05:59 +00:00
|
|
|
* @param User $user
|
2018-04-05 11:27:13 +00:00
|
|
|
* @param OATHAuthKey|null $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
|
|
|
}
|
|
|
|
|
2016-09-16 23:18:35 +00:00
|
|
|
/**
|
|
|
|
* @return User
|
|
|
|
*/
|
2014-05-19 00:05:59 +00:00
|
|
|
public function getUser() {
|
|
|
|
return $this->user;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return String
|
|
|
|
*/
|
2016-11-13 03:43:55 +00:00
|
|
|
public function getIssuer() {
|
2016-10-31 14:17:27 +00:00
|
|
|
global $wgSitename, $wgOATHAuthAccountPrefix;
|
|
|
|
if ( $wgOATHAuthAccountPrefix !== false ) {
|
2016-11-13 03:43:55 +00:00
|
|
|
return $wgOATHAuthAccountPrefix;
|
2016-10-31 14:17:27 +00:00
|
|
|
}
|
2016-11-13 03:43:55 +00:00
|
|
|
return $wgSitename;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
public function getAccount() {
|
|
|
|
return $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
|
|
|
}
|
|
|
|
}
|