]> git.mxchange.org Git - friendica-addons.git/commitdiff
Fix errors in membersince addon
authorArt4 <art4@wlabs.de>
Sun, 8 Dec 2024 22:49:23 +0000 (22:49 +0000)
committerArt4 <art4@wlabs.de>
Sun, 8 Dec 2024 22:49:23 +0000 (22:49 +0000)
membersince/membersince.php

index 20e41ac978b98077e1da95e17702673bc5ae7bb0..448b8cf2c02372c5bd1f9c2acbfadfbef2b889b0 100644 (file)
@@ -9,6 +9,7 @@
 
 use Friendica\Core\Hook;
 use Friendica\DI;
+use Friendica\Model\User;
 use Friendica\Util\DateTimeFormat;
 
 function membersince_install()
@@ -18,6 +19,18 @@ function membersince_install()
 
 function membersince_display(array &$b)
 {
+       $uid = DI::userSession()->getLocalUserId();
+
+       if ($uid === false) {
+               return;
+       }
+
+       $user = User::getById($uid, ['register_date']);
+
+       if ($user === false || !array_key_exists('register_date', $user)) {
+               return;
+       }
+
        if (DI::appHelper()->getCurrentTheme() == 'frio') {
                // Works in Frio.
                $doc = new DOMDocument();
@@ -38,7 +51,7 @@ function membersince_display(array &$b)
                $label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted');
 
                // The div for the register date of the profile owner.
-               $entry = $doc->createElement('div', DateTimeFormat::local(DI::appHelper()->profile['register_date']));
+               $entry = $doc->createElement('div', DateTimeFormat::local($user['register_date']));
                $entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
 
                $div->appendChild($hr);
@@ -49,6 +62,6 @@ function membersince_display(array &$b)
                $b = $doc->saveHTML();
        } else {
                // Works in Vier.
-               $b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . DI::l10n()->t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local(DI::appHelper()->profile['register_date']) . "</dd>\n</dl>", $b, 1);
+               $b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . DI::l10n()->t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local($user['register_date']) . "</dd>\n</dl>", $b, 1);
        }
 }