]> git.mxchange.org Git - friendica.git/blob - src/Module/Security/Logout.php
Merge pull request #8034 from MrPetovan/bug/fatal-errors
[friendica.git] / src / Module / Security / Logout.php
1 <?php
2 /**
3  * @file src/Module/Logout.php
4  */
5
6 namespace Friendica\Module\Security;
7
8 use Friendica\BaseModule;
9 use Friendica\App\Authentication;
10 use Friendica\Core\Cache;
11 use Friendica\Core\Hook;
12 use Friendica\Core\L10n;
13 use Friendica\Core\Session;
14 use Friendica\Core\System;
15 use Friendica\DI;
16 use Friendica\Model\Profile;
17
18 /**
19  * Logout module
20  *
21  * @author Hypolite Petovan <hypolite@mrpetovan.com>
22  */
23 class Logout extends BaseModule
24 {
25         /**
26          * @brief Process logout requests
27          */
28         public static function init(array $parameters = [])
29         {
30                 $visitor_home = null;
31                 if (remote_user()) {
32                         $visitor_home = Profile::getMyURL();
33                         Cache::delete('zrlInit:' . $visitor_home);
34                 }
35
36                 Hook::callAll("logging_out");
37                 Session::clear();
38
39                 if ($visitor_home) {
40                         System::externalRedirect($visitor_home);
41                 } else {
42                         info(L10n::t('Logged out.'));
43                         DI::baseUrl()->redirect();
44                 }
45         }
46 }