diff --git a/administrator/language/en-GB/en-GB.com_users.ini b/administrator/language/en-GB/en-GB.com_users.ini index e5c68ac8ee3c3..be5bf3fdc7bfb 100644 --- a/administrator/language/en-GB/en-GB.com_users.ini +++ b/administrator/language/en-GB/en-GB.com_users.ini @@ -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" @@ -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" diff --git a/administrator/language/en-GB/en-GB.com_users.sys.ini b/administrator/language/en-GB/en-GB.com_users.sys.ini index c29847dd559b8..14e39127cc46d 100644 --- a/administrator/language/en-GB/en-GB.com_users.sys.ini +++ b/administrator/language/en-GB/en-GB.com_users.sys.ini @@ -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." COM_USERS_XML_DESCRIPTION="Component for managing users." diff --git a/components/com_users/Controller/DisplayController.php b/components/com_users/Controller/DisplayController.php index 919c56c160085..b6cda9ecd3641 100644 --- a/components/com_users/Controller/DisplayController.php +++ b/components/com_users/Controller/DisplayController.php @@ -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; diff --git a/components/com_users/Model/UserModel.php b/components/com_users/Model/UserModel.php new file mode 100644 index 0000000000000..7e5f177b1b563 --- /dev/null +++ b/components/com_users/Model/UserModel.php @@ -0,0 +1,63 @@ +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; + } +} diff --git a/components/com_users/Model/UsersModel.php b/components/com_users/Model/UsersModel.php new file mode 100644 index 0000000000000..8dff795e0153f --- /dev/null +++ b/components/com_users/Model/UsersModel.php @@ -0,0 +1,196 @@ +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); + } +} diff --git a/components/com_users/View/User/HtmlView.php b/components/com_users/View/User/HtmlView.php new file mode 100644 index 0000000000000..6b9de1bcbbc98 --- /dev/null +++ b/components/com_users/View/User/HtmlView.php @@ -0,0 +1,68 @@ +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); + } +} diff --git a/components/com_users/View/Users/HtmlView.php b/components/com_users/View/Users/HtmlView.php new file mode 100644 index 0000000000000..fa64cc354ec4c --- /dev/null +++ b/components/com_users/View/Users/HtmlView.php @@ -0,0 +1,83 @@ +state = $this->get('State'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + + // Get params for active menu + $this->params = Factory::getApplication()->getMenu()->getActive()->getParams(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + parent::display($tpl); + } +} diff --git a/components/com_users/tmpl/user/default.php b/components/com_users/tmpl/user/default.php new file mode 100644 index 0000000000000..ffd4c84ef9d2c --- /dev/null +++ b/components/com_users/tmpl/user/default.php @@ -0,0 +1,26 @@ +item, true); + +if ($fields) +{ + foreach ($fields as $field) + { + $this->item->{$field->label} = $field->value; + } +} +?> +

+ escape($this->item->name); ?> +

diff --git a/components/com_users/tmpl/users/default.php b/components/com_users/tmpl/users/default.php new file mode 100644 index 0000000000000..93edb27983de6 --- /dev/null +++ b/components/com_users/tmpl/users/default.php @@ -0,0 +1,129 @@ +params; +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); + +HTMLHelper::_('behavior.keepalive'); +HTMLHelper::_('behavior.formvalidator'); +?> + +params->get('show_page_heading')) : ?> +

+ escape($this->params->get('page_heading')); ?> +

+ + +items)) : ?> + get('show_no_users', 1)) : ?> +

+ + +
+
+ + + get('show_headings')) : ?> + + + + get('show_last_visited')) : ?> + + + get('show_online_status')) : ?> + + + + + + + items as $i => $item): ?> + + + + get('show_last_visited')) : ?> + + + get('show_online_status')) : ?> + + + + + +
+ , +
+ + + + + + +
+ + escape($item->name); ?> + + + lastvisitDate, + $this->escape( + $params->get('date_format', Text::_('DATE_FORMAT_LC1')) + ) + ); ?> + + time): ?> + + + + + + + + +
+ + + + + + items)) : ?> + params->def('show_pagination', 2) == 1 || ($this->params->get('show_pagination') == 2)) + && ($this->pagination->pagesTotal > 1)) : ?> +
+ params->def('show_pagination_results', 1)) : ?> +

+ pagination->getPagesCounter(); ?> +

+ +
+ pagination->getPagesLinks(); ?> +
+
+ + + +
+ +
diff --git a/components/com_users/tmpl/users/default.xml b/components/com_users/tmpl/users/default.xml new file mode 100644 index 0000000000000..7c9e687f7d77b --- /dev/null +++ b/components/com_users/tmpl/users/default.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
diff --git a/language/en-GB/en-GB.com_users.ini b/language/en-GB/en-GB.com_users.ini index e785f2afbceba..c63733260a3cc 100644 --- a/language/en-GB/en-GB.com_users.ini +++ b/language/en-GB/en-GB.com_users.ini @@ -137,3 +137,9 @@ COM_USERS_USER_FIELD_FRONTEND_LANGUAGE_LABEL="Frontend Language" COM_USERS_USER_FIELD_TIMEZONE_LABEL="Time Zone" COM_USERS_USER_NOT_FOUND="User not found." COM_USERS_USER_SAVE_FAILED="Failed to save user: %s" +COM_USERS_USERS_LASTVISIT="Last Vistited" +COM_USERS_USERS_NAME="Name" +COM_USERS_USERS_NO_USERS="No Users to display" +COM_USERS_USERS_OFFLINE="Offline" +COM_USERS_USERS_ONLINE_STATUS="Online status" +COM_USERS_USERS_ONLINE="Online"