first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,18 @@
<?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.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" />
</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>
</access>

View File

@ -0,0 +1,226 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset name="component">
<field
name="allowUserRegistration"
type="radio"
class="btn-group"
default="1"
label="COM_USERS_CONFIG_FIELD_ALLOWREGISTRATION_LABEL"
description="COM_USERS_CONFIG_FIELD_ALLOWREGISTRATION_DESC">
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
<field
name="new_usertype"
type="usergroup"
default="2"
label="COM_USERS_CONFIG_FIELD_NEW_USER_TYPE_LABEL"
description="COM_USERS_CONFIG_FIELD_NEW_USER_TYPE_DESC">
</field>
<field
name="guest_usergroup"
type="usergroup"
default="1"
label="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_LABEL"
description="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_DESC">
</field>
<field
name="sendpassword"
type="radio"
class="btn-group"
default="1"
label="COM_USERS_CONFIG_FIELD_SENDPASSWORD_LABEL"
description="COM_USERS_CONFIG_FIELD_SENDPASSWORD_DESC">
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
<field
name="useractivation"
type="list"
default="2"
label="COM_USERS_CONFIG_FIELD_USERACTIVATION_LABEL"
description="COM_USERS_CONFIG_FIELD_USERACTIVATION_DESC">
<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"
class="btn-group"
default="1"
label="COM_USERS_CONFIG_FIELD_MAILTOADMIN_LABEL"
description="COM_USERS_CONFIG_FIELD_MAILTOADMIN_DESC">
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
<field
name="captcha"
type="plugins"
folder="captcha"
default=""
label="COM_USERS_CONFIG_FIELD_CAPTCHA_LABEL"
description="COM_USERS_CONFIG_FIELD_CAPTCHA_DESC"
filter="cmd" >
<option
value="">JOPTION_USE_DEFAULT</option>
<option
value="0">JOPTION_DO_NOT_USE</option>
</field>
<field
name="frontend_userparams"
type="radio"
class="btn-group"
default="1"
label="COM_USERS_CONFIG_FIELD_FRONTEND_USERPARAMS_LABEL"
description="COM_USERS_CONFIG_FIELD_FRONTEND_USERPARAMS_DESC">
<option
value="0">JHIDE</option>
<option
value="1">JSHOW</option>
</field>
<field
name="site_language"
type="radio"
class="btn-group"
default="0"
label="COM_USERS_CONFIG_FIELD_FRONTEND_LANG_LABEL"
description="COM_USERS_CONFIG_FIELD_FRONTEND_LANG_DESC">
<option
value="0">JHIDE</option>
<option
value="1">JSHOW</option>
</field>
<field
name="change_login_name"
type="radio"
class="btn-group"
default="0"
label="COM_USERS_CONFIG_FIELD_CHANGEUSERNAME_LABEL"
description="COM_USERS_CONFIG_FIELD_CHANGEUSERNAME_DESC">
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
<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>
<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>
<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>
<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>
<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>
<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>
</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"
rows="5"
cols="30"
label="COM_USERS_CONFIG_FIELD_MAILBODY_SUFFIX_LABEL"
description="COM_USERS_CONFIG_FIELD_MAILBODY_SUFFIX_DESC"
/>
</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>

View File

@ -0,0 +1,111 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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 = UsersHelper::getActions();
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 If true, the view output will be cached
* @param array 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))
{
JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
// 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();
}
}

View File

@ -0,0 +1,69 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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 An array of input data.
* @param string 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 An array of input data.
* @param string 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);
}
}

View File

@ -0,0 +1,126 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @since 1.6
*/
public function checkin()
{
if (!JFactory::getUser()->authorise('core.admin', $this->option))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
jexit();
}
return parent::checkin();
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,81 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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 An array of input data.
* @param string 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));
}
/**
* Method to remove a record.
*/
public function delete()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JInvalid_Token'));
$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();
JArrayHelper::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');
}
}

View File

@ -0,0 +1,36 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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.
*
* @since 1.6
*/
public function getModel($name = 'Level', $prefix = 'UsersModel')
{
return parent::getModel($name, $prefix, array('ignore_request' => true));
}
}

View File

@ -0,0 +1,45 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
*/
class UsersControllerMail extends JControllerLegacy
{
public function send()
{
// Check for request forgeries.
JSession::checkToken('request') or jexit(JText::_('JINVALID_TOKEN'));
$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);
}
public function cancel()
{
// Check for request forgeries.
JSession::checkToken('request') or jexit(JText::_('JINVALID_TOKEN'));
$this->setRedirect('index.php');
}
}

View File

@ -0,0 +1,51 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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;
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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';
/**
* @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);
}
}

View File

@ -0,0 +1,120 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// 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);
}
/**
* Overrides parent save method to check the submitted passwords match.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return boolean True if successful, false otherwise.
*
* @since 1.6
*/
public function save($key = null, $urlVar = null)
{
$data = $this->input->post->get('jform', array(), 'array');
// TODO: JForm should really have a validation handler for this.
if (isset($data['password']) && isset($data['password2']))
{
// Check the passwords match.
if ($data['password'] != $data['password2'])
{
$this->setMessage(JText::_('JLIB_USER_ERROR_PASSWORD_NOT_MATCH'), 'warning');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=user&layout=edit', false));
}
unset($data['password2']);
}
return parent::save();
}
/**
* 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;
}
}

View File

@ -0,0 +1,144 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Users list controller class.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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.
*
* @return UsersControllerUsers
*
* @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.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$ids = $this->input->get('cid', array(), 'array');
$values = array('block' => 1, 'unblock' => 0);
$task = $this->getTask();
$value = JArrayHelper::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.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$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');
}
}

View File

@ -0,0 +1,155 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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 debugging helper.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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, false)
|| $lang->load("$extension.sys", $source, null, false, false)
|| $lang->load("$extension.sys", JPATH_ADMINISTRATOR, $lang->getDefault(), false, false)
|| $lang->load("$extension.sys", $source, $lang->getDefault(), false, false);
// Translate component name
$item->text = JText::_($item->text);
}
// Sort by component name
JArrayHelper::sortObjects($items, 'text', 1, true, true);
}
return $items;
}
/**
* Get a list of the actions for the component or code actions.
*
* @param string 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/models/forms/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;
break;
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;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,205 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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) . '">'
. '<span class="label label-info"><i class="icon-vcard"></i>' . $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) . '">'
. JHtml::_('image', 'admin/filter_16.png', 'COM_USERS_NOTES', array('title' => $title), true) . '</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 '<a class="modal"'
. ' href="' . JRoute::_('index.php?option=com_users&view=notes&tmpl=component&layout=modal&u_id=' . (int) $userId) . '"'
. ' rel="{handler: \'iframe\', size: {x: 800, y: 450}}">'
. '<span class="label label-info"><i class="icon-drawer-2"></i>' . $title . '</span></a>';
}
/**
* 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;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,193 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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 = self::getActions();
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'
);
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_NOTES'),
'index.php?option=com_users&view=notes',
$vName == 'notes'
);
$extension = JFactory::getApplication()->input->getString('extension');
JHtmlSidebar::addEntry(
JText::_('COM_USERS_SUBMENU_NOTE_CATEGORIES'),
'index.php?option=com_categories&extension=com_users',
$vName == 'categories' || $extension == 'com_users'
);
}
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject
*
* @since 1.6
* @todo Refactor to work with notes
*/
public static function getActions()
{
if (empty(self::$actions))
{
$user = JFactory::getUser();
self::$actions = new JObject;
$actions = JAccess::getActions('com_users');
foreach ($actions as $action)
{
self::$actions->set($action->name, $user->authorise($action->name, 'com_users'));
}
}
return self::$actions;
}
/**
* 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()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.id AS value')
->select('a.title AS text')
->select('COUNT(DISTINCT b.id) AS level')
->from('#__usergroups as a')
->join('LEFT', '#__usergroups AS b ON a.lft > b.lft AND a.rgt < b.rgt')
->group('a.id, a.title, a.lft, a.rgt')
->order('a.lft ASC');
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseNotice(500, $e->getMessage());
return null;
}
foreach ($options as &$option)
{
$option->text = str_repeat('- ', $option->level).$option->text;
}
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;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,243 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_COMPONENT . '/helpers/debug.php';
/**
* Methods supporting a list of user records.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersModelDebuggroup extends JModelList
{
/**
* 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('filter.group_id');
if (($assets = parent::getItems()) && $groupId)
{
$actions = $this->getDebugActions();
foreach ($assets as &$asset)
{
$asset->checks = array();
foreach ($actions as $action)
{
$name = $action[0];
$level = $action[1];
// Check that we check this action for the level of the asset.
if ($level === null || $level >= $asset->level)
{
// We need to test this action.
$asset->checks[$name] = JAccess::checkGroup($groupId, $name, $asset->name);
}
else
{
// We ignore this action.
$asset->checks[$name] = 'skip';
}
}
}
}
return $assets;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$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.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$value = $this->getUserStateFromRequest($this->context . '.filter.group_id', 'group_id', 0, 'int', false);
$this->setState('filter.group_id', $value);
$levelStart = $this->getUserStateFromRequest($this->context . '.filter.level_start', 'filter_level_start', 0, 'int');
$this->setState('filter.level_start', $levelStart);
$value = $this->getUserStateFromRequest($this->context . '.filter.level_end', 'filter_level_end', 0, 'int');
if ($value > 0 && $value < $levelStart)
{
$value = $levelStart;
}
$this->setState('filter.level_end', $value);
$component = $this->getUserStateFromRequest($this->context . '.filter.component', 'filter_component');
$this->setState('filter.component', $component);
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState('a.lft', 'asc');
}
/**
* 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.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('filter.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') . ' AS a');
// Filter the items over the search string if set.
if ($this->getState('filter.search'))
{
// Escape the search token.
$token = $db->quote('%' . $db->escape($this->getState('filter.search')) . '%');
// Compile the different search clauses.
$searches = array();
$searches[] = 'a.name LIKE ' . $token;
$searches[] = 'a.title LIKE ' . $token;
// 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;
}
}

View File

@ -0,0 +1,233 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_COMPONENT . '/helpers/debug.php';
/**
* Methods supporting a list of user records.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersModelDebugUser extends JModelList
{
/**
* 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('filter.user_id');
if (($assets = parent::getItems()) && $userId)
{
$actions = $this->getDebugActions();
foreach ($assets as &$asset)
{
$asset->checks = array();
foreach ($actions as $action)
{
$name = $action[0];
$level = $action[1];
// Check that we check this action for the level of the asset.
if ($level === null || $level >= $asset->level)
{
// We need to test this action.
$asset->checks[$name] = JAccess::check($userId, $name, $asset->name);
}
else
{
// We ignore this action.
$asset->checks[$name] = 'skip';
}
}
}
}
return $assets;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$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.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$value = $this->getUserStateFromRequest($this->context . '.filter.user_id', 'user_id', 0, 'int');
$this->setState('filter.user_id', $value);
$levelStart = $this->getUserStateFromRequest($this->context . '.filter.level_start', 'filter_level_start', 0, 'int');
$this->setState('filter.level_start', $levelStart);
$value = $this->getUserStateFromRequest($this->context . '.filter.level_end', 'filter_level_end', 0, 'int');
if ($value > 0 && $value < $levelStart)
{
$value = $levelStart;
}
$this->setState('filter.level_end', $value);
$component = $this->getUserStateFromRequest($this->context . '.filter.component', 'filter_component');
$this->setState('filter.component', $component);
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState('a.lft', 'asc');
}
/**
* 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.user_id');
$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('filter.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') . ' AS a');
// Filter the items over the group id if set.
if ($groupId = $this->getState('filter.group_id'))
{
$query->join('LEFT', '#__user_usergroup_map AS map2 ON map2.user_id = a.id')
->where('map2.group_id = ' . (int) $groupId);
}
// Filter the items over the search string if set.
if ($this->getState('filter.search'))
{
// Escape the search token.
$token = $db->quote('%' . $db->escape($this->getState('filter.search')) . '%');
// Compile the different search clauses.
$searches = array();
$searches[] = 'a.name LIKE ' . $token;
$searches[] = 'a.title LIKE ' . $token;
// 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;
}
}

View File

@ -0,0 +1,89 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('JPATH_BASE') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class JFormFieldGroupParent extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'GroupParent';
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
protected function getOptions()
{
$options = array();
$db = JFactory::getDbo();
$user = JFactory::getUser();
$query = $db->getQuery(true)
->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level')
->from('#__usergroups AS a')
->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
// Prevent parenting to children of this item.
if ($id = $this->form->getValue('id'))
{
$query->join('LEFT', $db->quoteName('#__usergroups') . ' AS p ON p.id = ' . (int) $id)
->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
}
$query->group('a.id, a.title, a.lft, a.rgt')
->order('a.lft ASC');
// Get the options.
$db->setQuery($query);
try
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
}
// 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 ($user->authorise('core.admin') || (!JAccess::checkGroup($options[$i]->value, 'core.admin')))
{
$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
}
else
{
unset($options[$i]);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field name="id" type="hidden"
default="0"
required="true"
readonly="true"
/>
<field name="title" type="text"
class="inputbox" required="true"
description="COM_USERS_GROUP_FIELD_TITLE_DESC"
label="COM_USERS_GROUP_FIELD_TITLE_LABEL"
size="40"
/>
<field name="parent_id" type="groupparent"
class="inputbox"
description="COM_USERS_GROUP_FIELD_PARENT_DESC"
label="COM_USERS_GROUP_FIELD_PARENT_LABEL"
required="true"
/>
<field name="actions" type="hidden"
multiple="true"
/>
<field name="lft" type="hidden"
filter="unset"
/>
<field name="rgt" type="hidden"
filter="unset"
/>
</fieldset>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,27 @@
<?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"
class="inputbox" required="true"
description="COM_USERS_LEVEL_FIELD_TITLE_DESC"
label="COM_USERS_LEVEL_FIELD_TITLE_LABEL"
size="50"
/>
<field name="ordering" type="text"
default="0"
description="JFIELD_ORDERING_DESC"
label="JFIELD_ORDERING_LABEL"
/>
<field name="rules" type="hidden"
filter="int_array"
/>
</fieldset>
</form>

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field name="recurse" type="checkbox"
description="COM_USERS_MAIL_FIELD_RECURSE_DESC"
label="COM_USERS_MAIL_FIELD_RECURSE_LABEL"
value="1"
/>
<field name="mode" type="checkbox"
description="COM_USERS_MAIL_FIELD_SEND_IN_HTML_MODE_DESC"
label="COM_USERS_MAIL_FIELD_SEND_IN_HTML_MODE_LABEL"
value="1"
/>
<field name="disabled" type="checkbox"
description="COM_USERS_MAIL_FIELD_EMAIL_DISABLED_USERS_DESC"
label="COM_USERS_MAIL_FIELD_EMAIL_DISABLED_USERS_LABEL"
value="1"
/>
<field name="group" type="usergroup"
default="0"
description="COM_USERS_MAIL_FIELD_GROUP_DESC"
label="COM_USERS_MAIL_FIELD_GROUP_LABEL"
size="10"
>
<option value="0">COM_USERS_MAIL_FIELD_VALUE_ALL_USERS_GROUPS</option>
</field>
<field name="bcc" type="checkbox"
default="1"
description="COM_USERS_MAIL_FIELD_SEND_AS_BLIND_CARBON_COPY_DESC"
label="COM_USERS_MAIL_FIELD_SEND_AS_BLIND_CARBON_COPY_LABEL"
value="1"
/>
<field name="subject" type="text"
class="inputbox span8"
description="COM_USERS_MAIL_FIELD_SUBJECT_DESC"
label="COM_USERS_MAIL_FIELD_SUBJECT_LABEL"
maxlength="150"
size="30"
/>
<field name="message" type="textarea"
class="inputbox span11"
cols="70"
description="COM_USERS_MAIL_FIELD_MESSAGE_DESC"
label="COM_USERS_MAIL_FIELD_MESSAGE_LABEL"
rows="20"
/>
</fieldset>
</form>

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="hidden"
class="readonly"
size="6"
default="0"
readonly="true"
label="COM_USERS_FIELD_ID_LABEL"
/>
<field
name="user_id"
type="user"
size="50"
class="inputbox"
required="true"
label="COM_USERS_FIELD_USER_ID_LABEL"
/>
<field
name="catid"
type="category"
class="inputbox"
extension="com_users"
label="COM_USERS_FIELD_CATEGORY_ID_LABEL"
description="JFIELD_CATEGORY_DESC" >
</field>
<field
name="subject"
type="text"
class="inputbox"
size="80"
label="COM_USERS_FIELD_SUBJECT_LABEL"
description="COM_USERS_FIELD_SUBJECT_DESC"
/>
<field
name="body"
type="editor"
class="inputbox"
rows="10"
cols="80"
filter="safehtml"
label="COM_USERS_FIELD_NOTEBODY_LABEL"
description="COM_USERS_FIELD_NOTEBODY_DESC"
/>
<field
name="state"
type="list"
label="JSTATUS"
description="COM_USERS_FIELD_STATE_DESC"
class="inputbox"
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"
class="inputbox"
label="COM_USERS_FIELD_REVIEW_TIME_LABEL"
description="COM_USERS_FIELD_REVIEW_TIME_DESC"
default="0000-00-00"
format="%Y-%m-%d"
/>
<field
name="checked_out"
type="hidden"
filter="unset"
/>
<field
name="checked_out_time"
type="hidden"
filter="unset"
/>
<field
name="created_user_id"
type="hidden"
filter="unset"
/>
<field
name="created_time"
type="hidden"
filter="unset"
/>
<field
name="modified_user_id"
type="hidden"
filter="unset"
/>
<field
name="modified_time"
type="hidden"
filter="unset"
/>
<field name="publish_up" type="calendar"
label="JGLOBAL_FIELD_PUBLISH_UP_LABEL" description="JGLOBAL_FIELD_PUBLISH_UP_DESC"
class="inputbox" format="%Y-%m-%d %H:%M:%S" size="22"
filter="user_utc" />
<field name="publish_down" type="calendar"
label="JGLOBAL_FIELD_PUBLISH_DOWN_LABEL" description="JGLOBAL_FIELD_PUBLISH_DOWN_DESC"
class="inputbox" format="%Y-%m-%d %H:%M:%S" size="22"
filter="user_utc" />
</fieldset>
</form>

View File

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="user_details">
<field name="name" type="text"
class="inputbox"
description="COM_USERS_USER_FIELD_NAME_DESC"
label="COM_USERS_USER_FIELD_NAME_LABEL"
required="true"
size="30"
/>
<field name="username" type="text"
class="inputbox"
description="COM_USERS_USER_FIELD_USERNAME_DESC"
label="COM_USERS_USER_FIELD_USERNAME_LABEL"
required="true"
size="30"
/>
<field name="password" type="password"
autocomplete="off"
class="inputbox validate-password"
description="COM_USERS_USER_FIELD_PASSWORD_DESC"
filter="raw"
validate="password"
label="JGLOBAL_PASSWORD"
size="30"
/>
<field name="password2" type="password"
autocomplete="off"
class="inputbox validate-password"
description="COM_USERS_USER_FIELD_PASSWORD2_DESC"
filter="raw"
label="COM_USERS_USER_FIELD_PASSWORD2_LABEL"
size="30"
validate="equals"
field="password"
/>
<field name="email" type="email"
class="inputbox"
description="COM_USERS_USER_FIELD_EMAIL_DESC"
label="JGLOBAL_EMAIL"
required="true"
size="30"
validate="email"
/>
<field
name="registerDate"
type="calendar"
class="readonly"
label="COM_USERS_USER_FIELD_REGISTERDATE_LABEL"
description="COM_USERS_USER_FIELD_REGISTERDATE_DESC"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
size="22"
filter="user_utc"
/>
<field
name="lastvisitDate"
type="calendar"
class="readonly"
label="COM_USERS_USER_FIELD_LASTVISIT_LABEL"
description="COM_USERS_USER_FIELD_LASTVISIT_DESC"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
size="22"
filter="user_utc"
/>
<field
name="lastResetTime"
type="calendar"
class="readonly"
label="COM_USERS_USER_FIELD_LASTRESET_LABEL"
description="COM_USERS_USER_FIELD_LASTRESET_DESC"
readonly="true"
format="%Y-%m-%d %H:%M:%S"
size="22"
filter="user_utc"
/>
<field
name="resetCount"
type="text"
class="readonly"
label="COM_USERS_USER_FIELD_RESETCOUNT_LABEL"
description ="COM_USERS_USER_FIELD_RESETCOUNT_DESC"
default="0"
readonly="true"
/>
<field
name="sendEmail"
type="radio"
default="0"
class="btn-group"
label="COM_USERS_USER_FIELD_SENDEMAIL_LABEL"
description="COM_USERS_USER_FIELD_SENDEMAIL_DESC">
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
<field
name="block"
type="radio"
class="btn-group"
default="0"
label="COM_USERS_USER_FIELD_BLOCK_LABEL"
description="COM_USERS_USER_FIELD_BLOCK_DESC">
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
<field
name="id"
type="text"
class="readonly"
label="JGLOBAL_FIELD_ID_LABEL"
description ="JGLOBAL_FIELD_ID_DESC"
default="0"
readonly="true"
/>
</fieldset>
<field name="groups" type="hidden" />
<fields name="params">
<!-- Basic user account settings. -->
<fieldset name="settings" label="COM_USERS_SETTINGS_FIELDSET_LABEL">
<field name="admin_style" type="templatestyle"
client="administrator"
description="COM_USERS_USER_FIELD_BACKEND_TEMPLATE_DESC"
label="COM_USERS_USER_FIELD_BACKEND_TEMPLATE_LABEL"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field name="admin_language" type="language"
client="administrator"
description="COM_USERS_USER_FIELD_BACKEND_LANGUAGE_DESC"
label="COM_USERS_USER_FIELD_BACKEND_LANGUAGE_LABEL"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field name="language" type="language"
client="site"
description="COM_USERS_USER_FIELD_FRONTEND_LANGUAGE_DESC"
label="COM_USERS_USER_FIELD_FRONTEND_LANGUAGE_LABEL"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field name="editor" type="plugins" folder="editors"
description="COM_USERS_USER_FIELD_EDITOR_DESC"
label="COM_USERS_USER_FIELD_EDITOR_LABEL"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
<field name="helpsite" type="helpsite"
label="COM_USERS_USER_FIELD_HELPSITE_LABEL"
description="COM_USERS_USER_FIELD_HELPSITE_DESC"
>
<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>

View File

@ -0,0 +1,261 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User group model.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersModelGroup extends JModelAdmin
{
/**
* @var string The event to trigger after saving the data.
* @since 1.6
*/
protected $event_after_save = 'onUserAfterSaveGroup';
/**
* @var string The event to trigger after before the data.
* @since 1.6
*/
protected $event_before_save = 'onUserBeforeSaveGroup';
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array 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 interogate.
* @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 object A form object.
* @param mixed The data expected for the form.
* @throws Exception if there is an error in the form event.
* @since 1.6
*/
protected function preprocessForm(JForm $form, $data, $groups = '')
{
$obj = is_array($data) ? JArrayHelper::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 The form data.
* @return boolean True on success.
* @since 1.6
*/
public function save($data)
{
// Include the content plugins for events.
JPluginHelper::importPlugin('user');
// 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))
{
try
{
throw new Exception(JText::_('JLIB_USER_ERROR_NOT_SUPERADMIN'));
}
catch (Exception $e)
{
$this->setError($e->getMessage());
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) ? $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))
{
try
{
throw new Exception(JText::_('JLIB_USER_ERROR_CANNOT_DEMOTE_SELF'));
}
catch (Exception $e)
{
$this->setError($e->getMessage());
return false;
}
}
}
}
// Proceed with the save
return parent::save($data);
}
/**
* Method to delete rows.
*
* @param array An array of item ids.
* @return boolean Returns true on success, false on failure.
* @since 1.6
*/
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('user');
$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 onUserBeforeDeleteGroup event.
$dispatcher->trigger('onUserBeforeDeleteGroup', array($table->getProperties()));
if (!$table->delete($pk))
{
$this->setError($table->getError());
return false;
} else {
// Trigger the onUserAfterDeleteGroup event.
$dispatcher->trigger('onUserAfterDeleteGroup', 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;
}
}

View File

@ -0,0 +1,202 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersModelGroups extends JModelList
{
/**
* Constructor.
*
* @param array 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.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState('a.lft', 'asc');
}
/**
* 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');
$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()
{
$db = $this->getDbo();
// 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;
}
// First pass: get list of the group id's and reset the counts.
$groupIds = array();
foreach ($items as $item)
{
$groupIds[] = (int) $item->id;
$item->user_count = 0;
}
// Get the counts from the database only for the users in the list.
$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') . ' AS map')
->where('map.group_id IN (' . implode(',', $groupIds) . ')')
->group('map.group_id');
$db->setQuery($query);
// Load the counts into an array indexed on the user id field.
try
{
$users = $db->loadObjectList('group_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($users[$item->id]))
{
$item->user_count = $users[$item->id]->user_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
*/
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');
// Add the level in the tree.
$query->select('COUNT(DISTINCT c2.id) AS level')
->join('LEFT OUTER', $db->quoteName('#__usergroups') . ' AS c2 ON a.lft > c2.lft AND a.rgt < c2.rgt')
->group('a.id, a.lft, a.rgt, a.parent_id, a.title');
// 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('%' . $db->escape($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')));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,205 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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 model.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersModelLevel extends JModelAdmin
{
/**
* @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)
{
// 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');
// from is added dynamically
// Get all the tables and the prefix
$tables = $db->getTableList();
//$fields = $db->getTableFields($tables);
$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 type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array 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 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 interogate.
* @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;
}
/**
* Override preprocessForm to load the user plugin group instead of content.
*
* @param object A form object.
* @param mixed The data expected for the form.
* @throws Exception if there is an error in the form event.
* @since 1.6
*/
protected function preprocessForm(JForm $form, $data, $groups = '')
{
parent::preprocessForm($form, $data, 'user');
}
/**
* Method to save the form data.
*
* @param array The form data.
* @return boolean True on success.
* @since 1.6
*/
public function save($data)
{
if (!isset($data['rules']))
{
$data['rules'] = array();
}
return parent::save($data);
}
}

View File

@ -0,0 +1,219 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersModelLevels extends JModelList
{
/**
* Constructor.
*
* @param array 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.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState('a.title', 'asc');
}
/**
* 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('%' . $db->escape($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.lft')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
/**
* Method to adjust the ordering of a row.
*
* @param integer The ID of the primary key to move.
* @param integer 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 An array of primary key ids.
* @param integer +/-1
*/
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;
}
}

View File

@ -0,0 +1,192 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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 interogate.
* @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;
}
/**
* Override preprocessForm to load the user plugin group instead of content.
*
* @param object A form object.
* @param mixed The data expected for the form.
* @throws Exception if there is an error in the form event.
* @since 1.6
*/
protected function preprocessForm(JForm $form, $data, $group = 'user')
{
parent::preprocessForm($form, $data, $group);
}
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
$to = $access->getUsersByGroup($grp, $recurse);
// Get all users email and group except for senders
$query = $db->getQuery(true)
->select('email')
->from('#__users')
->where('id != '.(int) $user->get('id'));
if ($grp !== 0)
{
if (empty($to))
{
$query->where('0');
} else {
$query->where('id IN (' . implode(',', $to) . ')');
}
}
if ($disabled == 0){
$query->where("block = 0");
}
$db->setQuery($query);
$rows = $db->loadColumn();
// Check to see if there are any users in this group before we continue
if (!count($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->getCfg('mailfrom'), $app->getCfg('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->getCfg('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;
}
}
}

View File

@ -0,0 +1,186 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 2.5
*/
class UsersModelNote extends JModelAdmin
{
/**
* 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 users plugins.
$dispatcher = JEventDispatcher::getInstance();
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);
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 2.5
*/
/*public function save($data)
{
$pk = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('note.id');
$table = $this->getTable();
$isNew = empty($pk);
if (!$table->bind($data))
{
$this->setError($table->getError());
return false;
}
// JTableCategory doesn't bind the params, so we need to do that by hand.
if (isset($data['params']) && is_array($data['params']))
{
$registry = new JRegistry();
$registry->loadArray($data['params']);
$table->params = $registry->toString();
// This will give us INI format.
}
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
$this->setState('note.id', $table->id);
return true;
}*/
}

View File

@ -0,0 +1,224 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @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',
'state', 'a.state',
'c.title',
'review_time',
'a.review_time',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
);
}
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);
$section = $this->getState('filter.category_id');
// 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('%' . $db->escape($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.state');
if (is_numeric($published))
{
$query->where('a.state = '.(int) $published);
} elseif ($published === '')
{
$query->where('(a.state IN (0, 1))');
}
// Filter by a single or group of categories.
$categoryId = (int) $this->getState('filter.category_id');
if ($categoryId)
{
if (is_scalar($section))
{
$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);
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
$query->order($db->escape($orderCol . ' ' . $orderDirn));
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.state');
$id .= ':' . $this->getState('filter.category_id');
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 = JFactory::getApplication()->input->get('u_id', 0, 'int');
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.
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$input = $app->input;
// Adjust the context to support modal layouts.
if ($layout = $input->get('layout'))
{
$this->context .= '.' . $layout;
}
$value = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $value);
$published = $this->getUserStateFromRequest($this->context.'.filter.state', 'filter_published', '', 'string');
$this->setState('filter.state', $published);
$section = $app->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
$this->setState('filter.category_id', $section);
$userId = $input->get('u_id', 0, 'int');
$this->setState('filter.user_id', $userId);
parent::populateState('a.review_time', 'DESC');
}
}

View File

@ -0,0 +1,698 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* User model.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersModelUser extends JModelAdmin
{
/**
* 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)
{
$result = parent::getItem($pk);
$result->tags = new JHelperTags;
$result->tags->getTagIds($result->id, 'com_users.user');
// Get the dispatcher and load the users plugins.
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('user');
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.user', $result));
return $result;
}
/**
* Method to get the record form.
*
* @param array $data An optional array of data for the form to interogate.
* @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)
{
$plugin = JPluginHelper::getPlugin('user', 'joomla');
$pluginParams = new JRegistry($plugin->params);
// Get the form.
$form = $this->loadForm('com_users.user', 'user', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Passwords fields are required when mail to user is set to No in joomla user plugin
$userId = $form->getValue('id');
if ($userId === 0 && $pluginParams->get('mail_to_user') === "0")
{
$form->setFieldAttribute('password', 'required', 'true');
$form->setFieldAttribute('password2', 'required', 'true');
}
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();
}
JPluginHelper::importPlugin('user');
$this->preprocessData('com_users.profile', $data);
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();
if ($data['block'] && $pk == $my->id && !$my->block)
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF'));
return false;
}
// Make sure that we are not removing ourself from Super Admin group
$iAmSuperAdmin = $my->authorise('core.admin');
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) ? ($stillSuperAdmin) : JAccess::checkGroup($group, 'core.admin');
}
if (!$stillSuperAdmin)
{
$this->setError(JText::_('COM_USERS_USERS_ERROR_CANNOT_DEMOTE_SELF'));
return false;
}
}
// 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');
// Trigger the onUserBeforeSave event.
JPluginHelper::importPlugin('user');
$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 onUserBeforeDelete event.
$dispatcher->trigger('onUserBeforeDelete', array($table->getProperties()));
if (!$table->delete($pk))
{
$this->setError($table->getError());
return false;
}
else
{
// Trigger the onUserAfterDelete event.
$dispatcher->trigger('onUserAfterDelete', 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('user');
// 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;
// Prepare the logout options.
$options = array(
'clientid' => 0
);
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 onUserBeforeSave event.
$result = $dispatcher->trigger('onUserBeforeSave', 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;
}
// Trigger the onAftereStoreUser event
$dispatcher->trigger('onUserAfterSave', 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('user');
// 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 onUserBeforeSave event.
$result = $dispatcher->trigger('onUserBeforeSave', 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 onAftereStoreUser event
$dispatcher->trigger('onUserAfterSave', 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);
JArrayHelper::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 = JArrayHelper::getValue($commands, 'group_action', 'add');
if (!$this->batchUser((int) $commands['group_id'], $pks, $cmd))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Perform batch operations
*
* @param integer $group_id The group ID which assignments are being edited
* @param array $user_ids 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($group_id, $user_ids, $action)
{
// Get the DB object
$db = $this->getDbo();
JArrayHelper::toInteger($user_ids);
// Non-super admin cannot work with super-admin group
if ((!JFactory::getUser()->get('isRoot') && JAccess::checkGroup($group_id, 'core.admin')) || $group_id < 1)
{
$this->setError(JText::_('COM_USERS_ERROR_INVALID_GROUP'));
return false;
}
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(',', $user_ids) . ')');
// Only remove users from selected group
if ($doDelete == 'group')
{
$query->where($db->quoteName('group_id') . ' = ' . (int) $group_id);
}
$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) $group_id);
$db->setQuery($query);
$users = $db->loadColumn();
// Build the values clause for the assignment query.
$query->clear();
$groups = false;
foreach ($user_ids as $id)
{
if (!in_array($id, $users))
{
$query->values($id . ',' . $group_id);
$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();
$config = JComponentHelper::getParams('com_users');
if ($groupId = $config->get('new_usertype'))
{
$result[] = $groupId;
}
}
else
{
$result = JUserHelper::getUserGroups($userId);
}
return $result;
}
}

View File

@ -0,0 +1,416 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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 records.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersModelUsers 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',
'name', 'a.name',
'username', 'a.username',
'email', 'a.email',
'block', 'a.block',
'sendEmail', 'a.sendEmail',
'registerDate', 'a.registerDate',
'lastvisitDate', 'a.lastvisitDate',
'activation', 'a.activation',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$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.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$active = $this->getUserStateFromRequest($this->context . '.filter.active', 'filter_active');
$this->setState('filter.active', $active);
$state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state');
$this->setState('filter.state', $state);
$groupId = $this->getUserStateFromRequest($this->context . '.filter.group', 'filter_group_id', null, 'int');
$this->setState('filter.group_id', $groupId);
$range = $this->getUserStateFromRequest($this->context . '.filter.range', 'filter_range');
$this->setState('filter.range', $range);
$groups = json_decode(base64_decode($app->input->get('groups', '', 'BASE64')));
if (isset($groups))
{
JArrayHelper::toInteger($groups);
}
$this->setState('filter.groups', $groups);
$excluded = json_decode(base64_decode($app->input->get('excluded', '', 'BASE64')));
if (isset($excluded))
{
JArrayHelper::toInteger($excluded);
}
$this->setState('filter.excluded', $excluded);
// Load the parameters.
$params = JComponentHelper::getParams('com_users');
$this->setState('params', $params);
// List state information.
parent::populateState('a.name', 'asc');
}
/**
* 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 = ' . $db->quote(''));
}
elseif ($active == '1')
{
$query->where($query->length('a.activation') . ' = 32');
}
}
// 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.
if ($this->getState('filter.search') !== '' && $this->getState('filter.search') !== null)
{
// Escape the search token.
$token = $db->quote('%' . $db->escape($this->getState('filter.search')) . '%');
// Compile the different search clauses.
$searches = array();
$searches[] = 'a.name LIKE ' . $token;
$searches[] = 'a.username LIKE ' . $token;
$searches[] = 'a.email LIKE ' . $token;
// 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)
{
// 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':
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->getCfg('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;
}
if ($range == 'post_year')
{
$query->where(
'a.registerDate < ' . $db->quote($dStart->format('Y-m-d H:i:s'))
);
}
else
{
$query->where(
'a.registerDate >= ' . $db->quote($dStart->format('Y-m-d H:i:s')) .
' AND a.registerDate <=' . $db->quote($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->escape($this->getState('list.ordering', 'a.name')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
return $query;
}
//sqlsrv change
function _getUserDisplayedGroups($user_id)
{
$db = JFactory::getDbo();
$query = "SELECT title FROM " . $db->quoteName('#__usergroups') . " ug left join " .
$db->quoteName('#__user_usergroup_map') . " map on (ug.id = map.group_id)" .
" WHERE map.user_id=" . $user_id;
$db->setQuery($query);
$result = $db->loadColumn();
return implode("\n", $result);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,152 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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 table class
*
* @package Joomla.Administrator
* @subpackage com_users
* @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);
}
/**
* 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');
if (empty($this->id))
{
// New record.
$this->created_time = $date;
$this->created_user_id = $userId;
}
else
{
// Existing record.
$this->modified_time = $date;
$this->modified_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.
*
* @link http://docs.joomla.org/JTable/publish
* @since 2.5
*/
public function publish($pks = null, $state = 1, $userId = 0)
{
$k = $this->_tbl_key;
// Sanitize input.
JArrayHelper::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;
}
}

View File

@ -0,0 +1,21 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
if (!JFactory::getUser()->authorise('core.manage', 'com_users'))
{
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
JLoader::register('UsersHelper', __DIR__ . '/helpers/users.php');
$controller = JControllerLegacy::getInstance('Users');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();

View File

@ -0,0 +1,42 @@
<?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 - 2013 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>index.html</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>index.html</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>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,131 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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');
$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=debuggroup&user_id='.(int) $this->state->get('filter.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;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_USERS_SEARCH_ASSETS'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_RESET'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
</div>
<div class="clearfix"> </div>
<table class="table table-striped">
<thead>
<tr>
<th class="left">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_ASSET_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th class="left">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_ASSET_NAME', 'a.name', $listDirn, $listOrder); ?>
</th>
<?php foreach ($this->actions as $key => $action) : ?>
<th width="5%" class="nowrap 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::_('grid.sort', 'COM_USERS_HEADING_LFT', 'a.lft', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<tr class="row1">
<td colspan="15">
<div>
<?php echo JText::_('COM_USERS_DEBUG_LEGEND'); ?>
<span class="btn disabled btn-micro btn-warning"><i class="icon-white icon-ban-circle"></i></span> <?php echo JText::_('COM_USERS_DEBUG_IMPLICIT_DENY');?>
<span class="btn disabled btn-micro btn-success"><i class="icon-white icon-ok"></i></span> <?php echo JText::_('COM_USERS_DEBUG_EXPLICIT_ALLOW');?>
<span class="btn disabled btn-micro btn-danger"><i class="icon-white icon-remove"></i></span> <?php echo JText::_('COM_USERS_DEBUG_EXPLICIT_DENY');?>
</div>
</td>
</tr>
<?php foreach ($this->items as $i => $item) : ?>
<tr class="row0">
<td>
<?php echo $this->escape($item->title); ?>
</td>
<td class="nowrap">
<?php echo str_repeat('<span class="gi">|&mdash;</span>', $item->level) ?>
<?php echo $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="btn disabled btn-micro <?php echo $button; ?>">
<i class="icon-white <?php echo $class; ?>"></i>
</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" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,97 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersViewDebuggroup extends JViewLegacy
{
protected $actions;
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
// Access check.
if (!JFactory::getUser()->authorise('core.manage', 'com_users') || !JFactory::getConfig()->get('debug'))
{
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
$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->levels = UsersHelperDebug::getLevelsOptions();
$this->components = UsersHelperDebug::getComponents();
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JToolbarHelper::title(JText::sprintf('COM_USERS_VIEW_DEBUG_GROUP_TITLE', $this->group->id, $this->group->title), 'groups');
JToolbarHelper::help('JHELP_USERS_DEBUG_GROUPS');
JHtmlSidebar::setAction('index.php?option=com_users&view=debuggroup&user_id=' . (int) $this->state->get('filter.user_id'));
$option = '';
if (!empty($this->components))
{
$option = JHtml::_('select.options', $this->components, 'value', 'text', $this->state->get('filter.component'));
}
JHtmlSidebar::addFilter(
JText::_('COM_USERS_OPTION_SELECT_COMPONENT'),
'filter_component',
$option
);
JHtmlSidebar::addFilter(
JText::_('COM_USERS_OPTION_SELECT_LEVEL_START'),
'filter_level_start',
JHtml::_('select.options', $this->levels, 'value', 'text', $this->state->get('filter.level_start'))
);
JHtmlSidebar::addFilter(
JText::_('COM_USERS_OPTION_SELECT_LEVEL_END'),
'filter_level_end',
JHtml::_('select.options', $this->levels, 'value', 'text', $this->state->get('filter.level_end'))
);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,130 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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');
$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=debuguser&user_id=' . (int) $this->state->get('filter.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;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_USERS_SEARCH_ASSETS'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_RESET'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
</div>
<div class="clearfix"> </div>
<table class="table table-striped">
<thead>
<tr>
<th class="left">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_ASSET_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th class="nowrap left">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_ASSET_NAME', 'a.name', $listDirn, $listOrder); ?>
</th>
<?php foreach ($this->actions as $key => $action) : ?>
<th width="5%" class="nowrap 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::_('grid.sort', 'COM_USERS_HEADING_LFT', 'a.lft', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<tr class="row1">
<td colspan="15">
<div>
<?php echo JText::_('COM_USERS_DEBUG_LEGEND'); ?>
<span class="btn disabled btn-micro btn-warning"><i class="icon-white icon-ban-circle"></i></span> <?php echo JText::_('COM_USERS_DEBUG_IMPLICIT_DENY');?>
<span class="btn disabled btn-micro btn-success"><i class="icon-white icon-ok"></i></span> <?php echo JText::_('COM_USERS_DEBUG_EXPLICIT_ALLOW');?>
<span class="btn disabled btn-micro btn-danger"><i class="icon-white icon-remove"></i></span> <?php echo JText::_('COM_USERS_DEBUG_EXPLICIT_DENY');?>
</div>
</td>
</tr>
<?php foreach ($this->items as $i => $item) : ?>
<tr class="row0">
<td>
<?php echo $this->escape($item->title); ?>
</td>
<td class="nowrap">
<?php echo str_repeat('<span class="gi">|&mdash;</span>', $item->level) ?>
<?php echo $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="btn disabled btn-micro <?php echo $button; ?>">
<i class="icon-white <?php echo $class; ?>"></i>
</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" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,99 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersViewDebuguser extends JViewLegacy
{
protected $actions;
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
// Access check.
if (!JFactory::getUser()->authorise('core.manage', 'com_users') || !JFactory::getConfig()->get('debug'))
{
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
$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->levels = UsersHelperDebug::getLevelsOptions();
$this->components = UsersHelperDebug::getComponents();
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JToolbarHelper::title(JText::sprintf('COM_USERS_VIEW_DEBUG_USER_TITLE', $this->user->id, $this->user->name), 'user');
JToolbarHelper::help('JHELP_USERS_DEBUG_USERS');
JHtmlSidebar::setAction('index.php?option=com_users&view=debuguser&user_id=' . (int) $this->state->get('filter.user_id'));
$option = '';
if (!empty($this->components))
{
$option = JHtml::_('select.options', $this->components, 'value', 'text', $this->state->get('filter.component'));
}
JHtmlSidebar::addFilter(
JText::_('COM_USERS_OPTION_SELECT_COMPONENT'),
'filter_component',
$option
);
JHtmlSidebar::addFilter(
JText::_('COM_USERS_OPTION_SELECT_LEVEL_START'),
'filter_level_start',
JHtml::_('select.options', $this->levels, 'value', 'text', $this->state->get('filter.level_start'))
);
JHtmlSidebar::addFilter(
JText::_('COM_USERS_OPTION_SELECT_LEVEL_END'),
'filter_level_end',
JHtml::_('select.options', $this->levels, 'value', 'text', $this->state->get('filter.level_end'))
);
$this->sidebar = JHtmlSidebar::render();
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,55 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
$canDo = UsersHelper::getActions();
?>
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'group.cancel' || document.formvalidator.isValid(document.id('group-form')))
{
Joomla.submitform(task, document.getElementById('group-form'));
}
}
</script>
<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>
<legend><?php echo JText::_('COM_USERS_USERGROUP_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>
<div class="control-group">
<?php $parent_id = $this->form->getField('parent_id');?>
<?php if (!$parent_id->hidden) : ?>
<div class="control-label">
<?php echo $parent_id->label; ?>
</div>
<?php endif;?>
<div class="controls">
<?php echo $parent_id->input; ?>
</div>
</div>
</fieldset>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,88 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersViewGroup extends JViewLegacy
{
protected $form;
protected $item;
protected $state;
/**
* Display the view
*/
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')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$isNew = ($this->item->id == 0);
$canDo = UsersHelper::getActions();
JToolbarHelper::title(JText::_($isNew ? 'COM_USERS_VIEW_NEW_GROUP_TITLE' : 'COM_USERS_VIEW_EDIT_GROUP_TITLE'), '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');
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,179 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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::_('dropdown.init');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$sortFields = $this->getSortFields();
JText::script('COM_USERS_GROUPS_CONFIRM_DELETE');
?>
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'groups.delete')
{
var f = document.adminForm;
var cb='';
<?php foreach ($this->items as $i => $item):?>
<?php if ($item->user_count > 0):?>
cb = f['cb'+<?php echo $i;?>];
if (cb && cb.checked)
{
if (confirm(Joomla.JText._('COM_USERS_GROUPS_CONFIRM_DELETE')))
{
Joomla.submitform(task);
}
return;
}
<?php endif;?>
<?php endforeach;?>
}
Joomla.submitform(task);
}
</script>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<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;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_USERS_SEARCH_IN_GROUPS'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC'); ?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC'); ?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC'); ?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING'); ?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING'); ?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY'); ?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
<?php echo JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder); ?>
</select>
</div>
</div>
<div class="clearfix"> </div>
<table class="table table-striped">
<thead>
<tr>
<th width="1%">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th class="left">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_GROUP_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="20%" class="center">
<?php echo JText::_('COM_USERS_HEADING_USERS_IN_GROUP'); ?>
</th>
<th width="1%">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">
<?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">
<?php if ($canEdit) : ?>
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
<?php endif; ?>
</td>
<td>
<?php echo str_repeat('<span class="gi">|&mdash;</span>', $item->level) ?>
<?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 (JDEBUG) : ?>
<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">
<?php echo $item->user_count ? $item->user_count : ''; ?>
</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" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,98 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersViewGroups extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
UsersHelper::addSubmenu('groups');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = UsersHelper::getActions();
JToolbarHelper::title(JText::_('COM_USERS_VIEW_GROUPS_TITLE'), '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('', 'groups.delete');
JToolbarHelper::divider();
}
if ($canDo->get('core.admin'))
{
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')
);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,114 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.formvalidation');
$canDo = UsersHelper::getActions();
?>
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'level.cancel' || document.formvalidator.isValid(document.id('level-form')))
{
Joomla.submitform(task, document.id('level-form'));
}
}
/*
window.addEvent('domready', function(){
document.id('user-groups').getElements('input').each(function(i){
// Event to check all child groups.
i.addEvent('check', function(e){
// Check the child groups.
document.id('user-groups').getElements('input').each(function(c){
if (this.getProperty('rel') == c.id)
{
c.setProperty('checked', true);
c.setProperty('disabled', true);
c.fireEvent('check');
}
}.bind(this));
}.bind(i));
// Event to uncheck all the parent groups.
i.addEvent('uncheck', function(e){
// Uncheck the parent groups.
document.id('user-groups').getElements('input').each(function(c){
if (c.getProperty('rel') == this.id)
{
c.setProperty('checked', false);
c.setProperty('disabled', false);
c.fireEvent('uncheck');
}
}.bind(this));
}.bind(i));
// Bind to the click event to check/uncheck child/parent groups.
i.addEvent('click', function(e){
// Check the child groups.
document.id('user-groups').getElements('input').each(function(c){
if (this.getProperty('rel') == c.id)
{
c.setProperty('checked', true);
if (this.getProperty('checked'))
{
c.setProperty('disabled', true);
} else {
c.setProperty('disabled', false);
}
c.fireEvent('check');
}
}.bind(this));
// Uncheck the parent groups.
document.id('user-groups').getElements('input').each(function(c){
if (c.getProperty('rel') == this.id)
{
c.setProperty('checked', false);
c.setProperty('disabled', false);
c.fireEvent('uncheck');
}
}.bind(this));
}.bind(i));
// Initialise the widget.
if (i.getProperty('checked'))
{
i.fireEvent('click');
}
});
});
*/
</script>
<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); ?>
</fieldset>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,85 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersViewLevel extends JViewLegacy
{
protected $form;
protected $item;
protected $state;
/**
* Display the view
*/
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')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$isNew = ($this->item->id == 0);
$canDo = UsersHelper::getActions();
JToolbarHelper::title(JText::_($isNew ? 'COM_USERS_VIEW_NEW_LEVEL_TITLE' : 'COM_USERS_VIEW_EDIT_LEVEL_TITLE'), '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');
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,172 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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::_('dropdown.init');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$canOrder = $user->authorise('core.edit.state', 'com_users');
$saveOrder = $listOrder == 'a.ordering';
$sortFields = $this->getSortFields();
$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);
}
?>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<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;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_USERS_SEARCH_TITLE_LEVELS'); ?>" />
</div>
<div class="filter-search btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_RESET'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC'); ?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC'); ?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC'); ?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING'); ?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING'); ?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY'); ?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
<?php echo JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder); ?>
</select>
</div>
</div>
<div class="clearfix"> </div>
<table class="table table-striped" id="levelList">
<thead>
<tr>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', '<i class="icon-menu-2"></i>', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?>
</th>
<th width="1%">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th class="left">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_LEVEL_NAME', 'a.title', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
<th width="40%">
&#160;
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15">
<?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');
?>
<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 ?>">
<i class="icon-menu"></i>
</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 echo JHtml::_('grid.id', $i, $item->id); ?>
</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="center">
<?php echo (int) $item->id; ?>
</td>
<td>
&#160;
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,98 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* The HTML Users access levels view.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersViewLevels extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
UsersHelper::addSubmenu('levels');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = UsersHelper::getActions();
JToolbarHelper::title(JText::_('COM_USERS_VIEW_LEVELS_TITLE'), '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('', 'level.delete');
JToolbarHelper::divider();
}
if ($canDo->get('core.admin'))
{
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')
);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,72 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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::_('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 $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'); ?></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>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
*/
class UsersViewMail extends JViewLegacy
{
/**
* @var object form object
*/
protected $form;
/**
* Display the view
*/
public function display($tpl = null)
{
// Get data from the model
$this->form = $this->get('Form');
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
JToolbarHelper::title(JText::_('COM_USERS_MASS_MAIL'), 'massmail.png');
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');
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,79 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
?>
<script language="javascript" type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'note.cancel' || document.formvalidator.isValid(document.id('note-form')))
{
Joomla.submitform(task, document.getElementById('note-form'));
}
}
</script>
<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('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>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,122 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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
*
* @package Joomla.Administrator
* @subpackage com_users
* @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'));
$canDo = UsersHelper::getActions($this->state->get('filter.category_id'), $this->item->id);
JToolbarHelper::title(JText::_('COM_USERS_NOTES'), '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
{
JToolbarHelper::cancel('note.cancel', 'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_USERS_USER_NOTES_EDIT');
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,167 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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::_('formbehavior.chosen', 'select');
JHtml::_('dropdown.init');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$canEdit = $user->authorise('core.edit', 'com_users');
$sortFields = $this->getSortFields();
?>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<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;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_USERS_SEARCH_IN_NOTE_TITLE'); ?>" />
</div>
<div class="btn-group">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC'); ?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC'); ?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC'); ?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING'); ?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING'); ?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY'); ?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
<?php echo JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder); ?>
</select>
</div>
<div class="clearfix"> </div>
</div>
<table class="table table-striped">
<thead>
<tr>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th class="left" class="nowrap">
<?php echo JHtml::_('grid.sort', 'COM_USERS_USER_HEADING', 'u.name', $listDirn, $listOrder); ?>
</th>
<th class="left" class="nowrap">
<?php echo JHtml::_('grid.sort', 'COM_USERS_SUBJECT_HEADING', 'a.subject', $listDirn, $listOrder); ?>
</th>
<th width="20%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'COM_USERS_CATEGORY_HEADING', 'c.title', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'COM_USERS_REVIEW_HEADING', 'a.review_time', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<?php $canChange = $user->authorise('core.edit.state', 'com_users'); ?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center checklist">
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td>
<td>
<?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_users&task=note.edit&id='.$item->id);?>">
<?php echo $this->escape($item->user_name); ?></a>
<?php else : ?>
<?php echo $this->escape($item->user_name); ?>
<?php endif; ?>
</td>
<td>
<?php if ($item->subject) : ?>
<?php echo $this->escape($item->subject); ?>
<?php else : ?>
<?php echo JText::_('COM_USERS_EMPTY_SUBJECT'); ?>
<?php endif; ?>
</td>
<td class="center">
<?php if ($item->catid && $item->cparams->get('image')) : ?>
<?php echo JHtml::_('users.image', $item->cparams->get('image')); ?>
<?php endif; ?>
<?php echo $this->escape($item->category_title); ?>
</td>
<td class="center">
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'notes.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
</td>
<td class="center">
<?php if (intval($item->review_time)) : ?>
<?php echo $this->escape($item->review_time); ?>
<?php else : ?>
<?php echo JText::_('COM_USERS_EMPTY_REVIEW'); ?>
<?php endif; ?>
</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" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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 : ?>
<ol 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, 'D d M Y H:i'); ?>
</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 $item->body; ?>
</div>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
</div>

View File

@ -0,0 +1,178 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('_JEXEC') or die;
/**
* User notes list view
*
* @package Joomla.Administrator
* @subpackage com_users
* @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');
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 JRegistry;
$item->cparams->loadString($item->category_params);
}
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Display the toolbar.
*
* @return void
*
* @since 2.5
*/
protected function addToolbar()
{
$canDo = UsersHelper::getActions();
JToolbarHelper::title(JText::_('COM_USERS_VIEW_NOTES_TITLE'), '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.state') == -2 && $canDo->get('core.delete'))
{
JToolbarHelper::deleteList('', 'notes.delete', 'JTOOLBAR_EMPTY_TRASH');
JToolbarHelper::divider();
}
elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::trash('notes.trash');
JToolbarHelper::divider();
}
if ($canDo->get('core.admin'))
{
JToolbarHelper::preferences('com_users');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_USERS_USER_NOTES');
JHtmlSidebar::setAction('index.php?option=com_users&view=notes');
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_PUBLISHED'),
'filter_published',
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true)
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_CATEGORY'),
'filter_category_id',
JHtml::_('select.options', JHtml::_('category.options', 'com_users.notes'), 'value', 'text', $this->state->get('filter.category_id'))
);
}
/**
* 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')
);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,93 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
$canDo = UsersHelper::getActions();
// Get the form fieldsets.
$fieldsets = $this->form->getFieldsets();
?>
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'user.cancel' || document.formvalidator.isValid(document.id('user-form')))
{
Joomla.submitform(task, document.getElementById('user-form'));
}
}
</script>
<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', true)); ?>
<?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 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', true)); ?>
<?php echo $this->loadTemplate('groups'); ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php endif; ?>
<?php
foreach ($fieldsets as $fieldset) :
if ($fieldset->name == 'user_details') :
continue;
endif;
?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', $fieldset->name, JText::_($fieldset->label, true)); ?>
<?php foreach ($this->form->getFieldset($fieldset->name) as $field) : ?>
<?php if ($field->hidden) : ?>
<div class="control-group">
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php else: ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php endforeach; ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
</fieldset>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@ -0,0 +1,15 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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); ?>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,91 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.5
*/
class UsersViewUser extends JViewLegacy
{
protected $form;
protected $item;
protected $grouplist;
protected $groups;
protected $state;
/**
* Display the view
*
* @since 1.5
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->grouplist = $this->get('Groups');
$this->groups = $this->get('AssignedGroups');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->form->setValue('password', null);
$this->form->setValue('password2', null);
parent::display($tpl);
$this->addToolbar();
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$canDo = UsersHelper::getActions();
$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')), $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');
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,211 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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::_('dropdown.init');
JHtml::_('formbehavior.chosen', 'select');
$canDo = UsersHelper::getActions();
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$loggeduser = JFactory::getUser();
$sortFields = $this->getSortFields();
?>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<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;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_USERS_SEARCH_USERS'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_RESET'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC'); ?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC'); ?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC'); ?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING'); ?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING'); ?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY'); ?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
<?php echo JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder); ?>
</select>
</div>
</div>
<div class="clearfix"> </div>
<table class="table table-striped">
<thead>
<tr>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th class="left">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_NAME', 'a.name', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_USERNAME', 'a.username', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_ENABLED', 'a.block', $listDirn, $listOrder); ?>
</th>
<th width="5%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_ACTIVATED', 'a.activation', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap center">
<?php echo JText::_('COM_USERS_HEADING_GROUPS'); ?>
</th>
<th width="15%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_EMAIL', 'a.email', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_LAST_VISIT_DATE', 'a.lastvisitDate', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_REGISTRATION_DATE', 'a.registerDate', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :
$canEdit = $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) : ?>
<?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=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>
<?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 if (JDEBUG) : ?>
<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="center">
<?php echo $this->escape($item->username); ?>
</td>
<td class="center">
<?php if ($canChange) : ?>
<?php
$self = $loggeduser->id == $item->id;
echo JHtml::_('jgrid.state', JHtmlUsers::blockStates($self), $item->block, $i, 'users.', !$self);
?>
<?php else : ?>
<?php echo JText::_($item->block ? 'JNO' : 'JYES'); ?>
<?php endif; ?>
</td>
<td class="center">
<?php
$activated = empty( $item->activation) ? 0 : 1;
echo JHtml::_('jgrid.state', JHtmlUsers::activateStates(), $activated, $i, 'users.', (boolean) $activated);
?>
</td>
<td class="center">
<?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="center">
<?php echo JStringPunycode::emailToUTF8($this->escape($item->email)); ?>
</td>
<td class="center">
<?php if ($item->lastvisitDate != '0000-00-00 00:00:00'):?>
<?php echo JHtml::_('date', $item->lastvisitDate, 'Y-m-d H:i:s'); ?>
<?php else:?>
<?php echo JText::_('JNEVER'); ?>
<?php endif;?>
</td>
<td class="center">
<?php echo JHtml::_('date', $item->registerDate, 'Y-m-d H:i:s'); ?>
</td>
<td class="center">
<?php echo (int) $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php //Load the batch processing form. ?>
<?php echo $this->loadTemplate('batch'); ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1,51 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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'))
);
JHtml::_('formbehavior.chosen', 'select');
?>
<div class="modal hide fade" id="collapseModal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">x</button>
<h3><?php echo JText::_('COM_USERS_BATCH_OPTIONS');?></h3>
</div>
<div class="modal-body">
<div id="batch-choose-action" class="combo control-group">
<label id="batch-choose-action-lbl" class="control-label" for="batch-choose-action">
<?php echo JText::_('COM_USERS_BATCH_GROUP') ?>
</label>
</div>
<div id="batch-choose-action" class="combo controls">
<div class="control-group">
<select name="batch[group_id]" class="inputbox" 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 class="modal-footer">
<button class="btn" type="button" onclick="document.id('batch-group-id').value=''" data-dismiss="modal">
<?php echo JText::_('JCANCEL'); ?>
</button>
<button class="btn btn-primary" type="submit" onclick="Joomla.submitbutton('user.batch');">
<?php echo JText::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
</div>
</div>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,90 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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');
JHtml::_('formbehavior.chosen', 'select');
$input = JFactory::getApplication()->input;
$field = $input->getCmd('field');
$function = 'jSelectUser_'.$field;
$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=users&layout=modal&tmpl=component&groups=' . $input->get('groups', '', 'BASE64') . '&excluded=' . $input->get('excluded', '', 'BASE64'));?>" method="post" name="adminForm" id="adminForm">
<fieldset class="filter">
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<label for="filter_search" class="element-invisible"><?php echo JText::_('JSEARCH_FILTER'); ?></label>
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_USERS_SEARCH_IN_NAME'); ?>" />
</div>
<div class="btn-group pull-left hidden-phone">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
<button type="button" class="btn" onclick="if (window.parent) window.parent.<?php echo $this->escape($function); ?>('', '<?php echo JText::_('JLIB_FORM_SELECT_USER'); ?>');"><?php echo JText::_('JOPTION_NO_USER'); ?></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="filter_group_id" class="element-invisible"><?php echo JText::_('COM_USERS_FILTER_USER_GROUP'); ?></label>
<?php echo JHtml::_('access.usergroup', 'filter_group_id', $this->state->get('filter.group_id'), 'onchange="this.form.submit()"'); ?>
</div>
</div>
</fieldset>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th class="left">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_NAME', 'a.name', $listDirn, $listOrder); ?>
</th>
<th class="nowrap" width="25%">
<?php echo JHtml::_('grid.sort', 'JGLOBAL_USERNAME', 'a.username', $listDirn, $listOrder); ?>
</th>
<th class="nowrap" width="25%">
<?php echo JHtml::_('grid.sort', 'COM_USERS_HEADING_GROUPS', 'group_names', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
$i = 0;
foreach ($this->items as $item) : ?>
<tr class="row<?php echo $i % 2; ?>">
<td>
<a class="pointer" onclick="if (window.parent) window.parent.<?php echo $this->escape($function);?>('<?php echo $item->id; ?>', '<?php echo $this->escape(addslashes($item->name)); ?>');">
<?php echo $item->name; ?></a>
</td>
<td align="center">
<?php echo $item->username; ?>
</td>
<td align="left">
<?php echo nl2br($item->group_names); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div>
<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="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1,160 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 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.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersViewUsers extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
UsersHelper::addSubmenu('users');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
// 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.
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = UsersHelper::getActions();
$user = JFactory::getUser();
// Get the toolbar object instance
$bar = JToolBar::getInstance('toolbar');
JToolbarHelper::title(JText::_('COM_USERS_VIEW_USERS_TITLE'), '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('', 'users.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'))
{
JHtml::_('bootstrap.modal', 'collapseModal');
$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'))
{
JToolbarHelper::preferences('com_users');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_USERS_USER_MANAGER');
JHtmlSidebar::setAction('index.php?option=com_users&view=users');
JHtmlSidebar::addFilter(
JText::_('COM_USERS_FILTER_STATE'),
'filter_state',
JHtml::_('select.options', UsersHelper::getStateOptions(), 'value', 'text', $this->state->get('filter.state'))
);
JHtmlSidebar::addFilter(
JText::_('COM_USERS_FILTER_ACTIVE'),
'filter_active',
JHtml::_('select.options', UsersHelper::getActiveOptions(), 'value', 'text', $this->state->get('filter.active'))
);
JHtmlSidebar::addFilter(
JText::_('COM_USERS_FILTER_USERGROUP'),
'filter_group_id',
JHtml::_('select.options', UsersHelper::getGroups(), 'value', 'text', $this->state->get('filter.group_id'))
);
JHtmlSidebar::addFilter(
JText::_('COM_USERS_OPTION_FILTER_DATE'),
'filter_range',
JHtml::_('select.options', Usershelper::getRangeOptions(), 'value', 'text', $this->state->get('filter.range'))
);
}
/**
* 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')
);
}
}