CoreFiles by mySites.guru
user.php40 lines, 775 bytes, from Joomla_5.3.3-Stable-Full_Package.zip
Raw History Compare with 5.3.2
md5
fac4fda80f545fec01f0bdb00edbe2e4
sha1
c2441b09e10c1145f146ce2d4e38ff39d1fa8d0a
sha256
4aae28bf6c046b459d6fb23f12f6c28b40e3b25ab6e73af945ee07c1ae630b9e
<?php

/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.User
 *
 * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/** @var \Joomla\CMS\Layout\FileLayout $this */
$value = $field->value;

if ($value == '') {
    return;
}

$value = (array) $value;
$texts = [];

foreach ($value as $userId) {
    if (!$userId) {
        continue;
    }

    $user = $this->getUserFactory()->loadUserById($userId);

    if ($user) {
        // Use the Username
        $texts[] = $user->name;
        continue;
    }

    // Fallback and add the User ID if we get no JUser Object
    $texts[] = $userId;
}

echo htmlentities(implode(', ', $texts));

The same content is in 67 releases, Joomla 5.2.0-alpha1 to 5.4.10. See them all, or every version of this file.