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
|
|
|
|
|
|
|
/**
|
2014-05-22 07:33:40 +00:00
|
|
|
* Proxy page that redirects to the proper OATH special page
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-22 07:33:40 +00:00
|
|
|
class SpecialOATH extends ProxySpecialPage {
|
2014-05-11 08:16:03 +00:00
|
|
|
/**
|
2014-05-22 07:33:40 +00:00
|
|
|
* If the user already has OATH enabled, show them a page to disable
|
|
|
|
* If the user has OATH disabled, show them a page to enable
|
2014-05-11 08:16:03 +00:00
|
|
|
*
|
2016-11-12 02:48:49 +00:00
|
|
|
* @return SpecialOATHDisable|SpecialOATHEnable
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-22 07:33:40 +00:00
|
|
|
protected function getTargetPage() {
|
2015-05-25 23:47:03 +00:00
|
|
|
$repo = OATHAuthHooks::getOATHUserRepository();
|
2012-05-07 21:54:44 +00:00
|
|
|
|
2016-11-12 02:48:49 +00:00
|
|
|
$user = $repo->findByUser( $this->getUser() );
|
2014-05-27 18:00:21 +00:00
|
|
|
|
2016-11-12 02:48:49 +00:00
|
|
|
if ( $user->getKey() === null ) {
|
|
|
|
return new SpecialOATHEnable( $repo, $user );
|
2012-05-07 21:54:44 +00:00
|
|
|
} else {
|
2016-11-12 02:48:49 +00:00
|
|
|
return new SpecialOATHDisable( $repo, $user );
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-23 18:57:40 +00:00
|
|
|
protected function getGroupName() {
|
|
|
|
return 'oath';
|
|
|
|
}
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|