city.php
3 days ago
country.php
3 days ago
currency.php
3 days ago
date.php
3 days ago
empgroup.php
3 days ago
employee.php
3 days ago
group.php
3 days ago
index.html
3 days ago
optiongroup.php
3 days ago
service.php
3 days ago
state.php
3 days ago
user.php
3 days ago
user.php
74 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | /** |
| 15 | * Populate the options array with the existing CMS users, |
| 16 | * in order to support the correct placeholders while |
| 17 | * importing and exporting the records. |
| 18 | * |
| 19 | * @since 1.7 |
| 20 | */ |
| 21 | class ImportColumnUser extends ImportColumn |
| 22 | { |
| 23 | /** |
| 24 | * Users cache. |
| 25 | * |
| 26 | * @var array |
| 27 | */ |
| 28 | private static $users = null; |
| 29 | |
| 30 | /** |
| 31 | * Binds the internal properties with the given array/object. |
| 32 | * |
| 33 | * @param mixed $data Either an array or an object. |
| 34 | * |
| 35 | * @return void |
| 36 | */ |
| 37 | protected function setup($data) |
| 38 | { |
| 39 | // use parent to set up data |
| 40 | parent::setup($data); |
| 41 | |
| 42 | foreach (static::getUsers() as $user) |
| 43 | { |
| 44 | // register user as option |
| 45 | $this->options[$user->id] = $user->username; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Loads a list of available users. |
| 51 | * |
| 52 | * @return array |
| 53 | */ |
| 54 | protected static function getUsers() |
| 55 | { |
| 56 | // load users only once |
| 57 | if (is_null(static::$users)) |
| 58 | { |
| 59 | $dbo = JFactory::getDbo(); |
| 60 | |
| 61 | $q = $dbo->getQuery(true) |
| 62 | ->select($dbo->qn(array('id', 'username'))) |
| 63 | ->from($dbo->qn('#__users')); |
| 64 | |
| 65 | $dbo->setQuery($q); |
| 66 | |
| 67 | // cache users found |
| 68 | static::$users = $dbo->loadObjectList(); |
| 69 | } |
| 70 | |
| 71 | return static::$users; |
| 72 | } |
| 73 | } |
| 74 |