Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
access.xml000064400000005200151160243100006515 0ustar00<?xml
version="1.0" encoding="utf-8" ?>
<access component="com_users">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN"
description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.options"
title="JACTION_OPTIONS"
description="JACTION_OPTIONS_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE"
description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE"
description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE"
description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT"
description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state"
title="JACTION_EDITSTATE"
description="JACTION_EDITSTATE_COMPONENT_DESC" />
<action name="core.edit.value"
title="JACTION_EDITVALUE"
description="JACTION_EDITVALUE_COMPONENT_DESC" />
</section>
<section name="category">
<action name="core.create" title="JACTION_CREATE"
description="COM_CATEGORIES_ACCESS_CREATE_DESC" />
<action name="core.delete" title="JACTION_DELETE"
description="COM_CATEGORIES_ACCESS_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT"
description="COM_CATEGORIES_ACCESS_EDIT_DESC" />
<action name="core.edit.state"
title="JACTION_EDITSTATE"
description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />
<action name="core.edit.own"
title="JACTION_EDITOWN"
description="COM_CATEGORIES_ACCESS_EDITOWN_DESC" />
</section>
<section name="fieldgroup">
<action name="core.create" title="JACTION_CREATE"
description="COM_FIELDS_GROUP_PERMISSION_CREATE_DESC" />
<action name="core.delete" title="JACTION_DELETE"
description="COM_FIELDS_GROUP_PERMISSION_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT"
description="COM_FIELDS_GROUP_PERMISSION_EDIT_DESC" />
<action name="core.edit.state"
title="JACTION_EDITSTATE"
description="COM_FIELDS_GROUP_PERMISSION_EDITSTATE_DESC" />
<action name="core.edit.own"
title="JACTION_EDITOWN"
description="COM_FIELDS_GROUP_PERMISSION_EDITOWN_DESC" />
<action name="core.edit.value"
title="JACTION_EDITVALUE"
description="COM_FIELDS_GROUP_PERMISSION_EDITVALUE_DESC" />
</section>
<section name="field">
<action name="core.delete" title="JACTION_DELETE"
description="COM_FIELDS_FIELD_PERMISSION_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT"
description="COM_FIELDS_FIELD_PERMISSION_EDIT_DESC" />
<action name="core.edit.state"
title="JACTION_EDITSTATE"
description="COM_FIELDS_FIELD_PERMISSION_EDITSTATE_DESC" />
<action name="core.edit.value"
title="JACTION_EDITVALUE"
description="COM_FIELDS_FIELD_PERMISSION_EDITVALUE_DESC" />
</section>
</access>
config.xml000064400000020120151160243100006517 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<config>
<fieldset
name="user_options"
label="COM_USERS_CONFIG_USER_OPTIONS" >
<field
name="allowUserRegistration"
type="radio"
label="COM_USERS_CONFIG_FIELD_ALLOWREGISTRATION_LABEL"
description="COM_USERS_CONFIG_FIELD_ALLOWREGISTRATION_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="new_usertype"
type="usergrouplist"
label="COM_USERS_CONFIG_FIELD_NEW_USER_TYPE_LABEL"
description="COM_USERS_CONFIG_FIELD_NEW_USER_TYPE_DESC"
default="2"
checksuperusergroup="1"
/>
<field
name="guest_usergroup"
type="usergrouplist"
label="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_LABEL"
description="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_DESC"
default="1"
checksuperusergroup="1"
/>
<field
name="sendpassword"
type="radio"
label="COM_USERS_CONFIG_FIELD_SENDPASSWORD_LABEL"
description="COM_USERS_CONFIG_FIELD_SENDPASSWORD_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="useractivation"
type="list"
label="COM_USERS_CONFIG_FIELD_USERACTIVATION_LABEL"
description="COM_USERS_CONFIG_FIELD_USERACTIVATION_DESC"
default="2"
>
<option value="0">JNONE</option>
<option
value="1">COM_USERS_CONFIG_FIELD_USERACTIVATION_OPTION_SELFACTIVATION</option>
<option
value="2">COM_USERS_CONFIG_FIELD_USERACTIVATION_OPTION_ADMINACTIVATION</option>
</field>
<field
name="mail_to_admin"
type="radio"
label="COM_USERS_CONFIG_FIELD_MAILTOADMIN_LABEL"
description="COM_USERS_CONFIG_FIELD_MAILTOADMIN_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="captcha"
type="plugins"
label="COM_USERS_CONFIG_FIELD_CAPTCHA_LABEL"
description="COM_USERS_CONFIG_FIELD_CAPTCHA_DESC"
folder="captcha"
filter="cmd"
useglobal="true"
>
<option value="0">JOPTION_DO_NOT_USE</option>
</field>
<field
name="frontend_userparams"
type="radio"
label="COM_USERS_CONFIG_FIELD_FRONTEND_USERPARAMS_LABEL"
description="COM_USERS_CONFIG_FIELD_FRONTEND_USERPARAMS_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="site_language"
type="radio"
label="COM_USERS_CONFIG_FIELD_FRONTEND_LANG_LABEL"
description="COM_USERS_CONFIG_FIELD_FRONTEND_LANG_DESC"
class="btn-group btn-group-yesno"
default="0"
showon="frontend_userparams:1"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
<field
name="change_login_name"
type="radio"
label="COM_USERS_CONFIG_FIELD_CHANGEUSERNAME_LABEL"
description="COM_USERS_CONFIG_FIELD_CHANGEUSERNAME_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset
name="domain_options"
label="COM_USERS_CONFIG_DOMAIN_OPTIONS"
>
<field
name="domains"
type="subform"
label="COM_USERS_CONFIG_FIELD_DOMAINS_LABEL"
description="COM_USERS_CONFIG_FIELD_DOMAINS_DESC"
multiple="true"
layout="joomla.form.field.subform.repeatable-table"
formsource="administrator/components/com_users/models/forms/config_domain.xml"
/>
</fieldset>
<fieldset
name="password_options"
label="COM_USERS_CONFIG_PASSWORD_OPTIONS" >
<field
name="reset_count"
type="integer"
label="COM_USERS_CONFIG_FIELD_FRONTEND_RESET_COUNT_LABEL"
description="COM_USERS_CONFIG_FIELD_FRONTEND_RESET_COUNT_DESC"
first="0"
last="20"
step="1"
default="10"
/>
<field
name="reset_time"
type="integer"
label="COM_USERS_CONFIG_FIELD_FRONTEND_RESET_TIME_LABEL"
description="COM_USERS_CONFIG_FIELD_FRONTEND_RESET_TIME_DESC"
first="1"
last="24"
step="1"
default="1"
/>
<field
name="minimum_length"
type="integer"
label="COM_USERS_CONFIG_FIELD_MINIMUM_PASSWORD_LENGTH"
description="COM_USERS_CONFIG_FIELD_MINIMUM_PASSWORD_LENGTH_DESC"
first="4"
last="99"
step="1"
default="4"
/>
<field
name="minimum_integers"
type="integer"
label="COM_USERS_CONFIG_FIELD_MINIMUM_INTEGERS"
description="COM_USERS_CONFIG_FIELD_MINIMUM_INTEGERS_DESC"
first="0"
last="98"
step="1"
default="0"
/>
<field
name="minimum_symbols"
type="integer"
label="COM_USERS_CONFIG_FIELD_MINIMUM_SYMBOLS"
description="COM_USERS_CONFIG_FIELD_MINIMUM_SYMBOLS_DESC"
first="0"
last="98"
step="1"
default="0"
/>
<field
name="minimum_uppercase"
type="integer"
label="COM_USERS_CONFIG_FIELD_MINIMUM_UPPERCASE"
description="COM_USERS_CONFIG_FIELD_MINIMUM_UPPERCASE_DESC"
first="0"
last="98"
step="1"
default="0"
/>
<field
name="minimum_lowercase"
type="integer"
label="COM_USERS_CONFIG_FIELD_MINIMUM_LOWERCASE"
description="COM_USERS_CONFIG_FIELD_MINIMUM_LOWERCASE_DESC"
first="0"
last="98"
step="1"
default="0"
/>
</fieldset>
<fieldset
name="user_notes_history"
label="COM_USERS_CONFIG_FIELD_NOTES_HISTORY" >
<field
name="save_history"
type="radio"
label="JGLOBAL_SAVE_HISTORY_OPTIONS_LABEL"
description="JGLOBAL_SAVE_HISTORY_OPTIONS_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="history_limit"
type="number"
label="JGLOBAL_HISTORY_LIMIT_OPTIONS_LABEL"
description="JGLOBAL_HISTORY_LIMIT_OPTIONS_DESC"
filter="integer"
default="5"
showon="save_history:1"
/>
</fieldset>
<fieldset
name="massmail"
label="COM_USERS_MASS_MAIL"
description="COM_USERS_MASS_MAIL_DESC">
<field
name="mailSubjectPrefix"
type="text"
label="COM_USERS_CONFIG_FIELD_SUBJECT_PREFIX_LABEL"
description="COM_USERS_CONFIG_FIELD_SUBJECT_PREFIX_DESC"
/>
<field
name="mailBodySuffix"
type="textarea"
label="COM_USERS_CONFIG_FIELD_MAILBODY_SUFFIX_LABEL"
description="COM_USERS_CONFIG_FIELD_MAILBODY_SUFFIX_DESC"
rows="5"
cols="30"
/>
</fieldset>
<fieldset
name="debug"
label="COM_USERS_DEBUG_LABEL"
description="COM_USERS_DEBUG_DESC">
<field
name="debugUsers"
type="radio"
label="COM_USERS_DEBUG_USERS_LABEL"
description="COM_USERS_DEBUG_USERS_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="debugGroups"
type="radio"
label="COM_USERS_DEBUG_GROUPS_LABEL"
description="COM_USERS_DEBUG_GROUPS_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset name="integration"
label="JGLOBAL_INTEGRATION_LABEL"
description="COM_USERS_CONFIG_INTEGRATION_SETTINGS_DESC"
>
<field
name="integration_sef"
type="note"
label="JGLOBAL_SEF_TITLE"
/>
<field
name="sef_advanced"
type="radio"
class="btn-group btn-group-yesno btn-group-reversed"
default="0"
label="JGLOBAL_SEF_ADVANCED_LABEL"
description="JGLOBAL_SEF_ADVANCED_DESC"
filter="integer"
>
<option
value="0">JGLOBAL_SEF_ADVANCED_LEGACY</option>
<option
value="1">JGLOBAL_SEF_ADVANCED_MODERN</option>
</field>
<field
name="integration_customfields"
type="note"
label="JGLOBAL_FIELDS_TITLE"
/>
<field
name="custom_fields_enable"
type="radio"
label="JGLOBAL_CUSTOM_FIELDS_ENABLE_LABEL"
description="JGLOBAL_CUSTOM_FIELDS_ENABLE_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC"
>
<field
name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
filter="rules"
validate="rules"
component="com_users"
section="component"
/>
</fieldset>
</config>
controller.php000064400000006212151160243100007432 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users master display controller.
*
* @since 1.6
*/
class UsersController extends JControllerLegacy
{
/**
* Checks whether a user can see this view.
*
* @param string $view The view name.
*
* @return boolean
*
* @since 1.6
*/
protected function canView($view)
{
$canDo = JHelperContent::getActions('com_users');
switch ($view)
{
// Special permissions.
case 'groups':
case 'group':
case 'levels':
case 'level':
return $canDo->get('core.admin');
break;
// Default permissions.
default:
return true;
}
}
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe URL parameters and their
variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
$view = $this->input->get('view', 'users');
$layout = $this->input->get('layout',
'default');
$id = $this->input->getInt('id');
if (!$this->canView($view))
{
throw new
JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'),
403);
}
// Check for edit form.
if ($view == 'user' && $layout == 'edit'
&& !$this->checkEditId('com_users.edit.user', $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID',
$id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=users',
false));
return false;
}
elseif ($view == 'group' && $layout == 'edit'
&& !$this->checkEditId('com_users.edit.group', $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID',
$id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=groups',
false));
return false;
}
elseif ($view == 'level' && $layout == 'edit'
&& !$this->checkEditId('com_users.edit.level', $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID',
$id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=levels',
false));
return false;
}
elseif ($view == 'note' && $layout == 'edit'
&& !$this->checkEditId('com_users.edit.note', $id))
{
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID',
$id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=notes',
false));
return false;
}
return parent::display();
}
}
controllers/group.php000064400000003172151160243100010753 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User view level controller class.
*
* @since 1.6
*/
class UsersControllerGroup extends JControllerForm
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_USERS_GROUP';
/**
* Method to check if you can save a new or existing record.
*
* Overrides JControllerForm::allowSave to check the core.admin
permission.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowSave($data, $key = 'id')
{
return (JFactory::getUser()->authorise('core.admin',
$this->option) && parent::allowSave($data, $key));
}
/**
* Overrides JControllerForm::allowEdit
*
* Checks that non-Super Admins are not editing Super Admins.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check if this group is a Super Admin
if (JAccess::checkGroup($data[$key], 'core.admin'))
{
// If I'm not a Super Admin, then disallow the edit.
if (!JFactory::getUser()->authorise('core.admin'))
{
return false;
}
}
return parent::allowEdit($data, $key);
}
}
controllers/groups.php000064400000005727151160243100011146 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User groups list controller class.
*
* @since 1.6
*/
class UsersControllerGroups extends JControllerAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_USERS_GROUPS';
/**
* Proxy for getModel.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'Group', $prefix =
'UsersModel', $config = array())
{
return parent::getModel($name, $prefix, array('ignore_request'
=> true));
}
/**
* Removes an item.
*
* Overrides JControllerAdmin::delete to check the core.admin permission.
*
* @return boolean Returns true on success, false on failure.
*
* @since 1.6
*/
public function delete()
{
if (!JFactory::getUser()->authorise('core.admin',
$this->option))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
jexit();
}
return parent::delete();
}
/**
* Method to publish a list of records.
*
* Overrides JControllerAdmin::publish to check the core.admin permission.
*
* @return void
*
* @since 1.6
*/
public function publish()
{
if (!JFactory::getUser()->authorise('core.admin',
$this->option))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
jexit();
}
return parent::publish();
}
/**
* Changes the order of one or more records.
*
* Overrides JControllerAdmin::reorder to check the core.admin permission.
*
* @return boolean True on success
*
* @since 1.6
*/
public function reorder()
{
if (!JFactory::getUser()->authorise('core.admin',
$this->option))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
jexit();
}
return parent::reorder();
}
/**
* Method to save the submitted ordering values for records.
*
* Overrides JControllerAdmin::saveorder to check the core.admin
permission.
*
* @return boolean True on success
*
* @since 1.6
*/
public function saveorder()
{
if (!JFactory::getUser()->authorise('core.admin',
$this->option))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
jexit();
}
return parent::saveorder();
}
/**
* Check in of one or more records.
*
* Overrides JControllerAdmin::checkin to check the core.admin permission.
*
* @return boolean True on success
*
* @since 1.6
*/
public function checkin()
{
if (!JFactory::getUser()->authorise('core.admin',
$this->option))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
jexit();
}
return parent::checkin();
}
}
controllers/level.php000064400000006066151160243100010733 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* User view level controller class.
*
* @since 1.6
*/
class UsersControllerLevel extends JControllerForm
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_USERS_LEVEL';
/**
* Method to check if you can save a new or existing record.
*
* Overrides JControllerForm::allowSave to check the core.admin
permission.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowSave($data, $key = 'id')
{
return (JFactory::getUser()->authorise('core.admin',
$this->option) && parent::allowSave($data, $key));
}
/**
* Overrides JControllerForm::allowEdit
*
* Checks that non-Super Admins are not editing Super Admins.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 3.8.8
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Get user instance
$user = JFactory::getUser();
// Check for if Super Admin can edit
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__viewlevels'))
->where($db->quoteName('id') . ' = ' . (int)
$data['id']);
$db->setQuery($query);
$viewlevel = $db->loadAssoc();
// Decode level groups
$groups = json_decode($viewlevel['rules']);
// If this group is super admin and this user is not super admin, canEdit
is false
if (!$user->authorise('core.admin') &&
JAccess::checkGroup($groups[0], 'core.admin'))
{
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'));
return false;
}
return parent::allowEdit($data, $key);
}
/**
* Removes an item.
*
* Overrides JControllerAdmin::delete to check the core.admin permission.
*
* @return boolean Returns true on success, false on failure.
*
* @since 1.6
*/
public function delete()
{
// Check for request forgeries.
$this->checkToken();
$ids = $this->input->get('cid', array(),
'array');
if (!JFactory::getUser()->authorise('core.admin',
$this->option))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
jexit();
}
elseif (empty($ids))
{
JError::raiseWarning(500,
JText::_('COM_USERS_NO_LEVELS_SELECTED'));
}
else
{
// Get the model.
$model = $this->getModel();
$ids = ArrayHelper::toInteger($ids);
// Remove the items.
if (!$model->delete($ids))
{
JError::raiseWarning(500, $model->getError());
}
else
{
$this->setMessage(JText::plural('COM_USERS_N_LEVELS_DELETED',
count($ids)));
}
}
$this->setRedirect('index.php?option=com_users&view=levels');
}
}
controllers/levels.php000064400000001735151160243100011114 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User view levels list controller class.
*
* @since 1.6
*/
class UsersControllerLevels extends JControllerAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_USERS_LEVELS';
/**
* Proxy for getModel.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'Level', $prefix =
'UsersModel', $config = array())
{
return parent::getModel($name, $prefix, array('ignore_request'
=> true));
}
}
controllers/mail.php000064400000002424151160243100010540 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users mail controller.
*
* @since 1.6
*/
class UsersControllerMail extends JControllerLegacy
{
/**
* Send the mail
*
* @return void
*
* @since 1.6
*/
public function send()
{
// Redirect to admin index if mass mailer disabled in conf
if (JFactory::getApplication()->get('massmailoff', 0) == 1)
{
JFactory::getApplication()->redirect(JRoute::_('index.php',
false));
}
// Check for request forgeries.
$this->checkToken('request');
$model = $this->getModel('Mail');
if ($model->send())
{
$type = 'message';
}
else
{
$type = 'error';
}
$msg = $model->getError();
$this->setRedirect('index.php?option=com_users&view=mail',
$msg, $type);
}
/**
* Cancel the mail
*
* @return void
*
* @since 1.6
*/
public function cancel()
{
// Check for request forgeries.
$this->checkToken('request');
// Clear data from session.
\JFactory::getApplication()->setUserState('com_users.display.mail.data',
null);
$this->setRedirect('index.php');
}
}
controllers/note.php000064400000002140151160243100010556 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User note controller class.
*
* @since 2.5
*/
class UsersControllerNote extends JControllerForm
{
/**
* The prefix to use with controller messages.
*
* @var string
* @since 2.5
*/
protected $text_prefix = 'COM_USERS_NOTE';
/**
* Gets the URL arguments to append to an item redirect.
*
* @param integer $recordId The primary key id for the item.
* @param string $key The name of the primary key variable.
*
* @return string The arguments to append to the redirect URL.
*
* @since 2.5
*/
protected function getRedirectToItemAppend($recordId = null, $key =
'id')
{
$append = parent::getRedirectToItemAppend($recordId, $key);
$userId = JFactory::getApplication()->input->get('u_id',
0, 'int');
if ($userId)
{
$append .= '&u_id=' . $userId;
}
return $append;
}
}
controllers/notes.php000064400000001766151160243100010756 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User notes controller class.
*
* @since 2.5
*/
class UsersControllerNotes extends JControllerAdmin
{
/**
* The prefix to use with controller messages.
*
* @var string
* @since 2.5
*/
protected $text_prefix = 'COM_USERS_NOTES';
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 2.5
*/
public function getModel($name = 'Note', $prefix =
'UsersModel', $config = array('ignore_request' =>
true))
{
return parent::getModel($name, $prefix, $config);
}
}
controllers/user.php000064400000003763151160243100010603 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User controller class.
*
* @since 1.6
*/
class UsersControllerUser extends JControllerForm
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_USERS_USER';
/**
* Overrides JControllerForm::allowEdit
*
* Checks that non-Super Admins are not editing Super Admins.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean True if allowed, false otherwise.
*
* @since 1.6
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Check if this person is a Super Admin
if (JAccess::check($data[$key], 'core.admin'))
{
// If I'm not a Super Admin, then disallow the edit.
if (!JFactory::getUser()->authorise('core.admin'))
{
return false;
}
}
return parent::allowEdit($data, $key);
}
/**
* Method to run batch operations.
*
* @param object $model The model.
*
* @return boolean True on success, false on failure
*
* @since 2.5
*/
public function batch($model = null)
{
$this->checkToken();
// Set the model
$model = $this->getModel('User', '', array());
// Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_users&view=users'
. $this->getRedirectToListAppend(), false));
return parent::batch($model);
}
/**
* Function that allows child controller access to model data after the
data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 3.1
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
return;
}
}
controllers/users.php000064400000006004151160243100010755 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Users list controller class.
*
* @since 1.6
*/
class UsersControllerUsers extends JControllerAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_USERS_USERS';
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 1.6
* @see JController
*/
public function __construct($config = array())
{
parent::__construct($config);
$this->registerTask('block', 'changeBlock');
$this->registerTask('unblock', 'changeBlock');
}
/**
* Proxy for getModel.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'User', $prefix =
'UsersModel', $config = array('ignore_request' =>
true))
{
return parent::getModel($name, $prefix, $config);
}
/**
* Method to change the block status on a record.
*
* @return void
*
* @since 1.6
*/
public function changeBlock()
{
// Check for request forgeries.
$this->checkToken();
$ids = $this->input->get('cid', array(),
'array');
$values = array('block' => 1, 'unblock' => 0);
$task = $this->getTask();
$value = ArrayHelper::getValue($values, $task, 0, 'int');
if (empty($ids))
{
JError::raiseWarning(500,
JText::_('COM_USERS_USERS_NO_ITEM_SELECTED'));
}
else
{
// Get the model.
$model = $this->getModel();
// Change the state of the records.
if (!$model->block($ids, $value))
{
JError::raiseWarning(500, $model->getError());
}
else
{
if ($value == 1)
{
$this->setMessage(JText::plural('COM_USERS_N_USERS_BLOCKED',
count($ids)));
}
elseif ($value == 0)
{
$this->setMessage(JText::plural('COM_USERS_N_USERS_UNBLOCKED',
count($ids)));
}
}
}
$this->setRedirect('index.php?option=com_users&view=users');
}
/**
* Method to activate a record.
*
* @return void
*
* @since 1.6
*/
public function activate()
{
// Check for request forgeries.
$this->checkToken();
$ids = $this->input->get('cid', array(),
'array');
if (empty($ids))
{
JError::raiseWarning(500,
JText::_('COM_USERS_USERS_NO_ITEM_SELECTED'));
}
else
{
// Get the model.
$model = $this->getModel();
// Change the state of the records.
if (!$model->activate($ids))
{
JError::raiseWarning(500, $model->getError());
}
else
{
$this->setMessage(JText::plural('COM_USERS_N_USERS_ACTIVATED',
count($ids)));
}
}
$this->setRedirect('index.php?option=com_users&view=users');
}
}
helpers/debug.php000064400000007530151160243100010003 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Users component debugging helper.
*
* @since 1.6
*/
class UsersHelperDebug
{
/**
* Get a list of the components.
*
* @return array
*
* @since 1.6
*/
public static function getComponents()
{
// Initialise variable.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('name AS text, element AS value')
->from('#__extensions')
->where('enabled >= 1')
->where('type =' . $db->quote('component'));
$items = $db->setQuery($query)->loadObjectList();
if (count($items))
{
$lang = JFactory::getLanguage();
foreach ($items as &$item)
{
// Load language
$extension = $item->value;
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null,
false, true)
|| $lang->load("$extension.sys", $source, null, false,
true);
// Translate component name
$item->text = JText::_($item->text);
}
// Sort by component name
$items = ArrayHelper::sortObjects($items, 'text', 1, true,
true);
}
return $items;
}
/**
* Get a list of the actions for the component or code actions.
*
* @param string $component The name of the component.
*
* @return array
*
* @since 1.6
*/
public static function getDebugActions($component = null)
{
$actions = array();
// Try to get actions for the component
if (!empty($component))
{
$component_actions = JAccess::getActions($component);
if (!empty($component_actions))
{
foreach ($component_actions as &$action)
{
$actions[$action->title] = array($action->name,
$action->description);
}
}
}
// Use default actions from configuration if no component selected or
component doesn't have actions
if (empty($actions))
{
$filename = JPATH_ADMINISTRATOR .
'/components/com_config/model/form/application.xml';
if (is_file($filename))
{
$xml = simplexml_load_file($filename);
foreach ($xml->children()->fieldset as $fieldset)
{
if ('permissions' == (string) $fieldset['name'])
{
foreach ($fieldset->children() as $field)
{
if ('rules' == (string) $field['name'])
{
foreach ($field->children() as $action)
{
$actions[(string) $action['title']] = array(
(string) $action['name'],
(string) $action['description']
);
}
break;
}
}
}
}
// Load language
$lang = JFactory::getLanguage();
$extension = 'com_config';
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load($extension, JPATH_ADMINISTRATOR, null, false, false)
|| $lang->load($extension, $source, null, false, false)
|| $lang->load($extension, JPATH_ADMINISTRATOR,
$lang->getDefault(), false, false)
|| $lang->load($extension, $source, $lang->getDefault(), false,
false);
}
}
return $actions;
}
/**
* Get a list of filter options for the levels.
*
* @return array An array of JHtmlOption elements.
*/
public static function getLevelsOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '1',
JText::sprintf('COM_USERS_OPTION_LEVEL_COMPONENT', 1));
$options[] = JHtml::_('select.option', '2',
JText::sprintf('COM_USERS_OPTION_LEVEL_CATEGORY', 2));
$options[] = JHtml::_('select.option', '3',
JText::sprintf('COM_USERS_OPTION_LEVEL_DEEPER', 3));
$options[] = JHtml::_('select.option', '4',
'4');
$options[] = JHtml::_('select.option', '5',
'5');
$options[] = JHtml::_('select.option', '6',
'6');
return $options;
}
}
helpers/html/users.php000064400000013716151160243100011025 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Extended Utility class for the Users component.
*
* @since 2.5
*/
class JHtmlUsers
{
/**
* Display an image.
*
* @param string $src The source of the image
*
* @return string A <img> element if the specified file exists,
otherwise, a null string
*
* @since 2.5
*/
public static function image($src)
{
$src = preg_replace('#[^A-Z0-9\-_\./]#i', '', $src);
$file = JPATH_SITE . '/' . $src;
jimport('joomla.filesystem.path');
JPath::check($file);
if (!file_exists($file))
{
return '';
}
return '<img src="' . JUri::root() . $src .
'" alt="" />';
}
/**
* Displays an icon to add a note for this user.
*
* @param integer $userId The user ID
*
* @return string A link to add a note
*
* @since 2.5
*/
public static function addNote($userId)
{
$title = JText::_('COM_USERS_ADD_NOTE');
return '<a href="' .
JRoute::_('index.php?option=com_users&task=note.add&u_id='
. (int) $userId) . '" class="hasTooltip btn btn-mini"
title="'
. $title . '"><span class="icon-vcard"
aria-hidden="true"></span><span
class="hidden-phone">' . $title .
'</span></a>';
}
/**
* Displays an icon to filter the notes list on this user.
*
* @param integer $count The number of notes for the user
* @param integer $userId The user ID
*
* @return string A link to apply a filter
*
* @since 2.5
*/
public static function filterNotes($count, $userId)
{
if (empty($count))
{
return '';
}
$title = JText::_('COM_USERS_FILTER_NOTES');
return '<a href="' .
JRoute::_('index.php?option=com_users&view=notes&filter[search]=uid:'
. (int) $userId)
. '" class="hasTooltip btn btn-mini"
title="' . $title . '"><span
class="icon-filter"></span></a>';
}
/**
* Displays a note icon.
*
* @param integer $count The number of notes for the user
* @param integer $userId The user ID
*
* @return string A link to a modal window with the user notes
*
* @since 2.5
*/
public static function notes($count, $userId)
{
if (empty($count))
{
return '';
}
$title = JText::plural('COM_USERS_N_USER_NOTES', $count);
return '<button type="button"
data-target="#userModal_' . (int) $userId . '"
id="modal-' . (int) $userId . '"
data-toggle="modal"'
. ' class="hasTooltip btn btn-mini" title="' .
$title . '">'
. '<span class="icon-drawer-2"
aria-hidden="true"></span><span
class="hidden-phone">' . $title .
'</span></button>';
}
/**
* Renders the modal html.
*
* @param integer $count The number of notes for the user
* @param integer $userId The user ID
*
* @return string The html for the rendered modal
*
* @since 3.4.1
*/
public static function notesModal($count, $userId)
{
if (empty($count))
{
return '';
}
$title = JText::plural('COM_USERS_N_USER_NOTES', $count);
$footer = '<button type="button" class="btn"
data-dismiss="modal">'
. JText::_('JTOOLBAR_CLOSE') . '</button>';
return JHtml::_(
'bootstrap.renderModal',
'userModal_' . (int) $userId,
array(
'title' => $title,
'backdrop' => 'static',
'keyboard' => true,
'closeButton' => true,
'footer' => $footer,
'url' =>
JRoute::_('index.php?option=com_users&view=notes&tmpl=component&layout=modal&filter[user_id]='
. (int) $userId),
'height' => '300px',
'width' => '800px',
)
);
}
/**
* Build an array of block/unblock user states to be used by jgrid.state,
* State options will be different for any user
* and for currently logged in user
*
* @param boolean $self True if state array is for currently logged in
user
*
* @return array a list of possible states to display
*
* @since 3.0
*/
public static function blockStates( $self = false)
{
if ($self)
{
$states = array(
1 => array(
'task' => 'unblock',
'text' => '',
'active_title' =>
'COM_USERS_USER_FIELD_BLOCK_DESC',
'inactive_title' => '',
'tip' => true,
'active_class' => 'unpublish',
'inactive_class' => 'unpublish',
),
0 => array(
'task' => 'block',
'text' => '',
'active_title' => '',
'inactive_title' =>
'COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF',
'tip' => true,
'active_class' => 'publish',
'inactive_class' => 'publish',
)
);
}
else
{
$states = array(
1 => array(
'task' => 'unblock',
'text' => '',
'active_title' =>
'COM_USERS_TOOLBAR_UNBLOCK',
'inactive_title' => '',
'tip' => true,
'active_class' => 'unpublish',
'inactive_class' => 'unpublish',
),
0 => array(
'task' => 'block',
'text' => '',
'active_title' =>
'COM_USERS_USER_FIELD_BLOCK_DESC',
'inactive_title' => '',
'tip' => true,
'active_class' => 'publish',
'inactive_class' => 'publish',
)
);
}
return $states;
}
/**
* Build an array of activate states to be used by jgrid.state,
*
* @return array a list of possible states to display
*
* @since 3.0
*/
public static function activateStates()
{
$states = array(
1 => array(
'task' => 'activate',
'text' => '',
'active_title' =>
'COM_USERS_TOOLBAR_ACTIVATE',
'inactive_title' => '',
'tip' => true,
'active_class' => 'unpublish',
'inactive_class' => 'unpublish',
),
0 => array(
'task' => '',
'text' => '',
'active_title' => '',
'inactive_title' => 'COM_USERS_ACTIVATED',
'tip' => true,
'active_class' => 'publish',
'inactive_class' => 'publish',
)
);
return $states;
}
}
helpers/users.php000064400000015426151160243100010061 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users component helper.
*
* @since 1.6
*/
class UsersHelper
{
/**
* @var JObject A cache for the available actions.
* @since 1.6
*/
protected static $actions;
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_USERS'),
'index.php?option=com_users&view=users',
$vName == 'users'
);
// Groups and Levels are restricted to core.admin
$canDo = JHelperContent::getActions('com_users');
if ($canDo->get('core.admin'))
{
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_GROUPS'),
'index.php?option=com_users&view=groups',
$vName == 'groups'
);
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_LEVELS'),
'index.php?option=com_users&view=levels',
$vName == 'levels'
);
}
if (JComponentHelper::isEnabled('com_fields') &&
JComponentHelper::getParams('com_users')->get('custom_fields_enable',
'1'))
{
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELDS'),
'index.php?option=com_fields&context=com_users.user',
$vName == 'fields.fields'
);
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELD_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_users.user',
$vName == 'fields.groups'
);
}
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_NOTES'),
'index.php?option=com_users&view=notes',
$vName == 'notes'
);
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_NOTE_CATEGORIES'),
'index.php?option=com_categories&extension=com_users',
$vName == 'categories'
);
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject
*
* @deprecated 3.2 Use JHelperContent::getActions() instead
*/
public static function getActions()
{
// Log usage of deprecated function
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperContent::getActions() with
new arguments order instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
// Get list of actions
return JHelperContent::getActions('com_users');
}
/**
* Get a list of filter options for the blocked state of a user.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getStateOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0',
JText::_('JENABLED'));
$options[] = JHtml::_('select.option', '1',
JText::_('JDISABLED'));
return $options;
}
/**
* Get a list of filter options for the activated state of a user.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getActiveOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0',
JText::_('COM_USERS_ACTIVATED'));
$options[] = JHtml::_('select.option', '1',
JText::_('COM_USERS_UNACTIVATED'));
return $options;
}
/**
* Get a list of the user groups for filtering.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
public static function getGroups()
{
$options = JHelperUsergroups::getInstance()->getAll();
foreach ($options as &$option)
{
$option->value = $option->id;
$option->text = str_repeat('- ', $option->level) .
$option->title;
}
return $options;
}
/**
* Creates a list of range options used in filter select list
* used in com_users on users view
*
* @return array
*
* @since 2.5
*/
public static function getRangeOptions()
{
$options = array(
JHtml::_('select.option', 'today',
JText::_('COM_USERS_OPTION_RANGE_TODAY')),
JHtml::_('select.option', 'past_week',
JText::_('COM_USERS_OPTION_RANGE_PAST_WEEK')),
JHtml::_('select.option', 'past_1month',
JText::_('COM_USERS_OPTION_RANGE_PAST_1MONTH')),
JHtml::_('select.option', 'past_3month',
JText::_('COM_USERS_OPTION_RANGE_PAST_3MONTH')),
JHtml::_('select.option', 'past_6month',
JText::_('COM_USERS_OPTION_RANGE_PAST_6MONTH')),
JHtml::_('select.option', 'past_year',
JText::_('COM_USERS_OPTION_RANGE_PAST_YEAR')),
JHtml::_('select.option', 'post_year',
JText::_('COM_USERS_OPTION_RANGE_POST_YEAR')),
);
return $options;
}
/**
* Creates a list of two factor authentication methods used in com_users
* on user view
*
* @return array
*
* @since 3.2.0
*/
public static function getTwoFactorMethods()
{
FOFPlatform::getInstance()->importPlugin('twofactorauth');
$identities =
FOFPlatform::getInstance()->runPlugins('onUserTwofactorIdentify',
array());
$options = array(
JHtml::_('select.option', 'none',
JText::_('JGLOBAL_OTPMETHOD_NONE'), 'value',
'text'),
);
if (!empty($identities))
{
foreach ($identities as $identity)
{
if (!is_object($identity))
{
continue;
}
$options[] = JHtml::_('select.option', $identity->method,
$identity->title, 'value', 'text');
}
}
return $options;
}
/**
* Get a list of the User Groups for Viewing Access Levels
*
* @param string $rules User Groups in JSON format
*
* @return string $groups Comma separated list of User Groups
*
* @since 3.6
*/
public static function getVisibleByGroups($rules)
{
$rules = json_decode($rules);
if (!$rules)
{
return false;
}
$rules = implode(',', $rules);
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.title AS text')
->from('#__usergroups as a')
->where('a.id IN (' . $rules . ')');
$db->setQuery($query);
$groups = $db->loadColumn();
$groups = implode(', ', $groups);
return $groups;
}
/**
* Returns a valid section for users. If it is not valid then null
* is returned.
*
* @param string $section The section to get the mapping for
*
* @return string|null The new section
*
* @since 3.7.0
*/
public static function validateSection($section)
{
if (JFactory::getApplication()->isClient('site'))
{
switch ($section)
{
case 'registration':
case 'profile':
$section = 'user';
}
}
if ($section != 'user')
{
// We don't know other sections
return null;
}
return $section;
}
/**
* Returns valid contexts
*
* @return array
*
* @since 3.7.0
*/
public static function getContexts()
{
JFactory::getLanguage()->load('com_users',
JPATH_ADMINISTRATOR);
$contexts = array(
'com_users.user' => JText::_('COM_USERS'),
);
return $contexts;
}
}
models/debuggroup.php000064400000014331151160243100010676 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('UsersHelperDebug', JPATH_ADMINISTRATOR .
'/components/com_users/helpers/debug.php');
/**
* Methods supporting a list of User ACL permissions
*
* @since 1.6
*/
class UsersModelDebuggroup extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 3.6.0
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.title',
'component', 'a.name',
'a.lft',
'a.id',
'level_start', 'level_end', 'a.level',
);
}
parent::__construct($config);
}
/**
* Get a list of the actions.
*
* @return array
*
* @since 1.6
*/
public function getDebugActions()
{
$component = $this->getState('filter.component');
return UsersHelperDebug::getDebugActions($component);
}
/**
* Override getItems method.
*
* @return array
*
* @since 1.6
*/
public function getItems()
{
$groupId = $this->getState('group_id');
if (($assets = parent::getItems()) && $groupId)
{
$actions = $this->getDebugActions();
foreach ($assets as &$asset)
{
$asset->checks = array();
foreach ($actions as $action)
{
$name = $action[0];
$asset->checks[$name] = JAccess::checkGroup($groupId, $name,
$asset->name);
}
}
}
return $assets;
}
/**
* 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
*
* @since 1.6
*/
protected function populateState($ordering = 'a.lft', $direction
= 'asc')
{
$app = JFactory::getApplication('administrator');
// Adjust the context to support modal layouts.
$layout = $app->input->get('layout',
'default');
if ($layout)
{
$this->context .= '.' . $layout;
}
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('group_id',
$this->getUserStateFromRequest($this->context .
'.group_id', 'group_id', 0, 'int', false));
$levelStart = $this->getUserStateFromRequest($this->context .
'.filter.level_start', 'filter_level_start',
'', 'cmd');
$this->setState('filter.level_start', $levelStart);
$value = $this->getUserStateFromRequest($this->context .
'.filter.level_end', 'filter_level_end', '',
'cmd');
if ($value > 0 && $value < $levelStart)
{
$value = $levelStart;
}
$this->setState('filter.level_end', $value);
$this->setState('filter.component',
$this->getUserStateFromRequest($this->context .
'.filter.component', 'filter_component', '',
'string'));
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('group_id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' .
$this->getState('filter.level_start');
$id .= ':' . $this->getState('filter.level_end');
$id .= ':' . $this->getState('filter.component');
return parent::getStoreId($id);
}
/**
* Get the group being debugged.
*
* @return JObject
*
* @since 1.6
*/
public function getGroup()
{
$groupId = (int) $this->getState('group_id');
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('id, title')
->from('#__usergroups')
->where('id = ' . $groupId);
$db->setQuery($query);
try
{
$group = $db->loadObject();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
return $group;
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.name, a.title, a.level, a.lft, a.rgt'
)
);
$query->from($db->quoteName('#__assets', 'a'));
// Filter the items over the search string if set.
if ($this->getState('filter.search'))
{
// Escape the search token.
$search = $db->quote('%' . str_replace(' ',
'%',
$db->escape(trim($this->getState('filter.search')), true) .
'%'));
// Compile the different search clauses.
$searches = array();
$searches[] = 'a.name LIKE ' . $search;
$searches[] = 'a.title LIKE ' . $search;
// Add the clauses to the query.
$query->where('(' . implode(' OR ', $searches) .
')');
}
// Filter on the start and end levels.
$levelStart = (int) $this->getState('filter.level_start');
$levelEnd = (int) $this->getState('filter.level_end');
if ($levelEnd > 0 && $levelEnd < $levelStart)
{
$levelEnd = $levelStart;
}
if ($levelStart > 0)
{
$query->where('a.level >= ' . $levelStart);
}
if ($levelEnd > 0)
{
$query->where('a.level <= ' . $levelEnd);
}
// Filter the items over the component if set.
if ($this->getState('filter.component'))
{
$component = $this->getState('filter.component');
$query->where('(a.name = ' . $db->quote($component) .
' OR a.name LIKE ' . $db->quote($component . '.%') .
')');
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.lft')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
}
models/debuguser.php000064400000013701151160243100010520 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('UsersHelperDebug', JPATH_ADMINISTRATOR .
'/components/com_users/helpers/debug.php');
/**
* Methods supporting a list of User ACL permissions
*
* @since 1.6
*/
class UsersModelDebugUser extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 3.6.0
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'a.title',
'component', 'a.name',
'a.lft',
'a.id',
'level_start', 'level_end', 'a.level',
);
}
parent::__construct($config);
}
/**
* Get a list of the actions.
*
* @return array
*
* @since 1.6
*/
public function getDebugActions()
{
$component = $this->getState('filter.component');
return UsersHelperDebug::getDebugActions($component);
}
/**
* Override getItems method.
*
* @return array
*
* @since 1.6
*/
public function getItems()
{
$userId = $this->getState('user_id');
$user = JFactory::getUser($userId);
if (($assets = parent::getItems()) && $userId)
{
$actions = $this->getDebugActions();
foreach ($assets as &$asset)
{
$asset->checks = array();
foreach ($actions as $action)
{
$name = $action[0];
$asset->checks[$name] = $user->authorise($name,
$asset->name);
}
}
}
return $assets;
}
/**
* 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
*
* @since 1.6
*/
protected function populateState($ordering = 'a.lft', $direction
= 'asc')
{
$app = JFactory::getApplication('administrator');
// Adjust the context to support modal layouts.
$layout = $app->input->get('layout',
'default');
if ($layout)
{
$this->context .= '.' . $layout;
}
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('user_id',
$this->getUserStateFromRequest($this->context . '.user_id',
'user_id', 0, 'int', false));
$levelStart = $this->getUserStateFromRequest($this->context .
'.filter.level_start', 'filter_level_start',
'', 'cmd');
$this->setState('filter.level_start', $levelStart);
$value = $this->getUserStateFromRequest($this->context .
'.filter.level_end', 'filter_level_end', '',
'cmd');
if ($value > 0 && $value < $levelStart)
{
$value = $levelStart;
}
$this->setState('filter.level_end', $value);
$this->setState('filter.component',
$this->getUserStateFromRequest($this->context .
'.filter.component', 'filter_component', '',
'string'));
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('user_id');
$id .= ':' . $this->getState('filter.search');
$id .= ':' .
$this->getState('filter.level_start');
$id .= ':' . $this->getState('filter.level_end');
$id .= ':' . $this->getState('filter.component');
return parent::getStoreId($id);
}
/**
* Get the user being debugged.
*
* @return JUser
*
* @since 1.6
*/
public function getUser()
{
$userId = $this->getState('user_id');
return JFactory::getUser($userId);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.name, a.title, a.level, a.lft, a.rgt'
)
);
$query->from($db->quoteName('#__assets', 'a'));
// Filter the items over the search string if set.
if ($this->getState('filter.search'))
{
// Escape the search token.
$search = $db->quote('%' . str_replace(' ',
'%',
$db->escape(trim($this->getState('filter.search')), true) .
'%'));
// Compile the different search clauses.
$searches = array();
$searches[] = 'a.name LIKE ' . $search;
$searches[] = 'a.title LIKE ' . $search;
// Add the clauses to the query.
$query->where('(' . implode(' OR ', $searches) .
')');
}
// Filter on the start and end levels.
$levelStart = (int) $this->getState('filter.level_start');
$levelEnd = (int) $this->getState('filter.level_end');
if ($levelEnd > 0 && $levelEnd < $levelStart)
{
$levelEnd = $levelStart;
}
if ($levelStart > 0)
{
$query->where('a.level >= ' . $levelStart);
}
if ($levelEnd > 0)
{
$query->where('a.level <= ' . $levelEnd);
}
// Filter the items over the component if set.
if ($this->getState('filter.component'))
{
$component = $this->getState('filter.component');
$query->where('(a.name = ' . $db->quote($component) .
' OR a.name LIKE ' . $db->quote($component . '.%') .
')');
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.lft')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
}
models/fields/groupparent.php000064400000005277151160243100012360
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Helper\UserGroupsHelper;
FormHelper::loadFieldClass('list');
/**
* User Group Parent field..
*
* @since 1.6
*/
class JFormFieldGroupParent extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'GroupParent';
/**
* Method to clean the Usergroup Options from all children starting by a
given father
*
* @param array $userGroupsOptions The usergroup options to clean
* @param integer $fatherId The father ID to start with
*
* @return array The cleaned field options
*
* @since 3.9.4
*/
private function cleanOptionsChildrenByFather($userGroupsOptions,
$fatherId)
{
foreach ($userGroupsOptions as $userGroupsOptionsId =>
$userGroupsOptionsData)
{
if ((int) $userGroupsOptionsData->parent_id === (int) $fatherId)
{
unset($userGroupsOptions[$userGroupsOptionsId]);
$userGroupsOptions =
$this->cleanOptionsChildrenByFather($userGroupsOptions,
$userGroupsOptionsId);
}
}
return $userGroupsOptions;
}
/**
* Method to get the field options.
*
* @return array The field option objects
*
* @since 1.6
*/
protected function getOptions()
{
$options = UserGroupsHelper::getInstance()->getAll();
$currentGroupId = $this->form->getValue('id');
// Prevent to set yourself as parent
if ($currentGroupId)
{
unset($options[$currentGroupId]);
}
// We should not remove any groups when we are creating a new group
if (!is_null($currentGroupId))
{
// Prevent parenting direct children and children of children of this
item.
$options = $this->cleanOptionsChildrenByFather($options,
$currentGroupId);
}
$options = array_values($options);
$isSuperAdmin = Factory::getUser()->authorise('core.admin');
// Pad the option text with spaces using depth level as a multiplier.
for ($i = 0, $n = count($options); $i < $n; $i++)
{
// Show groups only if user is super admin or group is not super admin
if ($isSuperAdmin || !Access::checkGroup($options[$i]->id,
'core.admin'))
{
$options[$i]->value = $options[$i]->id;
$options[$i]->text = str_repeat('- ',
$options[$i]->level) . $options[$i]->title;
}
else
{
unset($options[$i]);
}
}
// Merge any additional options in the XML definition.
return array_merge(parent::getOptions(), $options);
}
}
models/fields/levels.php000064400000001465151160243100011277
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JFormHelper::loadFieldClass('list');
/**
* Access Levels field.
*
* @since 3.6.0
*/
class JFormFieldLevels extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.6.0
*/
protected $type = 'Levels';
/**
* Method to get the field options.
*
* @return array The field option objects
*
* @since 3.6.0
*/
protected function getOptions()
{
// Merge any additional options in the XML definition.
return array_merge(parent::getOptions(),
UsersHelperDebug::getLevelsOptions());
}
}
models/forms/config_domain.xml000064400000001165151160243100012467
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="name"
type="text"
label="COM_USERS_CONFIG_FIELD_DOMAIN_NAME_LABEL"
description="COM_USERS_CONFIG_FIELD_DOMAIN_NAME_DESC"
required="true"
/>
<field
name="rule"
type="list"
label="COM_USERS_CONFIG_FIELD_DOMAIN_RULE_LABEL"
description="COM_USERS_CONFIG_FIELD_DOMAIN_RULE_DESC"
required="true"
default="0"
filter="integer"
>
<option
value="1">COM_USERS_CONFIG_FIELD_DOMAIN_RULE_OPTION_ALLOW</option>
<option
value="0">COM_USERS_CONFIG_FIELD_DOMAIN_RULE_OPTION_DISALLOW</option>
</field>
</fieldset>
</form>
models/forms/fields/user.xml000064400000000357151160243100012121
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params"
label="COM_FIELDS_FIELD_BASIC_LABEL">
<fieldset name="basic">
<field
name="display"
type="hidden"
default="2"
/>
</fieldset>
</fields>
</form>
models/forms/filter_debuggroup.xml000064400000003577151160243100013414
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_ASSETS"
description="COM_USERS_SEARCH_IN_ASSETS"
hint="JSEARCH_FILTER"
/>
<field
name="component"
type="Components"
label="COM_USERS_FILTER_COMPONENT_LABEL"
description="COM_USERS_FILTER_COMPONENT_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_COMPONENT</option>
</field>
<field
name="level_start"
type="Levels"
label="COM_USERS_FILTER_LEVEL_START_LABEL"
description="COM_USERS_FILTER_LEVEL_START_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_LEVEL_START</option>
</field>
<field
name="level_end"
type="Levels"
label="COM_USERS_FILTER_LEVEL_END_LABEL"
description="COM_USERS_FILTER_LEVEL_END_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_LEVEL_END</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
onchange="this.form.submit();"
default="a.lft ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.title
ASC">COM_USERS_HEADING_ASSET_TITLE_ASC</option>
<option value="a.title
DESC">COM_USERS_HEADING_ASSET_TITLE_DESC</option>
<option value="a.name
ASC">COM_USERS_HEADING_ASSET_NAME_ASC</option>
<option value="a.name
DESC">COM_USERS_HEADING_ASSET_NAME_DESC</option>
<option value="a.lft
ASC">COM_USERS_HEADING_LFT_ASC</option>
<option value="a.lft
DESC">COM_USERS_HEADING_LFT_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
models/forms/filter_debuguser.xml000064400000003572151160243100013231
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_ASSETS"
description="COM_USERS_SEARCH_IN_ASSETS"
hint="JSEARCH_FILTER"
/>
<field
name="component"
type="Components"
label="COM_USERS_FILTER_COMPONENT_LABEL"
description="COM_USERS_FILTER_COMPONENT_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_COMPONENT</option>
</field>
<field
name="level_start"
type="Levels"
label="COM_USERS_FILTER_LEVEL_START_LABEL"
description="COM_USERS_FILTER_LEVEL_START_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_LEVEL_START</option>
</field>
<field
name="level_end"
type="Levels"
label="COM_USERS_FILTER_LEVEL_END_LABEL"
description="COM_USERS_FILTER_LEVEL_END_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_SELECT_LEVEL_END</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
onchange="this.form.submit();"
default="a.lft ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.title
ASC">COM_USERS_HEADING_ASSET_TITLE_ASC</option>
<option value="a.title
DESC">COM_USERS_HEADING_ASSET_TITLE_DESC</option>
<option value="a.name
ASC">COM_USERS_HEADING_ASSET_NAME_ASC</option>
<option value="a.name
DESC">COM_USERS_HEADING_ASSET_NAME_DESC</option>
<option value="a.lft
ASC">COM_USERS_HEADING_LFT_ASC</option>
<option value="a.lft
DESC">COM_USERS_HEADING_LFT_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
models/forms/filter_groups.xml000064400000002144151160243100012555
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_GROUPS_LABEL"
description="COM_USERS_SEARCH_IN_GROUPS"
hint="JSEARCH_FILTER"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.lft ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.lft
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.lft
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.title
ASC">COM_USERS_HEADING_GROUP_TITLE_ASC</option>
<option value="a.title
DESC">COM_USERS_HEADING_GROUP_TITLE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
models/forms/filter_levels.xml000064400000002166151160243100012534
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_ACCESS_LEVELS"
description="COM_USERS_SEARCH_IN_LEVEL_NAME"
hint="JSEARCH_FILTER"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.ordering ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering
ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering
DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.title
ASC">COM_USERS_HEADING_LEVEL_NAME_ASC</option>
<option value="a.title
DESC">COM_USERS_HEADING_LEVEL_NAME_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
models/forms/filter_notes.xml000064400000004256151160243100012374
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_USER_NOTES"
description="COM_USERS_SEARCH_IN_NOTE_TITLE"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
extension="com_users"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_CATEGORY</option>
</field>
<field
name="level"
type="integer"
label="JOPTION_FILTER_LEVEL"
description="JOPTION_FILTER_LEVEL_DESC"
first="1"
last="10"
step="1"
languages="*"
onchange="this.form.submit();"
>
<option
value="">JOPTION_SELECT_MAX_LEVELS</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
description="JGLOBAL_SORT_BY"
onchange="this.form.submit();"
default="a.review_time DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.subject
ASC">COM_USERS_HEADING_SUBJECT_ASC</option>
<option value="a.subject
DESC">COM_USERS_HEADING_SUBJECT_DESC</option>
<option value="c.title
ASC">COM_USERS_HEADING_CATEGORY_ASC</option>
<option value="c.title
DESC">COM_USERS_HEADING_CATEGORY_DESC</option>
<option value="u.name
ASC">COM_USERS_HEADING_USER_ASC</option>
<option value="u.name
DESC">COM_USERS_HEADING_USER_DESC</option>
<option value="a.review_time
ASC">COM_USERS_HEADING_REVIEW_ASC</option>
<option value="a.review_time
DESC">COM_USERS_HEADING_REVIEW_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIMIT"
description="JGLOBAL_LIMIT"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
models/forms/filter_users.xml000064400000006175151160243100012407
0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_USERS_SEARCH_USERS"
description="COM_USERS_SEARCH_IN_NAME"
hint="JSEARCH_FILTER"
/>
<field
name="state"
type="userstate"
label="COM_USERS_FILTER_STATE"
description="COM_USERS_FILTER_STATE_DESC"
onchange="this.form.submit();"
>
<option value="">COM_USERS_FILTER_STATE</option>
</field>
<field
name="active"
type="useractive"
label="COM_USERS_FILTER_ACTIVE"
description="COM_USERS_FILTER_ACTIVE_DESC"
onchange="this.form.submit();"
>
<option value="">COM_USERS_FILTER_ACTIVE</option>
</field>
<field
name="group_id"
type="usergrouplist"
label="COM_USERS_FILTER_GROUP"
description="COM_USERS_FILTER_GROUP_DESC"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_FILTER_USERGROUP</option>
</field>
<field
name="lastvisitrange"
type="lastvisitdaterange"
label="COM_USERS_OPTION_FILTER_LAST_VISIT_DATE"
description="COM_USERS_OPTION_FILTER_LAST_VISIT_DATE"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_FILTER_LAST_VISIT_DATE</option>
</field>
<field
name="range"
type="registrationdaterange"
label="COM_USERS_OPTION_FILTER_DATE"
description="COM_USERS_OPTION_FILTER_DATE"
onchange="this.form.submit();"
>
<option
value="">COM_USERS_OPTION_FILTER_DATE</option>
</field>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.name ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.name
ASC">COM_USERS_HEADING_NAME_ASC</option>
<option value="a.name
DESC">COM_USERS_HEADING_NAME_DESC</option>
<option value="a.username
ASC">COM_USERS_HEADING_USERNAME_ASC</option>
<option value="a.username
DESC">COM_USERS_HEADING_USERNAME_DESC</option>
<option value="a.block
ASC">COM_USERS_HEADING_ENABLED_ASC</option>
<option value="a.block
DESC">COM_USERS_HEADING_ENABLED_DESC</option>
<option value="a.activation
ASC">COM_USERS_HEADING_ACTIVATED_ASC</option>
<option value="a.activation
DESC">COM_USERS_HEADING_ACTIVATED_DESC</option>
<option value="a.email
ASC">COM_USERS_HEADING_EMAIL_ASC</option>
<option value="a.email
DESC">COM_USERS_HEADING_EMAIL_DESC</option>
<option value="a.lastvisitDate
ASC">COM_USERS_HEADING_LAST_VISIT_DATE_ASC</option>
<option value="a.lastvisitDate
DESC">COM_USERS_HEADING_LAST_VISIT_DATE_DESC</option>
<option value="a.registerDate
ASC">COM_USERS_HEADING_REGISTRATION_DATE_ASC</option>
<option value="a.registerDate
DESC">COM_USERS_HEADING_REGISTRATION_DATE_DESC</option>
<option value="a.id
ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id
DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>
models/forms/group.xml000064400000001335151160243100011026 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset name="group_details">
<field
name="id"
type="hidden"
default="0"
required="true"
readonly="true"
/>
<field
name="title"
type="text"
label="COM_USERS_GROUP_FIELD_TITLE_LABEL"
description="COM_USERS_GROUP_FIELD_TITLE_DESC"
required="true"
size="40"
/>
<field
name="parent_id"
type="groupparent"
label="COM_USERS_GROUP_FIELD_PARENT_LABEL"
description="COM_USERS_GROUP_FIELD_PARENT_DESC"
/>
<field
name="actions"
type="hidden"
multiple="true"
/>
<field
name="lft"
type="hidden"
filter="unset"
/>
<field
name="rgt"
type="hidden"
filter="unset"
/>
</fieldset>
</form>
models/forms/level.xml000064400000001062151160243100010776 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="hidden"
default="0"
readonly="true"
required="true"
/>
<field
name="title"
type="text"
label="COM_USERS_LEVEL_FIELD_TITLE_LABEL"
description="COM_USERS_LEVEL_FIELD_TITLE_DESC"
required="true"
size="50"
/>
<field
name="ordering"
type="text"
label="JFIELD_ORDERING_LABEL"
description="JFIELD_ORDERING_DESC"
default="0"
/>
<field
name="rules"
type="hidden"
filter="int_array"
/>
</fieldset>
</form>
models/forms/mail.xml000064400000002734151160243100010620 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="recurse"
type="checkbox"
label="COM_USERS_MAIL_FIELD_RECURSE_LABEL"
description="COM_USERS_MAIL_FIELD_RECURSE_DESC"
value="1"
/>
<field
name="mode"
type="checkbox"
label="COM_USERS_MAIL_FIELD_SEND_IN_HTML_MODE_LABEL"
description="COM_USERS_MAIL_FIELD_SEND_IN_HTML_MODE_DESC"
value="1"
/>
<field
name="disabled"
type="checkbox"
label="COM_USERS_MAIL_FIELD_EMAIL_DISABLED_USERS_LABEL"
description="COM_USERS_MAIL_FIELD_EMAIL_DISABLED_USERS_DESC"
value="1"
/>
<field
name="group"
type="usergrouplist"
label="COM_USERS_MAIL_FIELD_GROUP_LABEL"
description="COM_USERS_MAIL_FIELD_GROUP_DESC"
default="0"
size="10"
>
<option
value="0">COM_USERS_MAIL_FIELD_VALUE_ALL_USERS_GROUPS</option>
</field>
<field
name="bcc"
type="checkbox"
label="COM_USERS_MAIL_FIELD_SEND_AS_BLIND_CARBON_COPY_LABEL"
description="COM_USERS_MAIL_FIELD_SEND_AS_BLIND_CARBON_COPY_DESC"
default="1"
value="1"
checked="1"
/>
<field
name="subject"
type="text"
label="COM_USERS_MAIL_FIELD_SUBJECT_LABEL"
description="COM_USERS_MAIL_FIELD_SUBJECT_DESC"
class="span8"
maxlength="150"
size="30"
/>
<field
name="message"
type="textarea"
label="COM_USERS_MAIL_FIELD_MESSAGE_LABEL"
description="COM_USERS_MAIL_FIELD_MESSAGE_DESC"
class="span11 vert"
cols="70"
rows="20"
/>
</fieldset>
</form>
models/forms/note.xml000064400000005452151160243100010643 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset
addfieldpath="/administrator/components/com_categories/models/fields"
>
<field
name="id"
type="hidden"
label="COM_USERS_FIELD_ID_LABEL"
class="readonly"
size="6"
default="0"
readonly="true"
/>
<field
name="user_id"
type="user"
label="COM_USERS_FIELD_USER_ID_LABEL"
description="JLIB_FORM_SELECT_USER"
size="50"
class="input-medium"
required="true"
/>
<field
name="catid"
type="modal_category"
label="COM_USERS_FIELD_CATEGORY_ID_LABEL"
description="JFIELD_CATEGORY_DESC"
extension="com_users"
required="true"
select="true"
new="true"
edit="true"
clear="true"
/>
<field
name="subject"
type="text"
label="COM_USERS_FIELD_SUBJECT_LABEL"
description="COM_USERS_FIELD_SUBJECT_DESC"
size="80"
/>
<field
name="body"
type="editor"
label="COM_USERS_FIELD_NOTEBODY_LABEL"
description="COM_USERS_FIELD_NOTEBODY_DESC"
rows="10"
cols="80"
filter="safehtml"
/>
<field
name="state"
type="list"
label="JSTATUS"
description="COM_USERS_FIELD_STATE_DESC"
size="1"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field
name="review_time"
type="calendar"
label="COM_USERS_FIELD_REVIEW_TIME_LABEL"
description="COM_USERS_FIELD_REVIEW_TIME_DESC"
default="NOW"
translateformat="true"
filter="user_utc"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="created_user_id"
type="hidden"
label="JGLOBAL_FIELD_CREATED_BY_LABEL"
filter="unset"
/>
<field
name="created_time"
type="hidden"
label="JGLOBAL_FIELD_CREATED_LABEL"
filter="unset"
/>
<field
name="modified_user_id"
type="hidden"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
filter="unset"
/>
<field
name="modified_time"
type="hidden"
label="JGLOBAL_FIELD_MODIFIED_LABEL"
filter="unset"
/>
<field
name="publish_up"
type="calendar"
label="JGLOBAL_FIELD_PUBLISH_UP_LABEL"
description="JGLOBAL_FIELD_PUBLISH_UP_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="publish_down"
type="calendar"
label="JGLOBAL_FIELD_PUBLISH_DOWN_LABEL"
description="JGLOBAL_FIELD_PUBLISH_DOWN_DESC"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="version_note"
type="text"
label="JGLOBAL_FIELD_VERSION_NOTE_LABEL"
description="JGLOBAL_FIELD_VERSION_NOTE_DESC"
maxlength="255"
size="45"
labelclass="control-label"
/>
</fieldset>
</form>
models/forms/user.xml000064400000011402151160243100010644 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<form>
<fieldset name="user_details">
<field
name="name"
type="text"
label="COM_USERS_USER_FIELD_NAME_LABEL"
description="COM_USERS_USER_FIELD_NAME_DESC"
required="true"
size="30"
/>
<field
name="username"
type="text"
label="COM_USERS_USER_FIELD_USERNAME_LABEL"
description="COM_USERS_USER_FIELD_USERNAME_DESC"
required="true"
size="30"
/>
<field
name="password"
type="password"
label="JGLOBAL_PASSWORD"
description="COM_USERS_USER_FIELD_PASSWORD_DESC"
autocomplete="off"
class="validate-password"
filter="raw"
validate="password"
size="30"
/>
<field
name="password2"
type="password"
label="COM_USERS_USER_FIELD_PASSWORD2_LABEL"
description="COM_USERS_USER_FIELD_PASSWORD2_DESC"
autocomplete="off"
class="validate-password"
filter="raw"
message="COM_USERS_USER_FIELD_PASSWORD1_MESSAGE"
size="30"
validate="equals"
field="password"
/>
<field
name="email"
type="email"
label="JGLOBAL_EMAIL"
description="COM_USERS_USER_FIELD_EMAIL_DESC"
required="true"
size="30"
validate="email"
validDomains="com_users.domains"
/>
<field
name="registerDate"
type="calendar"
label="COM_USERS_USER_FIELD_REGISTERDATE_LABEL"
description="COM_USERS_USER_FIELD_REGISTERDATE_DESC"
class="readonly"
readonly="true"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="lastvisitDate"
type="calendar"
label="COM_USERS_USER_FIELD_LASTVISIT_LABEL"
description="COM_USERS_USER_FIELD_LASTVISIT_DESC"
class="readonly"
readonly="true"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="lastResetTime"
type="calendar"
label="COM_USERS_USER_FIELD_LASTRESET_LABEL"
description="COM_USERS_USER_FIELD_LASTRESET_DESC"
class="readonly"
readonly="true"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>
<field
name="resetCount"
type="number"
label="COM_USERS_USER_FIELD_RESETCOUNT_LABEL"
description="COM_USERS_USER_FIELD_RESETCOUNT_DESC"
class="readonly"
default="0"
readonly="true"
/>
<field
name="sendEmail"
type="radio"
label="COM_USERS_USER_FIELD_SENDEMAIL_LABEL"
description="COM_USERS_USER_FIELD_SENDEMAIL_DESC"
default="0"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="block"
type="radio"
label="COM_USERS_USER_FIELD_BLOCK_LABEL"
description="COM_USERS_USER_FIELD_BLOCK_DESC"
class="btn-group btn-group-yesno btn-group-reversed"
default="0"
>
<option
value="1">COM_USERS_USER_FIELD_BLOCK</option>
<option
value="0">COM_USERS_USER_FIELD_ENABLE</option>
</field>
<field
name="requireReset"
type="radio"
label="COM_USERS_USER_FIELD_REQUIRERESET_LABEL"
description="COM_USERS_USER_FIELD_REQUIRERESET_DESC"
default="0"
class="btn-group btn-group-yesno"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="id"
type="number"
label="JGLOBAL_FIELD_ID_LABEL"
description="JGLOBAL_FIELD_ID_DESC"
class="readonly"
default="0"
readonly="true"
/>
</fieldset>
<field name="groups" type="hidden" />
<field name="twofactor" type="hidden" />
<fields name="params">
<!-- Basic user account settings. -->
<fieldset name="settings"
label="COM_USERS_SETTINGS_FIELDSET_LABEL">
<field
name="admin_style"
type="templatestyle"
label="COM_USERS_USER_FIELD_BACKEND_TEMPLATE_LABEL"
description="COM_USERS_USER_FIELD_BACKEND_TEMPLATE_DESC"
client="administrator"
filter="uint"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="admin_language"
type="language"
label="COM_USERS_USER_FIELD_BACKEND_LANGUAGE_LABEL"
description="COM_USERS_USER_FIELD_BACKEND_LANGUAGE_DESC"
client="administrator"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="language"
type="language"
label="COM_USERS_USER_FIELD_FRONTEND_LANGUAGE_LABEL"
description="COM_USERS_USER_FIELD_FRONTEND_LANGUAGE_DESC"
client="site"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="editor"
type="plugins"
label="COM_USERS_USER_FIELD_EDITOR_LABEL"
description="COM_USERS_USER_FIELD_EDITOR_DESC"
folder="editors"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field
name="timezone"
type="timezone"
label="COM_USERS_USER_FIELD_TIMEZONE_LABEL"
description="COM_USERS_USER_FIELD_TIMEZONE_DESC"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
</fieldset>
</fields>
</form>
models/group.php000064400000020741151160243100007671 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
/**
* User group model.
*
* @since 1.6
*/
class UsersModelGroup extends JModelAdmin
{
/**
* Constructor
*
* @param array $config An optional associative array of configuration
settings.
*/
public function __construct($config = array())
{
$config = array_merge(
array(
'event_after_delete' =>
'onUserAfterDeleteGroup',
'event_after_save' => 'onUserAfterSaveGroup',
'event_before_delete' =>
'onUserBeforeDeleteGroup',
'event_before_save' =>
'onUserBeforeSaveGroup',
'events_map' => array('delete' =>
'user', 'save' => 'user')
), $config
);
parent::__construct($config);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Usergroup', $prefix =
'JTable', $config = array())
{
$return = JTable::getInstance($type, $prefix, $config);
return $return;
}
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to
interrogate.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.group',
'group', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_users.edit.group.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_users.group', $data);
return $data;
}
/**
* Override preprocessForm to load the user plugin group instead of
content.
*
* @param JForm $form A form object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @since 1.6
* @throws Exception if there is an error loading the form.
*/
protected function preprocessForm(JForm $form, $data, $group =
'')
{
$obj = is_array($data) ? ArrayHelper::toObject($data,
'JObject') : $data;
if (isset($obj->parent_id) && $obj->parent_id == 0
&& $obj->id > 0)
{
$form->setFieldAttribute('parent_id', 'type',
'hidden');
$form->setFieldAttribute('parent_id', 'hidden',
'true');
}
parent::preprocessForm($form, $data, 'user');
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
// Include the user plugins for events.
JPluginHelper::importPlugin($this->events_map['save']);
/**
* Check the super admin permissions for group
* We get the parent group permissions and then check the group
permissions manually
* We have to calculate the group permissions manually because we
haven't saved the group yet
*/
$parentSuperAdmin = JAccess::checkGroup($data['parent_id'],
'core.admin');
// Get core.admin rules from the root asset
$rules =
JAccess::getAssetRules('root.1')->getData('core.admin');
// Get the value for the current group (will be true (allowed), false
(denied), or null (inherit)
$groupSuperAdmin =
$rules['core.admin']->allow($data['id']);
// We only need to change the $groupSuperAdmin if the parent is true or
false. Otherwise, the value set in the rule takes effect.
if ($parentSuperAdmin === false)
{
// If parent is false (Denied), effective value will always be false
$groupSuperAdmin = false;
}
elseif ($parentSuperAdmin === true)
{
// If parent is true (allowed), group is true unless explicitly set to
false
$groupSuperAdmin = ($groupSuperAdmin === false) ? false : true;
}
// Check for non-super admin trying to save with super admin group
$iAmSuperAdmin =
JFactory::getUser()->authorise('core.admin');
if (!$iAmSuperAdmin && $groupSuperAdmin)
{
$this->setError(JText::_('JLIB_USER_ERROR_NOT_SUPERADMIN'));
return false;
}
/**
* Check for super-admin changing self to be non-super-admin
* First, are we a super admin
*/
if ($iAmSuperAdmin)
{
// Next, are we a member of the current group?
$myGroups =
JAccess::getGroupsByUser(JFactory::getUser()->get('id'),
false);
if (in_array($data['id'], $myGroups))
{
// Now, would we have super admin permissions without the current
group?
$otherGroups = array_diff($myGroups, array($data['id']));
$otherSuperAdmin = false;
foreach ($otherGroups as $otherGroup)
{
$otherSuperAdmin = $otherSuperAdmin ?:
JAccess::checkGroup($otherGroup, 'core.admin');
}
/**
* If we would not otherwise have super admin permissions
* and the current group does not have super admin permissions, throw
an exception
*/
if ((!$otherSuperAdmin) && (!$groupSuperAdmin))
{
$this->setError(JText::_('JLIB_USER_ERROR_CANNOT_DEMOTE_SELF'));
return false;
}
}
}
if (JFactory::getApplication()->input->get('task') ==
'save2copy')
{
$data['title'] =
$this->generateGroupTitle($data['parent_id'],
$data['title']);
}
// Proceed with the save
return parent::save($data);
}
/**
* Method to delete rows.
*
* @param array &$pks An array of item ids.
*
* @return boolean Returns true on success, false on failure.
*
* @since 1.6
* @throws Exception
*/
public function delete(&$pks)
{
// Typecast variable.
$pks = (array) $pks;
$user = JFactory::getUser();
$groups = JAccess::getGroupsByUser($user->get('id'));
// Get a row instance.
$table = $this->getTable();
// Load plugins.
JPluginHelper::importPlugin($this->events_map['delete']);
$dispatcher = JEventDispatcher::getInstance();
// Check if I am a Super Admin
$iAmSuperAdmin = $user->authorise('core.admin');
// Do not allow to delete groups to which the current user belongs
foreach ($pks as $pk)
{
if (in_array($pk, $groups))
{
JError::raiseWarning(403,
JText::_('COM_USERS_DELETE_ERROR_INVALID_GROUP'));
return false;
}
}
// Iterate the items to delete each one.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
// Access checks.
$allow = $user->authorise('core.edit.state',
'com_users');
// Don't allow non-super-admin to delete a super admin
$allow = (!$iAmSuperAdmin && JAccess::checkGroup($pk,
'core.admin')) ? false : $allow;
if ($allow)
{
// Fire the before delete event.
$dispatcher->trigger($this->event_before_delete,
array($table->getProperties()));
if (!$table->delete($pk))
{
$this->setError($table->getError());
return false;
}
else
{
// Trigger the after delete event.
$dispatcher->trigger($this->event_after_delete,
array($table->getProperties(), true, $this->getError()));
}
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
}
else
{
$this->setError($table->getError());
return false;
}
}
return true;
}
/**
* Method to generate the title of group on Save as Copy action
*
* @param integer $parentId The id of the parent.
* @param string $title The title of group
*
* @return string Contains the modified title.
*
* @since 3.3.7
*/
protected function generateGroupTitle($parentId, $title)
{
// Alter the title & alias
$table = $this->getTable();
while ($table->load(array('title' => $title,
'parent_id' => $parentId)))
{
if ($title == $table->title)
{
$title = StringHelper::increment($title);
}
}
return $title;
}
}
models/groups.php000064400000013453151160243100010056 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Methods supporting a list of user group records.
*
* @since 1.6
*/
class UsersModelGroups extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'parent_id', 'a.parent_id',
'title', 'a.title',
'lft', 'a.lft',
'rgt', 'a.rgt',
);
}
parent::__construct($config);
}
/**
* 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
*
* @since 1.6
*/
protected function populateState($ordering = 'a.lft', $direction
= 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
return parent::getStoreId($id);
}
/**
* Gets the list of groups and adds expensive joins to the result set.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.6
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId();
// Try to load the data from internal storage.
if (empty($this->cache[$store]))
{
$items = parent::getItems();
// Bail out on an error or empty list.
if (empty($items))
{
$this->cache[$store] = $items;
return $items;
}
try
{
$items = $this->populateExtraData($items);
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
}
return $this->cache[$store];
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from($db->quoteName('#__usergroups') . ' AS
a');
// Filter the comments over the search string if set.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('a.title LIKE ' . $search);
}
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.lft')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Populate level & path for items.
*
* @param array $items Array of stdClass objects
*
* @return array
*
* @since 3.6.3
*/
private function populateExtraData(array $items)
{
// First pass: get list of the group id's and reset the counts.
$groupsByKey = array();
foreach ($items as $item)
{
$groupsByKey[(int) $item->id] = $item;
}
$groupIds = array_keys($groupsByKey);
$db = $this->getDbo();
// Get total enabled users in group.
$query = $db->getQuery(true);
// Count the objects in the user group.
$query->select('map.group_id, COUNT(DISTINCT map.user_id) AS
user_count')
->from($db->quoteName('#__user_usergroup_map',
'map'))
->join('LEFT', $db->quoteName('#__users',
'u') . ' ON ' . $db->quoteName('u.id') .
' = ' . $db->quoteName('map.user_id'))
->where($db->quoteName('map.group_id') . ' IN
(' . implode(',', $groupIds) . ')')
->where($db->quoteName('u.block') . ' = 0')
->group($db->quoteName('map.group_id'));
$db->setQuery($query);
try
{
$countEnabled = $db->loadAssocList('group_id',
'count_enabled');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Get total disabled users in group.
$query->clear('where')
->where('map.group_id IN (' . implode(',',
$groupIds) . ')')
->where('u.block = 1');
$db->setQuery($query);
try
{
$countDisabled = $db->loadAssocList('group_id',
'count_disabled');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Inject the values back into the array.
foreach ($groupsByKey as &$item)
{
$item->count_enabled = isset($countEnabled[$item->id]) ? (int)
$countEnabled[$item->id]['user_count'] : 0;
$item->count_disabled = isset($countDisabled[$item->id]) ? (int)
$countDisabled[$item->id]['user_count'] : 0;
$item->user_count = $item->count_enabled +
$item->count_disabled;
}
$groups = new JHelperUsergroups($groupsByKey);
return array_values($groups->getAll());
}
}
models/level.php000064400000016443151160243100007650 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\UserGroupsHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\Utilities\ArrayHelper;
/**
* User view level model.
*
* @since 1.6
*/
class UsersModelLevel extends AdminModel
{
/**
* @var array A list of the access levels in use.
* @since 1.6
*/
protected $levelsInUse = null;
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the
permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
$groups = json_decode($record->rules);
if ($groups === null)
{
throw new RuntimeException('Invalid rules schema');
}
$isAdmin = JFactory::getUser()->authorise('core.admin');
// Check permissions
foreach ($groups as $group)
{
if (!$isAdmin && JAccess::checkGroup($group,
'core.admin'))
{
$this->setError(JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
}
// Check if the access level is being used by any content.
if ($this->levelsInUse === null)
{
// Populate the list once.
$this->levelsInUse = array();
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('DISTINCT access');
// Get all the tables and the prefix
$tables = $db->getTableList();
$prefix = $db->getPrefix();
foreach ($tables as $table)
{
// Get all of the columns in the table
$fields = $db->getTableColumns($table);
/**
* We are looking for the access field. If custom tables are using
something other
* than the 'access' field they are on their own
unfortunately.
* Also make sure the table prefix matches the live db prefix (eg, it
is not a "bak_" table)
*/
if (strpos($table, $prefix) === 0 &&
isset($fields['access']))
{
// Lookup the distinct values of the field.
$query->clear('from')
->from($db->quoteName($table));
$db->setQuery($query);
try
{
$values = $db->loadColumn();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
$this->levelsInUse = array_merge($this->levelsInUse, $values);
// TODO Could assemble an array of the tables used by each view level
list those,
// giving the user a clue in the error where to look.
}
}
// Get uniques.
$this->levelsInUse = array_unique($this->levelsInUse);
// Ok, after all that we are ready to check the record :)
}
if (in_array($record->id, $this->levelsInUse))
{
$this->setError(JText::sprintf('COM_USERS_ERROR_VIEW_LEVEL_IN_USE',
$record->id, $record->title));
return false;
}
return parent::canDelete($record);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Viewlevel', $prefix =
'JTable', $config = array())
{
$return = JTable::getInstance($type, $prefix, $config);
return $return;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
$result = parent::getItem($pk);
// Convert the params field to an array.
$result->rules = json_decode($result->rules);
return $result;
}
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to
interrogate.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.level',
'level', array('control' => 'jform',
'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_users.edit.level.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_users.level', $data);
return $data;
}
/**
* Method to preprocess the form
*
* @param JForm $form A form object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @since 1.6
* @throws Exception if there is an error loading the form.
*/
protected function preprocessForm(JForm $form, $data, $group =
'')
{
parent::preprocessForm($form, $data, 'user');
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
if (!isset($data['rules']))
{
$data['rules'] = array();
}
$data['title'] =
JFilterInput::getInstance()->clean($data['title'],
'TRIM');
return parent::save($data);
}
/**
* Method to validate the form data.
*
* @param \JForm $form The form to validate against.
* @param array $data The data to validate.
* @param string $group The name of the field group to validate.
*
* @return array|boolean Array of filtered data if valid, false
otherwise.
*
* @see \JFormRule
* @see \JFilterInput
* @since 3.8.8
*/
public function validate($form, $data, $group = null)
{
$isSuperAdmin = Factory::getUser()->authorise('core.admin');
// Non Super user should not be able to change the access levels of super
user groups
if (!$isSuperAdmin)
{
if (!isset($data['rules']) ||
!is_array($data['rules']))
{
$data['rules'] = array();
}
$groups = array_values(UserGroupsHelper::getInstance()->getAll());
$rules = array();
if (!empty($data['id']))
{
$table = $this->getTable();
$table->load($data['id']);
$rules = json_decode($table->rules);
}
$rules = ArrayHelper::toInteger($rules);
for ($i = 0, $n = count($groups); $i < $n; ++$i)
{
if (Access::checkGroup((int) $groups[$i]->id,
'core.admin'))
{
if (in_array((int) $groups[$i]->id, $rules) &&
!in_array((int) $groups[$i]->id, $data['rules']))
{
$data['rules'][] = (int) $groups[$i]->id;
}
elseif (!in_array((int) $groups[$i]->id, $rules) &&
in_array((int) $groups[$i]->id, $data['rules']))
{
$this->setError(Text::_('JLIB_USER_ERROR_NOT_SUPERADMIN'));
return false;
}
}
}
}
return parent::validate($form, $data, $group);
}
}
models/levels.php000064400000012357151160243100010033 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Methods supporting a list of user access level records.
*
* @since 1.6
*/
class UsersModelLevels extends JModelList
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'ordering', 'a.ordering',
);
}
parent::__construct($config);
}
/**
* 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
*
* @since 1.6
*/
protected function populateState($ordering = 'a.ordering',
$direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search'));
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from($db->quoteName('#__viewlevels') . ' AS
a');
// Add the level in the tree.
$query->group('a.id, a.title, a.ordering, a.rules');
// Filter the items over the search string if set.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('a.title LIKE ' . $search);
}
}
$query->group('a.id');
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.ordering')) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Method to adjust the ordering of a row.
*
* @param integer $pk The ID of the primary key to move.
* @param integer $direction Increment, usually +1 or -1
*
* @return boolean False on failure or error, true otherwise.
*/
public function reorder($pk, $direction = 0)
{
// Sanitize the id and adjustment.
$pk = (!empty($pk)) ? $pk : (int)
$this->getState('level.id');
$user = JFactory::getUser();
// Get an instance of the record's table.
$table = JTable::getInstance('viewlevel');
// Load the row.
if (!$table->load($pk))
{
$this->setError($table->getError());
return false;
}
// Access checks.
$allow = $user->authorise('core.edit.state',
'com_users');
if (!$allow)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
return false;
}
// Move the row.
// TODO: Where clause to restrict category.
$table->move($pk);
return true;
}
/**
* Saves the manually set order of records.
*
* @param array $pks An array of primary key ids.
* @param integer $order Order position
*
* @return boolean|JException Boolean true on success, boolean false or
JException instance on error
*/
public function saveorder($pks, $order)
{
$table = JTable::getInstance('viewlevel');
$user = JFactory::getUser();
$conditions = array();
if (empty($pks))
{
return JError::raiseWarning(500,
JText::_('COM_USERS_ERROR_LEVELS_NOLEVELS_SELECTED'));
}
// Update ordering values
foreach ($pks as $i => $pk)
{
$table->load((int) $pk);
// Access checks.
$allow = $user->authorise('core.edit.state',
'com_users');
if (!$allow)
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
elseif ($table->ordering != $order[$i])
{
$table->ordering = $order[$i];
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
}
}
// Execute reorder for each category.
foreach ($conditions as $cond)
{
$table->load($cond[0]);
$table->reorder($cond[1]);
}
return true;
}
}
models/mail.php000064400000013253151160243100007457 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users mail model.
*
* @since 1.6
*/
class UsersModelMail extends JModelAdmin
{
/**
* Method to get the row form.
*
* @param array $data An optional array of data for the form to
interrogate.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return JForm A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.mail', 'mail',
array('control' => 'jform', 'load_data'
=> $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_users.display.mail.data',
array());
$this->preprocessData('com_users.mail', $data);
return $data;
}
/**
* Method to preprocess the form
*
* @param JForm $form A form object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @since 1.6
* @throws Exception if there is an error loading the form.
*/
protected function preprocessForm(JForm $form, $data, $group =
'user')
{
parent::preprocessForm($form, $data, $group);
}
/**
* Send the email
*
* @return boolean
*/
public function send()
{
$app = JFactory::getApplication();
$data = $app->input->post->get('jform', array(),
'array');
$user = JFactory::getUser();
$access = new JAccess;
$db = $this->getDbo();
$mode = array_key_exists('mode', $data) ? (int)
$data['mode'] : 0;
$subject = array_key_exists('subject', $data) ?
$data['subject'] : '';
$grp = array_key_exists('group', $data) ? (int)
$data['group'] : 0;
$recurse = array_key_exists('recurse', $data) ? (int)
$data['recurse'] : 0;
$bcc = array_key_exists('bcc', $data) ? (int)
$data['bcc'] : 0;
$disabled = array_key_exists('disabled', $data) ? (int)
$data['disabled'] : 0;
$message_body = array_key_exists('message', $data) ?
$data['message'] : '';
// Automatically removes html formatting
if (!$mode)
{
$message_body = JFilterInput::getInstance()->clean($message_body,
'string');
}
// Check for a message body and subject
if (!$message_body || !$subject)
{
$app->setUserState('com_users.display.mail.data', $data);
$this->setError(JText::_('COM_USERS_MAIL_PLEASE_FILL_IN_THE_FORM_CORRECTLY'));
return false;
}
// Get users in the group out of the ACL, if group is provided.
$to = $grp !== 0 ? $access->getUsersByGroup($grp, $recurse) : array();
// When group is provided but no users are found in the group.
if ($grp !== 0 && !$to)
{
$rows = array();
}
else
{
// Get all users email and group except for senders
$query = $db->getQuery(true)
->select($db->quoteName('email'))
->from($db->quoteName('#__users'))
->where($db->quoteName('id') . ' != ' . (int)
$user->id);
if ($grp !== 0)
{
$query->where($db->quoteName('id') . ' IN ('
. implode(',', $to) . ')');
}
if ($disabled === 0)
{
$query->where($db->quoteName('block') . ' =
0');
}
$db->setQuery($query);
$rows = $db->loadColumn();
}
// Check to see if there are any users in this group before we continue
if (!$rows)
{
$app->setUserState('com_users.display.mail.data', $data);
if (in_array($user->id, $to))
{
$this->setError(JText::_('COM_USERS_MAIL_ONLY_YOU_COULD_BE_FOUND_IN_THIS_GROUP'));
}
else
{
$this->setError(JText::_('COM_USERS_MAIL_NO_USERS_COULD_BE_FOUND_IN_THIS_GROUP'));
}
return false;
}
// Get the Mailer
$mailer = JFactory::getMailer();
$params = JComponentHelper::getParams('com_users');
// Build email message format.
$mailer->setSender(array($app->get('mailfrom'),
$app->get('fromname')));
$mailer->setSubject($params->get('mailSubjectPrefix') .
stripslashes($subject));
$mailer->setBody($message_body .
$params->get('mailBodySuffix'));
$mailer->IsHtml($mode);
// Add recipients
if ($bcc)
{
$mailer->addBcc($rows);
$mailer->addRecipient($app->get('mailfrom'));
}
else
{
$mailer->addRecipient($rows);
}
// Send the Mail
$rs = $mailer->Send();
// Check for an error
if ($rs instanceof Exception)
{
$app->setUserState('com_users.display.mail.data', $data);
$this->setError($rs->getError());
return false;
}
elseif (empty($rs))
{
$app->setUserState('com_users.display.mail.data', $data);
$this->setError(JText::_('COM_USERS_MAIL_THE_MAIL_COULD_NOT_BE_SENT'));
return false;
}
else
{
/**
* Fill the data (specially for the 'mode', 'group'
and 'bcc': they could not exist in the array
* when the box is not checked and in this case, the default value would
be used instead of the '0'
* one)
*/
$data['mode'] = $mode;
$data['subject'] = $subject;
$data['group'] = $grp;
$data['recurse'] = $recurse;
$data['bcc'] = $bcc;
$data['message'] = $message_body;
$app->setUserState('com_users.display.mail.data', array());
$app->enqueueMessage(JText::plural('COM_USERS_MAIL_EMAIL_SENT_TO_N_USERS',
count($rows)), 'message');
return true;
}
}
}
models/note.php000064400000006433151160243100007504 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User note model.
*
* @since 2.5
*/
class UsersModelNote extends JModelAdmin
{
/**
* The type alias for this content type.
*
* @var string
* @since 3.2
*/
public $typeAlias = 'com_users.note';
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 2.5
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.note', 'note',
array('control' => 'jform', 'load_data'
=> $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 2.5
*/
public function getItem($pk = null)
{
$result = parent::getItem($pk);
// Get the dispatcher and load the content plugins.
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('content');
// Load the user plugins for backward compatibility (v3.3.3 and earlier).
JPluginHelper::importPlugin('user');
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData',
array('com_users.note', $result));
return $result;
}
/**
* Method to get a table object, load it if necessary.
*
* @param string $name The table name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $options Configuration array for model. Optional.
*
* @return JTable The table object
*
* @since 2.5
*/
public function getTable($name = 'Note', $prefix =
'UsersTable', $options = array())
{
return JTable::getInstance($name, $prefix, $options);
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Get the application
$app = JFactory::getApplication();
// Check the session for previously entered form data.
$data = $app->getUserState('com_users.edit.note.data',
array());
if (empty($data))
{
$data = $this->getItem();
// Prime some default values.
if ($this->getState('note.id') == 0)
{
$data->set('catid',
$app->input->get('catid',
$app->getUserState('com_users.notes.filter.category_id'),
'int'));
}
$userId = $app->input->get('u_id', 0, 'int');
if ($userId != 0)
{
$data->user_id = $userId;
}
}
$this->preprocessData('com_users.note', $data);
return $data;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 2.5
*/
protected function populateState()
{
parent::populateState();
$userId = JFactory::getApplication()->input->get('u_id',
0, 'int');
$this->setState('note.user_id', $userId);
}
}
models/notes.php000064400000013450151160243100007664 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User notes model class.
*
* @since 2.5
*/
class UsersModelNotes extends JModelList
{
/**
* Class constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 2.5
*/
public function __construct($config = array())
{
// Set the list ordering fields.
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'user_id', 'a.user_id',
'u.name',
'subject', 'a.subject',
'catid', 'a.catid', 'category_id',
'state', 'a.state', 'published',
'c.title',
'review_time', 'a.review_time',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'level', 'c.level',
);
}
parent::__construct($config);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data
set.
*
* @since 2.5
*/
protected function getListQuery()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState('list.select',
'a.id, a.subject, a.checked_out, a.checked_out_time,' .
'a.catid, a.created_time, a.review_time,' .
'a.state, a.publish_up, a.publish_down'
)
);
$query->from('#__user_notes AS a');
// Join over the category
$query->select('c.title AS category_title, c.params AS
category_params')
->join('LEFT', '#__categories AS c ON c.id =
a.catid');
// Join over the users for the note user.
$query->select('u.name AS user_name')
->join('LEFT', '#__users AS u ON u.id =
a.user_id');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id =
a.checked_out');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
elseif (stripos($search, 'uid:') === 0)
{
$query->where('a.user_id = ' . (int) substr($search, 4));
}
else
{
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
$query->where('((a.subject LIKE ' . $search . ') OR
(u.name LIKE ' . $search . ') OR (u.username LIKE ' .
$search . '))');
}
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.state IN (0, 1))');
}
// Filter by a single category.
$categoryId = (int) $this->getState('filter.category_id');
if ($categoryId)
{
$query->where('a.catid = ' . $categoryId);
}
// Filter by a single user.
$userId = (int) $this->getState('filter.user_id');
if ($userId)
{
// Add the body and where filter.
$query->select('a.body')
->where('a.user_id = ' . $userId);
}
// Filter on the level.
if ($level = $this->getState('filter.level'))
{
$query->where($db->quoteName('c.level') . ' <=
' . (int) $level);
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering',
'a.review_time')) . ' ' .
$db->escape($this->getState('list.direction',
'DESC')));
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 2.5
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.published');
$id .= ':' .
$this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.user_id');
$id .= ':' . $this->getState('filter.level');
return parent::getStoreId($id);
}
/**
* Gets a user object if the user filter is set.
*
* @return JUser The JUser object
*
* @since 2.5
*/
public function getUser()
{
$user = new JUser;
// Filter by search in title
$search = (int) $this->getState('filter.user_id');
if ($search != 0)
{
$user->load((int) $search);
}
return $user;
}
/**
* 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
*
* @since 1.6
*/
protected function populateState($ordering = 'a.review_time',
$direction = 'desc')
{
// Adjust the context to support modal layouts.
if ($layout =
JFactory::getApplication()->input->get('layout'))
{
$this->context .= '.' . $layout;
}
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search'));
$this->setState('filter.published',
$this->getUserStateFromRequest($this->context .
'.filter.published', 'filter_published', '',
'string'));
$this->setState('filter.category_id',
$this->getUserStateFromRequest($this->context .
'.filter.category_id', 'filter_category_id'));
$this->setState('filter.user_id',
$this->getUserStateFromRequest($this->context .
'.filter.user_id', 'filter_user_id'));
$this->setState('filter.level',
$this->getUserStateFromRequest($this->context .
'.filter.level', 'filter_level', '',
'cmd'));
parent::populateState($ordering, $direction);
}
}
models/user.php000064400000101446151160243100007515 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
/**
* User model.
*
* @since 1.6
*/
class UsersModelUser extends JModelAdmin
{
/**
* An item.
*
* @var array
*/
protected $_item = null;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @since 3.2
*/
public function __construct($config = array())
{
$config = array_merge(
array(
'event_after_delete' => 'onUserAfterDelete',
'event_after_save' => 'onUserAfterSave',
'event_before_delete' => 'onUserBeforeDelete',
'event_before_save' => 'onUserBeforeSave',
'events_map' => array('save' =>
'user', 'delete' => 'user',
'validate' => 'user')
), $config
);
parent::__construct($config);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param string $type The table type to instantiate
* @param string $prefix A prefix for the table class name. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'User', $prefix =
'JTable', $config = array())
{
$table = JTable::getInstance($type, $prefix, $config);
return $table;
}
/**
* Method to get a single record.
*
* @param integer $pk The id of the primary key.
*
* @return mixed Object on success, false on failure.
*
* @since 1.6
*/
public function getItem($pk = null)
{
$pk = (!empty($pk)) ? $pk : (int)
$this->getState('user.id');
if ($this->_item === null)
{
$this->_item = array();
}
if (!isset($this->_item[$pk]))
{
$this->_item[$pk] = parent::getItem($pk);
}
return $this->_item[$pk];
}
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to
interrogate.
* @param boolean $loadData True if the form is to load its own data
(default case), false if not.
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_users.user', 'user',
array('control' => 'jform', 'load_data'
=> $loadData));
if (empty($form))
{
return false;
}
// If the user needs to change their password, mark the password fields
as required
if (JFactory::getUser()->requireReset)
{
$form->setFieldAttribute('password', 'required',
'true');
$form->setFieldAttribute('password2', 'required',
'true');
}
// When multilanguage is set, a user's default site language should
also be a Content Language
if (JLanguageMultilang::isEnabled())
{
$form->setFieldAttribute('language', 'type',
'frontend_language', 'params');
}
$userId = $form->getValue('id');
// The user should not be able to set the requireReset value on their own
account
if ((int) $userId === (int) JFactory::getUser()->id)
{
$form->removeField('requireReset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data =
JFactory::getApplication()->getUserState('com_users.edit.user.data',
array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_users.profile', $data,
'user');
return $data;
}
/**
* Override JModelAdmin::preprocessForm to ensure the correct plugin group
is loaded.
*
* @param JForm $form A JForm object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import
(defaults to "content").
*
* @return void
*
* @since 1.6
* @throws Exception if there is an error in the form event.
*/
protected function preprocessForm(JForm $form, $data, $group =
'user')
{
parent::preprocessForm($form, $data, $group);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function save($data)
{
$pk = (!empty($data['id'])) ? $data['id'] : (int)
$this->getState('user.id');
$user = JUser::getInstance($pk);
$my = JFactory::getUser();
$iAmSuperAdmin = $my->authorise('core.admin');
// User cannot modify own user groups
if ((int) $user->id == (int) $my->id && !$iAmSuperAdmin
&& isset($data['groups']))
{
// Form was probably tampered with
JFactory::getApplication()->enqueueMessage(JText::_('COM_USERS_USERS_ERROR_CANNOT_EDIT_OWN_GROUP'),
'warning');
$data['groups'] = null;
}
if ($data['block'] && $pk == $my->id &&
!$my->block)
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF'));
return false;
}
// Make sure user groups is selected when add/edit an account
if (empty($data['groups']) && ((int) $user->id !=
(int) $my->id || $iAmSuperAdmin))
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_SAVE_ACCOUNT_WITHOUT_GROUPS'));
return false;
}
// Make sure that we are not removing ourself from Super Admin group
if ($iAmSuperAdmin && $my->get('id') == $pk)
{
// Check that at least one of our new groups is Super Admin
$stillSuperAdmin = false;
$myNewGroups = $data['groups'];
foreach ($myNewGroups as $group)
{
$stillSuperAdmin = $stillSuperAdmin ?: JAccess::checkGroup($group,
'core.admin');
}
if (!$stillSuperAdmin)
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_DEMOTE_SELF'));
return false;
}
}
// Handle the two factor authentication setup
if (array_key_exists('twofactor', $data))
{
$twoFactorMethod = $data['twofactor']['method'];
// Get the current One Time Password (two factor auth) configuration
$otpConfig = $this->getOtpConfig($pk);
if ($twoFactorMethod != 'none')
{
// Run the plugins
FOFPlatform::getInstance()->importPlugin('twofactorauth');
$otpConfigReplies =
FOFPlatform::getInstance()->runPlugins('onUserTwofactorApplyConfiguration',
array($twoFactorMethod));
// Look for a valid reply
foreach ($otpConfigReplies as $reply)
{
if (!is_object($reply) || empty($reply->method) ||
($reply->method != $twoFactorMethod))
{
continue;
}
$otpConfig->method = $reply->method;
$otpConfig->config = $reply->config;
break;
}
// Save OTP configuration.
$this->setOtpConfig($pk, $otpConfig);
// Generate one time emergency passwords if required (depleted or not
set)
if (empty($otpConfig->otep))
{
$oteps = $this->generateOteps($pk);
}
}
else
{
$otpConfig->method = 'none';
$otpConfig->config = array();
$this->setOtpConfig($pk, $otpConfig);
}
// Unset the raw data
unset($data['twofactor']);
// Reload the user record with the updated OTP configuration
$user->load($pk);
}
// Bind the data.
if (!$user->bind($data))
{
$this->setError($user->getError());
return false;
}
// Store the data.
if (!$user->save())
{
$this->setError($user->getError());
return false;
}
$this->setState('user.id', $user->id);
return true;
}
/**
* Method to delete rows.
*
* @param array &$pks An array of item ids.
*
* @return boolean Returns true on success, false on failure.
*
* @since 1.6
*/
public function delete(&$pks)
{
$user = JFactory::getUser();
$table = $this->getTable();
$pks = (array) $pks;
// Check if I am a Super Admin
$iAmSuperAdmin = $user->authorise('core.admin');
JPluginHelper::importPlugin($this->events_map['delete']);
$dispatcher = JEventDispatcher::getInstance();
if (in_array($user->id, $pks))
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_DELETE_SELF'));
return false;
}
// Iterate the items to delete each one.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
// Access checks.
$allow = $user->authorise('core.delete',
'com_users');
// Don't allow non-super-admin to delete a super admin
$allow = (!$iAmSuperAdmin && JAccess::check($pk,
'core.admin')) ? false : $allow;
if ($allow)
{
// Get users data for the users to delete.
$user_to_delete = JFactory::getUser($pk);
// Fire the before delete event.
$dispatcher->trigger($this->event_before_delete,
array($table->getProperties()));
if (!$table->delete($pk))
{
$this->setError($table->getError());
return false;
}
else
{
// Trigger the after delete event.
$dispatcher->trigger($this->event_after_delete,
array($user_to_delete->getProperties(), true, $this->getError()));
}
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
}
else
{
$this->setError($table->getError());
return false;
}
}
return true;
}
/**
* Method to block user records.
*
* @param array &$pks The ids of the items to publish.
* @param integer $value The value of the published state
*
* @return boolean True on success.
*
* @since 1.6
*/
public function block(&$pks, $value = 1)
{
$app = JFactory::getApplication();
$dispatcher = JEventDispatcher::getInstance();
$user = JFactory::getUser();
// Check if I am a Super Admin
$iAmSuperAdmin = $user->authorise('core.admin');
$table = $this->getTable();
$pks = (array) $pks;
JPluginHelper::importPlugin($this->events_map['save']);
// Prepare the logout options.
$options = array(
'clientid' => $app->get('shared_session',
'0') ? null : 0,
);
// Access checks.
foreach ($pks as $i => $pk)
{
if ($value == 1 && $pk == $user->get('id'))
{
// Cannot block yourself.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF'));
}
elseif ($table->load($pk))
{
$old = $table->getProperties();
$allow = $user->authorise('core.edit.state',
'com_users');
// Don't allow non-super-admin to delete a super admin
$allow = (!$iAmSuperAdmin && JAccess::check($pk,
'core.admin')) ? false : $allow;
if ($allow)
{
// Skip changing of same state
if ($table->block == $value)
{
unset($pks[$i]);
continue;
}
$table->block = (int) $value;
// If unblocking, also change password reset count to zero to unblock
reset
if ($table->block === 0)
{
$table->resetCount = 0;
}
// Allow an exception to be thrown.
try
{
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Trigger the before save event.
$result = $dispatcher->trigger($this->event_before_save,
array($old, false, $table->getProperties()));
if (in_array(false, $result, true))
{
// Plugin will have to raise its own error or throw an exception.
return false;
}
// Store the table.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Trigger the after save event
$dispatcher->trigger($this->event_after_save,
array($table->getProperties(), false, true, null));
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
// Log the user out.
if ($value)
{
$app->logout($table->id, $options);
}
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
}
}
return true;
}
/**
* Method to activate user records.
*
* @param array &$pks The ids of the items to activate.
*
* @return boolean True on success.
*
* @since 1.6
*/
public function activate(&$pks)
{
$dispatcher = JEventDispatcher::getInstance();
$user = JFactory::getUser();
// Check if I am a Super Admin
$iAmSuperAdmin = $user->authorise('core.admin');
$table = $this->getTable();
$pks = (array) $pks;
JPluginHelper::importPlugin($this->events_map['save']);
// Access checks.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
$old = $table->getProperties();
$allow = $user->authorise('core.edit.state',
'com_users');
// Don't allow non-super-admin to delete a super admin
$allow = (!$iAmSuperAdmin && JAccess::check($pk,
'core.admin')) ? false : $allow;
if (empty($table->activation))
{
// Ignore activated accounts.
unset($pks[$i]);
}
elseif ($allow)
{
$table->block = 0;
$table->activation = '';
// Allow an exception to be thrown.
try
{
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Trigger the before save event.
$result = $dispatcher->trigger($this->event_before_save,
array($old, false, $table->getProperties()));
if (in_array(false, $result, true))
{
// Plugin will have to raise it's own error or throw an
exception.
return false;
}
// Store the table.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Fire the after save event
$dispatcher->trigger($this->event_after_save,
array($table->getProperties(), false, true, null));
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
}
else
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403,
JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
}
}
return true;
}
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 2.5
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize user ids.
$pks = array_unique($pks);
$pks = ArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('COM_USERS_USERS_NO_ITEM_SELECTED'));
return false;
}
$done = false;
if (!empty($commands['group_id']))
{
$cmd = ArrayHelper::getValue($commands, 'group_action',
'add');
if (!$this->batchUser((int) $commands['group_id'], $pks,
$cmd))
{
return false;
}
$done = true;
}
if (!empty($commands['reset_id']))
{
if (!$this->batchReset($pks, $commands['reset_id']))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch flag users as being required to reset their passwords
*
* @param array $userIds An array of user IDs on which to operate
* @param string $action The action to perform
*
* @return boolean True on success, false on failure
*
* @since 3.2
*/
public function batchReset($userIds, $action)
{
$userIds = ArrayHelper::toInteger($userIds);
// Check if I am a Super Admin
$iAmSuperAdmin =
JFactory::getUser()->authorise('core.admin');
// Non-super super user cannot work with super-admin user.
if (!$iAmSuperAdmin &&
JUserHelper::checkSuperUserInUsers($userIds))
{
$this->setError(JText::_('COM_USERS_ERROR_CANNOT_BATCH_SUPERUSER'));
return false;
}
// Set the action to perform
if ($action === 'yes')
{
$value = 1;
}
else
{
$value = 0;
}
// Prune out the current user if they are in the supplied user ID array
$userIds = array_diff($userIds, array(JFactory::getUser()->id));
if (empty($userIds))
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_REQUIRERESET_SELF'));
return false;
}
// Get the DB object
$db = $this->getDbo();
$userIds = ArrayHelper::toInteger($userIds);
$query = $db->getQuery(true);
// Update the reset flag
$query->update($db->quoteName('#__users'))
->set($db->quoteName('requireReset') . ' = ' .
$value)
->where($db->quoteName('id') . ' IN (' .
implode(',', $userIds) . ')');
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
return true;
}
/**
* Perform batch operations
*
* @param integer $groupId The group ID which assignments are being
edited
* @param array $userIds An array of user IDs on which to operate
* @param string $action The action to perform
*
* @return boolean True on success, false on failure
*
* @since 1.6
*/
public function batchUser($groupId, $userIds, $action)
{
$userIds = ArrayHelper::toInteger($userIds);
// Check if I am a Super Admin
$iAmSuperAdmin =
JFactory::getUser()->authorise('core.admin');
// Non-super super user cannot work with super-admin user.
if (!$iAmSuperAdmin &&
JUserHelper::checkSuperUserInUsers($userIds))
{
$this->setError(JText::_('COM_USERS_ERROR_CANNOT_BATCH_SUPERUSER'));
return false;
}
// Non-super admin cannot work with super-admin group.
if ((!$iAmSuperAdmin && JAccess::checkGroup($groupId,
'core.admin')) || $groupId < 1)
{
$this->setError(JText::_('COM_USERS_ERROR_INVALID_GROUP'));
return false;
}
// Get the DB object
$db = $this->getDbo();
switch ($action)
{
// Sets users to a selected group
case 'set':
$doDelete = 'all';
$doAssign = true;
break;
// Remove users from a selected group
case 'del':
$doDelete = 'group';
break;
// Add users to a selected group
case 'add':
default:
$doAssign = true;
break;
}
// Remove the users from the group if requested.
if (isset($doDelete))
{
$query = $db->getQuery(true);
// Remove users from the group
$query->delete($db->quoteName('#__user_usergroup_map'))
->where($db->quoteName('user_id') . ' IN (' .
implode(',', $userIds) . ')');
// Only remove users from selected group
if ($doDelete == 'group')
{
$query->where($db->quoteName('group_id') . ' =
' . (int) $groupId);
}
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
// Assign the users to the group if requested.
if (isset($doAssign))
{
$query = $db->getQuery(true);
// First, we need to check if the user is already assigned to a group
$query->select($db->quoteName('user_id'))
->from($db->quoteName('#__user_usergroup_map'))
->where($db->quoteName('group_id') . ' = ' .
(int) $groupId);
$db->setQuery($query);
$users = $db->loadColumn();
// Build the values clause for the assignment query.
$query->clear();
$groups = false;
foreach ($userIds as $id)
{
if (!in_array($id, $users))
{
$query->values($id . ',' . $groupId);
$groups = true;
}
}
// If we have no users to process, throw an error to notify the user
if (!$groups)
{
$this->setError(JText::_('COM_USERS_ERROR_NO_ADDITIONS'));
return false;
}
$query->insert($db->quoteName('#__user_usergroup_map'))
->columns(array($db->quoteName('user_id'),
$db->quoteName('group_id')));
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
return true;
}
/**
* Gets the available groups.
*
* @return array An array of groups
*
* @since 1.6
*/
public function getGroups()
{
$user = JFactory::getUser();
if ($user->authorise('core.edit', 'com_users')
&& $user->authorise('core.manage',
'com_users'))
{
$model = JModelLegacy::getInstance('Groups',
'UsersModel', array('ignore_request' => true));
return $model->getItems();
}
else
{
return null;
}
}
/**
* Gets the groups this object is assigned to
*
* @param integer $userId The user ID to retrieve the groups for
*
* @return array An array of assigned groups
*
* @since 1.6
*/
public function getAssignedGroups($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
if (empty($userId))
{
$result = array();
$form = $this->getForm();
if ($form)
{
$groupsIDs = $form->getValue('groups');
}
if (!empty($groupsIDs))
{
$result = $groupsIDs;
}
else
{
$params = JComponentHelper::getParams('com_users');
if ($groupId = $params->get('new_usertype',
$params->get('guest_usergroup', 1)))
{
$result[] = $groupId;
}
}
}
else
{
$result = JUserHelper::getUserGroups($userId);
}
return $result;
}
/**
* Returns the one time password (OTP) – a.k.a. two factor
authentication –
* configuration for a particular user.
*
* @param integer $userId The numeric ID of the user
*
* @return stdClass An object holding the OTP configuration for this
user
*
* @since 3.2
*/
public function getOtpConfig($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
// Initialise
$otpConfig = (object) array(
'method' => 'none',
'config' => array(),
'otep' => array()
);
/**
* Get the raw data, without going through JUser (required in order to
* be able to modify the user record before logging in the user).
*/
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('*')
->from($db->qn('#__users'))
->where($db->qn('id') . ' = ' . (int)
$userId);
$db->setQuery($query);
$item = $db->loadObject();
// Make sure this user does have OTP enabled
if (empty($item->otpKey))
{
return $otpConfig;
}
// Get the encrypted data
list($method, $config) = explode(':', $item->otpKey, 2);
$encryptedOtep = $item->otep;
// Get the secret key, yes the thing that is saved in the configuration
file
$key = $this->getOtpConfigEncryptionKey();
if (strpos($config, '{') === false)
{
$openssl = new FOFEncryptAes($key, 256);
$mcrypt = new FOFEncryptAes($key, 256, 'cbc', null,
'mcrypt');
$decryptedConfig = $mcrypt->decryptString($config);
if (strpos($decryptedConfig, '{') !== false)
{
// Data encrypted with mcrypt
$decryptedOtep = $mcrypt->decryptString($encryptedOtep);
$encryptedOtep = $openssl->encryptString($decryptedOtep);
}
else
{
// Config data seems to be save encrypted, this can happen with 3.6.3
and openssl, lets get the data
$decryptedConfig = $openssl->decryptString($config);
}
$otpKey = $method . ':' . $decryptedConfig;
$query = $db->getQuery(true)
->update($db->qn('#__users'))
->set($db->qn('otep') . '=' .
$db->q($encryptedOtep))
->set($db->qn('otpKey') . '=' .
$db->q($otpKey))
->where($db->qn('id') . ' = ' .
$db->q($userId));
$db->setQuery($query);
$db->execute();
}
else
{
$decryptedConfig = $config;
}
// Create an encryptor class
$aes = new FOFEncryptAes($key, 256);
// Decrypt the data
$decryptedOtep = $aes->decryptString($encryptedOtep);
// Remove the null padding added during encryption
$decryptedConfig = rtrim($decryptedConfig, "\0");
$decryptedOtep = rtrim($decryptedOtep, "\0");
// Update the configuration object
$otpConfig->method = $method;
$otpConfig->config = @json_decode($decryptedConfig);
$otpConfig->otep = @json_decode($decryptedOtep);
/*
* If the decryption failed for any reason we essentially disable the
* two-factor authentication. This prevents impossible to log in sites
* if the site admin changes the site secret for any reason.
*/
if (is_null($otpConfig->config))
{
$otpConfig->config = array();
}
if (is_object($otpConfig->config))
{
$otpConfig->config = (array) $otpConfig->config;
}
if (is_null($otpConfig->otep))
{
$otpConfig->otep = array();
}
if (is_object($otpConfig->otep))
{
$otpConfig->otep = (array) $otpConfig->otep;
}
// Return the configuration object
return $otpConfig;
}
/**
* Sets the one time password (OTP) – a.k.a. two factor authentication
–
* configuration for a particular user. The $otpConfig object is the same
as
* the one returned by the getOtpConfig method.
*
* @param integer $userId The numeric ID of the user
* @param stdClass $otpConfig The OTP configuration object
*
* @return boolean True on success
*
* @since 3.2
*/
public function setOtpConfig($userId, $otpConfig)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
$updates = (object) array(
'id' => $userId,
'otpKey' => '',
'otep' => ''
);
// Create an encryptor class
$key = $this->getOtpConfigEncryptionKey();
$aes = new FOFEncryptAes($key, 256);
// Create the encrypted option strings
if (!empty($otpConfig->method) && ($otpConfig->method !=
'none'))
{
$decryptedConfig = json_encode($otpConfig->config);
$decryptedOtep = json_encode($otpConfig->otep);
$updates->otpKey = $otpConfig->method . ':' .
$decryptedConfig;
$updates->otep = $aes->encryptString($decryptedOtep);
}
$db = $this->getDbo();
$result = $db->updateObject('#__users', $updates,
'id');
return $result;
}
/**
* Gets the symmetric encryption key for the OTP configuration data. It
* currently returns the site's secret.
*
* @return string The encryption key
*
* @since 3.2
*/
public function getOtpConfigEncryptionKey()
{
return JFactory::getConfig()->get('secret');
}
/**
* Gets the configuration forms for all two-factor authentication methods
* in an array.
*
* @param integer $userId The user ID to load the forms for (optional)
*
* @return array
*
* @since 3.2
*/
public function getTwofactorform($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
$otpConfig = $this->getOtpConfig($userId);
FOFPlatform::getInstance()->importPlugin('twofactorauth');
return
FOFPlatform::getInstance()->runPlugins('onUserTwofactorShowConfiguration',
array($otpConfig, $userId));
}
/**
* Generates a new set of One Time Emergency Passwords (OTEPs) for a given
user.
*
* @param integer $userId The user ID
* @param integer $count How many OTEPs to generate? Default: 10
*
* @return array The generated OTEPs
*
* @since 3.2
*/
public function generateOteps($userId, $count = 10)
{
$userId = (!empty($userId)) ? $userId : (int)
$this->getState('user.id');
// Initialise
$oteps = array();
// Get the OTP configuration for the user
$otpConfig = $this->getOtpConfig($userId);
// If two factor authentication is not enabled, abort
if (empty($otpConfig->method) || ($otpConfig->method ==
'none'))
{
return $oteps;
}
$salt = '0123456789';
$base = strlen($salt);
$length = 16;
for ($i = 0; $i < $count; $i++)
{
$makepass = '';
$random = JCrypt::genRandomBytes($length + 1);
$shift = ord($random[0]);
for ($j = 1; $j <= $length; ++$j)
{
$makepass .= $salt[($shift + ord($random[$j])) % $base];
$shift += ord($random[$j]);
}
$oteps[] = $makepass;
}
$otpConfig->otep = $oteps;
// Save the now modified OTP configuration
$this->setOtpConfig($userId, $otpConfig);
return $oteps;
}
/**
* Checks if the provided secret key is a valid two factor authentication
* secret key. If not, it will check it against the list of one time
* emergency passwords (OTEPs). If it's a valid OTEP it will also
remove it
* from the user's list of OTEPs.
*
* This method will return true in the following conditions:
* - The two factor authentication is not enabled
* - You have provided a valid secret key for
* - You have provided a valid OTEP
*
* You can define the following options in the $options array:
* otp_config The OTP (one time password, a.k.a. two factor auth)
* configuration object. If not set we'll load it
automatically.
* warn_if_not_req Issue a warning if you are checking a secret key
against
* a user account which doesn't have any two factor
* authentication method enabled.
* warn_irq_msg The string to use for the warn_if_not_req warning
*
* @param integer $userId The user's numeric ID
* @param string $secretKey The secret key you want to check
* @param array $options Options; see above
*
* @return boolean True if it's a valid secret key for this user.
*
* @since 3.2
*/
public function isValidSecretKey($userId, $secretKey, $options = array())
{
// Load the user's OTP (one time password, a.k.a. two factor auth)
configuration
if (!array_key_exists('otp_config', $options))
{
$otpConfig = $this->getOtpConfig($userId);
$options['otp_config'] = $otpConfig;
}
else
{
$otpConfig = $options['otp_config'];
}
// Check if the user has enabled two factor authentication
if (empty($otpConfig->method) || ($otpConfig->method ==
'none'))
{
// Load language
$lang = JFactory::getLanguage();
$extension = 'com_users';
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load($extension, JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load($extension, $source, null, false, true);
$warn = true;
$warnMessage =
JText::_('COM_USERS_ERROR_SECRET_CODE_WITHOUT_TFA');
if (array_key_exists('warn_if_not_req', $options))
{
$warn = $options['warn_if_not_req'];
}
if (array_key_exists('warn_irq_msg', $options))
{
$warnMessage = $options['warn_irq_msg'];
}
// Warn the user if they are using a secret code but they have not
// enabled two factor auth in their account.
if (!empty($secretKey) && $warn)
{
try
{
$app = JFactory::getApplication();
$app->enqueueMessage($warnMessage, 'warning');
}
catch (Exception $exc)
{
// This happens when we are in CLI mode. In this case
// no warning is issued
return true;
}
}
return true;
}
$credentials = array(
'secretkey' => $secretKey,
);
// Try to validate the OTP
FOFPlatform::getInstance()->importPlugin('twofactorauth');
$otpAuthReplies =
FOFPlatform::getInstance()->runPlugins('onUserTwofactorAuthenticate',
array($credentials, $options));
$check = false;
/*
* This looks like noob code but DO NOT TOUCH IT and do not convert
* to in_array(). During testing in_array() inexplicably returned
* null when the OTEP begins with a zero! o_O
*/
if (!empty($otpAuthReplies))
{
foreach ($otpAuthReplies as $authReply)
{
$check = $check || $authReply;
}
}
// Fall back to one time emergency passwords
if (!$check)
{
$check = $this->isValidOtep($userId, $secretKey, $otpConfig);
}
return $check;
}
/**
* Checks if the supplied string is a valid one time emergency password
* (OTEP) for this user. If it is it will be automatically removed from
the
* user's list of OTEPs.
*
* @param integer $userId The user ID against which you are
checking
* @param string $otep The string you want to test for validity
* @param object $otpConfig Optional; the two factor authentication
configuration (automatically fetched if not set)
*
* @return boolean True if it's a valid OTEP or if two factor auth
is not
* enabled in this user's account.
*
* @since 3.2
*/
public function isValidOtep($userId, $otep, $otpConfig = null)
{
if (is_null($otpConfig))
{
$otpConfig = $this->getOtpConfig($userId);
}
// Did the user use an OTEP instead?
if (empty($otpConfig->otep))
{
if (empty($otpConfig->method) || ($otpConfig->method ==
'none'))
{
// Two factor authentication is not enabled on this account.
// Any string is assumed to be a valid OTEP.
return true;
}
else
{
/**
* Two factor authentication enabled and no OTEPs defined. The
* user has used them all up. Therefore anything they enter is
* an invalid OTEP.
*/
return false;
}
}
// Clean up the OTEP (remove dashes, spaces and other funny stuff
// our beloved users may have unwittingly stuffed in it)
$otep = filter_var($otep, FILTER_SANITIZE_NUMBER_INT);
$otep = str_replace('-', '', $otep);
$check = false;
// Did we find a valid OTEP?
if (in_array($otep, $otpConfig->otep))
{
// Remove the OTEP from the array
$otpConfig->otep = array_diff($otpConfig->otep, array($otep));
$this->setOtpConfig($userId, $otpConfig);
// Return true; the OTEP was a valid one
$check = true;
}
return $check;
}
}
models/users.php000064400000032004151160243100007671 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* Methods supporting a list of user records.
*
* @since 1.6
*/
class UsersModelUsers extends JModelList
{
/**
* A blacklist of filter variables to not merge into the model's
state
*
* @var array
*/
protected $filterBlacklist = array('groups',
'excluded');
/**
* Constructor.
*
* @param array $config An optional associative array of configuration
settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'name', 'a.name',
'username', 'a.username',
'email', 'a.email',
'block', 'a.block',
'sendEmail', 'a.sendEmail',
'registerDate', 'a.registerDate',
'lastvisitDate', 'a.lastvisitDate',
'activation', 'a.activation',
'active',
'group_id',
'range',
'lastvisitrange',
'state',
);
}
parent::__construct($config);
}
/**
* 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
*
* @since 1.6
*/
protected function populateState($ordering = 'a.name',
$direction = 'asc')
{
$app = JFactory::getApplication('administrator');
// Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout',
'default', 'cmd'))
{
$this->context .= '.' . $layout;
}
// Load the filter state.
$this->setState('filter.search',
$this->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search', '',
'string'));
$this->setState('filter.active',
$this->getUserStateFromRequest($this->context .
'.filter.active', 'filter_active', '',
'cmd'));
$this->setState('filter.state',
$this->getUserStateFromRequest($this->context .
'.filter.state', 'filter_state', '',
'cmd'));
$this->setState('filter.group_id',
$this->getUserStateFromRequest($this->context .
'.filter.group_id', 'filter_group_id', null,
'int'));
$this->setState('filter.range',
$this->getUserStateFromRequest($this->context .
'.filter.range', 'filter_range', '',
'cmd'));
$this->setState(
'filter.lastvisitrange',
$this->getUserStateFromRequest($this->context .
'.filter.lastvisitrange', 'filter_lastvisitrange',
'', 'cmd')
);
$groups =
json_decode(base64_decode($app->input->get('groups',
'', 'BASE64')));
if (isset($groups))
{
$groups = ArrayHelper::toInteger($groups);
}
$this->setState('filter.groups', $groups);
$excluded =
json_decode(base64_decode($app->input->get('excluded',
'', 'BASE64')));
if (isset($excluded))
{
$excluded = ArrayHelper::toInteger($excluded);
}
$this->setState('filter.excluded', $excluded);
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.active');
$id .= ':' . $this->getState('filter.state');
$id .= ':' . $this->getState('filter.group_id');
$id .= ':' . $this->getState('filter.range');
return parent::getStoreId($id);
}
/**
* Gets the list of users and adds expensive joins to the result set.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.6
*/
public function getItems()
{
// Get a storage key.
$store = $this->getStoreId();
// Try to load the data from internal storage.
if (empty($this->cache[$store]))
{
$groups = $this->getState('filter.groups');
$groupId = $this->getState('filter.group_id');
if (isset($groups) && (empty($groups) || $groupId &&
!in_array($groupId, $groups)))
{
$items = array();
}
else
{
$items = parent::getItems();
}
// Bail out on an error or empty list.
if (empty($items))
{
$this->cache[$store] = $items;
return $items;
}
// Joining the groups with the main query is a performance hog.
// Find the information only on the result set.
// First pass: get list of the user id's and reset the counts.
$userIds = array();
foreach ($items as $item)
{
$userIds[] = (int) $item->id;
$item->group_count = 0;
$item->group_names = '';
$item->note_count = 0;
}
// Get the counts from the database only for the users in the list.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Join over the group mapping table.
$query->select('map.user_id, COUNT(map.group_id) AS
group_count')
->from('#__user_usergroup_map AS map')
->where('map.user_id IN (' . implode(',',
$userIds) . ')')
->group('map.user_id')
// Join over the user groups table.
->join('LEFT', '#__usergroups AS g2 ON g2.id =
map.group_id');
$db->setQuery($query);
// Load the counts into an array indexed on the user id field.
try
{
$userGroups = $db->loadObjectList('user_id');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
$query->clear()
->select('n.user_id, COUNT(n.id) As note_count')
->from('#__user_notes AS n')
->where('n.user_id IN (' . implode(',',
$userIds) . ')')
->where('n.state >= 0')
->group('n.user_id');
$db->setQuery($query);
// Load the counts into an array indexed on the aro.value field (the
user id).
try
{
$userNotes = $db->loadObjectList('user_id');
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// Second pass: collect the group counts into the master items array.
foreach ($items as &$item)
{
if (isset($userGroups[$item->id]))
{
$item->group_count = $userGroups[$item->id]->group_count;
// Group_concat in other databases is not supported
$item->group_names =
$this->_getUserDisplayedGroups($item->id);
}
if (isset($userNotes[$item->id]))
{
$item->note_count = $userNotes[$item->id]->note_count;
}
}
// Add the items to the internal cache.
$this->cache[$store] = $items;
}
return $this->cache[$store];
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.*'
)
);
$query->from($db->quoteName('#__users') . ' AS
a');
// If the model is set to check item state, add to the query.
$state = $this->getState('filter.state');
if (is_numeric($state))
{
$query->where('a.block = ' . (int) $state);
}
// If the model is set to check the activated state, add to the query.
$active = $this->getState('filter.active');
if (is_numeric($active))
{
if ($active == '0')
{
$query->where('a.activation IN (' .
$db->quote('') . ', ' . $db->quote('0')
. ')');
}
elseif ($active == '1')
{
$query->where($query->length('a.activation') . '
> 1');
}
}
// Filter the items over the group id if set.
$groupId = $this->getState('filter.group_id');
$groups = $this->getState('filter.groups');
if ($groupId || isset($groups))
{
$query->join('LEFT', '#__user_usergroup_map AS map2 ON
map2.user_id = a.id')
->group(
$db->quoteName(
array(
'a.id',
'a.name',
'a.username',
'a.password',
'a.block',
'a.sendEmail',
'a.registerDate',
'a.lastvisitDate',
'a.activation',
'a.params',
'a.email'
)
)
);
if ($groupId)
{
$query->where('map2.group_id = ' . (int) $groupId);
}
if (isset($groups))
{
$query->where('map2.group_id IN (' .
implode(',', $groups) . ')');
}
}
// Filter the items over the search string if set.
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
elseif (stripos($search, 'username:') === 0)
{
$search = $db->quote('%' . $db->escape(substr($search,
9), true) . '%');
$query->where('a.username LIKE ' . $search);
}
else
{
// Escape the search token.
$search = $db->quote('%' . str_replace(' ',
'%', $db->escape(trim($search), true) . '%'));
// Compile the different search clauses.
$searches = array();
$searches[] = 'a.name LIKE ' . $search;
$searches[] = 'a.username LIKE ' . $search;
$searches[] = 'a.email LIKE ' . $search;
// Add the clauses to the query.
$query->where('(' . implode(' OR ', $searches) .
')');
}
}
// Add filter for registration ranges select list
$range = $this->getState('filter.range');
// Apply the range filter.
if ($range)
{
$dates = $this->buildDateRange($range);
if ($dates['dNow'] === false)
{
$query->where(
$db->qn('a.registerDate') . ' < ' .
$db->quote($dates['dStart']->format('Y-m-d
H:i:s'))
);
}
else
{
$query->where(
$db->qn('a.registerDate') . ' >= ' .
$db->quote($dates['dStart']->format('Y-m-d
H:i:s')) .
' AND ' . $db->qn('a.registerDate') . '
<= ' .
$db->quote($dates['dNow']->format('Y-m-d H:i:s'))
);
}
}
// Add filter for registration ranges select list
$lastvisitrange = $this->getState('filter.lastvisitrange');
// Apply the range filter.
if ($lastvisitrange)
{
$dates = $this->buildDateRange($lastvisitrange);
if (is_string($dates['dStart']))
{
$query->where(
$db->qn('a.lastvisitDate') . ' = ' .
$db->quote($dates['dStart'])
);
}
elseif ($dates['dNow'] === false)
{
$query->where(
$db->qn('a.lastvisitDate') . ' < ' .
$db->quote($dates['dStart']->format('Y-m-d
H:i:s'))
);
}
else
{
$query->where(
$db->qn('a.lastvisitDate') . ' >= ' .
$db->quote($dates['dStart']->format('Y-m-d
H:i:s')) .
' AND ' . $db->qn('a.lastvisitDate') . '
<= ' .
$db->quote($dates['dNow']->format('Y-m-d H:i:s'))
);
}
}
// Filter by excluded users
$excluded = $this->getState('filter.excluded');
if (!empty($excluded))
{
$query->where('id NOT IN (' . implode(',',
$excluded) . ')');
}
// Add the list ordering clause.
$query->order($db->qn($db->escape($this->getState('list.ordering',
'a.name'))) . ' ' .
$db->escape($this->getState('list.direction',
'ASC')));
return $query;
}
/**
* Construct the date range to filter on.
*
* @param string $range The textual range to construct the filter for.
*
* @return string The date range to filter on.
*
* @since 3.6.0
*/
private function buildDateRange($range)
{
// Get UTC for now.
$dNow = new JDate;
$dStart = clone $dNow;
switch ($range)
{
case 'past_week':
$dStart->modify('-7 day');
break;
case 'past_1month':
$dStart->modify('-1 month');
break;
case 'past_3month':
$dStart->modify('-3 month');
break;
case 'past_6month':
$dStart->modify('-6 month');
break;
case 'post_year':
$dNow = false;
case 'past_year':
$dStart->modify('-1 year');
break;
case 'today':
// Ranges that need to align with local 'days' need special
treatment.
$app = JFactory::getApplication();
$offset = $app->get('offset');
// Reset the start time to be the beginning of today, local time.
$dStart = new JDate('now', $offset);
$dStart->setTime(0, 0, 0);
// Now change the timezone back to UTC.
$tz = new DateTimeZone('GMT');
$dStart->setTimezone($tz);
break;
case 'never':
$dNow = false;
$dStart = $this->_db->getNullDate();
break;
}
return array('dNow' => $dNow, 'dStart' =>
$dStart);
}
/**
* SQL server change
*
* @param integer $userId User identifier
*
* @return string Groups titles imploded :$
*/
protected function _getUserDisplayedGroups($userId)
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($db->qn('title'))
->from($db->qn('#__usergroups', 'ug'))
->join('LEFT',
$db->qn('#__user_usergroup_map', 'map') . ' ON
(ug.id = map.group_id)')
->where($db->qn('map.user_id') . ' = ' . (int)
$userId);
try
{
$result = $db->setQuery($query)->loadColumn();
}
catch (RunTimeException $e)
{
$result = array();
}
return implode("\n", $result);
}
}
tables/note.php000064400000007423151160243100007473 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Utilities\ArrayHelper;
/**
* User notes table class
*
* @since 2.5
*/
class UsersTableNote extends JTable
{
/**
* Constructor
*
* @param JDatabaseDriver &$db Database object
*
* @since 2.5
*/
public function __construct(&$db)
{
parent::__construct('#__user_notes', 'id', $db);
$this->setColumnAlias('published', 'state');
JTableObserverContenthistory::createObserver($this,
array('typeAlias' => 'com_users.note'));
}
/**
* Overloaded store method for the notes table.
*
* @param boolean $updateNulls Toggle whether null values should be
updated.
*
* @return boolean True on success, false on failure.
*
* @since 2.5
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate()->toSql();
$userId = JFactory::getUser()->get('id');
$this->modified_time = $date;
$this->modified_user_id = $userId;
if (!((int) $this->review_time))
{
// Null date.
$this->review_time = $this->_db->getNullDate();
}
if (empty($this->id))
{
// New record.
$this->created_time = $date;
$this->created_user_id = $userId;
}
// Attempt to store the data.
return parent::store($updateNulls);
}
/**
* Method to set the publishing state for a row or list of rows in the
database
* table. The method respects checked out rows by other users and will
attempt
* to check-in rows that it can after adjustments are made.
*
* @param mixed $pks An optional array of primary key values to
update. If not set the instance property value is used.
* @param integer $state The publishing state. eg. [0 = unpublished,
1 = published]
* @param integer $userId The user id of the user performing the
operation.
*
* @return boolean True on success.
*
* @since 2.5
*/
public function publish($pks = null, $state = 1, $userId = 0)
{
$k = $this->_tbl_key;
// Sanitize input.
$pks = ArrayHelper::toInteger($pks);
$userId = (int) $userId;
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is
set.
if (empty($pks))
{
if ($this->$k)
{
$pks = array($this->$k);
}
// Nothing to set publishing state on, return false.
else
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
return false;
}
}
$query = $this->_db->getQuery(true)
->update($this->_db->quoteName($this->_tbl))
->set($this->_db->quoteName('state') . ' =
' . (int) $state);
// Build the WHERE clause for the primary keys.
$query->where($k . '=' . implode(' OR ' . $k .
'=', $pks));
// Determine if there is checkin support for the table.
if (!property_exists($this, 'checked_out') ||
!property_exists($this, 'checked_out_time'))
{
$checkin = false;
}
else
{
$query->where('(checked_out = 0 OR checked_out = ' . (int)
$userId . ')');
$checkin = true;
}
// Update the publishing state for rows with the given primary keys.
$this->_db->setQuery($query);
try
{
$this->_db->execute();
}
catch (RuntimeException $e)
{
$this->setError($this->_db->getMessage());
return false;
}
// If checkin is supported and all rows were adjusted, check them in.
if ($checkin && (count($pks) ==
$this->_db->getAffectedRows()))
{
// Checkin the rows.
foreach ($pks as $pk)
{
$this->checkin($pk);
}
}
// If the JTable instance value is in the list of primary keys that were
set, set the instance.
if (in_array($this->$k, $pks))
{
$this->state = $state;
}
$this->setError('');
return true;
}
}
users.php000064400000001240151160243100006404 0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.tabstate');
if (!JFactory::getUser()->authorise('core.manage',
'com_users'))
{
throw new
JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'),
403);
}
JLoader::register('UsersHelper', __DIR__ .
'/helpers/users.php');
$controller = JControllerLegacy::getInstance('Users');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
users.xml000064400000002525151160243100006424 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension type="component" version="3.1"
method="upgrade">
<name>com_users</name>
<author>Joomla! Project</author>
<creationDate>April 2006</creationDate>
<copyright>(C) 2005 - 2020 Open Source Matters. All rights
reserved.</copyright>
<license>GNU General Public License version 2 or later; see
LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>COM_USERS_XML_DESCRIPTION</description>
<files folder="site">
<filename>controller.php</filename>
<filename>router.php</filename>
<filename>users.php</filename>
<folder>controllers</folder>
<folder>helpers</folder>
<folder>models</folder>
<folder>views</folder>
</files>
<languages folder="site">
<language
tag="en-GB">language/en-GB.com_users.ini</language>
</languages>
<administration>
<files folder="admin">
<filename>config.xml</filename>
<filename>controller.php</filename>
<filename>users.php</filename>
<folder>controllers</folder>
<folder>helpers</folder>
<folder>models</folder>
<folder>views</folder>
</files>
<languages folder="admin">
<language
tag="en-GB">language/en-GB.com_users.ini</language>
<language
tag="en-GB">language/en-GB.com_users.sys.ini</language>
</languages>
</administration>
</extension>
views/debuggroup/tmpl/default.php000064400000007744151160243100013162
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('formbehavior.chosen', 'select');
$listOrder =
$this->escape($this->state->get('list.ordering'));
$listDirn =
$this->escape($this->state->get('list.direction'));
$colSpan = 4 + count($this->actions);
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&view=debuggroup&group_id='
. (int) $this->state->get('group_id')); ?>"
method="post" name="adminForm"
id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php echo
JLayoutHelper::render('joomla.searchtools.default',
array('view' => $this)); ?>
<div class="clearfix"> </div>
<table class="table table-striped">
<thead>
<tr>
<th class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_ASSET_TITLE', 'a.title', $listDirn,
$listOrder); ?>
</th>
<th class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_ASSET_NAME', 'a.name', $listDirn,
$listOrder); ?>
</th>
<?php foreach ($this->actions as $key => $action) : ?>
<th width="5%" class="center">
<span class="hasTooltip" title="<?php echo
JHtml::_('tooltipText', $key, $action[1]);
?>"><?php echo JText::_($key); ?></span>
</th>
<?php endforeach; ?>
<th width="5%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_LFT', 'a.lft', $listDirn,
$listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort',
'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder);
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="<?php echo $colSpan; ?>">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<tr class="row0">
<td>
<?php echo $this->escape($item->title); ?>
</td>
<td class="nowrap">
<?php echo
JLayoutHelper::render('joomla.html.treeprefix',
array('level' => $item->level + 1)) .
$this->escape($item->name); ?>
</td>
<?php foreach ($this->actions as $action) : ?>
<?php
$name = $action[0];
$check = $item->checks[$name];
if ($check === true) :
$class = 'icon-ok';
$button = 'btn-success';
elseif ($check === false) :
$class = 'icon-remove';
$button = 'btn-danger';
elseif ($check === null) :
$class = 'icon-ban-circle';
$button = 'btn-warning';
else :
$class = '';
$button = '';
endif;
?>
<td class="center">
<span class="icon-white <?php echo $class;
?>"></span>
</td>
<?php endforeach; ?>
<td class="center">
<?php echo (int) $item->lft; ?>
- <?php echo (int) $item->rgt; ?>
</td>
<td class="center">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="task"
value="" />
<input type="hidden" name="boxchecked"
value="0" />
<?php echo JHtml::_('form.token'); ?>
<div>
<?php echo JText::_('COM_USERS_DEBUG_LEGEND'); ?>
<span class="icon-white
icon-ban-circle"></span><?php echo
JText::_('COM_USERS_DEBUG_IMPLICIT_DENY'); ?>
<span class="icon-white icon-ok"></span><?php
echo JText::_('COM_USERS_DEBUG_EXPLICIT_ALLOW'); ?>
<span class="icon-white
icon-remove"></span><?php echo
JText::_('COM_USERS_DEBUG_EXPLICIT_DENY'); ?>
<br /><br />
</div>
</div>
</form>
views/debuggroup/view.html.php000064400000004567151160243100012477
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View class for a list of User Group ACL permissions.
*
* @since 1.6
*/
class UsersViewDebuggroup extends JViewLegacy
{
protected $actions;
/**
* The item data.
*
* @var object
* @since 1.6
*/
protected $items;
/**
* The pagination object.
*
* @var JPagination
* @since 1.6
*/
protected $pagination;
/**
* The model state.
*
* @var JObject
* @since 1.6
*/
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
// Access check.
if (!JFactory::getUser()->authorise('core.manage',
'com_users'))
{
throw new
JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'),
403);
}
$this->actions = $this->get('DebugActions');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->group = $this->get('Group');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Vars only used in hathor.
// @deprecated 4.0 To be removed with Hathor
$this->levels = UsersHelperDebug::getLevelsOptions();
$this->components = UsersHelperDebug::getComponents();
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = JHelperContent::getActions('com_users');
JToolbarHelper::title(JText::sprintf('COM_USERS_VIEW_DEBUG_GROUP_TITLE',
$this->group->id, $this->escape($this->group->title)),
'users groups');
JToolbarHelper::cancel('group.cancel',
'JTOOLBAR_CLOSE');
if ($canDo->get('core.admin') ||
$canDo->get('core.options'))
{
JToolbarHelper::preferences('com_users');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_USERS_DEBUG_GROUPS');
}
}
views/debuguser/tmpl/default.php000064400000007741151160243100013001
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('formbehavior.chosen', 'select');
$listOrder =
$this->escape($this->state->get('list.ordering'));
$listDirn =
$this->escape($this->state->get('list.direction'));
$colSpan = 4 + count($this->actions);
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&view=debuguser&user_id='
. (int) $this->state->get('user_id')); ?>"
method="post" name="adminForm"
id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php echo
JLayoutHelper::render('joomla.searchtools.default',
array('view' => $this)); ?>
<div class="clearfix"> </div>
<table class="table table-striped">
<thead>
<tr>
<th class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_ASSET_TITLE', 'a.title', $listDirn,
$listOrder); ?>
</th>
<th class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_ASSET_NAME', 'a.name', $listDirn,
$listOrder); ?>
</th>
<?php foreach ($this->actions as $key => $action) : ?>
<th width="5%" class="center">
<span class="hasTooltip" title="<?php echo
JHtml::_('tooltipText', $key, $action[1]);
?>"><?php echo JText::_($key); ?></span>
</th>
<?php endforeach; ?>
<th width="5%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_LFT', 'a.lft', $listDirn,
$listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort',
'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder);
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="<?php echo $colSpan; ?>">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<tr class="row0">
<td>
<?php echo $this->escape($item->title); ?>
</td>
<td class="nowrap">
<?php echo
JLayoutHelper::render('joomla.html.treeprefix',
array('level' => $item->level + 1)) .
$this->escape($item->name); ?>
</td>
<?php foreach ($this->actions as $action) : ?>
<?php
$name = $action[0];
$check = $item->checks[$name];
if ($check === true) :
$class = 'icon-ok';
$button = 'btn-success';
elseif ($check === false) :
$class = 'icon-remove';
$button = 'btn-danger';
elseif ($check === null) :
$class = 'icon-ban-circle';
$button = 'btn-warning';
else :
$class = '';
$button = '';
endif;
?>
<td class="center">
<span class="icon-white <?php echo $class;
?>"></span>
</td>
<?php endforeach; ?>
<td class="center">
<?php echo (int) $item->lft; ?>
- <?php echo (int) $item->rgt; ?>
</td>
<td class="center">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="task"
value="" />
<input type="hidden" name="boxchecked"
value="0" />
<?php echo JHtml::_('form.token'); ?>
<div>
<?php echo JText::_('COM_USERS_DEBUG_LEGEND'); ?>
<span class="icon-white
icon-ban-circle"></span><?php echo
JText::_('COM_USERS_DEBUG_IMPLICIT_DENY'); ?>
<span class="icon-white icon-ok"></span><?php
echo JText::_('COM_USERS_DEBUG_EXPLICIT_ALLOW'); ?>
<span class="icon-white
icon-remove"></span><?php echo
JText::_('COM_USERS_DEBUG_EXPLICIT_DENY'); ?>
<br /><br />
</div>
</div>
</form>
views/debuguser/view.html.php000064400000004547151160243100012317
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View class for a list of User ACL permissions.
*
* @since 1.6
*/
class UsersViewDebuguser extends JViewLegacy
{
protected $actions;
/**
* The item data.
*
* @var object
* @since 1.6
*/
protected $items;
/**
* The pagination object.
*
* @var JPagination
* @since 1.6
*/
protected $pagination;
/**
* The model state.
*
* @var JObject
* @since 1.6
*/
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
// Access check.
if (!JFactory::getUser()->authorise('core.manage',
'com_users'))
{
throw new
JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'),
403);
}
$this->actions = $this->get('DebugActions');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->user = $this->get('User');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
// Vars only used in hathor.
// @deprecated 4.0 To be removed with Hathor
$this->levels = UsersHelperDebug::getLevelsOptions();
$this->components = UsersHelperDebug::getComponents();
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = JHelperContent::getActions('com_users');
JToolbarHelper::title(JText::sprintf('COM_USERS_VIEW_DEBUG_USER_TITLE',
$this->user->id, $this->escape($this->user->name)),
'users user');
JToolbarHelper::cancel('user.cancel',
'JTOOLBAR_CLOSE');
if ($canDo->get('core.admin') ||
$canDo->get('core.options'))
{
JToolbarHelper::preferences('com_users');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_USERS_DEBUG_USERS');
}
}
views/group/tmpl/edit.php000064400000003051151160243100011437
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
{
if (task == 'group.cancel' ||
document.formvalidator.isValid(document.getElementById('group-form')))
{
Joomla.submitform(task,
document.getElementById('group-form'));
}
};
");
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&layout=edit&id=' .
(int) $this->item->id); ?>" method="post"
name="adminForm" id="group-form"
class="form-validate form-horizontal">
<fieldset>
<?php echo JHtml::_('bootstrap.startTabSet',
'myTab', array('active' => 'details'));
?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab',
'details', JText::_('COM_USERS_USERGROUP_DETAILS'));
?>
<?php echo $this->form->renderField('title'); ?>
<?php echo $this->form->renderField('parent_id');
?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php $this->ignore_fieldsets = array('group_details');
?>
<?php echo JLayoutHelper::render('joomla.edit.params',
$this); ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
</fieldset>
<input type="hidden" name="task" value=""
/>
<?php echo JHtml::_('form.token'); ?>
</form>
views/group/tmpl/edit.xml000064400000000302151160243100011444
0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_USERS_GROUP_VIEW_EDIT_TITLE">
<message>
<![CDATA[COM_USERS_GROUP_VIEW_EDIT_DESC]]>
</message>
</layout>
</metadata>
views/group/view.html.php000064400000004115151160243100011455
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View to edit a user group.
*
* @since 1.6
*/
class UsersViewGroup extends JViewLegacy
{
protected $form;
/**
* The item data.
*
* @var object
* @since 1.6
*/
protected $item;
/**
* The model state.
*
* @var JObject
* @since 1.6
*/
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu',
true);
$isNew = ($this->item->id == 0);
$canDo = JHelperContent::getActions('com_users');
JToolbarHelper::title(JText::_($isNew ?
'COM_USERS_VIEW_NEW_GROUP_TITLE' :
'COM_USERS_VIEW_EDIT_GROUP_TITLE'), 'users
groups-add');
if ($canDo->get('core.edit') ||
$canDo->get('core.create'))
{
JToolbarHelper::apply('group.apply');
JToolbarHelper::save('group.save');
}
if ($canDo->get('core.create'))
{
JToolbarHelper::save2new('group.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create'))
{
JToolbarHelper::save2copy('group.save2copy');
}
if (empty($this->item->id))
{
JToolbarHelper::cancel('group.cancel');
}
else
{
JToolbarHelper::cancel('group.cancel',
'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_USERS_GROUPS_EDIT');
}
}
views/groups/tmpl/default.php000064400000012725151160243100012331
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$listOrder =
$this->escape($this->state->get('list.ordering'));
$listDirn =
$this->escape($this->state->get('list.direction'));
$debugGroups =
$this->state->get('params')->get('debugGroups',
1);
JText::script('COM_USERS_GROUPS_CONFIRM_DELETE');
JFactory::getDocument()->addScriptDeclaration('
Joomla.submitbutton = function(task) {
if (task == "groups.delete") {
var i, cids = document.getElementsByName("cid[]");
for (i = 0; i < cids.length; i++) {
if (cids[i].checked &&
cids[i].parentNode.getAttribute("data-usercount") != 0) {
if
(confirm(Joomla.JText._("COM_USERS_GROUPS_CONFIRM_DELETE"))) {
Joomla.submitform(task);
}
return false;
}
}
}
Joomla.submitform(task);
return false;
};
');
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&view=groups');
?>" method="post" name="adminForm"
id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php echo
JLayoutHelper::render('joomla.searchtools.default',
array('view' => $this, 'options' =>
array('filterButton' => false))); ?>
<div class="clearfix"> </div>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped"
id="groupList">
<thead>
<tr>
<th width="1%" class="nowrap">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_GROUP_TITLE', 'a.title', $listDirn,
$listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<span class="icon-publish hasTooltip"
aria-hidden="true" title="<?php echo
JText::_('COM_USERS_COUNT_ENABLED_USERS'); ?>">
<span class="element-invisible"><?php echo
JText::_('COM_USERS_COUNT_ENABLED_USERS'); ?></span>
</span>
</th>
<th width="1%" class="nowrap center">
<span class="icon-unpublish hasTooltip"
aria-hidden="true" title="<?php echo
JText::_('COM_USERS_COUNT_DISABLED_USERS'); ?>">
<span class="element-invisible"><?php echo
JText::_('COM_USERS_COUNT_DISABLED_USERS'); ?></span>
</span>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort',
'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder);
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :
$canCreate = $user->authorise('core.create',
'com_users');
$canEdit = $user->authorise('core.edit',
'com_users');
// If this group is super admin and this user is not super admin,
$canEdit is false
if (!$user->authorise('core.admin') &&
JAccess::checkGroup($item->id, 'core.admin'))
{
$canEdit = false;
}
$canChange = $user->authorise('core.edit.state',
'com_users');
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center" data-usercount="<?php echo
$item->user_count; ?>">
<?php if ($canEdit) : ?>
<?php echo JHtml::_('grid.id', $i, $item->id);
?>
<?php endif; ?>
</td>
<td>
<?php echo
JLayoutHelper::render('joomla.html.treeprefix',
array('level' => $item->level + 1)); ?>
<?php if ($canEdit) : ?>
<a href="<?php echo
JRoute::_('index.php?option=com_users&task=group.edit&id='
. $item->id); ?>">
<?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<?php echo $this->escape($item->title); ?>
<?php endif; ?>
<?php if ($debugGroups) : ?>
<div class="small"><a href="<?php echo
JRoute::_('index.php?option=com_users&view=debuggroup&group_id='
. (int) $item->id); ?>">
<?php echo JText::_('COM_USERS_DEBUG_GROUP');
?></a></div>
<?php endif; ?>
</td>
<td class="center btns">
<a class="badge <?php if ($item->count_enabled > 0)
echo 'badge-success'; ?>" href="<?php echo
JRoute::_('index.php?option=com_users&view=users&filter[group_id]='
. (int) $item->id . '&filter[state]=0'); ?>">
<?php echo $item->count_enabled; ?></a>
</td>
<td class="center btns">
<a class="badge <?php if ($item->count_disabled >
0) echo 'badge-important'; ?>" href="<?php echo
JRoute::_('index.php?option=com_users&view=users&filter[group_id]='
. (int) $item->id . '&filter[state]=1'); ?>">
<?php echo $item->count_disabled; ?></a>
</td>
<td class="hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task"
value="" />
<input type="hidden" name="boxchecked"
value="0" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>
views/groups/tmpl/default.xml000064400000000312151160243100012327
0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_USERS_GROUPS_VIEW_DEFAULT_TITLE">
<message>
<![CDATA[COM_USERS_GROUPS_VIEW_DEFAULT_DESC]]>
</message>
</layout>
</metadata>
views/groups/view.html.php000064400000005023151160243100011637
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View class for a list of user groups.
*
* @since 1.6
*/
class UsersViewGroups extends JViewLegacy
{
/**
* The item data.
*
* @var object
* @since 1.6
*/
protected $items;
/**
* The pagination object.
*
* @var JPagination
* @since 1.6
*/
protected $pagination;
/**
* The model state.
*
* @var JObject
* @since 1.6
*/
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
UsersHelper::addSubmenu('groups');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = JHelperContent::getActions('com_users');
JToolbarHelper::title(JText::_('COM_USERS_VIEW_GROUPS_TITLE'),
'users groups');
if ($canDo->get('core.create'))
{
JToolbarHelper::addNew('group.add');
}
if ($canDo->get('core.edit'))
{
JToolbarHelper::editList('group.edit');
JToolbarHelper::divider();
}
if ($canDo->get('core.delete'))
{
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE',
'groups.delete', 'JTOOLBAR_DELETE');
JToolbarHelper::divider();
}
if ($canDo->get('core.admin') ||
$canDo->get('core.options'))
{
JToolbarHelper::preferences('com_users');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_USERS_GROUPS');
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key
and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
return array(
'a.title' =>
JText::_('COM_USERS_HEADING_GROUP_TITLE'),
'a.id' => JText::_('JGRID_HEADING_ID'),
);
}
}
views/level/tmpl/edit.php000064400000002703151160243100011415
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator');
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
{
if (task == 'level.cancel' ||
document.formvalidator.isValid(document.getElementById('level-form')))
{
Joomla.submitform(task,
document.getElementById('level-form'));
}
};
");
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&id=' . (int)
$this->item->id); ?>" method="post"
name="adminForm" id="level-form"
class="form-validate form-horizontal">
<fieldset>
<legend><?php echo
JText::_('COM_USERS_LEVEL_DETAILS'); ?></legend>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('title'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('title'); ?>
</div>
</div>
</fieldset>
<fieldset>
<legend><?php echo
JText::_('COM_USERS_USER_GROUPS_HAVING_ACCESS');
?></legend>
<?php echo JHtml::_('access.usergroups',
'jform[rules]', $this->item->rules, true); ?>
</fieldset>
<input type="hidden" name="task" value=""
/>
<?php echo JHtml::_('form.token'); ?>
</form>
views/level/tmpl/edit.xml000064400000000302151160243100011417
0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_USERS_LEVEL_VIEW_EDIT_TITLE">
<message>
<![CDATA[COM_USERS_LEVEL_VIEW_EDIT_DESC]]>
</message>
</layout>
</metadata>
views/level/view.html.php000064400000004131151160243100011426
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View to edit a user view level.
*
* @since 1.6
*/
class UsersViewLevel extends JViewLegacy
{
protected $form;
/**
* The item data.
*
* @var object
* @since 1.6
*/
protected $item;
/**
* The model state.
*
* @var JObject
* @since 1.6
*/
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu',
true);
$isNew = ($this->item->id == 0);
$canDo = JHelperContent::getActions('com_users');
JToolbarHelper::title(JText::_($isNew ?
'COM_USERS_VIEW_NEW_LEVEL_TITLE' :
'COM_USERS_VIEW_EDIT_LEVEL_TITLE'), 'users
levels-add');
if ($canDo->get('core.edit') ||
$canDo->get('core.create'))
{
JToolbarHelper::apply('level.apply');
JToolbarHelper::save('level.save');
}
if ($canDo->get('core.create'))
{
JToolbarHelper::save2new('level.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create'))
{
JToolbarHelper::save2copy('level.save2copy');
}
if (empty($this->item->id))
{
JToolbarHelper::cancel('level.cancel');
}
else
{
JToolbarHelper::cancel('level.cancel',
'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_USERS_ACCESS_LEVELS_EDIT');
}
}
views/levels/tmpl/default.php000064400000011435151160243100012301
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$listOrder =
$this->escape($this->state->get('list.ordering'));
$listDirn =
$this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 'a.ordering';
if ($saveOrder)
{
$saveOrderingUrl =
'index.php?option=com_users&task=levels.saveOrderAjax&tmpl=component';
JHtml::_('sortablelist.sortable', 'levelList',
'adminForm', strtolower($listDirn), $saveOrderingUrl);
}
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&view=levels');
?>" method="post" id="adminForm"
name="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php echo
JLayoutHelper::render('joomla.searchtools.default',
array('view' => $this, 'options' =>
array('filterButton' => false))); ?>
<div class="clearfix"> </div>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped"
id="levelList">
<thead>
<tr>
<th width="1%" class="nowrap center
hidden-phone">
<?php echo JHtml::_('searchtools.sort', '',
'a.ordering', $listDirn, $listOrder, null, 'asc',
'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
</th>
<th width="1%">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th>
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_LEVEL_NAME', 'a.title', $listDirn,
$listOrder); ?>
</th>
<th class="nowrap hidden-phone">
<?php echo
JText::_('COM_USERS_USER_GROUPS_HAVING_ACCESS'); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort',
'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder);
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="5">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php $count = count($this->items); ?>
<?php foreach ($this->items as $i => $item) :
$ordering = ($listOrder == 'a.ordering');
$canCreate = $user->authorise('core.create',
'com_users');
$canEdit = $user->authorise('core.edit',
'com_users');
$canChange = $user->authorise('core.edit.state',
'com_users');
// Decode level groups
$groups = json_decode($item->rules);
// If this group is super admin and this user is not super admin,
$canEdit is false
if (!JFactory::getUser()->authorise('core.admin')
&& JAccess::checkGroup($groups[0], 'core.admin'))
{
$canEdit = false;
$canChange = false;
}
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="order nowrap center hidden-phone">
<?php
$iconClass = '';
if (!$canChange)
{
$iconClass = ' inactive';
}
elseif (!$saveOrder)
{
$iconClass = ' inactive tip-top hasTooltip"
title="' . JHtml::_('tooltipText',
'JORDERINGDISABLED');
}
?>
<span class="sortable-handler<?php echo $iconClass
?>">
<span class="icon-menu"
aria-hidden="true"></span>
</span>
<?php if ($canChange && $saveOrder) : ?>
<input type="text" style="display:none"
name="order[]" size="5" value="<?php echo
$item->ordering; ?>" class="width-20 text-area-order"
/>
<?php endif; ?>
</td>
<td class="center">
<?php if ($canEdit) : ?>
<?php echo JHtml::_('grid.id', $i, $item->id);
?>
<?php endif; ?>
</td>
<td>
<?php if ($canEdit) : ?>
<a href="<?php echo
JRoute::_('index.php?option=com_users&task=level.edit&id='
. $item->id); ?>">
<?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<?php echo $this->escape($item->title); ?>
<?php endif; ?>
</td>
<td class="hidden-phone">
<?php echo UsersHelper::getVisibleByGroups($item->rules);
?>
</td>
<td class="hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task"
value="" />
<input type="hidden" name="boxchecked"
value="0" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>
views/levels/tmpl/default.xml000064400000000312151160243100012302
0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_USERS_LEVELS_VIEW_DEFAULT_TITLE">
<message>
<![CDATA[COM_USERS_LEVELS_VIEW_DEFAULT_DESC]]>
</message>
</layout>
</metadata>
views/levels/view.html.php000064400000005124151160243100011614
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View class for a list of view levels.
*
* @since 1.6
*/
class UsersViewLevels extends JViewLegacy
{
/**
* The item data.
*
* @var object
* @since 1.6
*/
protected $items;
/**
* The pagination object.
*
* @var JPagination
* @since 1.6
*/
protected $pagination;
/**
* The model state.
*
* @var JObject
* @since 1.6
*/
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
UsersHelper::addSubmenu('levels');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = JHelperContent::getActions('com_users');
JToolbarHelper::title(JText::_('COM_USERS_VIEW_LEVELS_TITLE'),
'users levels');
if ($canDo->get('core.create'))
{
JToolbarHelper::addNew('level.add');
}
if ($canDo->get('core.edit'))
{
JToolbarHelper::editList('level.edit');
JToolbarHelper::divider();
}
if ($canDo->get('core.delete'))
{
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE',
'level.delete', 'JTOOLBAR_DELETE');
JToolbarHelper::divider();
}
if ($canDo->get('core.admin') ||
$canDo->get('core.options'))
{
JToolbarHelper::preferences('com_users');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_USERS_ACCESS_LEVELS');
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key
and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
return array(
'a.ordering' =>
JText::_('JGRID_HEADING_ORDERING'),
'a.title' =>
JText::_('COM_USERS_HEADING_LEVEL_NAME'),
'a.id' => JText::_('JGRID_HEADING_ID'),
);
}
}
views/mail/tmpl/default.php000064400000006621151160243100011732
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
$script = "\t" . 'Joomla.submitbutton =
function(pressbutton) {' . "\n";
$script .= "\t\t" . 'var form = document.adminForm;' .
"\n";
$script .= "\t\t" . 'if (pressbutton ==
\'mail.cancel\') {' . "\n";
$script .= "\t\t\t" . 'Joomla.submitform(pressbutton);'
. "\n";
$script .= "\t\t\t" . 'return;' . "\n";
$script .= "\t\t" . '}' . "\n";
$script .= "\t\t" . '// do field validation' .
"\n";
$script .= "\t\t" . 'if (form.jform_subject.value ==
""){' . "\n";
$script .= "\t\t\t" . 'alert("' .
JText::_('COM_USERS_MAIL_PLEASE_FILL_IN_THE_SUBJECT', true) .
'");' . "\n";
$script .= "\t\t" . '} else if
(getSelectedValue(\'adminForm\',\'jform[group]\') <
0){' . "\n";
$script .= "\t\t\t" . 'alert("' .
JText::_('COM_USERS_MAIL_PLEASE_SELECT_A_GROUP', true) .
'");' . "\n";
$script .= "\t\t" . '} else if (form.jform_message.value ==
""){' . "\n";
$script .= "\t\t\t" . 'alert("' .
JText::_('COM_USERS_MAIL_PLEASE_FILL_IN_THE_MESSAGE', true) .
'");' . "\n";
$script .= "\t\t" . '} else {' . "\n";
$script .= "\t\t\t" . 'Joomla.submitform(pressbutton);'
. "\n";
$script .= "\t\t" . '}' . "\n";
$script .= "\t\t" . '}' . "\n";
JHtml::_('behavior.core');
JHtml::_('formbehavior.chosen', 'select');
JFactory::getDocument()->addScriptDeclaration($script);
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&view=mail');
?>" name="adminForm" method="post"
id="adminForm">
<div class="row-fluid">
<div class="span9">
<fieldset class="adminform">
<div class="control-group">
<div class="control-label"><?php echo
$this->form->getLabel('subject'); ?></div>
<div class="controls"><?php echo
JComponentHelper::getParams('com_users')->get('mailSubjectPrefix');
?>
<?php echo $this->form->getInput('subject');
?></div>
</div>
<div class="control-group">
<div class="control-label"><?php echo
$this->form->getLabel('message'); ?></div>
<div class="controls"><?php echo
$this->form->getInput('message'); ?><br>
<?php echo
JComponentHelper::getParams('com_users')->get('mailBodySuffix');
?></div>
</div>
</fieldset>
<input type="hidden" name="task"
value="" />
<?php echo JHtml::_('form.token'); ?>
</div>
<div class="span3">
<fieldset class="form-inline">
<div class="control-group checkbox">
<div class="controls"><?php echo
$this->form->getInput('recurse'); ?> <?php echo
$this->form->getLabel('recurse'); ?></div>
</div>
<div class="control-group checkbox">
<div class="control-label"><?php echo
$this->form->getInput('mode'); ?> <?php echo
$this->form->getLabel('mode'); ?></div>
</div>
<div class="control-group checkbox">
<div class="control-label"><?php echo
$this->form->getInput('disabled'); ?> <?php echo
$this->form->getLabel('disabled'); ?></div>
</div>
<div class="control-group checkbox">
<div class="control-label"><?php echo
$this->form->getInput('bcc'); ?> <?php echo
$this->form->getLabel('bcc'); ?></div>
</div>
<div class="control-group">
<div class="control-label"><?php echo
$this->form->getLabel('group'); ?></div>
<div class="controls"><?php echo
$this->form->getInput('group'); ?></div>
</div>
</fieldset>
</div>
</div>
</form>
views/mail/tmpl/default.xml000064400000000306151160243100011735
0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_USERS_MAIL_VIEW_DEFAULT_TITLE">
<message>
<![CDATA[COM_USERS_MAIL_VIEW_DEFAULT_DESC]]>
</message>
</layout>
</metadata>
views/mail/view.html.php000064400000003005151160243100011240
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users mail view.
*
* @since 1.6
*/
class UsersViewMail extends JViewLegacy
{
/**
* @var object form object
*/
protected $form;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
// Redirect to admin index if mass mailer disabled in conf
if (JFactory::getApplication()->get('massmailoff', 0) == 1)
{
JFactory::getApplication()->redirect(JRoute::_('index.php',
false));
}
// Get data from the model
$this->form = $this->get('Form');
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu',
true);
JToolbarHelper::title(JText::_('COM_USERS_MASS_MAIL'),
'users massmail');
JToolbarHelper::custom('mail.send', 'envelope.png',
'send_f2.png', 'COM_USERS_TOOLBAR_MAIL_SEND_MAIL',
false);
JToolbarHelper::cancel('mail.cancel');
JToolbarHelper::divider();
JToolbarHelper::preferences('com_users');
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_USERS_MASS_MAIL_USERS');
}
}
views/note/tmpl/edit.php000064400000005137151160243100011257
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
JFactory::getDocument()->addScriptDeclaration('
jQuery(document).ready(function() {
Joomla.submitbutton = function(task)
{
if (task == "note.cancel" ||
document.formvalidator.isValid(document.getElementById("note-form")))
{
' . $this->form->getField('body')->save() .
'
Joomla.submitform(task, document.getElementById("note-form"));
}
}
});');
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&view=note&id=' .
(int) $this->item->id); ?>" method="post"
name="adminForm" id="note-form"
class="form-validate form-horizontal">
<fieldset class="adminform">
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('subject'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('subject'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('user_id'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('user_id'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('catid'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('catid'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('state'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('state'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('review_time');
?>
</div>
<div class="controls">
<?php echo $this->form->getInput('review_time');
?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('version_note');
?>
</div>
<div class="controls">
<?php echo $this->form->getInput('version_note');
?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('body'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('body'); ?>
</div>
</div>
<input type="hidden" name="task"
value="" />
<?php echo JHtml::_('form.token'); ?>
</fieldset>
</form>
views/note/tmpl/edit.xml000064400000000300151160243100011253
0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_USERS_NOTE_VIEW_EDIT_TITLE">
<message>
<![CDATA[COM_USERS_NOTE_VIEW_EDIT_DESC]]>
</message>
</layout>
</metadata>
views/note/view.html.php000064400000005710151160243100011270
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User note edit view
*
* @since 2.5
*/
class UsersViewNote extends JViewLegacy
{
/**
* The edit form.
*
* @var JForm
* @since 2.5
*/
protected $form;
/**
* The item data.
*
* @var object
* @since 2.5
*/
protected $item;
/**
* The model state.
*
* @var JObject
* @since 2.5
*/
protected $state;
/**
* Override the display method for the view.
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise a JError object.
*
* @since 2.5
*/
public function display($tpl = null)
{
// Initialise view variables.
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->form = $this->get('Form');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
// Get the component HTML helpers
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
parent::display($tpl);
$this->addToolbar();
}
/**
* Display the toolbar.
*
* @return void
*
* @since 2.5
*/
protected function addToolbar()
{
$input = JFactory::getApplication()->input;
$input->set('hidemainmenu', 1);
$user = JFactory::getUser();
$isNew = ($this->item->id == 0);
$checkedOut = !($this->item->checked_out == 0 ||
$this->item->checked_out == $user->get('id'));
// Since we don't track these assets at the item level, use the
category id.
$canDo = JHelperContent::getActions('com_users',
'category', $this->item->catid);
JToolbarHelper::title(JText::_('COM_USERS_NOTES'), 'users
user');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') ||
count($user->getAuthorisedCategories('com_users',
'core.create'))))
{
JToolbarHelper::apply('note.apply');
JToolbarHelper::save('note.save');
}
if (!$checkedOut &&
count($user->getAuthorisedCategories('com_users',
'core.create')))
{
JToolbarHelper::save2new('note.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew &&
(count($user->getAuthorisedCategories('com_users',
'core.create')) > 0))
{
JToolbarHelper::save2copy('note.save2copy');
}
if (empty($this->item->id))
{
JToolbarHelper::cancel('note.cancel');
}
else
{
if (JComponentHelper::isEnabled('com_contenthistory')
&& $this->state->params->get('save_history', 0)
&& $canDo->get('core.edit'))
{
JToolbarHelper::versions('com_users.note',
$this->item->id);
}
JToolbarHelper::cancel('note.cancel',
'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_USERS_USER_NOTES_EDIT');
}
}
views/notes/tmpl/default.php000064400000011575151160243100012144
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$listOrder =
$this->escape($this->state->get('list.ordering'));
$listDirn =
$this->escape($this->state->get('list.direction'));
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&view=notes');
?>" method="post" name="adminForm"
id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php echo
JLayoutHelper::render('joomla.searchtools.default',
array('view' => $this)); ?>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped">
<thead>
<tr>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort',
'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_SUBJECT', 'a.subject', $listDirn,
$listOrder); ?>
</th>
<th width="20%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_USER', 'u.name', $listDirn,
$listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone
hidden-tablet">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_REVIEW', 'a.review_time', $listDirn,
$listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort',
'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder);
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :
$canEdit = $user->authorise('core.edit',
'com_users.category.' . $item->catid);
$canCheckin = $user->authorise('core.admin',
'com_checkin') || $item->checked_out ==
$user->get('id') || $item->checked_out == 0;
$canChange = $user->authorise('core.edit.state',
'com_users.category.' . $item->catid) && $canCheckin;
$subject = $item->subject ?:
JText::_('COM_USERS_EMPTY_SUBJECT');
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center checklist">
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td>
<td class="center">
<div class="btn-group">
<?php echo JHtml::_('jgrid.published', $item->state,
$i, 'notes.', $canChange, 'cb', $item->publish_up,
$item->publish_down); ?>
<?php // Create dropdown items and render the dropdown list.
if ($canChange)
{
JHtml::_('actionsdropdown.' . ((int) $item->state ===
2 ? 'un' : '') . 'archive', 'cb' .
$i, 'notes');
JHtml::_('actionsdropdown.' . ((int) $item->state ===
-2 ? 'un' : '') . 'trash', 'cb' .
$i, 'notes');
echo JHtml::_('actionsdropdown.render',
$this->escape($subject));
}
?>
</div>
</td>
<td>
<?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i,
$item->editor, $item->checked_out_time, 'notes.',
$canCheckin); ?>
<?php endif; ?>
<?php $subject = $item->subject ?:
JText::_('COM_USERS_EMPTY_SUBJECT'); ?>
<?php if ($canEdit) : ?>
<a href="<?php echo
JRoute::_('index.php?option=com_users&task=note.edit&id='
. $item->id); ?>"><?php echo $this->escape($subject);
?></a>
<?php else : ?>
<?php echo $this->escape($subject); ?>
<?php endif; ?>
<div class="small">
<?php echo JText::_('JCATEGORY') . ': ' .
$this->escape($item->category_title); ?>
</div>
</td>
<td class="hidden-phone">
<?php echo $this->escape($item->user_name); ?>
</td>
<td class="hidden-phone hidden-tablet">
<?php if ($item->review_time !==
JFactory::getDbo()->getNullDate()) : ?>
<?php echo JHtml::_('date', $item->review_time,
JText::_('DATE_FORMAT_LC4')); ?>
<?php else : ?>
<?php echo JText::_('COM_USERS_EMPTY_REVIEW'); ?>
<?php endif; ?>
</td>
<td class="hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<div>
<input type="hidden" name="task"
value="" />
<input type="hidden" name="boxchecked"
value="0" />
<?php echo JHtml::_('form.token'); ?>
</div>
</div>
</form>
views/notes/tmpl/default.xml000064400000000310151160243100012136
0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_USERS_NOTES_VIEW_DEFAULT_TITLE">
<message>
<![CDATA[COM_USERS_NOTES_VIEW_DEFAULT_DESC]]>
</message>
</layout>
</metadata>
views/notes/tmpl/modal.php000064400000003224151160243100011604
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
?>
<div class="unotes">
<h1><?php echo
JText::sprintf('COM_USERS_NOTES_FOR_USER',
$this->user->name, $this->user->id); ?></h1>
<?php if (empty($this->items)) : ?>
<?php echo JText::_('COM_USERS_NO_NOTES'); ?>
<?php else : ?>
<ul class="alternating">
<?php foreach ($this->items as $item) : ?>
<li>
<div class="fltlft utitle">
<?php if ($item->subject) : ?>
<h4><?php echo
JText::sprintf('COM_USERS_NOTE_N_SUBJECT', (int) $item->id,
$this->escape($item->subject)); ?></h4>
<?php else : ?>
<h4><?php echo
JText::sprintf('COM_USERS_NOTE_N_SUBJECT', (int) $item->id,
JText::_('COM_USERS_EMPTY_SUBJECT')); ?></h4>
<?php endif; ?>
</div>
<div class="fltlft utitle">
<?php echo JHtml::_('date', $item->created_time,
JText::_('DATE_FORMAT_LC2')); ?>
</div>
<?php $category_image = $item->cparams->get('image');
?>
<?php if ($item->catid && isset($category_image)) : ?>
<div class="fltlft utitle">
<?php echo JHtml::_('users.image', $category_image); ?>
</div>
<div class="fltlft utitle">
<em><?php echo $this->escape($item->category_title);
?></em>
</div>
<?php endif; ?>
<div class="clr"></div>
<div class="ubody">
<?php echo (isset($item->body) ?
JHtml::_('content.prepare', $item->body) : '');
?>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
views/notes/view.html.php000064400000007553151160243100011462
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/**
* User notes list view
*
* @since 2.5
*/
class UsersViewNotes extends JViewLegacy
{
/**
* A list of user note objects.
*
* @var array
* @since 2.5
*/
protected $items;
/**
* The pagination object.
*
* @var JPagination
* @since 2.5
*/
protected $pagination;
/**
* The model state.
*
* @var JObject
* @since 2.5
*/
protected $state;
/**
* The model state.
*
* @var JUser
* @since 2.5
*/
protected $user;
/**
* Override the display method for the view.
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise a JError object.
*
* @since 2.5
*/
public function display($tpl = null)
{
// Initialise view variables.
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->user = $this->get('User');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
UsersHelper::addSubmenu('notes');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
// Get the component HTML helpers
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
// Turn parameters into registry objects
foreach ($this->items as $item)
{
$item->cparams = new Registry($item->category_params);
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Display the toolbar.
*
* @return void
*
* @since 2.5
*/
protected function addToolbar()
{
$canDo = JHelperContent::getActions('com_users',
'category',
$this->state->get('filter.category_id'));
JToolbarHelper::title(JText::_('COM_USERS_VIEW_NOTES_TITLE'),
'users user');
if ($canDo->get('core.create'))
{
JToolbarHelper::addNew('note.add');
}
if ($canDo->get('core.edit'))
{
JToolbarHelper::editList('note.edit');
}
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::divider();
JToolbarHelper::publish('notes.publish',
'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('notes.unpublish',
'JTOOLBAR_UNPUBLISH', true);
JToolbarHelper::divider();
JToolbarHelper::archiveList('notes.archive');
JToolbarHelper::checkin('notes.checkin');
}
if ($this->state->get('filter.published') == -2
&& $canDo->get('core.delete'))
{
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE',
'notes.delete', 'JTOOLBAR_EMPTY_TRASH');
JToolbarHelper::divider();
}
elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::trash('notes.trash');
JToolbarHelper::divider();
}
if ($canDo->get('core.admin') ||
$canDo->get('core.options'))
{
JToolbarHelper::preferences('com_users');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_USERS_USER_NOTES');
JHtmlSidebar::setAction('index.php?option=com_users&view=notes');
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key
and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
return array(
'u.name' =>
JText::_('COM_USERS_USER_HEADING'),
'a.subject' =>
JText::_('COM_USERS_SUBJECT_HEADING'),
'c.title' =>
JText::_('COM_USERS_CATEGORY_HEADING'),
'a.state' => JText::_('JSTATUS'),
'a.review_time' =>
JText::_('COM_USERS_REVIEW_HEADING'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
}
views/user/tmpl/edit.php000064400000011173151160243100011265
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
JFactory::getDocument()->addScriptDeclaration("
Joomla.submitbutton = function(task)
{
if (task == 'user.cancel' ||
document.formvalidator.isValid(document.getElementById('user-form')))
{
Joomla.submitform(task, document.getElementById('user-form'));
}
};
Joomla.twoFactorMethodChange = function(e)
{
var selectedPane = 'com_users_twofactor_' +
jQuery('#jform_twofactor_method').val();
jQuery.each(jQuery('#com_users_twofactor_forms_container>div'),
function(i, el) {
if (el.id != selectedPane)
{
jQuery('#' + el.id).hide(0);
}
else
{
jQuery('#' + el.id).show(0);
}
});
};
");
// Get the form fieldsets.
$fieldsets = $this->form->getFieldsets();
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&layout=edit&id=' .
(int) $this->item->id); ?>" method="post"
name="adminForm" id="user-form"
class="form-validate form-horizontal"
enctype="multipart/form-data">
<?php echo JLayoutHelper::render('joomla.edit.item_title',
$this); ?>
<fieldset>
<?php echo JHtml::_('bootstrap.startTabSet',
'myTab', array('active' => 'details'));
?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab',
'details', JText::_('COM_USERS_USER_ACCOUNT_DETAILS'));
?>
<?php foreach
($this->form->getFieldset('user_details') as $field) :
?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php if ($field->fieldname == 'password') : ?>
<?php // Disables autocomplete ?> <input
type="password" style="display:none">
<?php endif; ?>
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php if ($this->grouplist) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab',
'groups', JText::_('COM_USERS_ASSIGNED_GROUPS')); ?>
<?php echo $this->loadTemplate('groups'); ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php endif; ?>
<?php
$this->ignore_fieldsets = array('user_details');
echo JLayoutHelper::render('joomla.edit.params', $this);
?>
<?php if (!empty($this->tfaform) && $this->item->id)
: ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab',
'twofactorauth',
JText::_('COM_USERS_USER_TWO_FACTOR_AUTH')); ?>
<div class="control-group">
<div class="control-label">
<label id="jform_twofactor_method-lbl"
for="jform_twofactor_method" class="hasTooltip"
title="<?php echo '<strong>' .
JText::_('COM_USERS_USER_FIELD_TWOFACTOR_LABEL') .
'</strong><br />' .
JText::_('COM_USERS_USER_FIELD_TWOFACTOR_DESC'); ?>">
<?php echo
JText::_('COM_USERS_USER_FIELD_TWOFACTOR_LABEL'); ?>
</label>
</div>
<div class="controls">
<?php echo JHtml::_('select.genericlist',
Usershelper::getTwoFactorMethods(), 'jform[twofactor][method]',
array('onchange' =>
'Joomla.twoFactorMethodChange()'), 'value',
'text', $this->otpConfig->method,
'jform_twofactor_method', false); ?>
</div>
</div>
<div id="com_users_twofactor_forms_container">
<?php foreach ($this->tfaform as $form) : ?>
<?php $style = $form['method'] ==
$this->otpConfig->method ? 'display: block' :
'display: none'; ?>
<div id="com_users_twofactor_<?php echo
$form['method'] ?>" style="<?php echo $style;
?>">
<?php echo $form['form'] ?>
</div>
<?php endforeach; ?>
</div>
<fieldset>
<legend>
<?php echo JText::_('COM_USERS_USER_OTEPS'); ?>
</legend>
<div class="alert alert-info">
<?php echo JText::_('COM_USERS_USER_OTEPS_DESC'); ?>
</div>
<?php if (empty($this->otpConfig->otep)) : ?>
<div class="alert alert-warning">
<?php echo JText::_('COM_USERS_USER_OTEPS_WAIT_DESC');
?>
</div>
<?php else : ?>
<?php foreach ($this->otpConfig->otep as $otep) : ?>
<span class="span3">
<?php echo substr($otep, 0, 4); ?>-<?php echo substr($otep, 4,
4); ?>-<?php echo substr($otep, 8, 4); ?>-<?php echo
substr($otep, 12, 4); ?>
</span>
<?php endforeach; ?>
<div class="clearfix"></div>
<?php endif; ?>
</fieldset>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php endif; ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
</fieldset>
<input type="hidden" name="task" value=""
/>
<?php echo JHtml::_('form.token'); ?>
</form>
views/user/tmpl/edit.xml000064400000000300151160243100011264
0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_USERS_USER_VIEW_EDIT_TITLE">
<message>
<![CDATA[COM_USERS_USER_VIEW_EDIT_DESC]]>
</message>
</layout>
</metadata>
views/user/tmpl/edit_groups.php000064400000000713151160243100012662
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
?>
<?php echo JHtml::_('access.usergroups',
'jform[groups]', $this->groups, true); ?>
views/user/view.html.php000064400000005055151160243100011303
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User view class.
*
* @since 1.5
*/
class UsersViewUser extends JViewLegacy
{
protected $form;
protected $item;
protected $grouplist;
protected $groups;
protected $state;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return void
*
* @since 1.5
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->tfaform = $this->get('Twofactorform');
$this->otpConfig = $this->get('otpConfig');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
// Prevent user from modifying own group(s)
$user = JFactory::getUser();
if ((int) $user->id != (int) $this->item->id ||
$user->authorise('core.admin'))
{
$this->grouplist = $this->get('Groups');
$this->groups = $this->get('AssignedGroups');
}
$this->form->setValue('password', null);
$this->form->setValue('password2', null);
parent::display($tpl);
$this->addToolbar();
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu',
true);
$user = JFactory::getUser();
$canDo = JHelperContent::getActions('com_users');
$isNew = ($this->item->id == 0);
$isProfile = $this->item->id == $user->id;
JToolbarHelper::title(
JText::_(
$isNew ? 'COM_USERS_VIEW_NEW_USER_TITLE' : ($isProfile ?
'COM_USERS_VIEW_EDIT_PROFILE_TITLE' :
'COM_USERS_VIEW_EDIT_USER_TITLE')
),
'user ' . ($isNew ? 'user-add' : ($isProfile ?
'user-profile' : 'user-edit'))
);
if ($canDo->get('core.edit') ||
$canDo->get('core.create'))
{
JToolbarHelper::apply('user.apply');
JToolbarHelper::save('user.save');
}
if ($canDo->get('core.create') &&
$canDo->get('core.manage'))
{
JToolbarHelper::save2new('user.save2new');
}
if (empty($this->item->id))
{
JToolbarHelper::cancel('user.cancel');
}
else
{
JToolbarHelper::cancel('user.cancel',
'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_USERS_USER_MANAGER_EDIT');
}
}
views/users/tmpl/default.php000064400000016667151160243100012164
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
$listOrder =
$this->escape($this->state->get('list.ordering'));
$listDirn =
$this->escape($this->state->get('list.direction'));
$loggeduser = JFactory::getUser();
$debugUsers =
$this->state->get('params')->get('debugUsers',
1);
?>
<form action="<?php echo
JRoute::_('index.php?option=com_users&view=users');
?>" method="post" name="adminForm"
id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php
// Search tools bar
echo JLayoutHelper::render('joomla.searchtools.default',
array('view' => $this));
?>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped"
id="userList">
<thead>
<tr>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_NAME', 'a.name', $listDirn,
$listOrder); ?>
</th>
<th width="10%" class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'JGLOBAL_USERNAME', 'a.username', $listDirn,
$listOrder); ?>
</th>
<th width="5%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_ENABLED', 'a.block', $listDirn,
$listOrder); ?>
</th>
<th width="5%" class="nowrap center
hidden-phone">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_ACTIVATED', 'a.activation',
$listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap">
<?php echo JText::_('COM_USERS_HEADING_GROUPS'); ?>
</th>
<th width="15%" class="nowrap hidden-phone
hidden-tablet">
<?php echo JHtml::_('searchtools.sort',
'JGLOBAL_EMAIL', 'a.email', $listDirn, $listOrder);
?>
</th>
<th width="10%" class="nowrap hidden-phone
hidden-tablet">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_LAST_VISIT_DATE', 'a.lastvisitDate',
$listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone
hidden-tablet">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_REGISTRATION_DATE',
'a.registerDate', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort',
'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder);
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="10">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :
$canEdit = $this->canDo->get('core.edit');
$canChange =
$loggeduser->authorise('core.edit.state', 'com_users');
// If this group is super admin and this user is not super admin,
$canEdit is false
if ((!$loggeduser->authorise('core.admin')) &&
JAccess::check($item->id, 'core.admin'))
{
$canEdit = false;
$canChange = false;
}
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center">
<?php if ($canEdit || $canChange) : ?>
<?php echo JHtml::_('grid.id', $i, $item->id);
?>
<?php endif; ?>
</td>
<td>
<div class="name break-word">
<?php if ($canEdit) : ?>
<a href="<?php echo
JRoute::_('index.php?option=com_users&task=user.edit&id='
. (int) $item->id); ?>" title="<?php echo
JText::sprintf('COM_USERS_EDIT_USER',
$this->escape($item->name)); ?>">
<?php echo $this->escape($item->name); ?></a>
<?php else : ?>
<?php echo $this->escape($item->name); ?>
<?php endif; ?>
</div>
<div class="btn-group">
<?php echo JHtml::_('users.filterNotes',
$item->note_count, $item->id); ?>
<?php echo JHtml::_('users.notes',
$item->note_count, $item->id); ?>
<?php echo JHtml::_('users.addNote', $item->id);
?>
</div>
<?php echo JHtml::_('users.notesModal',
$item->note_count, $item->id); ?>
<?php if ($item->requireReset == '1') : ?>
<span class="label label-warning"><?php echo
JText::_('COM_USERS_PASSWORD_RESET_REQUIRED'); ?></span>
<?php endif; ?>
<?php if ($debugUsers) : ?>
<div class="small"><a href="<?php echo
JRoute::_('index.php?option=com_users&view=debuguser&user_id='
. (int) $item->id); ?>">
<?php echo JText::_('COM_USERS_DEBUG_USER');
?></a></div>
<?php endif; ?>
</td>
<td class="break-word">
<?php echo $this->escape($item->username); ?>
</td>
<td class="center">
<?php
$self = $loggeduser->id == $item->id;
if ($canChange) :
echo JHtml::_('jgrid.state',
JHtml::_('users.blockStates', $self), $item->block, $i,
'users.', !$self);
else :
echo JHtml::_('jgrid.state',
JHtml::_('users.blockStates', $self), $item->block, $i,
'users.', false);
endif; ?>
</td>
<td class="center hidden-phone">
<?php
$activated = empty( $item->activation) ? 0 : 1;
echo JHtml::_('jgrid.state',
JHtml::_('users.activateStates'), $activated, $i,
'users.', (boolean) $activated);
?>
</td>
<td>
<?php if (substr_count($item->group_names, "\n")
> 1) : ?>
<span class="hasTooltip" title="<?php echo
JHtml::_('tooltipText',
JText::_('COM_USERS_HEADING_GROUPS'),
nl2br($item->group_names), 0); ?>"><?php echo
JText::_('COM_USERS_USERS_MULTIPLE_GROUPS'); ?></span>
<?php else : ?>
<?php echo nl2br($item->group_names); ?>
<?php endif; ?>
</td>
<td class="hidden-phone break-word hidden-tablet">
<?php echo
JStringPunycode::emailToUTF8($this->escape($item->email)); ?>
</td>
<td class="hidden-phone hidden-tablet">
<?php if ($item->lastvisitDate !=
$this->db->getNullDate()) : ?>
<?php echo JHtml::_('date', $item->lastvisitDate,
JText::_('DATE_FORMAT_LC6')); ?>
<?php else : ?>
<?php echo JText::_('JNEVER'); ?>
<?php endif; ?>
</td>
<td class="hidden-phone hidden-tablet">
<?php echo JHtml::_('date', $item->registerDate,
JText::_('DATE_FORMAT_LC6')); ?>
</td>
<td class="hidden-phone">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php // Load the batch processing form if user is allowed ?>
<?php if ($loggeduser->authorise('core.create',
'com_users')
&& $loggeduser->authorise('core.edit',
'com_users')
&& $loggeduser->authorise('core.edit.state',
'com_users')) : ?>
<?php echo JHtml::_(
'bootstrap.renderModal',
'collapseModal',
array(
'title' =>
JText::_('COM_USERS_BATCH_OPTIONS'),
'footer' =>
$this->loadTemplate('batch_footer'),
),
$this->loadTemplate('batch_body')
); ?>
<?php endif; ?>
<?php endif; ?>
<input type="hidden" name="task"
value="" />
<input type="hidden" name="boxchecked"
value="0" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>
views/users/tmpl/default.xml000064400000000310151160243100012147
0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_USERS_USERS_VIEW_DEFAULT_TITLE">
<message>
<![CDATA[COM_USERS_USERS_VIEW_DEFAULT_DESC]]>
</message>
</layout>
</metadata>
views/users/tmpl/default_batch_body.php000064400000003351151160243100014324
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Create the copy/move options.
$options = array(
JHtml::_('select.option', 'add',
JText::_('COM_USERS_BATCH_ADD')),
JHtml::_('select.option', 'del',
JText::_('COM_USERS_BATCH_DELETE')),
JHtml::_('select.option', 'set',
JText::_('COM_USERS_BATCH_SET'))
);
// Create the reset password options.
$resetOptions = array(
JHtml::_('select.option', '',
JText::_('COM_USERS_NO_ACTION')),
JHtml::_('select.option', 'yes',
JText::_('JYES')),
JHtml::_('select.option', 'no',
JText::_('JNO'))
);
JHtml::_('formbehavior.chosen', 'select');
?>
<div class="container-fluid">
<div class="row-fluid">
<div class="controls">
<label id="batch-choose-action-lbl"
class="control-label" for="batch-group-id">
<?php echo JText::_('COM_USERS_BATCH_GROUP'); ?>
</label>
<div id="batch-choose-action" class="combo
controls">
<div class="control-group">
<select name="batch[group_id]"
id="batch-group-id">
<option value=""><?php echo
JText::_('JSELECT'); ?></option>
<?php echo JHtml::_('select.options',
JHtml::_('user.groups')); ?>
</select>
</div>
</div>
<div class="control-group radio">
<?php echo JHtml::_('select.radiolist', $options,
'batch[group_action]', '', 'value',
'text', 'add'); ?>
</div>
</div>
</div>
<label><?php echo
JText::_('COM_USERS_REQUIRE_PASSWORD_RESET'); ?></label>
<div class="control-group radio">
<?php echo JHtml::_('select.radiolist', $resetOptions,
'batch[reset_id]', '', 'value',
'text', ''); ?>
</div>
</div>
views/users/tmpl/default_batch_footer.php000064400000001136151160243100014664
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<button type="button" class="btn"
onclick="document.getElementById('batch-group-id').value=''"
data-dismiss="modal">
<?php echo JText::_('JCANCEL'); ?>
</button>
<button type="submit" class="btn btn-success"
onclick="Joomla.submitbutton('user.batch');return
false;">
<?php echo JText::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
views/users/tmpl/modal.php000064400000012230151160243100011612
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('bootstrap.tooltip', '.hasTooltip',
array('placement' => 'bottom'));
JHtml::_('bootstrap.popover', '.hasPopover',
array('placement' => 'bottom'));
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.multiselect');
// Special case for the search field tooltip.
$searchFilterDesc =
$this->filterForm->getFieldAttribute('search',
'description', null, 'filter');
JHtml::_('bootstrap.tooltip', '#filter_search',
array('title' => JText::_($searchFilterDesc),
'placement' => 'bottom'));
$input = JFactory::getApplication()->input;
$field = $input->getCmd('field');
$listOrder =
$this->escape($this->state->get('list.ordering'));
$listDirn =
$this->escape($this->state->get('list.direction'));
$enabledStates = array(0 => 'icon-publish', 1 =>
'icon-unpublish');
$activatedStates = array(0 => 'icon-publish', 1 =>
'icon-unpublish');
$userRequired = (int) $input->get('required', 0,
'int');
/**
* Mootools compatibility
*
* There is an extra option passed in the URL for the iframe &ismoo=0
for the bootstraped field.
* By default the value will be 1 or defaults to mootools behaviour using
function jSelectUser()
*
* This should be removed when mootools won't be shipped by Joomla.
*/
$isMoo = $input->getInt('ismoo', 1);
if ($isMoo)
{
$onClick =
"window.parent.jSelectUser(this);window.parent.jQuery('.modal.in').modal('hide');";
}
?>
<div class="container-popup">
<form action="<?php echo
JRoute::_('index.php?option=com_users&view=users&layout=modal&tmpl=component&groups='
. $input->get('groups', '', 'BASE64') .
'&excluded=' . $input->get('excluded',
'', 'BASE64')); ?>" method="post"
name="adminForm" id="adminForm">
<?php if (!$userRequired) : ?>
<div class="pull-left">
<button type="button" class="btn button-select"
data-user-value="0" data-user-name="<?php echo
$this->escape(JText::_('JLIB_FORM_SELECT_USER')); ?>"
data-user-field="<?php echo $this->escape($field);
?>" <?php if ($isMoo) : ?>value=""
onclick="window.parent.jSelectUser(this)"<?php endif;
?>><?php echo JText::_('JOPTION_NO_USER');
?></button>
</div>
<?php endif; ?>
<?php echo
JLayoutHelper::render('joomla.searchtools.default',
array('view' => $this)); ?>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_NAME', 'a.name', $listDirn,
$listOrder); ?>
</th>
<th width="25%" class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'JGLOBAL_USERNAME', 'a.username', $listDirn,
$listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_ENABLED', 'a.block', $listDirn,
$listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('searchtools.sort',
'COM_USERS_HEADING_ACTIVATED', 'a.activation',
$listDirn, $listOrder); ?>
</th>
<th width="25%" class="nowrap">
<?php echo JText::_('COM_USERS_HEADING_GROUPS'); ?>
</th>
<th width="1%" class="nowrap">
<?php echo JHtml::_('searchtools.sort',
'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder);
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php $i = 0; ?>
<?php foreach ($this->items as $item) : ?>
<tr class="row<?php echo $i % 2; ?>">
<td>
<a class="pointer button-select" href="#"
data-user-value="<?php echo $item->id; ?>"
data-user-name="<?php echo $this->escape($item->name);
?>"
data-user-field="<?php echo $this->escape($field);
?>" <?php if ($isMoo) : ?>onclick="<?php echo
$onClick; ?>"<?php endif; ?>>
<?php echo $this->escape($item->name); ?>
</a>
</td>
<td>
<?php echo $this->escape($item->username); ?>
</td>
<td class="center">
<span class="<?php echo $enabledStates[(int)
$this->escape($item->block)]; ?>"></span>
</td>
<td class="center">
<span class="<?php echo
$activatedStates[(empty($item->activation) ? 0 : 1)];
?>"></span>
</td>
<td>
<?php echo nl2br($item->group_names); ?>
</td>
<td>
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<input type="hidden" name="task"
value="" />
<input type="hidden" name="field"
value="<?php echo $this->escape($field); ?>" />
<input type="hidden" name="boxchecked"
value="0" />
<input type="hidden" name="required"
value="<?php echo $userRequired; ?>" />
<input type="hidden" name="ismoo"
value="<?php echo $isMoo; ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
</div>
views/users/view.html.php000064400000010645151160243100011467
0ustar00<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* View class for a list of users.
*
* @since 1.6
*/
class UsersViewUsers extends JViewLegacy
{
/**
* The item data.
*
* @var object
* @since 1.6
*/
protected $items;
/**
* The pagination object.
*
* @var JPagination
* @since 1.6
*/
protected $pagination;
/**
* The model state.
*
* @var JObject
* @since 1.6
*/
protected $state;
/**
* A JForm instance with filter fields.
*
* @var JForm
* @since 3.6.3
*/
public $filterForm;
/**
* An array with active filters.
*
* @var array
* @since 3.6.3
*/
public $activeFilters;
/**
* An ACL object to verify user rights.
*
* @var JObject
* @since 3.6.3
*/
protected $canDo;
/**
* An instance of JDatabaseDriver.
*
* @var JDatabaseDriver
* @since 3.6.3
*/
protected $db;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse;
automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->canDo =
JHelperContent::getActions('com_users');
$this->db = JFactory::getDbo();
UsersHelper::addSubmenu('users');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
}
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = $this->canDo;
$user = JFactory::getUser();
// Get the toolbar object instance
$bar = JToolbar::getInstance('toolbar');
JToolbarHelper::title(JText::_('COM_USERS_VIEW_USERS_TITLE'),
'users user');
if ($canDo->get('core.create'))
{
JToolbarHelper::addNew('user.add');
}
if ($canDo->get('core.edit'))
{
JToolbarHelper::editList('user.edit');
}
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::divider();
JToolbarHelper::publish('users.activate',
'COM_USERS_TOOLBAR_ACTIVATE', true);
JToolbarHelper::unpublish('users.block',
'COM_USERS_TOOLBAR_BLOCK', true);
JToolbarHelper::custom('users.unblock',
'unblock.png', 'unblock_f2.png',
'COM_USERS_TOOLBAR_UNBLOCK', true);
JToolbarHelper::divider();
}
if ($canDo->get('core.delete'))
{
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE',
'users.delete', 'JTOOLBAR_DELETE');
JToolbarHelper::divider();
}
// Add a batch button
if ($user->authorise('core.create', 'com_users')
&& $user->authorise('core.edit',
'com_users')
&& $user->authorise('core.edit.state',
'com_users'))
{
$title = JText::_('JTOOLBAR_BATCH');
// Instantiate a new JLayoutFile instance and render the batch button
$layout = new JLayoutFile('joomla.toolbar.batch');
$dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch');
}
if ($canDo->get('core.admin') ||
$canDo->get('core.options'))
{
JToolbarHelper::preferences('com_users');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_USERS_USER_MANAGER');
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key
and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
return array(
'a.name' =>
JText::_('COM_USERS_HEADING_NAME'),
'a.username' =>
JText::_('JGLOBAL_USERNAME'),
'a.block' =>
JText::_('COM_USERS_HEADING_ENABLED'),
'a.activation' =>
JText::_('COM_USERS_HEADING_ACTIVATED'),
'a.email' => JText::_('JGLOBAL_EMAIL'),
'a.lastvisitDate' =>
JText::_('COM_USERS_HEADING_LAST_VISIT_DATE'),
'a.registerDate' =>
JText::_('COM_USERS_HEADING_REGISTRATION_DATE'),
'a.id' =>
JText::_('JGRID_HEADING_ID'),
);
}
}