Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions administrator/language/en-GB/en-GB.com_users.ini
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ COM_USERS_OPTION_LEVEL_DEEPER="%d (deeper)"
COM_USERS_OPTION_SELECT_COMPONENT="- Select Component -"
COM_USERS_OPTION_SELECT_LEVEL_END="- Select End Level -"
COM_USERS_OPTION_SELECT_LEVEL_START="- Select Start Level -"
COM_USERS_PARAMS_SELECT_GROUPS="Select Groups"
COM_USERS_PARAMS_SHOW_LAST_VISITED="Last Visited Date"
COM_USERS_PARAMS_SHOW_ONLINE_STATUS="Online Status"
COM_USERS_PASSWORD_RESET_REQUIRED="Password Reset Required"
COM_USERS_N_QUICKICON="Users"
COM_USERS_N_QUICKICON_1="User"
Expand All @@ -274,6 +277,7 @@ COM_USERS_SUBMENU_NOTES="User Notes"
COM_USERS_SUBMENU_NOTE_CATEGORIES="User Note Categories"
COM_USERS_SUBMENU_USERS="Users"
COM_USERS_SUBJECT_HEADING="Subject"
COM_USERS_TAB="Users View"
COM_USERS_TFA_ACTIVE="Uses Two Factor Authentication"
COM_USERS_TFA_NOTACTIVE="Does not use Two Factor Authentication"
COM_USERS_TOOLBAR_ACTIVATE="Activate"
Expand Down
6 changes: 4 additions & 2 deletions administrator/language/en-GB/en-GB.com_users.sys.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ COM_USERS_RESET_VIEW_DEFAULT_DESC="Displays a request to reset password."
COM_USERS_RESET_VIEW_DEFAULT_OPTION="Default"
COM_USERS_RESET_VIEW_DEFAULT_TITLE="Password Reset"
COM_USERS_TAGS_CATEGORY="User Note Category"
COM_USERS_USERS_VIEW_DEFAULT_DESC="Shows a List of Users"
COM_USERS_USERS_VIEW_DEFAULT_TITLE="Users"
COM_USERS_USER_VIEW_EDIT_DESC="Shows a form to create a new User Account"
COM_USERS_USER_VIEW_EDIT_TITLE="Create User"
COM_USERS_USERS_VIEW_DEFAULT_DESC="Shows a List of Users"
COM_USERS_USERS_VIEW_DEFAULT_TITLE="Users"
COM_USERS_USERS_GROUP_VIEW_DEFAULT="List Users"
COM_USERS_USERS_GROUP_VIEW_DEFAULT_DESC="Displays a list of Users of a Group."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
COM_USERS_USERS_GROUP_VIEW_DEFAULT_DESC="Displays a list of Users of a Group."
COM_USERS_USERS_GROUP_VIEW_DEFAULT_DESC="Displays a list of Users from a Group."

COM_USERS_XML_DESCRIPTION="Component for managing users."
10 changes: 10 additions & 0 deletions components/com_users/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public function display($cachable = false, $urlparams = false)
$model = $this->getModel($vName);
break;

case 'users':
// If we just want to show the Users overview
$model = $this->getModel($vName);
break;

case 'user':
// If we just want to show the single User
$model = $this->getModel($vName);
break;

default:
$model = $this->getModel('Login');
break;
Expand Down
63 changes: 63 additions & 0 deletions components/com_users/Model/UserModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Users\Site\Model;

defined('_JEXEC') or die;

use Exception;
use Joomla\CMS\MVC\Model\ItemModel;
use Joomla\Database\ParameterType;

/**
* This models retrieves some data of a User.
*
* @since __DEPLOY_VERSION__
*/
class UserModel extends ItemModel
{
/**
* Load the User data.
*
* @param integer $id ID of User
*
* @return object The product information.
* @throws Exception
* @since __DEPLOY_VERSION__
*/
public function getItem($id = null)
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select(
$db->quoteName(
array(
'users.id',
'users.name',
'users.username',
'users.email',
'users.registerDate',
'users.lastvisitDate'
)
)
)
->from($db->quoteName('#__users', 'users'))
->where($db->quoteName('users.block') . ' = 0')
->where($db->quoteName('users.id') . ' = :user_id')
->leftJoin(
$db->quoteName('#__session', 'session')
. ' ON ' . $db->quoteName('session.userid') . ' = ' . $db->quoteName('users.id')
)
->bind(':user_id', $id, ParameterType::INTEGER);
$db->setQuery($query);
$item = $db->loadObject();

return $item;
}
}
196 changes: 196 additions & 0 deletions components/com_users/Model/UsersModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Users\Site\Model;

defined('_JEXEC') or die;

use Exception;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Database\ParameterType;
use Joomla\Utilities\ArrayHelper;

/**
* This models supports retrieving a list of users.
*
* @since __DEPLOY_VERSION__
*/
class UsersModel extends ListModel
{
/**
* User items data
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $item = null;

/**
* Constructor
*
* @param array $config An optional associative array of configuration settings.
*
* @throws Exception
* @since __DEPLOY_VERSION__
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'users.id',
'name', 'users.name',
'username', 'users.username',
'email', 'users.email',
'registerDate', 'users.registerDate',
'lastvisitDate', 'users.lastvisitDate',
'session.time'
);
}

parent::__construct($config);
}

/**
* Method to get a list of items.
*
* @return mixed An array of objects on success, false on failure.
* @since __DEPLOY_VERSION__
*/
public function getItems()
{
// Invoke the parent getItems method to get the main list
$items = parent::getItems();

return $items;
}

/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
* @throws Exception
* @since __DEPLOY_VERSION__
*/
protected function getListQuery()
{
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
$menuParams = $menu->getParams($itemId);
$groupIds = $menuParams->get('groups', 0, 'array');

$db = $this->getDbo();
$query = $db->getQuery(true);

// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
$db->quoteName(
array(
'users.id',
'users.name',
'users.username',
'users.email',
'users.registerDate',
'users.lastvisitDate'
)
)
)
)
->from($db->quoteName('#__users', 'users'))
->leftJoin(
$db->quoteName('#__user_usergroup_map', 'usergroupmap')
. ' ON ' . $db->quoteName('usergroupmap.user_id') . ' = ' . $db->quoteName('users.id')
)
->leftJoin(
$db->quoteName('#__session', 'session')
. ' ON ' . $db->quoteName('session.userid') . ' = ' . $db->quoteName('users.id')
)
->select($db->quoteName('session.time'))
->where($db->quoteName('users.block') . ' = 0')
->group($db->quoteName('users.id'))
->order(
$this->getState('list.ordering', 'users.name') . ' ' .
$this->getState('list.direction', 'ASC')
);

if (is_numeric($groupIds))
{
$query->where($db->quoteName('usergroupmap.group_id') . ' = :group_id')
->bind(':group_id', $groupIds, ParameterType::INTEGER);
}
elseif (is_array($groupIds) && (count($groupIds) > 0))
{
$groupIds = ArrayHelper::toInteger($groupIds);

$query->whereIn(
$db->quoteName('usergroupmap.group_id'), $groupIds
);
}

// Add the list ordering clause
$query->order(
$this->getState('list.ordering', 'users.name') . ' '
. $this->getState('list.direction', 'ASC')
);

return $query;
}

/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
* @throws Exception
* @since __DEPLOY_VERSION__
*/
protected function populateState($ordering = null, $direction = null)
{
$app = Factory::getApplication();
$params = ComponentHelper::getParams('com_users');

// List state information
$value = $app->input->get('limit', $app->get('list_limit', 0), 'uint');
$this->setState('list.limit', $value);

$value = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $value);

$orderCol = $app->input->get('filter_order', 'users.name');

if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = 'users.id';
}

$this->setState('list.ordering', $orderCol);

$listOrder = $app->input->get('filter_order_Dir', 'ASC');

if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{
$listOrder = 'ASC';
}

$this->setState('list.direction', $listOrder);

// Load the parameters.
$this->setState('params', $params);
}
}
68 changes: 68 additions & 0 deletions components/com_users/View/User/HtmlView.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Users\Site\View\User;

defined('_JEXEC') or die;

use Exception;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\Component\Users\Site\Model\UserModel;

/**
* View class for Single User
*
* @since __DEPLOY_VERSION__
*/
class HtmlView extends BaseHtmlView
{
/**
* The User data
*
* @var object
* @since __DEPLOY_VERSION__
*/
protected $item;

/**
* The model state
*
* @var Joomla\Registry\Registry
* @since __DEPLOY_VERSION__
*/
protected $state;

/**
* Method to display the view.
*
* @param string $tpl The template file to include
*
* @return void
* @throws Exception
* @since __DEPLOY_VERSION__
*/
public function display($tpl = null)
{
$authorId = Factory::getApplication()->input->getInt('id');

/** @var UserModel $model */
$model = $this->getModel();
$this->state = $model->getState();
$this->item = $model->getItem($authorId);

// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}

parent::display($tpl);
}
}
Loading