add multiple identicon drivers support, add icon field settings, make icons display optional

This commit is contained in:
ghost 2023-08-29 21:51:16 +03:00
parent edf9149654
commit 6bffa1c6b9
3 changed files with 16 additions and 7 deletions

View File

@ -72,6 +72,12 @@ define('MODERATOR_IP_LIST', (array)
// User
define('USER_DEFAULT_APPROVED', false);
define('USER_AUTO_APPROVE_ON_MAGNET_APPROVE', false);
define('USER_AUTO_APPROVE_ON_COMMENT_APPROVE', false);
define('USER_DEFAULT_IDENTICON', 'jidenticon'); // jidenticon|false
define('USER_IDENTICON_FIELD', 'address'); // address|userId|...
// Magnet
define('MAGNET_DEFAULT_APPROVED', USER_DEFAULT_APPROVED);
define('MAGNET_DEFAULT_PUBLIC', false);

View File

@ -31,7 +31,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
switch (isset($_GET['toggle']) ? $_GET['toggle'] : false)
{
case 'identicon':
case 'jidenticon':
// Yggdrasil connections only
if (!preg_match(YGGDRASIL_URL_REGEX, $_SERVER['REMOTE_ADDR']))
@ -62,7 +62,7 @@ switch (isset($_GET['target']) ? urldecode($_GET['target']) : false)
$icon = new Jdenticon\Identicon();
$icon->setValue($user->address);
$icon->setValue($user->{USER_IDENTICON_FIELD});
$icon->setSize(empty($_GET['size']) ? 100 : (int) $_GET['size']);
$icon->setStyle(
[

View File

@ -418,11 +418,14 @@ echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<div class="margin-b-16">
<?php echo nl2br(htmlentities($magnetComment->value)) ?>
</div>
<?php if (USER_DEFAULT_IDENTICON) { ?>
<img class="float-left margin-r-4"
alt=""
src="<?php echo sprintf('%s/action.php?target=profile&toggle=identicon&userId=%s&size=16',
src="<?php echo sprintf('%s/action.php?target=profile&toggle=%s&userId=%s&size=16',
WEBSITE_URL,
USER_DEFAULT_IDENTICON,
$magnetComment->userId) ?>" />
<?php } ?>
<sup>
<?php echo Time::ago((int) $magnetComment->timeAdded) ?>
</sup>