Fix errors in membersince addon

This commit is contained in:
Art4 2024-12-08 22:49:23 +00:00
parent 89a673cc11
commit b99ac65c0b

View 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);
}
}