public static array
usersList
(mixed $name, mixed $id, mixed $active, mixed $nouser = 0, mixed $javascript = NULL, mixed $order = 'name', mixed $reg = 1, mixed $returnArray = 0)
/**
* Method to display multiple select box
* @param string $name Name (id, name parameters)
* @param array $active Array of items which will be selected
* @param int $nouser Select no user
* @param string $javascript Add javascript to the select box
* @param string $order Ordering of items
* @param int $reg Only registered users
* @return array of id
*/
public static function usersList($name, $id, $active, $nouser = 0, $javascript = NULL, $order = 'name', $reg = 1, $returnArray = 0)
{
$activeArray = $active;
if ($active != '') {
$activeArray = explode(',', $active);
}
$db = Factory::getDBO();
$and = '';
if ($reg) {
// does not include registered users in the list
$and = ' AND m.group_id != 2';
}
$query = 'SELECT u.id AS value, u.name AS text' . ' FROM #__users AS u' . ' JOIN #__user_usergroup_map AS m ON m.user_id = u.id' . ' WHERE u.block = 0' . $and . ' GROUP BY u.id, u.name' . ' ORDER BY ' . $order;
$db->setQuery($query);
if ($nouser) {
// Access rights (Default open for all)
// Upload and Delete rights (Default closed for all)
$idInput1 = $idInput2 = $idInput3 = $idInput4 = false;
$idText1 = $idText2 = $idText3 = $idText4 = false;
switch ($name) {
case 'jform[accessuserid][]':
$idInput1 = -1;
$idText1 = Text::_('COM_PHOCAGALLERY_ALL_REGISTERED_USERS');
$idInput2 = -2;
$idText2 = Text::_('COM_PHOCAGALLERY_NOBODY');
break;
case 'batch[accessuserid][]':
$idInput4 = -3;
$idText4 = Text::_('COM_PHOCAGALLERY_KEEP_ORIGINAL_ACCESS_RIGHTS_LEVELS');
$idInput3 = 0;
$idText3 = Text::_('COM_PHOCAGALLERY_NOT_SET');
$idInput1 = -1;
$idText1 = Text::_('COM_PHOCAGALLERY_ALL_REGISTERED_USERS');
$idInput2 = -2;
$idText2 = Text::_('COM_PHOCAGALLERY_NOBODY');
break;
case 'jform[default_accessuserid][]':
$idInput3 = 0;
$idText3 = Text::_('COM_PHOCAGALLERY_NOT_SET');
$idInput1 = -1;
$idText1 = Text::_('COM_PHOCAGALLERY_ALL_REGISTERED_USERS');
$idInput2 = -2;
$idText2 = Text::_('COM_PHOCAGALLERY_NOBODY');
break;
default:
$idInput1 = -2;
$idText1 = Text::_('COM_PHOCAGALLERY_NOBODY');
$idInput2 = -1;
$idText2 = Text::_('COM_PHOCAGALLERY_ALL_REGISTERED_USERS');
break;
}
$users = array();
if ($idText4) {
$users[] = HTMLHelper::_('select.option', $idInput4, '- ' . $idText4 . ' -');
}
if ($idText3) {
$users[] = HTMLHelper::_('select.option', $idInput3, '- ' . $idText3 . ' -');
}
$users[] = HTMLHelper::_('select.option', $idInput1, '- ' . $idText1 . ' -');
$users[] = HTMLHelper::_('select.option', $idInput2, '- ' . $idText2 . ' -');
$users = array_merge($users, $db->loadObjectList());
} else {
$users = $db->loadObjectList();
}
if ($returnArray == 1) {
return $users;
}
$users = HTMLHelper::_('select.genericlist', $users, $name, 'class="form-control" size="4" multiple="multiple"' . $javascript, 'value', 'text', $activeArray, $id);
return $users;
}