Redirect remote visitors to their own profile after logout
[friendica.git/.git] / src / Module / Logout.php
1 <?php
2 /**
3  * @file src/Module/Logout.php
4  */
5
6 namespace Friendica\Module;
7
8 use Friendica\BaseModule;
9 use Friendica\Core\Authentication;
10 use Friendica\Core\Hook;
11 use Friendica\Core\L10n;
12 use Friendica\Core\System;
13 use Friendica\Model\Profile;
14
15 /**
16  * Logout module
17  *
18  * @author Hypolite Petovan <hypolite@mrpetovan.com>
19  */
20 class Logout extends BaseModule
21 {
22         /**
23          * @brief Process logout requests
24          */
25         public static function init()
26         {
27                 $visitor_home = null;
28                 if (remote_user()) {
29                         $visitor_home = Profile::getMyURL();
30                 }
31
32                 Hook::callAll("logging_out");
33                 Authentication::deleteSession();
34
35                 if ($visitor_home) {
36                         System::externalRedirect($visitor_home);
37                 } else {
38                         info(L10n::t('Logged out.'));
39                         self::getApp()->internalRedirect();
40                 }
41         }
42 }