diff --git a/src/administrator/controller.php b/src/administrator/controller.php index 383a9e1..9b4f2ae 100755 --- a/src/administrator/controller.php +++ b/src/administrator/controller.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; diff --git a/src/administrator/controllers/action.php b/src/administrator/controllers/action.php index 0dabcb6..b923a00 100755 --- a/src/administrator/controllers/action.php +++ b/src/administrator/controllers/action.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // No direct access diff --git a/src/administrator/controllers/actions.php b/src/administrator/controllers/actions.php index 8ca55b3..1979e81 100755 --- a/src/administrator/controllers/actions.php +++ b/src/administrator/controllers/actions.php @@ -1,11 +1,13 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ + defined('_JEXEC') or die(); use Joomla\CMS\MVC\Controller\AdminController; diff --git a/src/administrator/controllers/database.php b/src/administrator/controllers/database.php index db6c9d0..5cda846 100755 --- a/src/administrator/controllers/database.php +++ b/src/administrator/controllers/database.php @@ -2,18 +2,25 @@ /** * @package Subusers * @subpackage com_subusers - * @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Router\Route; + /** * Installer Database Controller * * @since 2.5 */ -class SubusersControllerDatabase extends JControllerLegacy +class SubusersControllerDatabase extends BaseController { /** * Tries to fix missing database updates @@ -26,19 +33,19 @@ class SubusersControllerDatabase extends JControllerLegacy public function fix() { // Get a handle to the Joomla! application object - $application = JFactory::getApplication(); + $application = Factory::getApplication(); $model = $this->getModel('database'); $model->fix(); // Purge updates - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_joomlaupdate/models', 'JoomlaupdateModel'); - $updateModel = JModelLegacy::getInstance('default', 'JoomlaupdateModel'); + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_joomlaupdate/models', 'JoomlaupdateModel'); + $updateModel = BaseDatabaseModel::getInstance('default', 'JoomlaupdateModel'); $updateModel->purge(); // Refresh versionable assets cache - JFactory::getApplication()->flushAssets(); + Factory::getApplication()->flushAssets(); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizations', false)); + $this->setRedirect(Route::_('index.php?option=com_subusers&view=organizations', false)); } } diff --git a/src/administrator/controllers/mapping.php b/src/administrator/controllers/mapping.php index db6c300..14d5be7 100755 --- a/src/administrator/controllers/mapping.php +++ b/src/administrator/controllers/mapping.php @@ -1,32 +1,23 @@ - * @copyright Copyright (c) 2009-2017 TechJoomla, Tekdi Technologies Pvt. Ltd. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // No direct access defined('_JEXEC') or die; -jimport('joomla.application.component.controllerform'); +use Joomla\CMS\MVC\Controller\FormController; /** * Mapping controller class. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersControllerMapping extends JControllerForm +class SubusersControllerMapping extends FormController { - /** - * Constructor - * - * @throws Exception - */ - public function __construct() - { - $this->view_list = 'mappings'; - parent::__construct(); - } } diff --git a/src/administrator/controllers/mappings.php b/src/administrator/controllers/mappings.php index c441e65..d7a73b5 100755 --- a/src/administrator/controllers/mappings.php +++ b/src/administrator/controllers/mappings.php @@ -1,59 +1,26 @@ - * @copyright Copyright (c) 2009-2017 TechJoomla, Tekdi Technologies Pvt. Ltd. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // No direct access. defined('_JEXEC') or die; -jimport('joomla.application.component.controlleradmin'); - +use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; /** * Mappings list controller class. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersControllerMappings extends JControllerAdmin +class SubusersControllerMappings extends AdminController { - /** - * Method to clone existing Mappings - * - * @return void - */ - public function duplicate() - { - // Check for request forgeries - Jsession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Get id(s) - $pks = $this->input->post->get('cid', array(), 'array'); - - try - { - if (empty($pks)) - { - throw new Exception(JText::_('COM_SUBUSERS_NO_ELEMENT_SELECTED')); - } - - ArrayHelper::toInteger($pks); - $model = $this->getModel(); - $model->duplicate($pks); - $this->setMessage(Jtext::_('COM_SUBUSERS_ITEMS_SUCCESS_DUPLICATED')); - } - catch (Exception $e) - { - JFactory::getApplication()->enqueueMessage($e->getMessage(), 'warning'); - } - - $this->setRedirect('index.php?option=com_subusers&view=mappings'); - } - /** * Proxy for getModel. * @@ -61,47 +28,12 @@ public function duplicate() * @param string $prefix Optional. Class prefix * @param array $config Optional. Configuration array for model * - * @return object The Model + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel|boolean The Model * - * @since 1.6 + * @since 1.0.0 */ public function getModel($name = 'mapping', $prefix = 'SubusersModel', $config = array()) { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; - } - - /** - * Method to save the submitted ordering values for records via AJAX. - * - * @return void - * - * @since 3.0 - */ - public function saveOrderAjax() - { - // Get the input - $input = JFactory::getApplication()->input; - $pks = $input->post->get('cid', array(), 'array'); - $order = $input->post->get('order', array(), 'array'); - - // Sanitize the input - ArrayHelper::toInteger($pks); - ArrayHelper::toInteger($order); - - // Get the model - $model = $this->getModel(); - - // Save the ordering - $return = $model->saveorder($pks, $order); - - if ($return) - { - echo "1"; - } - - // Close the application - JFactory::getApplication()->close(); + return parent::getModel($name, $prefix, array('ignore_request' => true)); } } diff --git a/src/administrator/controllers/role.php b/src/administrator/controllers/role.php index f8f1c6a..6170e2d 100755 --- a/src/administrator/controllers/role.php +++ b/src/administrator/controllers/role.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // No direct access diff --git a/src/administrator/controllers/roles.php b/src/administrator/controllers/roles.php index cdab763..df38804 100755 --- a/src/administrator/controllers/roles.php +++ b/src/administrator/controllers/roles.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; diff --git a/src/administrator/controllers/user.php b/src/administrator/controllers/user.php index ece4a7d..58ef7f7 100755 --- a/src/administrator/controllers/user.php +++ b/src/administrator/controllers/user.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; diff --git a/src/administrator/controllers/users.php b/src/administrator/controllers/users.php index 889bfc0..8b6b620 100755 --- a/src/administrator/controllers/users.php +++ b/src/administrator/controllers/users.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; diff --git a/src/administrator/helpers/subusers.php b/src/administrator/helpers/subusers.php index ec16945..b26a68f 100755 --- a/src/administrator/helpers/subusers.php +++ b/src/administrator/helpers/subusers.php @@ -1,19 +1,20 @@ - * @copyright Copyright (C) 2005 - 2014. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ -// No direct access -defined('_JEXEC') or die; + +defined('_JEXEC') or die(); +use Joomla\CMS\Language\Text; /** * Subusers helper. * - * @since 1.6 + * @since 1.0.0 */ class SubusersHelper { @@ -26,46 +27,9 @@ class SubusersHelper */ public static function addSubmenu($vName = '') { -JHtmlSidebar::addEntry( - JText::_('COM_SUBUSERS_TITLE_ROLES'), - 'index.php?option=com_subusers&view=roles', - $vName == 'roles' - ); -JHtmlSidebar::addEntry( - JText::_('COM_SUBUSERS_TITLE_ACTIONS'), - 'index.php?option=com_subusers&view=actions', - $vName == 'actions' - ); -JHtmlSidebar::addEntry( - JText::_('COM_SUBUSERS_TITLE_USERS'), - 'index.php?option=com_subusers&view=users', - $vName == 'users' - ); - } - - /** - * Gets a list of the actions that can be performed. - * - * @return JObject - * - * @since 1.6 - */ - public static function getActions() - { - $user = JFactory::getUser(); - $result = new JObject; - - $assetName = 'com_subusers'; - - $actions = array( - 'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.own', 'core.edit.state', 'core.delete' - ); - - foreach ($actions as $action) - { - $result->set($action, $user->authorise($action, $assetName)); - } - - return $result; + JHtmlSidebar::addEntry(Text::_('COM_SUBUSERS_TITLE_ROLES'), 'index.php?option=com_subusers&view=roles', $vName == 'roles'); + JHtmlSidebar::addEntry(Text::_('COM_SUBUSERS_TITLE_ACTIONS'), 'index.php?option=com_subusers&view=actions', $vName == 'actions'); + JHtmlSidebar::addEntry(Text::_('COM_SUBUSERS_TITLE_MAPPINGS'), 'index.php?option=com_subusers&view=mappings', $vName == 'mappings'); + JHtmlSidebar::addEntry(Text::_('COM_SUBUSERS_TITLE_USERS'), 'index.php?option=com_subusers&view=users', $vName == 'users'); } } diff --git a/src/administrator/includes/rbacl.php b/src/administrator/includes/rbacl.php index be4ff87..bb55c05 100644 --- a/src/administrator/includes/rbacl.php +++ b/src/administrator/includes/rbacl.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die(); @@ -63,7 +64,7 @@ public static function table($name) **/ public static function model($name, $config = array()) { - BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_subusers/models'); + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_subusers/models', 'SubusersModel'); // @TODO Add support for cache return BaseDatabaseModel::getInstance($name, 'SubusersModel', $config); @@ -129,7 +130,9 @@ public static function check($userId, $client, $action, $contentId = null) $userModel = self::model("user"); $contentRoleId = $userModel->getAssociatedContentRole($userId, $client, $contentId); - if (in_array($contentRoleId, $allowedRoles)) + $rolesAllowed = array_intersect($contentRoleId, $allowedRoles); + + if (!empty($rolesAllowed)) { return true; } @@ -165,15 +168,15 @@ public static function authorise($userId, $client, $action, $contentId = null) /** * Get user roles by user id and client id * - * @param integer $userId userId - * @param string $client client for role - * @param integer $clientContentIid content id + * @param integer $userId userId + * @param string $client client for role + * @param integer $clientContentId content id * * @return array * * @since __DEPLOY_VERSION__ */ - public static function getRoleByUser($userId, $client = '', $clientContentIid = 0) + public static function getRoleByUser($userId, $client = '', $clientContentId = null) { $roles = array(); @@ -190,9 +193,9 @@ public static function getRoleByUser($userId, $client = '', $clientContentIid = $query->where($db->quoteName('client') . " = " . $db->quote($client)); } - if (!empty($clientContentIid)) + if (!is_null($clientContentId)) { - $query->where($db->quoteName('client_id') . " = " . $db->quote($clientContentIid)); + $query->where($db->quoteName('client_id') . " = " . $db->quote($clientContentId)); } $db->setQuery($query); diff --git a/src/administrator/libraries/action.php b/src/administrator/libraries/action.php index 855e4d1..53d40f1 100644 --- a/src/administrator/libraries/action.php +++ b/src/administrator/libraries/action.php @@ -1,16 +1,18 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die('Unauthorized Access'); use Joomla\CMS\Factory; use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Language\Text; /** * Action class. Handles all application interaction with a Action @@ -159,7 +161,7 @@ public function bind(&$array) { if (empty($array)) { - $this->setError(JText::_('COM_SUBUSER_EMPTY_DATA')); + $this->setError(Text::_('COM_SUBUSER_EMPTY_DATA')); return false; } @@ -167,7 +169,7 @@ public function bind(&$array) // Bind the array if (!$this->setProperties($array)) { - $this->setError(\JText::_('COM_SUBUSER_BINDING_ERROR')); + $this->setError(Text::_('COM_SUBUSER_BINDING_ERROR')); return false; } diff --git a/src/administrator/libraries/role.php b/src/administrator/libraries/role.php index 7d2fd8e..4a154a6 100644 --- a/src/administrator/libraries/role.php +++ b/src/administrator/libraries/role.php @@ -1,16 +1,18 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die('Unauthorized Access'); use Joomla\CMS\Factory; use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Language\Text; /** * Role class. Handles all application interaction with a Role @@ -167,7 +169,7 @@ public function bind(&$array) { if (empty($array)) { - $this->setError(JText::_('COM_CLUSTER_EMPTY_DATA')); + $this->setError(Text::_('COM_CLUSTER_EMPTY_DATA')); return false; } @@ -175,7 +177,7 @@ public function bind(&$array) // Bind the array if (!$this->setProperties($array)) { - $this->setError(\JText::_('COM_CLUSTER_BINDING_ERROR')); + $this->setError(Text::_('COM_CLUSTER_BINDING_ERROR')); return false; } diff --git a/src/administrator/models/action.php b/src/administrator/models/action.php index af56ff6..4fdbe2f 100755 --- a/src/administrator/models/action.php +++ b/src/administrator/models/action.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; @@ -111,7 +112,16 @@ public function getAssignedRoles($actionId) $query->select('DISTINCT role_id'); $query->from($db->quoteName('#__tjsu_role_action_map')); - $query->where($db->quoteName('action_id') . " = " . (int) $actionId); + + if (is_array($actionId)) + { + $query->where($db->quoteName('action_id') . 'IN (' . implode(',', $db->quote($actionId)) . ')'); + } + else + { + $query->where($db->quoteName('action_id') . " = " . (int) $actionId); + } + $db->setQuery($query); return $db->loadColumn(); diff --git a/src/administrator/models/actions.php b/src/administrator/models/actions.php index 0133ecf..89fa085 100755 --- a/src/administrator/models/actions.php +++ b/src/administrator/models/actions.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die(); @@ -33,9 +34,10 @@ public function __construct($config = array()) if (empty($config['filter_fields'])) { $config['filter_fields'] = array( - 'id', 'a.`id`', - 'name', 'a.`name`', - 'client', 'a.`client`' + 'id', 'a.id', + 'name', 'a.name', + 'client', 'a.client', + 'code', 'a.code', ); } @@ -114,8 +116,11 @@ protected function getListQuery() } else { - $search = $db->Quote('%' . $db->escape($search, true) . '%'); - $query->where('( a.`name` LIKE ' . $search . ' )'); + $search = $db->Quote('%' . $db->escape(trim($search), true) . '%'); + $query->where('( a.`name` LIKE ' . $search . + ' OR a.client LIKE ' . $search . + ' OR a.code LIKE ' . $search . + ' )'); } } diff --git a/src/administrator/models/database.php b/src/administrator/models/database.php index b890c54..850afd7 100755 --- a/src/administrator/models/database.php +++ b/src/administrator/models/database.php @@ -3,11 +3,14 @@ * @package Subusers * @subpackage com_subusers * - * @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Schema\ChangeSet; require_once JPATH_ADMINISTRATOR . '/components/com_installer/models/database.php'; @@ -29,14 +32,15 @@ public function getItems() try { - $changeSet = JSchemaChangeset::getInstance($this->getDbo(), $folder); + $changeSet = ChangeSet::getInstance($this->getDbo(), $folder); } catch (RuntimeException $e) { - JFactory::getApplication()->enqueueMessage($e->getMessage(), 'warning'); + Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning'); return false; } + return $changeSet; } } diff --git a/src/administrator/models/fields/action.php b/src/administrator/models/fields/action.php new file mode 100644 index 0000000..6792137 --- /dev/null +++ b/src/administrator/models/fields/action.php @@ -0,0 +1,63 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +defined('_JEXEC') or die(); +use Joomla\CMS\Factory; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormHelper; + +FormHelper::loadFieldClass('list'); + +/** + * Supports an HTML select list of Roles + * + * @since __DEPLOY_VERSION__ + */ +class JFormFieldAction extends JFormFieldList +{ + /** + * The form field type. + * + * @var string + * @since __DEPLOY_VERSION__ + */ + protected $type = 'action'; + + /** + * Method to get list of role options. + * + * @return array role An array of HTMLHelper options + * + * @since __DEPLOY_VERSION__ + */ + protected function getOptions() + { + $jinput = Factory::getApplication()->input; + $client = $jinput->get('client', '', 'STRING'); + + $rolesModel = RBACL::model("actions", array("ignore_request" => true)); + $rolesModel->setState('filter.client', $client); + $results = $rolesModel->getItems(); + + $options = array(); + $options[] = HTMLHelper::_('select.option', '', Text::_('COM_SUBUSERS_FORM_LBL_SELECT_ACTION')); + + if (!empty($results)) + { + foreach ($results as $result) + { + $options[] = HTMLHelper::_('select.option', $result->id, $result->name); + } + } + + return $options; + } +} diff --git a/src/administrator/models/fields/role.php b/src/administrator/models/fields/role.php index 872bbc1..eb8ec69 100644 --- a/src/administrator/models/fields/role.php +++ b/src/administrator/models/fields/role.php @@ -1,21 +1,26 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // No direct access. defined('_JEXEC') or die(); +use Joomla\CMS\Factory; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormHelper; -JFormHelper::loadFieldClass('list'); +FormHelper::loadFieldClass('list'); /** * Supports an HTML select list of Roles * - * @since 1.0.0 + * @since __DEPLOY_VERSION__ */ class JFormFieldRole extends JFormFieldList { @@ -23,39 +28,34 @@ class JFormFieldRole extends JFormFieldList * The form field type. * * @var string - * @since 1.0.0 + * @since __DEPLOY_VERSION__ */ protected $type = 'role'; /** * Method to get list of role options. * - * @return array role An array of JHtml options + * @return array role An array of HTMLHelper options * - * @since 1.0.0 + * @since __DEPLOY_VERSION__ */ protected function getOptions() { - $jinput = JFactory::getApplication()->input; - $client = $jinput->get('client'); + $jinput = Factory::getApplication()->input; + $client = $jinput->get('client', '', 'STRING'); - // Include models - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_subusers/models'); - - // Get instance of model class, where class name will be SubusersModel - $subuserModelType = JModelLegacy::getInstance('Roles', 'SubusersModel'); - $subuserModelType->setState('filter.client', $client); - - $results = $subuserModelType->getItems(); + $roleModel = RBACL::model("roles", array("ignore_request" => true)); + $roleModel->setState('filter.client', $client); + $results = $roleModel->getItems(); $options = array(); - $options[] = JHtml::_('select.option', '', JText::_('COM_SUBUSERS_FORM_LBL_SELECT_ROLE')); + $options[] = HTMLHelper::_('select.option', '', Text::_('COM_SUBUSERS_FORM_LBL_SELECT_ROLE')); if ($results) { foreach ($results as $result) { - $options[] = JHtml::_('select.option', $result->id, $result->name); + $options[] = HTMLHelper::_('select.option', $result->id, $result->name); } } diff --git a/src/administrator/models/forms/filter_mappings.xml b/src/administrator/models/forms/filter_mappings.xml new file mode 100644 index 0000000..a223100 --- /dev/null +++ b/src/administrator/models/forms/filter_mappings.xml @@ -0,0 +1,25 @@ + +
+ + + + + + + +
diff --git a/src/administrator/models/forms/filter_roles.xml b/src/administrator/models/forms/filter_roles.xml new file mode 100644 index 0000000..0d181ed --- /dev/null +++ b/src/administrator/models/forms/filter_roles.xml @@ -0,0 +1,25 @@ + +
+ + + + + + + +
diff --git a/src/administrator/models/forms/mapping.xml b/src/administrator/models/forms/mapping.xml index f6fc5f0..d9678e8 100755 --- a/src/administrator/models/forms/mapping.xml +++ b/src/administrator/models/forms/mapping.xml @@ -1,59 +1,18 @@ - +
-
- - - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + - -
- - +
+ \ No newline at end of file diff --git a/src/administrator/models/mapping.php b/src/administrator/models/mapping.php index 361dbca..11f1e1f 100755 --- a/src/administrator/models/mapping.php +++ b/src/administrator/models/mapping.php @@ -1,33 +1,30 @@ - * @copyright Copyright (c) 2009-2017 TechJoomla, Tekdi Technologies Pvt. Ltd. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // No direct access. defined('_JEXEC') or die; -jimport('joomla.application.component.modeladmin'); +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\Table\Table; /** * Subusers model. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersModelMapping extends JModelAdmin +class SubusersModelMapping extends AdminModel { /** - * @var string The prefix to use with controller messages. - * @since 1.6 - */ - protected $text_prefix = 'COM_SUBUSERS'; - - /** - * @var null Item data - * @since 1.6 + * @var mixed Item data + * @since 1.0.0 */ protected $item = null; @@ -38,13 +35,13 @@ class SubusersModelMapping extends JModelAdmin * @param string $prefix A prefix for the table class name. Optional. * @param array $config Configuration array for model. Optional. * - * @return JTable A database object + * @return Table|boolean A database object * - * @since 1.6 + * @since 1.0.0 */ public function getTable($type = 'Mapping', $prefix = 'SubusersTable', $config = array()) { - return JTable::getInstance($type, $prefix, $config); + return Table::getInstance($type, $prefix, $config); } /** @@ -53,15 +50,12 @@ public function getTable($type = 'Mapping', $prefix = 'SubusersTable', $config = * @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 + * @return \Joomla\CMS\Form\Form|boolean A JForm object on success, false on failure * - * @since 1.6 + * @since 1.0.0 */ public function getForm($data = array(), $loadData = true) { - // Initialise variables. - $app = JFactory::getApplication(); - // Get the form. $form = $this->loadForm( 'com_subusers.mapping', 'mapping', @@ -83,12 +77,12 @@ public function getForm($data = array(), $loadData = true) * * @return mixed The data for the form. * - * @since 1.6 + * @since 1.0.0 */ protected function loadFormData() { // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_subusers.edit.mapping.data', array()); + $data = Factory::getApplication()->getUserState('com_subusers.edit.mapping.data', array()); if (empty($data)) { @@ -102,111 +96,4 @@ protected function loadFormData() return $data; } - - /** - * 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) - { - if ($item = parent::getItem($pk)) - { - // Do any procesing on fields here if needed - } - - return $item; - } - - /** - * Method to duplicate an Mapping - * - * @param array &$pks An array of primary key IDs. - * - * @return boolean True if successful. - * - * @throws Exception - */ - public function duplicate(&$pks) - { - $user = JFactory::getUser(); - - // Access checks. - if (!$user->authorise('core.create', 'com_subusers')) - { - throw new Exception(JText::_('JERROR_CORE_CREATE_NOT_PERMITTED')); - } - - $dispatcher = JEventDispatcher::getInstance(); - $context = $this->option . '.' . $this->name; - - // Include the plugins for the save events. - JPluginHelper::importPlugin($this->events_map['save']); - - $table = $this->getTable(); - - foreach ($pks as $pk) - { - if ($table->load($pk, true)) - { - // Reset the id to create a new record. - $table->id = 0; - - if (!$table->check()) - { - throw new Exception($table->getError()); - } - - // Trigger the before save event. - $result = $dispatcher->trigger($this->event_before_save, array($context, &$table, true)); - - if (in_array(false, $result, true) || !$table->store()) - { - throw new Exception($table->getError()); - } - - // Trigger the after save event. - $dispatcher->trigger($this->event_after_save, array($context, &$table, true)); - } - else - { - throw new Exception($table->getError()); - } - } - - // Clean cache - $this->cleanCache(); - - return true; - } - - /** - * Prepare and sanitise the table prior to saving. - * - * @param JTable $table Table Object - * - * @return void - * - * @since 1.6 - */ - protected function prepareTable($table) - { - jimport('joomla.filter.output'); - - if (empty($table->id)) - { - // Set ordering to the last item if not set - if (@$table->ordering === '') - { - $db = JFactory::getDbo(); - $db->setQuery('SELECT MAX(ordering) FROM #__tjsu_role_action_map'); - $max = $db->loadResult(); - $table->ordering = $max + 1; - } - } - } } diff --git a/src/administrator/models/mappings.php b/src/administrator/models/mappings.php index f3849ab..fe3e55e 100755 --- a/src/administrator/models/mappings.php +++ b/src/administrator/models/mappings.php @@ -1,22 +1,25 @@ - * @copyright Copyright (c) 2009-2017 TechJoomla, Tekdi Technologies Pvt. Ltd. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ + defined('_JEXEC') or die; -jimport('joomla.application.component.modellist'); +use Joomla\CMS\Factory; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\ListModel; /** * Methods supporting a list of Subusers records. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersModelMappings extends JModelList +class SubusersModelMappings extends ListModel { /** * Constructor. @@ -24,7 +27,7 @@ class SubusersModelMappings extends JModelList * @param array $config An optional associative array of configuration settings. * * @see JController - * @since 1.6 + * @since 1.0.0 */ public function __construct($config = array()) { @@ -32,12 +35,10 @@ public function __construct($config = array()) { $config['filter_fields'] = array( 'id', 'a.`id`', - 'role_id', 'a.`role_id`', - 'action_id', 'a.`action_id`', - 'client', 'a.`client`', - 'created_by', 'a.`created_by`', - 'ordering', 'a.`ordering`', - 'state', 'a.`state`', + 'b.name', + 'c.code', + 'b.client', + 'c.name', ); } @@ -56,46 +57,18 @@ public function __construct($config = array()) * * @throws Exception */ - protected function populateState($ordering = null, $direction = null) + protected function populateState($ordering = 'a.id', $direction = 'desc') { - // Initialise variables. - $app = JFactory::getApplication('administrator'); + $app = Factory::getApplication('administrator'); // Load the filter state. $search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); - $published = $app->getUserStateFromRequest($this->context . '.filter.state', 'filter_published', '', 'string'); - $this->setState('filter.state', $published); - - // Load the parameters. - $params = JComponentHelper::getParams('com_subusers'); + $params = ComponentHelper::getParams('com_subusers'); $this->setState('params', $params); - // List state information. - parent::populateState('a.id', '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.state'); - - return parent::getStoreId($id); + parent::populateState($ordering, $direction); } /** @@ -103,7 +76,7 @@ protected function getStoreId($id = '') * * @return JDatabaseQuery * - * @since 1.6 + * @since 1.0.0 */ protected function getListQuery() { @@ -111,35 +84,11 @@ protected function getListQuery() $db = $this->getDbo(); $query = $db->getQuery(true); - // Select the required fields from the table. - $query->select( - $this->getState( - 'list.select', 'DISTINCT a.*' - ) - ); + $query->select(array('a.*', 'b.name as role_name', 'b.client as role_client', 'c.name as action_name', 'c.code as action_code')); $query->from('`#__tjsu_role_action_map` AS a'); + $query->join('INNER', $db->quoteName('#__tjsu_roles', 'b') . ' ON (' . $db->quoteName('a.role_id') . ' = ' . $db->quoteName('b.id') . ')'); + $query->join('INNER', $db->quoteName('#__tjsu_actions', 'c') . ' ON (' . $db->quoteName('a.action_id') . ' = ' . $db->quoteName('c.id') . ')'); - // Join over the users for the checked out user - $query->select("uc.name AS editor"); - $query->join("LEFT", "#__users AS uc ON uc.id=a.checked_out"); - - // Join over the user field 'created_by' - $query->select('`created_by`.name AS `created_by`'); - $query->join('LEFT', '#__users AS `created_by` ON `created_by`.id = a.`created_by`'); - - // 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 search in title $search = $this->getState('filter.search'); if (!empty($search)) @@ -151,30 +100,19 @@ protected function getListQuery() else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); + $searches = array(); + $searches[] = 'b.name LIKE ' . $search; + $searches[] = 'c.name LIKE ' . $search; + $searches[] = 'c.code LIKE ' . $search; + + $query->where('(' . implode(' OR ', $searches) . ')'); } } - // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering'); - $orderDirn = $this->state->get('list.direction'); - - if ($orderCol && $orderDirn) - { - $query->order($db->escape($orderCol . ' ' . $orderDirn)); - } + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'DESC'); + $query->order($db->escape($orderCol) . ' ' . $db->escape($orderDirn)); return $query; } - - /** - * Get an array of data items - * - * @return mixed Array of data items on success, false on failure. - */ - public function getItems() - { - $items = parent::getItems(); - - return $items; - } } diff --git a/src/administrator/models/role.php b/src/administrator/models/role.php index 90c7c12..ec053f2 100755 --- a/src/administrator/models/role.php +++ b/src/administrator/models/role.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; @@ -80,7 +81,7 @@ public function getForm($data = array(), $loadData = true) protected function loadFormData() { // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_subusers.edit.role.data', array()); + $data = Factory::getApplication()->getUserState('com_subusers.edit.role.data', array()); if (empty($data)) { @@ -106,7 +107,7 @@ protected function loadFormData() */ public function getActions($roleId) { - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true); $query->select('action'); $query->from($db->quoteName('#__tjsu_role_action_map')); diff --git a/src/administrator/models/roles.php b/src/administrator/models/roles.php index b3cb016..5c5590c 100755 --- a/src/administrator/models/roles.php +++ b/src/administrator/models/roles.php @@ -1,22 +1,25 @@ - * @copyright Copyright (C) 2005 - 2014. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ + defined('_JEXEC') or die; -jimport('joomla.application.component.modellist'); +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\Component\ComponentHelper; /** * Methods supporting a list of Subusers records. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersModelRoles extends JModelList +class SubusersModelRoles extends ListModel { /** * Constructor. @@ -24,17 +27,16 @@ class SubusersModelRoles extends JModelList * @param array $config An optional associative array of configuration settings. * * @see JController - * @since 1.6 + * @since 1.0.0 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( - 'id', 'a.`id`', - 'name', 'a.`name`', - 'created_by', 'a.`created_by`', - 'ordering', 'a.`ordering`' + 'id', 'a.id', + 'name', 'a.name', + 'client', 'a.client', ); } @@ -53,42 +55,19 @@ public function __construct($config = array()) * * @throws Exception */ - protected function populateState($ordering = null, $direction = null) + protected function populateState($ordering = 'a.id', $direction = 'desc') { - // Initialise variables. - $app = JFactory::getApplication('administrator'); + $app = Factory::getApplication('administrator'); // Load the filter state. $search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); // Load the parameters. - $params = JComponentHelper::getParams('com_subusers'); + $params = ComponentHelper::getParams('com_subusers'); $this->setState('params', $params); - // List state information. - parent::populateState('a.id', 'desc'); - } - - /** - * 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'); - - return parent::getStoreId($id); + parent::populateState($ordering, $direction); } /** @@ -96,7 +75,7 @@ protected function getStoreId($id = '') * * @return JDatabaseQuery * - * @since 1.6 + * @since 1.0.0 */ protected function getListQuery() { @@ -127,8 +106,10 @@ protected function getListQuery() } else { - $search = $db->Quote('%' . $db->escape($search, true) . '%'); - $query->where('( a.`name` LIKE ' . $search . ' )'); + $search = $db->Quote('%' . $db->escape(trim($search), true) . '%'); + $query->where('( a.`name` LIKE ' . $search . + ' OR a.client LIKE ' . $search . + ' )'); } } @@ -151,16 +132,4 @@ protected function getListQuery() return $query; } - - /** - * Get an array of data items - * - * @return mixed Array of data items on success, false on failure. - */ - public function getItems() - { - $items = parent::getItems(); - - return $items; - } } diff --git a/src/administrator/models/user.php b/src/administrator/models/user.php index 1eb049a..84100c9 100755 --- a/src/administrator/models/user.php +++ b/src/administrator/models/user.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; @@ -82,7 +83,7 @@ public function getForm($data = array(), $loadData = true) protected function loadFormData() { // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_subusers.edit.user.data', array()); + $data = Factory::getApplication()->getUserState('com_subusers.edit.user.data', array()); if (empty($data)) { @@ -108,7 +109,7 @@ protected function loadFormData() * * @since __DEPLOY_VERSION__ */ - public function getAssociatedContentRole($userId, $client, $contentId) + public function getAssociatedContentRole($userId, $client, $contentId = null) { $db = Factory::getDbo(); $query = $db->getQuery(true); @@ -117,9 +118,14 @@ public function getAssociatedContentRole($userId, $client, $contentId) $query->from($db->quoteName('#__tjsu_users')); $query->where($db->quoteName('user_id') . " = " . (int) $userId); $query->where($db->quoteName('client') . " = " . $db->q($client)); - $query->where($db->quoteName('client_id') . " = " . (int) $contentId); + + if (!is_null($contentId)) + { + $query->where($db->quoteName('client_id') . " = " . $db->quote($contentId)); + } + $db->setQuery($query); - return $db->loadResult(); + return $db->loadColumn(); } } diff --git a/src/administrator/models/users.php b/src/administrator/models/users.php index 3850eed..179431d 100755 --- a/src/administrator/models/users.php +++ b/src/administrator/models/users.php @@ -1,15 +1,18 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; +use Joomla\CMS\Factory; use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\Component\ComponentHelper; /** * Methods supporting a list of Subusers records. @@ -30,12 +33,12 @@ public function __construct($config = array()) if (empty($config['filter_fields'])) { $config['filter_fields'] = array( - 'id', 'a.`id`', - 'user_id', 'a.`user_id`', - 'role_id', 'a.`role_id`', - 'client', 'a.`client`', - 'client_id', 'a.`client_id`', - 'created_by', 'a.`created_by`', + 'id', 'a.id', + 'user_id', 'a.user_id', + 'role_id', 'a.role_id', + 'client', 'a.client', + 'client_id', 'a.client_id', + 'created_by', 'a.created_by', ); } @@ -56,14 +59,14 @@ public function __construct($config = array()) */ protected function populateState($ordering = null, $direction = null) { - $app = JFactory::getApplication('administrator'); + $app = Factory::getApplication('administrator'); $search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); $this->setState('filter.user_id', $app->getUserStateFromRequest($this->context . ' . filter.user_id', 'filter_user_id', '', 'string')); - $params = JComponentHelper::getParams('com_subusers'); + $params = ComponentHelper::getParams('com_subusers'); $this->setState('params', $params); parent::populateState('a.id', 'desc'); @@ -123,7 +126,7 @@ protected function getListQuery() } else { - $search = $db->Quote('%' . $db->escape($search, true) . '%'); + $search = $db->Quote('%' . $db->escape(trim($search), true) . '%'); $query->where('( uc.`name` LIKE ' . $search . ' OR a.`user_id` LIKE ' . $search . ' OR a.`client_id` LIKE ' . $search . ' )'); } } diff --git a/src/administrator/sql/install.mysql.utf8.sql b/src/administrator/sql/install.mysql.utf8.sql index 56e1212..3c0bae7 100755 --- a/src/administrator/sql/install.mysql.utf8.sql +++ b/src/administrator/sql/install.mysql.utf8.sql @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS `#__tjsu_roles` ( `modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `ordering` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- @@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS `#__tjsu_actions` ( `client` varchar(255) NOT NULL COMMENT 'The client name Eg. com_tjlms, com_jlike', `created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- @@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS `#__tjsu_role_action_map` ( `role_id` int(11) NOT NULL COMMENT 'FK to roles table', `action_id` int(11) NOT NULL COMMENT 'FK to actions table', PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- @@ -57,5 +57,15 @@ CREATE TABLE IF NOT EXISTS `#__tjsu_users` ( `created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified_by` int(11) NOT NULL, `modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + PRIMARY KEY (`id`), + KEY `user_id_idx` (`user_id`), + KEY `client_id_idx` (`client_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +INSERT INTO `#__tjsu_roles` (`id`, `name`, `client`, `created_by`, `created_date`, `modified_by`, `modified_date`, `ordering`) VALUES +(1, 'Organization Manager', 'com_multiagency', 0, '0000-00-00 00:00:00', 0, '0000-00-00 00:00:00', 1), +(2, 'Organization User', 'com_multiagency', 0, '0000-00-00 00:00:00', 0, '0000-00-00 00:00:00', 2); + +INSERT INTO `#__tjsu_actions` (`id`, `code`, `name`, `client`, `created_date`) VALUES +(1, 'core.agency.user.delete', 'Remove user from agency', 'com_multiagency', '0000-00-00 00:00:00'), +(2, 'core.agency.delete', 'Remove agency', 'com_multiagency', '0000-00-00 00:00:00'); diff --git a/src/administrator/sql/updates/mysql/1.0.sql b/src/administrator/sql/updates/mysql/1.0.sql deleted file mode 100755 index 8b13789..0000000 --- a/src/administrator/sql/updates/mysql/1.0.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/administrator/sql/updates/mysql/1.1.0.sql b/src/administrator/sql/updates/mysql/1.1.0.sql new file mode 100755 index 0000000..735f87d --- /dev/null +++ b/src/administrator/sql/updates/mysql/1.1.0.sql @@ -0,0 +1,13 @@ + +ALTER TABLE `#__tjsu_roles` ENGINE = InnoDB; +ALTER TABLE `#__tjsu_actions` ENGINE = InnoDB; +ALTER TABLE `#__tjsu_role_action_map` ENGINE = InnoDB; +ALTER TABLE `#__tjsu_users` ENGINE = InnoDB; + +ALTER TABLE `#__tjsu_roles` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +ALTER TABLE `#__tjsu_actions` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +ALTER TABLE `#__tjsu_role_action_map` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +ALTER TABLE `#__tjsu_users` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +ALTER TABLE #__tjsu_users ADD INDEX user_id_idx (user_id); +ALTER TABLE #__tjsu_users ADD INDEX client_id_idx (client_id); diff --git a/src/administrator/subusers.php b/src/administrator/subusers.php index a09811a..3caaf7f 100755 --- a/src/administrator/subusers.php +++ b/src/administrator/subusers.php @@ -1,21 +1,23 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Language\Text; // Access check. if (!Factory::getUser()->authorise('core.manage', 'com_subusers')) { - throw new \Exception(JText::_('JERROR_ALERTNOAUTHOR')); + throw new \Exception(Text::_('JERROR_ALERTNOAUTHOR')); } \JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); diff --git a/src/administrator/tables/action.php b/src/administrator/tables/action.php index 01c9b52..03857c6 100755 --- a/src/administrator/tables/action.php +++ b/src/administrator/tables/action.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; diff --git a/src/administrator/tables/mapping.php b/src/administrator/tables/mapping.php index 6a4d74b..4c65ce9 100755 --- a/src/administrator/tables/mapping.php +++ b/src/administrator/tables/mapping.php @@ -1,22 +1,29 @@ - * @copyright Copyright (C) 2005 - 2014. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ + // No direct access defined('_JEXEC') or die; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Factory; +use Joomla\CMS\Access\Access; +use Joomla\CMS\Language\Text; +use Joomla\Registry\Registry; + /** * mapping Table class * * @since 1.6 */ -class SubusersTablemapping extends JTable +class SubusersTablemapping extends Table { /** * Constructor @@ -43,38 +50,38 @@ public function bind($array, $ignore = '') { if ($array['id'] == 0) { - $array['created_by'] = JFactory::getUser()->id; + $array['created_by'] = Factory::getUser()->id; } - $input = JFactory::getApplication()->input; + $input = Factory::getApplication()->input; $task = $input->getString('task', ''); - if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_subusers') && $array['state'] == 1)) + if (($task == 'save' || $task == 'apply') && (!Factory::getUser()->authorise('core.edit.state', 'com_subusers') && $array['state'] == 1)) { $array['state'] = 0; } if (isset($array['params']) && is_array($array['params'])) { - $registry = new JRegistry; + $registry = new Registry; $registry->loadArray($array['params']); $array['params'] = (string) $registry; } if (isset($array['metadata']) && is_array($array['metadata'])) { - $registry = new JRegistry; + $registry = new Registry; $registry->loadArray($array['metadata']); $array['metadata'] = (string) $registry; } - if (!JFactory::getUser()->authorise('core.admin', 'com_subusers.mapping.' . $array['id'])) + if (!Factory::getUser()->authorise('core.admin', 'com_subusers.mapping.' . $array['id'])) { - $actions = JAccess::getActionsFromFile( + $actions = Access::getActionsFromFile( JPATH_ADMINISTRATOR . '/components/com_subusers/access.xml', "/access/section[@name='mapping']/" ); - $default_actions = JAccess::getAssetRules('com_subusers.mapping.' . $array['id'])->getData(); + $default_actions = Access::getAssetRules('com_subusers.mapping.' . $array['id'])->getData(); $array_jaccess = array(); foreach ($actions as $action) @@ -172,7 +179,9 @@ public function publish($pks = null, $state = 1, $userId = 0) // Nothing to set publishing state on, return false. else { - throw new Exception(500, JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); + $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); + + return false; } } @@ -214,6 +223,8 @@ public function publish($pks = null, $state = 1, $userId = 0) $this->state = $state; } + $this->setError(''); + return true; } @@ -241,10 +252,10 @@ protected function _getAssetName() * * @return mixed The id on success, false on failure. */ - protected function _getAssetParentId(JTable $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { // We will retrieve the parent-asset from the Asset-table - $assetParent = JTable::getInstance('Asset'); + $assetParent = Table::getInstance('Asset'); // Default: if no asset-parent can be found we take the global asset $assetParentId = $assetParent->getRootId(); diff --git a/src/administrator/tables/role.php b/src/administrator/tables/role.php index 2d51399..d71063d 100755 --- a/src/administrator/tables/role.php +++ b/src/administrator/tables/role.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; diff --git a/src/administrator/tables/user.php b/src/administrator/tables/user.php index 26aee90..5a16eb7 100755 --- a/src/administrator/tables/user.php +++ b/src/administrator/tables/user.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; diff --git a/src/administrator/views/action/tmpl/edit.php b/src/administrator/views/action/tmpl/edit.php index a043df5..3d7cf25 100755 --- a/src/administrator/views/action/tmpl/edit.php +++ b/src/administrator/views/action/tmpl/edit.php @@ -25,7 +25,6 @@ { if (task == "action.cancel" || document.formvalidator.isValid(document.getElementById("action-form"))) { - jQuery("#permissions-sliders select").attr("disabled", "disabled"); Joomla.submitform(task, document.getElementById("action-form")); } }; diff --git a/src/administrator/views/action/view.html.php b/src/administrator/views/action/view.html.php index 1aad14c..9f54f9f 100755 --- a/src/administrator/views/action/view.html.php +++ b/src/administrator/views/action/view.html.php @@ -1,16 +1,20 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Helper\ContentHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * View to edit @@ -19,11 +23,33 @@ */ class SubusersViewAction extends HtmlView { - protected $state; + /** + * The JForm object + * + * @var JForm + */ + protected $form; + /** + * The active item + * + * @var object + */ protected $item; - protected $form; + /** + * The model state + * + * @var object + */ + protected $state; + + /** + * The actions the user is authorised to perform + * + * @var JObject + */ + protected $canDo; /** * Display the view @@ -40,13 +66,15 @@ public function display($tpl = null) $this->item = $this->get('Item'); $this->form = $this->get('Form'); - // Check for errors. + $this->canDo = ContentHelper::getActions('com_subusers', 'action', $this->item->id); + if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors)); + throw new Exception(implode("\n", $errors), 500); } $this->addToolbar(); + parent::display($tpl); } @@ -59,49 +87,51 @@ public function display($tpl = null) */ protected function addToolbar() { - Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getUser(); + $isNew = ($this->item->id == 0); - $user = Factory::getUser(); - $isNew = ($this->item->id == 0); + $canDo = $this->canDo; + $layout = Factory::getApplication()->input->get("layout"); - if (isset($this->item->checked_out)) - { - $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->id); - } - else - { - $checkedOut = false; - } - - $canDo = SubusersHelper::getActions(); - - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_ACTION'), 'action.png'); - - // If not checked out, can save the item. - if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) - { - JToolBarHelper::apply('action.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('action.save', 'JTOOLBAR_SAVE'); - } + $this->sidebar = JHtmlSidebar::render(); + ToolBarHelper::title(Text::_('COM_SUBUSERS_TITLE_ACTION'), 'action.png'); - if (!$checkedOut && ($canDo->get('core.create'))) + // For new records, check the create permission. + if ($layout != "default") { - JToolBarHelper::custom('action.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + Factory::getApplication()->input->set('hidemainmenu', true); + + if ($isNew) + { + ToolbarHelper::save('action.save'); + ToolbarHelper::save2new('action.save2new'); + ToolbarHelper::cancel('action.cancel'); + } + else + { + if ($this->isEditable($canDo, $user->id)) + { + ToolbarHelper::save('action.save'); + } + + ToolbarHelper::cancel('action.cancel', 'JTOOLBAR_CLOSE'); + } } - // If an existing item, can save to a copy. - if (!$isNew && $canDo->get('core.create')) - { - JToolBarHelper::custom('action.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } + ToolbarHelper::divider(); + } - if (empty($this->item->id)) - { - JToolBarHelper::cancel('action.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - JToolBarHelper::cancel('action.cancel', 'JTOOLBAR_CLOSE'); - } + /** + * Is editable + * + * @param Object $canDo Checked Out + * + * @param integer $userId User ID + * + * @return boolean + */ + protected function isEditable($canDo, $userId) + { + return $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId); } } diff --git a/src/administrator/views/actions/tmpl/default.php b/src/administrator/views/actions/tmpl/default.php index 5c9369b..ff74756 100755 --- a/src/administrator/views/actions/tmpl/default.php +++ b/src/administrator/views/actions/tmpl/default.php @@ -26,8 +26,8 @@
- - sidebar)) + sidebar)) { ?>
@@ -42,10 +42,10 @@
$this)); - ?> - items)) { ?> @@ -57,48 +57,50 @@ else { ?> - - - - - - - - - - - - - - - - - - items as $i => $item) - { - $canEdit = $this->canDo->get('core.edit'); - $canEditOwn = $this->canDo->get('core.edit.own'); - ?> - +
- - - - - - - - - -
- pagination->getListFooter(); ?> -
+ + + + + + + + + + + + + + + + + items as $i => $item) + { + $canEdit = $this->canDo->get('core.edit'); + $canEditOwn = $this->canDo->get('core.edit.own'); + ?> + - - -
+ + + + + + + + + +
+ pagination->getListFooter(); ?> +
id); ?>
- escape($item->name); ?> + } + else + { + ?> escape($item->name); ?> escape($item->client); ?>
id; ?>
- - - - + + + + + + +
diff --git a/src/administrator/views/actions/view.html.php b/src/administrator/views/actions/view.html.php index 107c757..bd69e5f 100755 --- a/src/administrator/views/actions/view.html.php +++ b/src/administrator/views/actions/view.html.php @@ -1,16 +1,20 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Helper\ContentHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * View class for a list of Subusers. @@ -93,7 +97,7 @@ public function display($tpl = null) $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); $this->user = Factory::getUser(); - $this->canDo = JHelperContent::getActions('com_subusers'); + $this->canDo = ContentHelper::getActions('com_subusers'); if (count($errors = $this->get('Errors'))) { @@ -117,30 +121,30 @@ public function display($tpl = null) */ protected function addToolbar() { - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_ACTIONS'), ''); + ToolBarHelper::title(Text::_('COM_SUBUSERS_TITLE_ACTIONS'), ''); $canDo = $this->canDo; if ($canDo->get('core.create')) { - JToolbarHelper::addNew('action.add'); + ToolbarHelper::addNew('action.add'); } if ($canDo->get('core.edit')) { - JToolbarHelper::editList('actions.edit'); + ToolbarHelper::editList('actions.edit'); } if ($canDo->get('core.delete')) { - JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'actions.delete', 'JTOOLBAR_DELETE'); - JToolbarHelper::divider(); + ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'actions.delete', 'JTOOLBAR_DELETE'); + ToolbarHelper::divider(); } if ($canDo->get('core.admin') || $canDo->get('core.options')) { - JToolbarHelper::preferences('com_subusers'); - JToolbarHelper::divider(); + ToolbarHelper::preferences('com_subusers'); + ToolbarHelper::divider(); } } } diff --git a/src/administrator/views/mapping/tmpl/edit.php b/src/administrator/views/mapping/tmpl/edit.php index 390a334..d56c41f 100755 --- a/src/administrator/views/mapping/tmpl/edit.php +++ b/src/administrator/views/mapping/tmpl/edit.php @@ -1,94 +1,48 @@ - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ -// No direct access -defined('_JEXEC') or die; - -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); -JHtml::_('behavior.tooltip'); -JHtml::_('behavior.formvalidation'); -JHtml::_('formbehavior.chosen', 'select'); -JHtml::_('behavior.keepalive'); - -// Import CSS -$document = JFactory::getDocument(); -$document->addStyleSheet(JPATH_ROOT . 'media/com_subusers/css/edit.css'); -?> - - + }; +'); +?>
- + action="item->id); ?>" + method="post" enctype="multipart/form-data" name="adminForm" + id="mapping-form" class="form-validate">
- 'general')); ?> - -
-
-
- - -
-
form->getLabel('role_id'); ?>
-
form->getInput('role_id'); ?>
-
-
-
form->getLabel('action_id'); ?>
-
form->getInput('action_id'); ?>
-
- - - item->created_by)){ ?> - - - - - - - - - - - -
+
+ form->renderField('id'); ?> + form->renderField('role_id');?> + form->renderField('action_id');?>
- - - - - - - - - + +
diff --git a/src/administrator/views/mapping/view.html.php b/src/administrator/views/mapping/view.html.php index 8557b72..65e15d4 100755 --- a/src/administrator/views/mapping/view.html.php +++ b/src/administrator/views/mapping/view.html.php @@ -1,29 +1,55 @@ - * @copyright Copyright (C) 2005 - 2014. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ -// No direct access + defined('_JEXEC') or die; -jimport('joomla.application.component.view'); +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Helper\ContentHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * View to edit * - * @since 1.6 + * @since 1.0.0 */ -class SubusersViewMapping extends JViewLegacy +class SubusersViewMapping extends HtmlView { - protected $state; + /** + * The JForm object + * + * @var \Joomla\CMS\Form\Form + */ + protected $form; + /** + * The active item + * + * @var object + */ protected $item; - protected $form; + /** + * The model state + * + * @var object + */ + protected $state; + + /** + * The actions the user is authorised to perform + * + * @var JObject + */ + protected $canDo; /** * Display the view @@ -40,13 +66,15 @@ public function display($tpl = null) $this->item = $this->get('Item'); $this->form = $this->get('Form'); - // Check for errors. + $this->canDo = ContentHelper::getActions('com_subusers', 'mapping', $this->item->id); + if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors)); + throw new Exception(implode("\n", $errors), 500); } $this->addToolbar(); + parent::display($tpl); } @@ -59,49 +87,51 @@ public function display($tpl = null) */ protected function addToolbar() { - JFactory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getUser(); + $isNew = ($this->item->id == 0); - $user = JFactory::getUser(); - $isNew = ($this->item->id == 0); + $canDo = $this->canDo; + $layout = Factory::getApplication()->input->get("layout"); - if (isset($this->item->checked_out)) - { - $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); - } - else - { - $checkedOut = false; - } - - $canDo = SubusersHelper::getActions(); - - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_MAPPING'), 'mapping.png'); + $this->sidebar = JHtmlSidebar::render(); + ToolBarHelper::title(Text::_('COM_SUBUSERS_TITLE_MAPPING'), 'mapping.png'); - // If not checked out, can save the item. - if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) + // For new records, check the create permission. + if ($layout != "default") { - JToolBarHelper::apply('mapping.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('mapping.save', 'JTOOLBAR_SAVE'); + Factory::getApplication()->input->set('hidemainmenu', true); + + if ($isNew) + { + ToolbarHelper::save('mapping.save'); + ToolbarHelper::save2new('mapping.save2new'); + ToolbarHelper::cancel('mapping.cancel'); + } + else + { + if ($this->isEditable($canDo, $user->id)) + { + ToolbarHelper::save('mapping.save'); + } + + ToolbarHelper::cancel('mapping.cancel', 'JTOOLBAR_CLOSE'); + } } - if (!$checkedOut && ($canDo->get('core.create'))) - { - JToolBarHelper::custom('mapping.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); - } - - // If an existing item, can save to a copy. - if (!$isNew && $canDo->get('core.create')) - { - JToolBarHelper::custom('mapping.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } + ToolbarHelper::divider(); + } - if (empty($this->item->id)) - { - JToolBarHelper::cancel('mapping.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - JToolBarHelper::cancel('mapping.cancel', 'JTOOLBAR_CLOSE'); - } + /** + * Is editable + * + * @param Object $canDo Checked Out + * + * @param integer $userId User ID + * + * @return boolean + */ + protected function isEditable($canDo, $userId) + { + return $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId); } } diff --git a/src/administrator/views/mappings/tmpl/default.php b/src/administrator/views/mappings/tmpl/default.php index 24dd0d6..f7e2903 100755 --- a/src/administrator/views/mappings/tmpl/default.php +++ b/src/administrator/views/mappings/tmpl/default.php @@ -1,238 +1,136 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('behavior.multiselect'); -JHtml::_('formbehavior.chosen', 'select'); +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; -// Import CSS -$document = JFactory::getDocument(); -$document->addStyleSheet(JPATH_ROOT . 'media/com_subusers/css/list.css'); +HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers/html'); +HTMLHelper::_('bootstrap.tooltip'); +HTMLHelper::_('behavior.multiselect'); +HTMLHelper::_('formbehavior.chosen', 'select'); -$user = JFactory::getUser(); -$userId = $user->get('id'); -$listOrder = $this->state->get('list.ordering'); -$listDirn = $this->state->get('list.direction'); -$canOrder = $user->authorise('core.edit.state', 'com_subusers'); -$saveOrder = $listOrder == 'a.`ordering`'; - -if ($saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_subusers&task=mappings.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'mappingList', 'adminForm', strtolower($listDirn), $saveOrderingUrl); -} - -$sortFields = $this->getSortFields(); +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); ?> - - -extra_sidebar)) -{ - $this->sidebar .= $this->extra_sidebar; -} - -?> +
+
+
- - sidebar)): ?> -
- sidebar; ?> -
-
- -
- - -
- -
- - + sidebar)) + { + ?> +
+ sidebar; ?>
-
- - pagination->getLimitBox(); ?> +
+ +
+ $this)); + ?> + items)) + { + ?> +
+
-
- - -
-
- - -
-
-
- - - - items[0]->ordering)): ?> - - - - items[0]->state)): ?> - - - - - - - - items[0]->id)): ?> - - - - - - - - - - - items as $i => $item) : - $ordering = ($listOrder == 'a.ordering'); - $canCreate = $user->authorise('core.create', 'com_subusers'); - $canEdit = $user->authorise('core.edit', 'com_subusers'); - $canCheckin = $user->authorise('core.manage', 'com_subusers'); - $canChange = $user->authorise('core.edit.state', 'com_subusers'); + +
- ', 'a.`ordering`', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> - - - - - - - - - - -
- pagination->getListFooter(); ?> -
+ + + + + + + + + + + + + + + + items as $i => $item) + { + $canEdit = $this->canDo->get('core.edit'); + $canEditOwn = $this->canDo->get('core.edit.own'); + ?> + + + + + + + + +
+ + + + + + + +
+ pagination->getListFooter(); ?> +
+ id); ?> + +
+ + + escape($item->role_name); ?> + + + escape($item->role_name); ?> + + +
+
escape($item->action_name); ?>id; ?>
+ - - - items[0]->ordering)) : ?> - - - - - - - - - - - - - - - id); ?> - - items[0]->state)): ?> - - state, $i, 'mappings.', $canChange, 'cb'); ?> - - - - - role_id; ?> - - - - action_id; ?> - - - - items[0]->id)): ?> - - id; ?> - - - - - - - - - - - - -
- + + + +
+ +
+
diff --git a/src/administrator/views/mappings/view.html.php b/src/administrator/views/mappings/view.html.php index 37c23dc..774623d 100755 --- a/src/administrator/views/mappings/view.html.php +++ b/src/administrator/views/mappings/view.html.php @@ -1,30 +1,85 @@ - * @copyright Copyright (C) 2005 - 2014. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // No direct access defined('_JEXEC') or die; -jimport('joomla.application.component.view'); +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Helper\ContentHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * View class for a list of Subusers. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersViewMappings extends JViewLegacy +class SubusersViewMappings extends HtmlView { + /** + * An array of items + * + * @var array + */ protected $items; + /** + * The pagination object + * + * @var JPagination + */ protected $pagination; + /** + * The model state + * + * @var object + */ protected $state; + /** + * Form object for search filters + * + * @var JForm + */ + public $filterForm; + + /** + * Logged in User + * + * @var JObject + */ + public $user; + + /** + * The active search filters + * + * @var array + */ + public $activeFilters; + + /** + * The sidebar markup + * + * @var string + */ + protected $sidebar; + + /** + * An ACL object to verify user rights. + * + * @var Joomla\CMS\Object\CMSObject + * @since 1.0.0 + */ + protected $canDo; + /** * Display the view * @@ -39,6 +94,10 @@ public function display($tpl = null) $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); + $this->filterForm = $this->get('FilterForm'); + $this->activeFilters = $this->get('ActiveFilters'); + $this->user = Factory::getUser(); + $this->canDo = ContentHelper::getActions('com_subusers'); // Check for errors. if (count($errors = $this->get('Errors'))) @@ -49,8 +108,8 @@ public function display($tpl = null) SubusersHelper::addSubmenu('mappings'); $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); + parent::display($tpl); } @@ -59,108 +118,32 @@ public function display($tpl = null) * * @return void * - * @since 1.6 + * @since 1.0.0 */ protected function addToolbar() { - require_once JPATH_COMPONENT . '/helpers/subusers.php'; - - $state = $this->get('State'); - $canDo = SubusersHelper::getActions($state->get('filter.category_id')); + ToolBarHelper::title(Text::_('COM_SUBUSERS_TITLE_MAPPINGS'), ''); - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_MAPPINGS'), 'mappings.png'); - - // Check if the form exists before showing the add/edit buttons - $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/mapping'; - - if (file_exists($formPath)) + if ($this->canDo->get('core.create')) { - if ($canDo->get('core.create')) - { - JToolBarHelper::addNew('mapping.add', 'JTOOLBAR_NEW'); - JToolbarHelper::custom('mappings.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); - } - - if ($canDo->get('core.edit') && isset($this->items[0])) - { - JToolBarHelper::editList('mapping.edit', 'JTOOLBAR_EDIT'); - } + ToolbarHelper::addNew('mapping.add'); } - if ($canDo->get('core.edit.state')) + if ($this->canDo->get('core.edit')) { - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::custom('mappings.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); - JToolBarHelper::custom('mappings.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); - } - elseif (isset($this->items[0])) - { - // If this component does not use state then show a direct delete button as we can not trash - JToolBarHelper::deleteList('', 'mappings.delete', 'JTOOLBAR_DELETE'); - } - - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::archiveList('mappings.archive', 'JTOOLBAR_ARCHIVE'); - } - - if (isset($this->items[0]->checked_out)) - { - JToolBarHelper::custom('mappings.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); - } + ToolbarHelper::editList('mapping.edit'); } - // Show trash and delete for components that uses the state field - if (isset($this->items[0]->state)) + if ($this->canDo->get('core.delete')) { - if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) - { - JToolBarHelper::deleteList('', 'mappings.delete', 'JTOOLBAR_EMPTY_TRASH'); - JToolBarHelper::divider(); - } - elseif ($canDo->get('core.edit.state')) - { - JToolBarHelper::trash('mappings.trash', 'JTOOLBAR_TRASH'); - JToolBarHelper::divider(); - } + ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'mappings.delete', 'JTOOLBAR_DELETE'); + ToolbarHelper::divider(); } - if ($canDo->get('core.admin')) + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { - JToolBarHelper::preferences('com_subusers'); + ToolbarHelper::preferences('com_subusers'); + ToolbarHelper::divider(); } - - // Set sidebar action - New in 3.0 - JHtmlSidebar::setAction('index.php?option=com_subusers&view=mappings'); - - $this->extra_sidebar = ''; - JHtmlSidebar::addFilter( - - JText::_('JOPTION_SELECT_PUBLISHED'), - - 'filter_published', - - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true) - - ); - } - - /** - * Method to order fields - * - * @return void - */ - protected function getSortFields() - { - return array( - 'a.`id`' => JText::_('JGRID_HEADING_ID'), - 'a.`role_id`' => JText::_('COM_SUBUSERS_MAPPINGS_ROLE_ID'), - 'a.`action_id`' => JText::_('COM_SUBUSERS_MAPPINGS_ACTION_ID'), - 'a.`ordering`' => JText::_('JGRID_HEADING_ORDERING'), - 'a.`state`' => JText::_('JSTATUS'), - ); } } diff --git a/src/administrator/views/role/view.html.php b/src/administrator/views/role/view.html.php index 7cc65ef..0fe8c66 100755 --- a/src/administrator/views/role/view.html.php +++ b/src/administrator/views/role/view.html.php @@ -1,29 +1,55 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Helper\ContentHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * View to edit * - * @since 1.6 + * @since 1.0.0 */ class SubusersViewRole extends HtmlView { - protected $state; + /** + * The JForm object + * + * @var \Joomla\CMS\Form\Form + */ + protected $form; + /** + * The active item + * + * @var object + */ protected $item; - protected $form; + /** + * The model state + * + * @var object + */ + protected $state; + + /** + * The actions the user is authorised to perform + * + * @var JObject + */ + protected $canDo; /** * Display the view @@ -40,13 +66,15 @@ public function display($tpl = null) $this->item = $this->get('Item'); $this->form = $this->get('Form'); - // Check for errors. + $this->canDo = ContentHelper::getActions('com_subusers', 'role', $this->item->id); + if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors)); + throw new Exception(implode("\n", $errors), 500); } $this->addToolbar(); + parent::display($tpl); } @@ -59,49 +87,51 @@ public function display($tpl = null) */ protected function addToolbar() { - Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getUser(); + $isNew = ($this->item->id == 0); - $user = Factory::getUser(); - $isNew = ($this->item->id == 0); + $canDo = $this->canDo; + $layout = Factory::getApplication()->input->get("layout"); - if (isset($this->item->checked_out)) - { - $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->id); - } - else - { - $checkedOut = false; - } - - $canDo = SubusersHelper::getActions(); - - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_ROLE'), 'role.png'); - - // If not checked out, can save the item. - if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) - { - JToolBarHelper::apply('role.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('role.save', 'JTOOLBAR_SAVE'); - } + $this->sidebar = JHtmlSidebar::render(); + ToolBarHelper::title(Text::_('COM_SUBUSERS_TITLE_ROLE'), 'role.png'); - if (!$checkedOut && ($canDo->get('core.create'))) + // For new records, check the create permission. + if ($layout != "default") { - JToolBarHelper::custom('role.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + Factory::getApplication()->input->set('hidemainmenu', true); + + if ($isNew) + { + ToolbarHelper::save('role.save'); + ToolbarHelper::save2new('role.save2new'); + ToolbarHelper::cancel('role.cancel'); + } + else + { + if ($this->isEditable($canDo, $user->id)) + { + ToolbarHelper::save('role.save'); + } + + ToolbarHelper::cancel('role.cancel', 'JTOOLBAR_CLOSE'); + } } - // If an existing item, can save to a copy. - if (!$isNew && $canDo->get('core.create')) - { - JToolBarHelper::custom('role.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } + ToolbarHelper::divider(); + } - if (empty($this->item->id)) - { - JToolBarHelper::cancel('role.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - JToolBarHelper::cancel('role.cancel', 'JTOOLBAR_CLOSE'); - } + /** + * Is editable + * + * @param Object $canDo Checked Out + * + * @param integer $userId User ID + * + * @return boolean + */ + protected function isEditable($canDo, $userId) + { + return $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId); } } diff --git a/src/administrator/views/roles/tmpl/default.php b/src/administrator/views/roles/tmpl/default.php index d6c5680..942a7aa 100755 --- a/src/administrator/views/roles/tmpl/default.php +++ b/src/administrator/views/roles/tmpl/default.php @@ -1,231 +1,136 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); -JHtml::_('bootstrap.tooltip'); -JHtml::_('behavior.multiselect'); -JHtml::_('formbehavior.chosen', 'select'); +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; -// Import CSS -$document = JFactory::getDocument(); -$document->addStyleSheet(JPATH_ROOT . 'media/com_subusers/css/list.css'); +HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers/html'); +HTMLHelper::_('bootstrap.tooltip'); +HTMLHelper::_('behavior.multiselect'); +HTMLHelper::_('formbehavior.chosen', 'select'); -$user = JFactory::getUser(); -$userId = $user->get('id'); -$listOrder = $this->state->get('list.ordering'); -$listDirn = $this->state->get('list.direction'); -$canOrder = $user->authorise('core.edit.state', 'com_subusers'); -$saveOrder = $listOrder == 'a.`ordering`'; - -if ($saveOrder) -{ - $saveOrderingUrl = 'index.php?option=com_subusers&task=roles.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'roleList', 'adminForm', strtolower($listDirn), $saveOrderingUrl); -} - -$sortFields = $this->getSortFields(); -?> - - -extra_sidebar)) -{ - $this->sidebar .= $this->extra_sidebar; -} +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); ?> - -
- sidebar)): ?> -
- sidebar; ?> -
-
- -
- - -
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - +
+
+ + + sidebar)) + { + ?> +
+ sidebar; ?>
-
- - +
+ +
+ $this)); + ?> + items)) + { + ?> +
+
-
-
- - - - items[0]->ordering)): ?> - - - - - - - - items[0]->id)): ?> - - - - - - - - - - - items as $i => $item) : - $ordering = ($listOrder == 'a.ordering'); - $canCreate = $user->authorise('core.create', 'com_subusers'); - $canEdit = $user->authorise('core.edit', 'com_subusers'); - $canCheckin = $user->authorise('core.manage', 'com_subusers'); - $canChange = $user->authorise('core.edit.state', 'com_subusers'); + +
- ', 'a.`ordering`', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> - - - - - - -
- pagination->getListFooter(); ?> -
+ + + + + + + + + + + + + + + + items as $i => $item) + { + $canEdit = $this->canDo->get('core.edit'); + $canEditOwn = $this->canDo->get('core.edit.own'); + ?> + + + + + + + + +
+ + + + + + + +
+ pagination->getListFooter(); ?> +
+ id); ?> + +
+ + + escape($item->name); ?> + + + escape($item->name); ?> + + +
+
escape($item->client); ?>id; ?>
+ - - - items[0]->ordering)) : ?> - - - - - - - - - - - - - - - id); ?> - - items[0]->state)): ?> - - - - checked_out) && $item->checked_out && ($canEdit || $canChange)) : ?> - editor, $item->checked_out_time, 'roles.', $canCheckin); ?> - - - - escape($item->name); ?> - - escape($item->name); ?> - - - - - items[0]->id)): ?> - - id; ?> - - - - - - - - - - - - -
- + + + +
+ +
+
diff --git a/src/administrator/views/roles/view.html.php b/src/administrator/views/roles/view.html.php index 9767b1d..9594cd0 100755 --- a/src/administrator/views/roles/view.html.php +++ b/src/administrator/views/roles/view.html.php @@ -1,30 +1,85 @@ - * @copyright Copyright (C) 2005 - 2014. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @package Subusers + * @subpackage com_subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // No direct access defined('_JEXEC') or die; -jimport('joomla.application.component.view'); +use Joomla\CMS\Factory; +use Joomla\CMS\Helper\ContentHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * View class for a list of Subusers. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersViewRoles extends JViewLegacy +class SubusersViewRoles extends HtmlView { + /** + * An array of items + * + * @var array + */ protected $items; + /** + * The pagination object + * + * @var JPagination + */ protected $pagination; + /** + * The model state + * + * @var object + */ protected $state; + /** + * Form object for search filters + * + * @var JForm + */ + public $filterForm; + + /** + * Logged in User + * + * @var JObject + */ + public $user; + + /** + * The active search filters + * + * @var array + */ + public $activeFilters; + + /** + * The sidebar markup + * + * @var string + */ + protected $sidebar; + + /** + * An ACL object to verify user rights. + * + * @var Joomla\CMS\Object\CMSObject + * @since 1.0.0 + */ + protected $canDo; + /** * Display the view * @@ -39,6 +94,10 @@ public function display($tpl = null) $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); + $this->filterForm = $this->get('FilterForm'); + $this->activeFilters = $this->get('ActiveFilters'); + $this->user = Factory::getUser(); + $this->canDo = ContentHelper::getActions('com_subusers'); // Check for errors. if (count($errors = $this->get('Errors'))) @@ -49,8 +108,8 @@ public function display($tpl = null) SubusersHelper::addSubmenu('roles'); $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); + parent::display($tpl); } @@ -59,111 +118,32 @@ public function display($tpl = null) * * @return void * - * @since 1.6 + * @since 1.0.0 */ protected function addToolbar() { - require_once JPATH_COMPONENT . '/helpers/subusers.php'; - - $state = $this->get('State'); - $canDo = SubusersHelper::getActions($state->get('filter.category_id')); - - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_ROLES'), 'roles.png'); - - // Check if the form exists before showing the add/edit buttons - $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/role'; - - if (file_exists($formPath)) - { - if ($canDo->get('core.create')) - { - JToolBarHelper::addNew('role.add', 'JTOOLBAR_NEW'); - JToolbarHelper::custom('roles.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); - } - - if ($canDo->get('core.edit') && isset($this->items[0])) - { - JToolBarHelper::editList('role.edit', 'JTOOLBAR_EDIT'); - } - } + ToolBarHelper::title(Text::_('COM_SUBUSERS_TITLE_ROLES'), ''); - if ($canDo->get('core.edit.state')) + if ($this->canDo->get('core.create')) { - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::custom('roles.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); - JToolBarHelper::custom('roles.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); - } - elseif (isset($this->items[0])) - { - // If this component does not use state then show a direct delete button as we can not trash - JToolBarHelper::deleteList('', 'roles.delete', 'JTOOLBAR_DELETE'); - } - - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::archiveList('roles.archive', 'JTOOLBAR_ARCHIVE'); - } - - if (isset($this->items[0]->checked_out)) - { - JToolBarHelper::custom('roles.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); - } + ToolbarHelper::addNew('role.add'); } - // Show trash and delete for components that uses the state field - if (isset($this->items[0]->state)) + if ($this->canDo->get('core.edit')) { - if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) - { - JToolBarHelper::deleteList('', 'roles.delete', 'JTOOLBAR_EMPTY_TRASH'); - JToolBarHelper::divider(); - } - elseif ($canDo->get('core.edit.state')) - { - JToolBarHelper::trash('roles.trash', 'JTOOLBAR_TRASH'); - JToolBarHelper::divider(); - } + ToolbarHelper::editList('role.edit'); } - if ($canDo->get('core.delete')) + if ($this->canDo->get('core.delete')) { - JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'roles.delete', 'JTOOLBAR_DELETE'); - JToolbarHelper::divider(); + ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'roles.delete', 'JTOOLBAR_DELETE'); + ToolbarHelper::divider(); } - if ($canDo->get('core.admin')) + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { - JToolBarHelper::preferences('com_subusers'); + ToolbarHelper::preferences('com_subusers'); + ToolbarHelper::divider(); } - - // Set sidebar action - New in 3.0 - JHtmlSidebar::setAction('index.php?option=com_subusers&view=roles'); - - $this->extra_sidebar = ''; - JHtmlSidebar::addFilter( - - JText::_('JOPTION_SELECT_PUBLISHED'), - - 'filter_published', - - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true) - - ); - } - - /** - * Method to order fields - * - * @return void - */ - protected function getSortFields() - { - return array( - 'a.`id`' => JText::_('JGRID_HEADING_ID'), - 'a.`name`' => JText::_('COM_SUBUSERS_ROLES_NAME') - ); } } diff --git a/src/administrator/views/user/view.html.php b/src/administrator/views/user/view.html.php index 5cf56ba..d295171 100755 --- a/src/administrator/views/user/view.html.php +++ b/src/administrator/views/user/view.html.php @@ -1,29 +1,55 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Helper\ContentHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * View to edit * - * @since 1.6 + * @since 1.0.0 */ class SubusersViewUser extends HtmlView { - protected $state; + /** + * The JForm object + * + * @var \Joomla\CMS\Form\Form + */ + protected $form; + /** + * The active item + * + * @var object + */ protected $item; - protected $form; + /** + * The model state + * + * @var object + */ + protected $state; + + /** + * The actions the user is authorised to perform + * + * @var JObject + */ + protected $canDo; /** * Display the view @@ -40,13 +66,15 @@ public function display($tpl = null) $this->item = $this->get('Item'); $this->form = $this->get('Form'); - // Check for errors. + $this->canDo = ContentHelper::getActions('com_subusers', 'user', $this->item->id); + if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors)); + throw new Exception(implode("\n", $errors), 500); } $this->addToolbar(); + parent::display($tpl); } @@ -59,49 +87,51 @@ public function display($tpl = null) */ protected function addToolbar() { - Factory::getApplication()->input->set('hidemainmenu', true); + $user = Factory::getUser(); + $isNew = ($this->item->id == 0); - $user = Factory::getUser(); - $isNew = ($this->item->id == 0); + $canDo = $this->canDo; + $layout = Factory::getApplication()->input->get("layout"); - if (isset($this->item->checked_out)) - { - $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->id); - } - else - { - $checkedOut = false; - } - - $canDo = SubusersHelper::getActions(); - - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_USER'), 'user.png'); - - // If not checked out, can save the item. - if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) - { - JToolBarHelper::apply('user.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('user.save', 'JTOOLBAR_SAVE'); - } + $this->sidebar = JHtmlSidebar::render(); + ToolBarHelper::title(Text::_('COM_SUBUSERS_TITLE_USER'), 'user.png'); - if (!$checkedOut && ($canDo->get('core.create'))) + // For new records, check the create permission. + if ($layout != "default") { - JToolBarHelper::custom('user.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + Factory::getApplication()->input->set('hidemainmenu', true); + + if ($isNew) + { + ToolbarHelper::save('user.save'); + ToolbarHelper::save2new('user.save2new'); + ToolbarHelper::cancel('user.cancel'); + } + else + { + if ($this->isEditable($canDo, $user->id)) + { + ToolbarHelper::save('user.save'); + } + + ToolbarHelper::cancel('user.cancel', 'JTOOLBAR_CLOSE'); + } } - // If an existing item, can save to a copy. - if (!$isNew && $canDo->get('core.create')) - { - JToolBarHelper::custom('user.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } + ToolbarHelper::divider(); + } - if (empty($this->item->id)) - { - JToolBarHelper::cancel('user.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - JToolBarHelper::cancel('user.cancel', 'JTOOLBAR_CLOSE'); - } + /** + * Is editable + * + * @param Object $canDo Checked Out + * + * @param integer $userId User ID + * + * @return boolean + */ + protected function isEditable($canDo, $userId) + { + return $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId); } } diff --git a/src/administrator/views/users/tmpl/default.php b/src/administrator/views/users/tmpl/default.php index bb567f4..e95fbe8 100755 --- a/src/administrator/views/users/tmpl/default.php +++ b/src/administrator/views/users/tmpl/default.php @@ -27,7 +27,7 @@
- sidebar)) + sidebar)) { ?>
@@ -71,7 +71,7 @@ - + diff --git a/src/administrator/views/users/view.html.php b/src/administrator/views/users/view.html.php index b30707e..c9510bd 100755 --- a/src/administrator/views/users/view.html.php +++ b/src/administrator/views/users/view.html.php @@ -1,16 +1,20 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2022 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die(); use Joomla\CMS\Factory; use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Helper\ContentHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * View class for a list of Subusers. @@ -93,7 +97,7 @@ public function display($tpl = null) $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); $this->user = Factory::getUser(); - $this->canDo = JHelperContent::getActions('com_subusers'); + $this->canDo = ContentHelper::getActions('com_subusers'); if (count($errors = $this->get('Errors'))) { @@ -117,30 +121,30 @@ public function display($tpl = null) */ protected function addToolbar() { - JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_USERS'), 'users.png'); + ToolBarHelper::title(Text::_('COM_SUBUSERS_TITLE_USERS'), 'users.png'); $canDo = $this->canDo; if ($canDo->get('core.create')) { - JToolbarHelper::addNew('user.add'); + ToolbarHelper::addNew('user.add'); } if ($canDo->get('core.edit')) { - JToolbarHelper::editList('users.edit'); + ToolbarHelper::editList('users.edit'); } if ($canDo->get('core.delete')) { - JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'users.delete', 'JTOOLBAR_DELETE'); - JToolbarHelper::divider(); + ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'users.delete', 'JTOOLBAR_DELETE'); + ToolbarHelper::divider(); } if ($canDo->get('core.admin') || $canDo->get('core.options')) { - JToolbarHelper::preferences('com_subusers'); - JToolbarHelper::divider(); + ToolbarHelper::preferences('com_subusers'); + ToolbarHelper::divider(); } } } diff --git a/src/languages/administrator/en-GB/en-GB.com_subusers.ini b/src/languages/administrator/en-GB/en-GB.com_subusers.ini index 9a08e13..68b88dc 100755 --- a/src/languages/administrator/en-GB/en-GB.com_subusers.ini +++ b/src/languages/administrator/en-GB/en-GB.com_subusers.ini @@ -202,3 +202,6 @@ COM_SUBUSERS_FORM_DESC_ACTION_CODE="Choose unique code name" ;Component option COM_SUBUSERS_TOOLBAR_DATABASE_FIX="Fix Database" +COM_SUBUSERS_ROLES_FILTER_SEARCH_DESC="Search by Name, Client" +COM_SUBUSERS_ACTION_FILTER_SEARCH_DESC="Search by Name, Code, Client" +COM_SUBUSERS_USERS_FILTER_SEARCH_DESC="Search by User Name, Role" diff --git a/src/script.php b/src/script.php index a6371d5..a1cc040 100755 --- a/src/script.php +++ b/src/script.php @@ -1,10 +1,11 @@ - * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ defined('_JEXEC') or die; @@ -61,7 +62,6 @@ public function install($parent) $this->installModules($parent); } - /** * Installs plugins for this component * @@ -114,7 +114,7 @@ private function installPlugins($parent) array( 'type LIKE ' . $db->quote('plugin'), 'element LIKE ' . $db->quote($pluginName), - 'folder LIKE ' . $db->quote($pluginGroup) + 'folder LIKE ' . $db->quote($pluginGroup), ) ); $db->setQuery($query); @@ -250,7 +250,7 @@ private function uninstallPlugins($parent) array( 'type LIKE ' . $db->quote('plugin'), 'element LIKE ' . $db->quote($pluginName), - 'folder LIKE ' . $db->quote($pluginGroup) + 'folder LIKE ' . $db->quote($pluginGroup), ) ); $db->setQuery($query); @@ -304,7 +304,7 @@ private function uninstallModules($parent) ->where( array( 'type LIKE ' . $db->quote('module'), - 'element LIKE ' . $db->quote($moduleName) + 'element LIKE ' . $db->quote($moduleName), ) ); $db->setQuery($query);