]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Settings/TwoFactor/Trusted.php
Merge pull request #11141 from urbalazs/language-names
[friendica.git] / src / Module / Settings / TwoFactor / Trusted.php
index e38d64ac0476ba5ced01ecc02f00136a7611b2b6..12327a5918961af3875de186faa5d6b48acb23f7 100644 (file)
@@ -1,14 +1,37 @@
 <?php
+/**
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\Module\Settings\TwoFactor;
 
-use Friendica\App\BaseURL;
+use Friendica\App;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
 use Friendica\Core\Renderer;
 use Friendica\Module\BaseSettings;
+use Friendica\Module\Response;
 use Friendica\Security\TwoFactor;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Profiler;
 use Friendica\Util\Temporal;
+use Psr\Log\LoggerInterface;
 use UAParser\Parser;
 
 /**
@@ -18,17 +41,14 @@ class Trusted extends BaseSettings
 {
        /** @var IManagePersonalConfigValues */
        protected $pConfig;
-       /** @var BaseURL */
-       protected $baseUrl;
        /** @var TwoFactor\Repository\TrustedBrowser */
        protected $trustedBrowserRepo;
 
-       public function __construct(IManagePersonalConfigValues $pConfig, BaseURL $baseUrl, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepo, L10n $l10n, array $parameters = [])
+       public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManagePersonalConfigValues $pConfig, TwoFactor\Repository\TrustedBrowser $trustedBrowserRepo, array $server, array $parameters = [])
        {
-               parent::__construct($l10n, $parameters);
+               parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
                $this->pConfig            = $pConfig;
-               $this->baseUrl            = $baseUrl;
                $this->trustedBrowserRepo = $trustedBrowserRepo;
 
                if (!local_user()) {
@@ -47,7 +67,7 @@ class Trusted extends BaseSettings
                }
        }
 
-       public function post()
+       protected function post(array $request = [])
        {
                if (!local_user()) {
                        return;
@@ -77,7 +97,7 @@ class Trusted extends BaseSettings
        }
 
 
-       public function content(): string
+       protected function content(array $request = []): string
        {
                parent::content();
 
@@ -87,8 +107,12 @@ class Trusted extends BaseSettings
 
                $trustedBrowserDisplay = array_map(function (TwoFactor\Model\TrustedBrowser $trustedBrowser) use ($parser) {
                        $dates = [
-                               'created_ago' => Temporal::getRelativeDate($trustedBrowser->created),
-                               'last_used_ago' => Temporal::getRelativeDate($trustedBrowser->last_used),
+                               'created_ago'     => Temporal::getRelativeDate($trustedBrowser->created),
+                               'created_utc'     => DateTimeFormat::utc($trustedBrowser->created, 'c'),
+                               'created_local'   => DateTimeFormat::local($trustedBrowser->created, 'r'),
+                               'last_used_ago'   => Temporal::getRelativeDate($trustedBrowser->last_used),
+                               'last_used_utc'   => $trustedBrowser->last_used ? DateTimeFormat::utc($trustedBrowser->last_used, 'c') : '',
+                               'last_used_local' => $trustedBrowser->last_used ? DateTimeFormat::local($trustedBrowser->last_used, 'r') : '',
                        ];
 
                        $result = $parser->parse($trustedBrowser->user_agent);