2008-01-08 18:10:58 +00:00
|
|
|
<?php
|
2010-02-23 18:05:46 +00:00
|
|
|
/**
|
2010-12-22 20:52:06 +00:00
|
|
|
*
|
2008-01-08 18:10:58 +00:00
|
|
|
*
|
2010-08-07 19:59:42 +00:00
|
|
|
* Created on Jan 4, 2008
|
|
|
|
|
*
|
2012-07-15 20:13:02 +00:00
|
|
|
* Copyright © 2008 Yuri Astrakhan "<Firstname><Lastname>@gmail.com",
|
2008-01-08 18:10:58 +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.,
|
2010-06-21 13:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-01-08 18:10:58 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2008-01-08 18:10:58 +00:00
|
|
|
*/
|
|
|
|
|
|
2008-01-12 07:08:17 +00:00
|
|
|
/**
|
2008-04-14 07:45:50 +00:00
|
|
|
* API module to allow users to log out of the wiki. API equivalent of
|
2008-01-12 07:08:17 +00:00
|
|
|
* Special:Userlogout.
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2008-01-12 07:08:17 +00:00
|
|
|
*/
|
2008-01-08 18:10:58 +00:00
|
|
|
class ApiLogout extends ApiBase {
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
2016-02-01 20:44:03 +00:00
|
|
|
// Make sure it's possible to log out
|
|
|
|
|
$session = MediaWiki\Session\SessionManager::getGlobalSession();
|
|
|
|
|
if ( !$session->canSetUser() ) {
|
|
|
|
|
$this->dieUsage(
|
|
|
|
|
'Cannot log out when using ' .
|
|
|
|
|
$session->getProvider()->describe( Language::factory( 'en' ) ),
|
|
|
|
|
'cannotlogout'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 23:27:01 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
$oldName = $user->getName();
|
|
|
|
|
$user->logout();
|
2010-02-23 18:05:46 +00:00
|
|
|
|
2008-05-24 20:44:49 +00:00
|
|
|
// Give extensions to do something after user logout
|
|
|
|
|
$injected_html = '';
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'UserLogoutComplete', array( &$user, &$injected_html, $oldName ) );
|
2008-01-08 18:10:58 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-06 13:49:44 +00:00
|
|
|
public function isReadMode() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-28 17:17:02 +00:00
|
|
|
protected function getExamplesMessages() {
|
2008-01-08 18:10:58 +00:00
|
|
|
return array(
|
2014-09-18 17:38:23 +00:00
|
|
|
'action=logout'
|
|
|
|
|
=> 'apihelp-logout-example-logout',
|
2008-01-08 18:10:58 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-17 16:23:29 +00:00
|
|
|
public function getHelpUrls() {
|
2011-11-28 15:43:11 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/API:Logout';
|
2011-07-17 16:18:09 +00:00
|
|
|
}
|
2008-01-12 07:08:17 +00:00
|
|
|
}
|