X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Flogout.php;h=60aec3c83a48d37a21bf435fff4d0da2aa513424;hb=76004660e9138b94668263769d4b10cfb1e77955;hp=3b6914411b263e6c80da5bc98b3246fde44296bd;hpb=b6cfd2dffeeb733f07818db5f4ce11d4b3d51771;p=quix0rs-gnu-social.git diff --git a/actions/logout.php b/actions/logout.php index 3b6914411b..60aec3c83a 100644 --- a/actions/logout.php +++ b/actions/logout.php @@ -1,32 +1,76 @@ + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + * + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 2009, StatusNet, Inc. + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 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 Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1) } +if (!defined('GNUSOCIAL')) { exit(1); } -class LogoutAction extends Action { - function handle($args) { - parent::handle($args); - if (!common_logged_in()) { - common_user_error(_t('Not logged in.')); - } else { - common_set_user(NULL); - common_redirect(common_local_url('main')); - } - } +/** + * Logout action class. + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ +class LogoutAction extends ManagedAction +{ + /** + * This is read only. + * + * @return boolean true + */ + function isReadOnly($args) + { + return false; + } + + protected function doPreparation() + { + if (!common_logged_in()) { + // TRANS: Error message displayed when trying to logout even though you are not logged in. + throw new AlreadyFulfilledException(_('Cannot log you out if you are not logged in.')); + } + if (Event::handle('StartLogout', array($this))) { + $this->logout(); + } + Event::handle('EndLogout', array($this)); + + common_redirect(common_local_url('startpage')); + } + + // Accessed through the action on events + public function logout() + { + common_set_user(null); + common_real_login(false); // not logged in + common_forgetme(); // don't log back in! + } }