Skip to content

Commit

Permalink
Fix errors in membersince addon
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Dec 8, 2024
1 parent 89a673c commit b99ac65
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions membersince/membersince.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Friendica\Core\Hook;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;

function membersince_install()
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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);
}
}

0 comments on commit b99ac65

Please sign in to comment.