CoreFiles by mySites.guru
LogcreatorField.php82 lines, 2,200 bytes, from Joomla_6.2.0-Stable-Full_Package.zip
Raw History Compare with 6.1.4
md5
ff4eb252c1e0dc2ffb8c2b057ad1ad04
sha1
f538880190d87c113bd1d6fb777ef47d10759f3c
sha256
01c9c9983aefe92a3357a83fd59e5c932cafafbbcc8e29157881e5f994db1294
<?php

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

namespace Joomla\Component\Actionlogs\Administrator\Field;

use Joomla\CMS\Form\Field\ListField;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Field to load a list of all users that have logged actions
 *
 * @since  3.9.0
 *
 * @deprecated  5.3  will be removed in 7.0 without replacement
 */
class LogcreatorField extends ListField
{
    /**
     * Cached array of the category items.
     *
     * @var    array
     * @since  3.9.0
     */
    protected static $options = [];

    /**
     * The form field type.
     *
     * @var    string
     * @since  3.9.0
     */
    protected $type = 'LogCreator';

    /**
     * Method to get the options to populate list
     *
     * @return  array  The field option objects.
     *
     * @since   3.9.0
     */
    protected function getOptions()
    {
        // Accepted modifiers
        $hash = md5($this->element);

        if (!isset(static::$options[$hash])) {
            static::$options[$hash] = parent::getOptions();

            $db = $this->getDatabase();

            // Construct the query
            $query = $db->createQuery()
                ->select($db->quoteName('u.id', 'value'))
                ->select($db->quoteName('u.username', 'text'))
                ->from($db->quoteName('#__users', 'u'))
                ->join('INNER', $db->quoteName('#__action_logs', 'c') . ' ON ' . $db->quoteName('c.user_id') . ' = ' . $db->quoteName('u.id'))
                ->group($db->quoteName('u.id'))
                ->group($db->quoteName('u.username'))
                ->order($db->quoteName('u.username'));

            // Setup the query
            $db->setQuery($query);

            // Return the result
            if ($options = $db->loadObjectList()) {
                static::$options[$hash] = array_merge(static::$options[$hash], $options);
            }
        }

        return static::$options[$hash];
    }
}

The same content is in 46 releases, Joomla 6.0.0-rc1 to 6.3.0-alpha1. See them all, or every version of this file.