diff --git a/src/administrator/config.xml b/src/administrator/config.xml index 323a0f3..83227ef 100755 --- a/src/administrator/config.xml +++ b/src/administrator/config.xml @@ -2,47 +2,6 @@
- - - - - - - - - - - - - - - -
- diff --git a/src/administrator/controller.php b/src/administrator/controller.php index ef0e676..383a9e1 100755 --- a/src/administrator/controller.php +++ b/src/administrator/controller.php @@ -1,21 +1,25 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Controller\BaseController; + +\JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + /** * Class SubusersController * - * @since 1.6 + * @since 1.0.0 */ -class SubusersController extends JControllerLegacy +class SubusersController extends BaseController { /** * Method to display a view. @@ -25,14 +29,14 @@ class SubusersController extends JControllerLegacy * * @return JController This object to support chaining. * - * @since 1.5 + * @since 1.0.0 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/subusers.php'; - $view = JFactory::getApplication()->input->getCmd('view', 'organizations'); - JFactory::getApplication()->input->set('view', $view); + $view = Factory::getApplication()->input->getCmd('view', 'roles'); + Factory::getApplication()->input->set('view', $view); parent::display($cachable, $urlparams); diff --git a/src/administrator/controllers/action.php b/src/administrator/controllers/action.php index 39e7716..0dabcb6 100755 --- a/src/administrator/controllers/action.php +++ b/src/administrator/controllers/action.php @@ -1,32 +1,22 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; -jimport('joomla.application.component.controllerform'); +use Joomla\CMS\MVC\Controller\FormController; /** * Action controller class. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersControllerAction extends JControllerForm +class SubusersControllerAction extends FormController { - /** - * Constructor - * - * @throws Exception - */ - public function __construct() - { - $this->view_list = 'actions'; - parent::__construct(); - } } diff --git a/src/administrator/controllers/actions.php b/src/administrator/controllers/actions.php index c1990af..8ca55b3 100755 --- a/src/administrator/controllers/actions.php +++ b/src/administrator/controllers/actions.php @@ -1,59 +1,22 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ +defined('_JEXEC') or die(); -// No direct access. -defined('_JEXEC') or die; - -jimport('joomla.application.component.controlleradmin'); - -use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\MVC\Controller\AdminController; /** * Actions list controller class. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersControllerActions extends JControllerAdmin +class SubusersControllerActions extends AdminController { - /** - * Method to clone existing Actions - * - * @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=actions'); - } - /** * Proxy for getModel. * @@ -61,47 +24,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 Model object on success; otherwise false on failure. * - * @since 1.6 + * @since 1.0.0 */ public function getModel($name = 'action', $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/database.php b/src/administrator/controllers/database.php index 8e763b7..db6c9d0 100755 --- a/src/administrator/controllers/database.php +++ b/src/administrator/controllers/database.php @@ -2,7 +2,6 @@ /** * @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 */ diff --git a/src/administrator/controllers/mapping.php b/src/administrator/controllers/mapping.php index 83c08c6..db6c300 100755 --- a/src/administrator/controllers/mapping.php +++ b/src/administrator/controllers/mapping.php @@ -3,7 +3,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @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 */ diff --git a/src/administrator/controllers/mappings.php b/src/administrator/controllers/mappings.php index e473d24..c441e65 100755 --- a/src/administrator/controllers/mappings.php +++ b/src/administrator/controllers/mappings.php @@ -3,7 +3,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @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 */ diff --git a/src/administrator/controllers/organization.php b/src/administrator/controllers/organization.php deleted file mode 100755 index 1955d7c..0000000 --- a/src/administrator/controllers/organization.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.controllerform'); - -/** - * Organization controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganization extends JControllerForm -{ - /** - * Constructor - * - * @throws Exception - */ - public function __construct() - { - $this->view_list = 'organizations'; - parent::__construct(); - } -} diff --git a/src/administrator/controllers/organizations.php b/src/administrator/controllers/organizations.php deleted file mode 100755 index 13a4eef..0000000 --- a/src/administrator/controllers/organizations.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -jimport('joomla.application.component.controlleradmin'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Organizations list controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganizations extends JControllerAdmin -{ - /** - * Method to clone existing Organizations - * - * @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=organizations'); - } - - /** - * Proxy for getModel. - * - * @param string $name Optional. Model name - * @param string $prefix Optional. Class prefix - * @param array $config Optional. Configuration array for model - * - * @return object The Model - * - * @since 1.6 - */ - public function getModel($name = 'organization', $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(); - } -} diff --git a/src/administrator/controllers/role.php b/src/administrator/controllers/role.php index c70876b..f8f1c6a 100755 --- a/src/administrator/controllers/role.php +++ b/src/administrator/controllers/role.php @@ -1,32 +1,22 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; -jimport('joomla.application.component.controllerform'); +use Joomla\CMS\MVC\Controller\FormController; /** * Role controller class. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersControllerRole extends JControllerForm +class SubusersControllerRole extends FormController { - /** - * Constructor - * - * @throws Exception - */ - public function __construct() - { - $this->view_list = 'roles'; - parent::__construct(); - } } diff --git a/src/administrator/controllers/roles.php b/src/administrator/controllers/roles.php index 2b8535a..cdab763 100755 --- a/src/administrator/controllers/roles.php +++ b/src/administrator/controllers/roles.php @@ -1,59 +1,25 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access. defined('_JEXEC') or die; jimport('joomla.application.component.controlleradmin'); -use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\MVC\Controller\AdminController; /** * Roles list controller class. * * @since 1.6 */ -class SubusersControllerRoles extends JControllerAdmin +class SubusersControllerRoles extends AdminController { - /** - * Method to clone existing Roles - * - * @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=roles'); - } - /** * Proxy for getModel. * @@ -67,41 +33,6 @@ public function duplicate() */ public function getModel($name = 'role', $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/user.php b/src/administrator/controllers/user.php index 151ddeb..ece4a7d 100755 --- a/src/administrator/controllers/user.php +++ b/src/administrator/controllers/user.php @@ -1,32 +1,21 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access defined('_JEXEC') or die; -jimport('joomla.application.component.controllerform'); +use Joomla\CMS\MVC\Controller\FormController; /** * User controller class. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersControllerUser extends JControllerForm +class SubusersControllerUser extends FormController { - /** - * Constructor - * - * @throws Exception - */ - public function __construct() - { - $this->view_list = 'users'; - parent::__construct(); - } } diff --git a/src/administrator/controllers/users.php b/src/administrator/controllers/users.php index 3a362f1..889bfc0 100755 --- a/src/administrator/controllers/users.php +++ b/src/administrator/controllers/users.php @@ -1,59 +1,23 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access. defined('_JEXEC') or die; -jimport('joomla.application.component.controlleradmin'); - -use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\MVC\Controller\AdminController; /** * Users list controller class. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersControllerUsers extends JControllerAdmin +class SubusersControllerUsers extends AdminController { - /** - * Method to clone existing Users - * - * @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=users'); - } - /** * Proxy for getModel. * @@ -63,45 +27,10 @@ public function duplicate() * * @return object The Model * - * @since 1.6 + * @since 1.0.0 */ public function getModel($name = 'user', $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/helpers/subusers.php b/src/administrator/helpers/subusers.php index 4df1436..ec16945 100755 --- a/src/administrator/helpers/subusers.php +++ b/src/administrator/helpers/subusers.php @@ -4,7 +4,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @copyright Copyright (C) 2005 - 2014. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access @@ -26,36 +26,21 @@ class SubusersHelper */ public static function addSubmenu($vName = '') { - JHtmlSidebar::addEntry( - JText::_('COM_SUBUSERS_TITLE_ORGANIZATIONS'), - 'index.php?option=com_subusers&view=organizations', - $vName == 'organizations' - ); - -JHtmlSidebar::addEntry( - JText::_('COM_SUBUSERS_TITLE_USERS'), - 'index.php?option=com_subusers&view=users', - $vName == 'users' - ); - 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_MAPPINGS'), - 'index.php?option=com_subusers&view=mappings', - $vName == 'mappings' + JText::_('COM_SUBUSERS_TITLE_USERS'), + 'index.php?option=com_subusers&view=users', + $vName == 'users' ); - } /** diff --git a/src/administrator/views/organization/index.html b/src/administrator/includes/index.html old mode 100755 new mode 100644 similarity index 100% rename from src/administrator/views/organization/index.html rename to src/administrator/includes/index.html diff --git a/src/administrator/includes/rbacl.php b/src/administrator/includes/rbacl.php new file mode 100644 index 0000000..7039cae --- /dev/null +++ b/src/administrator/includes/rbacl.php @@ -0,0 +1,202 @@ + + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die(); + +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Factory; + +JLoader::discover("Subusers", JPATH_ADMINISTRATOR . '/components/com_subusers/libraries'); + +/** + * Subusers factory class. + * + * This class perform the helpful operation for subuser + * + * @since __DEPLOY_VERSION__ + */ +class RBACL +{ + /** + * Array of loaded user roles + * + * @var array + * @since __DEPLOY_VERSION__ + */ + protected static $roles = array(); + + /** + * Retrieves a table from the table folder + * + * @param string $name The table file name + * + * @return \Joomla\CMS\Table\Table object + * + * @since __DEPLOY_VERSION__ + **/ + public static function table($name) + { + // @TODO Improve file loading with specific table file. + + Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_subusers/tables'); + + // @TODO Add support for cache + return Table::getInstance($name, 'SubusersTable'); + } + + /** + * Retrieves a model from the model folder + * + * @param string $name The model name to instantiate + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel object + * + * @since __DEPLOY_VERSION__ + **/ + public static function model($name, $config = array()) + { + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_subusers/models'); + + // @TODO Add support for cache + return BaseDatabaseModel::getInstance($name, 'SubusersModel', $config); + } + + /** + * Method to check if a user is authorised to perform an action, optionally on an content. + * + * @param integer $userId Id of the user for which to check authorisation. + * @param string $client The name of the client to authorise. com_content + * @param string $action The name of the action to authorise. Eg. core.edit + * @param integer $contentId The content key. null check with role and allowed actions. + * + * @return boolean True if allowed, false for an explicit deny, null for an implicit deny. + * + * @since __DEPLOY_VERSION__ + */ + public static function check($userId, $client, $action, $contentId = null) + { + $action = strtolower(preg_replace('#[\s\-]+#', '.', trim($action))); + + $user = Factory::getUser($userId); + + if ($user->id) + { + /* + * Step 1. Check the action is exist + */ + $actionObj = SubusersAction::loadActionByCode($action, $client); + + if ($actionObj->id) + { + /* + * Step 2. check allowed roles for the action + * It is may be more than one + */ + $authorizedRoles = $actionObj->getAuthorizedRoles(); + + /* + * Step 3. Load user assigned roles + * It is may be more than one + */ + if (!isset(self::$roles[$client][$user->id])) + { + self::$roles[$client][$userId] = self::getRoleByUser($user->id, $client); + } + + /* + * Step 4. Is user have right authority to perform this action + */ + $allowedRoles = array_intersect($authorizedRoles, self::$roles[$client][$userId]); + + if (!empty($allowedRoles)) + { + /* + * Step 5. If the content id is provided and check for the associated role to it + */ + if (empty($contentId)) + { + return true; + } + + $userModel = self::model("user"); + $contentRoleId = $userModel->getAssociatedContentRole($userId, $client, $contentId); + + if (in_array($contentRoleId, $allowedRoles)) + { + return true; + } + } + } + } + + return false; + } + + /** + * This method will check the core Joomla authorisatoion and RBACL authorisation + * + * @param integer $userId Id of the user for which to check authorisation. + * @param string $client The name of the client to authorise. com_content + * @param string $action The name of the action to authorise. Eg. core.edit + * @param integer $contentId The content key. null check with role and allowed actions. + * + * @return boolean True if authorised + * + * @since __DEPLOY_VERSION__ + */ + public static function authorise($userId, $client, $action, $contentId = null) + { + $user = Factory::getUser($userId); + $result = $user->authorise($action, $client); + + return $result && self::check($userId, $client, $action); + } + + /** + * Get user roles by user id and client id + * + * @param integer $userId userId + * @param string $client client for role + * @param integer $clientContentIid content id + * + * @return array + * + * @since __DEPLOY_VERSION__ + */ + public static function getRoleByUser($userId, $client = '', $clientContentIid = 0) + { + $roles = array(); + + if ($userId) + { + $db = Factory::getDbo(); + $query = $db->getQuery(true); + $query->select('DISTINCT role_id'); + $query->from($db->quoteName('#__tjsu_users')); + $query->where($db->quoteName('user_id') . " = " . $db->quote($userId)); + + if (!empty($client)) + { + $query->where($db->quoteName('client') . " = " . $db->quote($client)); + } + + if (!empty($clientContentIid)) + { + $query->where($db->quoteName('client_id') . " = " . $db->quote($clientContentIid)); + } + + $db->setQuery($query); + $roles = $db->loadColumn(); + } + + return $roles; + } +} diff --git a/src/administrator/libraries/action.php b/src/administrator/libraries/action.php new file mode 100644 index 0000000..e81200c --- /dev/null +++ b/src/administrator/libraries/action.php @@ -0,0 +1,212 @@ + + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die('Unauthorized Access'); + +use Joomla\CMS\Factory; +use Joomla\CMS\Object\CMSObject; + +/** + * Action class. Handles all application interaction with a Action + * + * @since __DEPLOY_VERSION__ + */ +class SubusersAction extends CMSObject +{ + public $id = 0; + + public $name = ""; + + public $code = ""; + + public $client = ""; + + public $created_date = 0; + + protected static $actionObj = array(); + + /** + * Constructor activating the default information of the Action + * + * @param int $id The unique event key to load. + * + * @since __DEPLOY_VERSION__ + */ + public function __construct($id = 0) + { + if (!empty($id)) + { + $this->load($id); + } + + $db = Factory::getDbo(); + } + + /** + * Returns the global Action object + * + * @param integer $id The primary key of the Action to load (optional). + * + * @return SubusersAction The Action object. + * + * @since __DEPLOY_VERSION__ + */ + public static function getInstance($id = 0) + { + if (!$id) + { + return new SubusersAction; + } + + if (empty(self::$actionObj[$id])) + { + $action = new SubusersAction($id); + self::$actionObj[$id] = $action; + } + + return self::$actionObj[$id]; + } + + /** + * Method to load a action object by action id + * + * @param int $id The Action id + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + */ + public function load($id) + { + $table = RBACL::table("action"); + + if (!$table->load($id)) + { + return false; + } + + $this->setProperties($table->getProperties()); + + return true; + } + + /** + * Method to save the action object to the database + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + * @throws \RuntimeException + */ + public function save() + { + // Create the widget table object + $table = RBACL::table("action"); + $table->bind($this->getProperties()); + + $user = Factory::getUser(); + + // Allow an exception to be thrown. + try + { + // Check and store the object. + if (!$table->check()) + { + $this->setError($table->getError()); + + return false; + } + + // Check if new record + $isNew = empty($this->id); + + // Store the user data in the database + if (!($table->store())) + { + $this->setError($table->getError()); + + return false; + } + } + catch (\Exception $e) + { + $this->setError($e->getMessage()); + + return false; + } + + $this->id = $table->id; + + return true; + } + + /** + * Method to bind an associative array of data to a Action object + * + * @param array &$array The associative array to bind to the object + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + */ + public function bind(&$array) + { + if (empty($array)) + { + $this->setError(JText::_('COM_SUBUSER_EMPTY_DATA')); + + return false; + } + + // Bind the array + if (!$this->setProperties($array)) + { + $this->setError(\JText::_('COM_SUBUSER_BINDING_ERROR')); + + return false; + } + + // Make sure its an integer + $this->id = (int) $this->id; + + return true; + } + + /** + * Method to create instance of action based on the code and client + * + * @param string $code The unique code of the action + * @param string $client action client + * + * @return SubusersAction The Action object. + * + * @since __DEPLOY_VERSION__ + */ + public static function loadActionByCode(String $code, String $client) + { + $table = RBACL::table("action"); + $table->load(array("code" => $code, "client" => $client)); + + return self::getInstance($table->id); + } + + /** + * This method will return the array of authorized roles that are allowed to perform current action + * + * @return array The roles array. + * + * @since __DEPLOY_VERSION__ + */ + public function getAuthorizedRoles() + { + $model = RBACL::model("action"); + + return $model->getAssignedRoles($this->id); + } +} diff --git a/src/administrator/views/organization/tmpl/index.html b/src/administrator/libraries/index.html old mode 100755 new mode 100644 similarity index 100% rename from src/administrator/views/organization/tmpl/index.html rename to src/administrator/libraries/index.html diff --git a/src/administrator/libraries/role.php b/src/administrator/libraries/role.php new file mode 100644 index 0000000..7d2fd8e --- /dev/null +++ b/src/administrator/libraries/role.php @@ -0,0 +1,188 @@ + + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die('Unauthorized Access'); + +use Joomla\CMS\Factory; +use Joomla\CMS\Object\CMSObject; + +/** + * Role class. Handles all application interaction with a Role + * + * @since __DEPLOY_VERSION__ + */ +class SubusersRole extends CMSObject +{ + public $id = 0; + + public $name = ""; + + public $client = ""; + + public $created_date = ""; + + public $modified_date = ""; + + public $created_by = 0; + + public $modified_by = 0; + + public $ordering = ""; + + protected static $roleObj = array(); + + /** + * Constructor activating the default information of the Role + * + * @param int $id The unique event key to load. + * + * @since __DEPLOY_VERSION__ + */ + public function __construct($id = 0) + { + if (!empty($id)) + { + $this->load($id); + } + + $db = Factory::getDbo(); + + $this->modified_date = $this->created_date = $db->getNullDate(); + } + + /** + * Returns the global Role object + * + * @param integer $id The primary key of the Role to load (optional). + * + * @return SubusersRole The Role object. + * + * @since __DEPLOY_VERSION__ + */ + public static function getInstance($id = 0) + { + if (!$id) + { + return new SubusersRole; + } + + if (empty(self::$roleObj[$id])) + { + $role = new SubusersRole($id); + self::$roleObj[$id] = $role; + } + + return self::$roleObj[$id]; + } + + /** + * Method to load a Role object by Role id + * + * @param int $id The Role id + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + */ + public function load($id) + { + $table = RBACL::table("role"); + + if (!$table->load($id)) + { + return false; + } + + $this->setProperties($table->getProperties()); + + return true; + } + + /** + * Method to save the Role object to the database + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + * @throws \RuntimeException + */ + public function save() + { + // Create the widget table object + $table = RBACL::table("role"); + $table->bind($this->getProperties()); + + $user = Factory::getUser(); + + // Allow an exception to be thrown. + try + { + // Check and store the object. + if (!$table->check()) + { + $this->setError($table->getError()); + + return false; + } + + // Check if new record + $isNew = empty($this->id); + + // Store the user data in the database + if (!($table->store())) + { + $this->setError($table->getError()); + + return false; + } + } + catch (\Exception $e) + { + $this->setError($e->getMessage()); + + return false; + } + + $this->id = $table->id; + + return true; + } + + /** + * Method to bind an associative array of data to a Role object + * + * @param array &$array The associative array to bind to the object + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + */ + public function bind(&$array) + { + if (empty($array)) + { + $this->setError(JText::_('COM_CLUSTER_EMPTY_DATA')); + + return false; + } + + // Bind the array + if (!$this->setProperties($array)) + { + $this->setError(\JText::_('COM_CLUSTER_BINDING_ERROR')); + + return false; + } + + // Make sure its an integer + $this->id = (int) $this->id; + + return true; + } +} diff --git a/src/administrator/models/action.php b/src/administrator/models/action.php index 94d6fd6..af56ff6 100755 --- a/src/administrator/models/action.php +++ b/src/administrator/models/action.php @@ -1,33 +1,28 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access. defined('_JEXEC') or die; -jimport('joomla.application.component.modeladmin'); +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Factory; /** * Subusers model. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersModelAction extends JModelAdmin +class SubusersModelAction 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 + * @since 1.0.0 */ protected $item = null; @@ -40,11 +35,11 @@ class SubusersModelAction extends JModelAdmin * * @return JTable A database object * - * @since 1.6 + * @since 1.0.0 */ public function getTable($type = 'Action', $prefix = 'SubusersTable', $config = array()) { - return JTable::getInstance($type, $prefix, $config); + return Table::getInstance($type, $prefix, $config); } /** @@ -55,13 +50,10 @@ public function getTable($type = 'Action', $prefix = 'SubusersTable', $config = * * @return JForm 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.action', 'action', @@ -83,12 +75,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.action.data', array()); + $data = Factory::getApplication()->getUserState('com_subusers.edit.action.data', array()); if (empty($data)) { @@ -104,110 +96,62 @@ protected function loadFormData() } /** - * Method to get a single record. + * Method to load the all role id that are allowed to perform given action * - * @param integer $pk The id of the primary key. + * @param integer $actionId The action id * - * @return mixed Object on success, false on failure. + * @return array The array Of role ids * - * @since 1.6 + * @since __DEPLOY_VERSION__ */ - public function getItem($pk = null) + public function getAssignedRoles($actionId) { - if ($item = parent::getItem($pk)) - { - // Do any procesing on fields here if needed - } + $db = Factory::getDbo(); + $query = $db->getQuery(true); + + $query->select('DISTINCT role_id'); + $query->from($db->quoteName('#__tjsu_role_action_map')); + $query->where($db->quoteName('action_id') . " = " . (int) $actionId); + $db->setQuery($query); - return $item; + return $db->loadColumn(); } /** - * Method to duplicate an Action + * Method to get a single record. * - * @param array &$pks An array of primary key IDs. + * @param array $data The id of the actionId. * - * @return boolean True if successful. + * @return boolean true on success, false on failure. * - * @throws Exception + * @since 1.0.0 */ - public function duplicate(&$pks) + public function save($data) { - $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; + $pk = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('action.id'); - // Include the plugins for the save events. - JPluginHelper::importPlugin($this->events_map['save']); + $action = SubusersAction::getInstance($pk); - $table = $this->getTable(); - - foreach ($pks as $pk) + // Bind the data. + if (!$action->bind($data)) { - if ($table->load($pk, true)) - { - // Reset the id to create a new record. - $table->id = 0; + $this->setError($action->getError()); - if (!$table->check()) - { - throw new Exception($table->getError()); - } - + return false; + } - // Trigger the before save event. - $result = $dispatcher->trigger($this->event_before_save, array($context, &$table, true)); + $result = $action->save(); - if (in_array(false, $result, true) || !$table->store()) - { - throw new Exception($table->getError()); - } + // Store the data. + if (!$result) + { + $this->setError($action->getError()); - // Trigger the after save event. - $dispatcher->trigger($this->event_after_save, array($context, &$table, true)); - } - else - { - throw new Exception($table->getError()); - } + return false; } - // Clean cache - $this->cleanCache(); + $this->setState('action.id', $action->id); 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_actions'); - $max = $db->loadResult(); - $table->ordering = $max + 1; - } - } - } } diff --git a/src/administrator/models/actions.php b/src/administrator/models/actions.php index 3c66f68..0133ecf 100755 --- a/src/administrator/models/actions.php +++ b/src/administrator/models/actions.php @@ -1,31 +1,33 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -defined('_JEXEC') or die; -jimport('joomla.application.component.modellist'); +defined('_JEXEC') or die(); + +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 SubusersModelActions extends JModelList +class SubusersModelActions extends ListModel { -/** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * - * @see JController - * @since 1.6 - */ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * + * @see JController + * @since 1.0.0 + */ public function __construct($config = array()) { if (empty($config['filter_fields'])) @@ -33,10 +35,7 @@ public function __construct($config = array()) $config['filter_fields'] = array( 'id', 'a.`id`', 'name', 'a.`name`', - 'client', 'a.`client`', - 'created_by', 'a.`created_by`', - 'ordering', 'a.`ordering`', - 'state', 'a.`state`', + 'client', 'a.`client`' ); } @@ -57,21 +56,14 @@ public function __construct($config = array()) */ protected function populateState($ordering = null, $direction = null) { - // 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.name', 'asc'); } @@ -86,13 +78,12 @@ protected function populateState($ordering = null, $direction = null) * * @return string A store id. * - * @since 1.6 + * @since 1.0.0 */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('filter.search'); - $id .= ':' . $this->getState('filter.state'); return parent::getStoreId($id); } @@ -102,46 +93,20 @@ protected function getStoreId($id = '') * * @return JDatabaseQuery * - * @since 1.6 + * @since 1.0.0 */ protected function getListQuery() { - // Create a new query object. - $db = $this->getDbo(); + $db = $this->getDbo(); $query = $db->getQuery(true); - // Select the required fields from the table. - $query->select( - $this->getState( - 'list.select', 'DISTINCT a.*' - ) - ); + $query->select($this->getState('list.select', 'DISTINCT a.*')); $query->from('`#__tjsu_actions` AS a'); - // 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)) + if (! empty($search)) { if (stripos($search, 'id:') === 0) { @@ -154,7 +119,6 @@ protected function getListQuery() } } - // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); @@ -165,16 +129,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/fields/createdby.php b/src/administrator/models/fields/createdby.php deleted file mode 100755 index f551d0a..0000000 --- a/src/administrator/models/fields/createdby.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -jimport('joomla.form.formfield'); - -/** - * Supports an HTML select list of categories - * - * @since 1.6 - */ -class JFormFieldCreatedby extends JFormField -{ - /** - * The form field type. - * - * @var string - * @since 1.6 - */ - protected $type = 'createdby'; - - /** - * Method to get the field input markup. - * - * @return string The field input markup. - * - * @since 1.6 - */ - protected function getInput() - { - // Initialize variables. - $html = array(); - - // Load user - $user_id = $this->value; - - if ($user_id) - { - $user = JFactory::getUser($user_id); - } - else - { - $user = JFactory::getUser(); - $html[] = ''; - } - - $html[] = "
" . $user->name . " (" . $user->username . ")
"; - - return implode($html); - } -} diff --git a/src/administrator/models/fields/custom_field.php b/src/administrator/models/fields/custom_field.php deleted file mode 100755 index e255fa6..0000000 --- a/src/administrator/models/fields/custom_field.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -jimport('joomla.html.html'); -jimport('joomla.form.formfield'); - -/** - * Supports an HTML select list of categories - * - * @since 1.6 - */ -class JFormFieldCustomField extends JFormField -{ - /** - * The form field type. - * - * @var string - * @since 1.6 - */ - protected $type = 'text'; - - /** - * Method to get the field input markup. - * - * @return string The field input markup. - * - * @since 1.6 - */ - protected function getInput() - { - // Initialize variables. - $html = array(); - - return implode($html); - } -} diff --git a/src/administrator/models/fields/filemultiple.php b/src/administrator/models/fields/filemultiple.php deleted file mode 100755 index ce25d36..0000000 --- a/src/administrator/models/fields/filemultiple.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -jimport('joomla.form.formfield'); - -/** - * Supports an HTML select list of categories - * - * @since 1.6 - */ -class JFormFieldFileMultiple extends JFormField -{ - /** - * The form field type. - * - * @var string - * @since 1.6 - */ - protected $type = 'file'; - - /** - * Method to get the field input markup. - * - * @return string The field input markup. - * - * @since 1.6 - */ - protected function getInput() - { - // Initialize variables. - $html = ''; - - return $html; - } -} diff --git a/src/administrator/models/fields/foreignkey.php b/src/administrator/models/fields/foreignkey.php deleted file mode 100755 index 52da465..0000000 --- a/src/administrator/models/fields/foreignkey.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -defined('JPATH_BASE') or die; - -jimport('joomla.form.formfield'); - -/** - * Supports a value from an external table - * - * @since 1.6 - */ -class JFormFieldForeignKey extends JFormField -{ - /** - * The form field type. - * - * @var string - * @since 1.6 - */ - protected $type = 'foreignkey'; - - private $input_type; - - private $table; - - private $key_field; - - private $value_field; - - /** - * Method to get the field input markup. - * - * @return string The field input markup. - * - * @since 1.6 - */ - protected function getInput() - { - // Assign field properties. - // Type of input the field shows - $this->input_type = $this->getAttribute('input_type'); - - // Database Table - $this->table = $this->getAttribute('table'); - - // The field that the field will save on the database - $this->key_field = (string) $this->getAttribute('key_field'); - - // The column that the field shows in the input - $this->value_field = (string) $this->getAttribute('value_field'); - - // Initialize variables. - $html = ''; - - // Load all the field options - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - - $query - ->select( - array( - $db->quoteName($this->key_field), - $db->quoteName($this->value_field) - ) - ) - ->from($this->table); - - $db->setQuery($query); - $results = $db->loadObjectList(); - - $input_options = 'class="' . $this->getAttribute('class') . '"'; - - // Depends of the type of input, the field will show a type or another - switch ($this->input_type) - { - case 'list': - default: - $options = array(); - - // Iterate through all the results - foreach ($results as $result) - { - $options[] = JHtml::_('select.option', $result->{$this->key_field}, $result->{$this->value_field}); - } - - $value = $this->value; - - // If the value is a string -> Only one result - if (is_string($value)) - { - $value = array($value); - } - elseif (is_object($value)) - { - // If the value is an object, let's get its properties. - $value = get_object_vars($value); - } - - // If the select is multiple - if ($this->multiple) - { - $input_options .= 'multiple="multiple"'; - } - else - { - array_unshift($options, JHtml::_('select.option', '', '')); - } - - $html = JHtml::_('select.genericlist', $options, $this->name, $input_options, 'value', 'text', $value, $this->id); - break; - } - - return $html; - } - - /** - * Wrapper method for getting attributes from the form element - * - * @param string $attr_name Attribute name - * @param mixed $default Optional value to return if attribute not found - * - * @return mixed The value of the attribute if it exists, null otherwise - */ - public function getAttribute($attr_name, $default = null) - { - if (!empty($this->element[$attr_name])) - { - return $this->element[$attr_name]; - } - else - { - return $default; - } - } -} diff --git a/src/administrator/models/fields/modifiedby.php b/src/administrator/models/fields/modifiedby.php deleted file mode 100755 index 151e189..0000000 --- a/src/administrator/models/fields/modifiedby.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -jimport('joomla.form.formfield'); - -/** - * Supports an HTML select list of categories - * - * @since 1.6 - */ -class JFormFieldModifiedby extends JFormField -{ - /** - * The form field type. - * - * @var string - * @since 1.6 - */ - protected $type = 'modifiedby'; - - /** - * Method to get the field input markup. - * - * @return string The field input markup. - * - * @since 1.6 - */ - protected function getInput() - { - // Initialize variables. - $html = array(); - $user = JFactory::getUser(); - $html[] = ''; - $html[] = "
" . $user->name . " (" . $user->username . ")
"; - - return implode($html); - } -} diff --git a/src/administrator/models/fields/role.php b/src/administrator/models/fields/role.php new file mode 100644 index 0000000..872bbc1 --- /dev/null +++ b/src/administrator/models/fields/role.php @@ -0,0 +1,64 @@ + + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access. +defined('_JEXEC') or die(); + +JFormHelper::loadFieldClass('list'); + +/** + * Supports an HTML select list of Roles + * + * @since 1.0.0 + */ +class JFormFieldRole extends JFormFieldList +{ + /** + * The form field type. + * + * @var string + * @since 1.0.0 + */ + protected $type = 'role'; + + /** + * Method to get list of role options. + * + * @return array role An array of JHtml options + * + * @since 1.0.0 + */ + protected function getOptions() + { + $jinput = JFactory::getApplication()->input; + $client = $jinput->get('client'); + + // 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(); + + $options = array(); + $options[] = JHtml::_('select.option', '', JText::_('COM_SUBUSERS_FORM_LBL_SELECT_ROLE')); + + if ($results) + { + foreach ($results as $result) + { + $options[] = JHtml::_('select.option', $result->id, $result->name); + } + } + + return $options; + } +} diff --git a/src/administrator/models/fields/timecreated.php b/src/administrator/models/fields/timecreated.php deleted file mode 100755 index 5cdae7d..0000000 --- a/src/administrator/models/fields/timecreated.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -jimport('joomla.form.formfield'); - -/** - * Supports an HTML select list of categories - * - * @since 1.6 - */ -class JFormFieldTimecreated extends JFormField -{ - /** - * The form field type. - * - * @var string - * @since 1.6 - */ - protected $type = 'timecreated'; - - /** - * Method to get the field input markup. - * - * @return string The field input markup. - * - * @since 1.6 - */ - protected function getInput() - { - // Initialize variables. - $html = array(); - - $time_created = $this->value; - - if (!strtotime($time_created)) - { - $time_created = JFactory::getDate('now', JFactory::getConfig()->get('offset'))->toSql(true); - $html[] = ''; - } - - $hidden = (boolean) $this->element['hidden']; - - if ($hidden == null || !$hidden) - { - $jdate = new JDate($time_created); - $pretty_date = $jdate->format(JText::_('DATE_FORMAT_LC2')); - $html[] = "
" . $pretty_date . "
"; - } - - return implode($html); - } -} diff --git a/src/administrator/models/fields/timeupdated.php b/src/administrator/models/fields/timeupdated.php deleted file mode 100755 index 74bcdd9..0000000 --- a/src/administrator/models/fields/timeupdated.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -jimport('joomla.form.formfield'); - -/** - * Supports an HTML select list of categories - * - * @since 1.6 - */ -class JFormFieldTimeupdated extends JFormField -{ - /** - * The form field type. - * - * @var string - * @since 1.6 - */ - protected $type = 'timeupdated'; - - /** - * Method to get the field input markup. - * - * @return string The field input markup. - * - * @since 1.6 - */ - protected function getInput() - { - // Initialize variables. - $html = array(); - - $old_time_updated = $this->value; - $hidden = (boolean) $this->element['hidden']; - - if ($hidden == null || !$hidden) - { - if (!strtotime($old_time_updated)) - { - $html[] = '-'; - } - else - { - $jdate = new JDate($old_time_updated); - $pretty_date = $jdate->format(JText::_('DATE_FORMAT_LC2')); - $html[] = "
" . $pretty_date . "
"; - } - } - - $time_updated = JFactory::getDate('now', JFactory::getConfig()->get('offset'))->toSql(true); - $html[] = ''; - - return implode($html); - } -} diff --git a/src/administrator/models/forms/action.xml b/src/administrator/models/forms/action.xml index 49948e8..901295c 100755 --- a/src/administrator/models/forms/action.xml +++ b/src/administrator/models/forms/action.xml @@ -1,50 +1,44 @@ - +
- - - - - - - - - - - - - - - - - - - + + + + +
-
diff --git a/src/administrator/models/forms/filter_actions.xml b/src/administrator/models/forms/filter_actions.xml new file mode 100644 index 0000000..a223100 --- /dev/null +++ b/src/administrator/models/forms/filter_actions.xml @@ -0,0 +1,25 @@ + +
+ + + + + + + +
diff --git a/src/administrator/models/forms/filter_users.xml b/src/administrator/models/forms/filter_users.xml new file mode 100644 index 0000000..30a5245 --- /dev/null +++ b/src/administrator/models/forms/filter_users.xml @@ -0,0 +1,25 @@ + +
+ + + + + + + +
diff --git a/src/administrator/models/forms/organization.xml b/src/administrator/models/forms/organization.xml deleted file mode 100755 index 53fa812..0000000 --- a/src/administrator/models/forms/organization.xml +++ /dev/null @@ -1,69 +0,0 @@ - -
-
- - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/administrator/models/forms/role.xml b/src/administrator/models/forms/role.xml index a4f2bb8..edd88d4 100755 --- a/src/administrator/models/forms/role.xml +++ b/src/administrator/models/forms/role.xml @@ -1,50 +1,56 @@ - +
- - - - - - - - - - - - - - - - - - - + + + + + + + +
- -
+ \ No newline at end of file diff --git a/src/administrator/models/forms/user.xml b/src/administrator/models/forms/user.xml index 53c9536..6121134 100755 --- a/src/administrator/models/forms/user.xml +++ b/src/administrator/models/forms/user.xml @@ -1,77 +1,63 @@ - +
- - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + +
-
diff --git a/src/administrator/models/mapping.php b/src/administrator/models/mapping.php index baf53d1..361dbca 100755 --- a/src/administrator/models/mapping.php +++ b/src/administrator/models/mapping.php @@ -3,7 +3,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @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 */ @@ -160,7 +160,6 @@ public function duplicate(&$pks) { throw new Exception($table->getError()); } - // Trigger the before save event. $result = $dispatcher->trigger($this->event_before_save, array($context, &$table, true)); diff --git a/src/administrator/models/mappings.php b/src/administrator/models/mappings.php index 9e5874b..f3849ab 100755 --- a/src/administrator/models/mappings.php +++ b/src/administrator/models/mappings.php @@ -4,7 +4,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @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 */ defined('_JEXEC') or die; @@ -151,7 +151,6 @@ protected function getListQuery() else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); - } } diff --git a/src/administrator/models/organization.php b/src/administrator/models/organization.php deleted file mode 100755 index 7f907ad..0000000 --- a/src/administrator/models/organization.php +++ /dev/null @@ -1,225 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -jimport('joomla.application.component.modeladmin'); - -/** - * Subusers model. - * - * @since 1.6 - */ -class SubusersModelOrganization extends JModelAdmin -{ - /** - * @var string The prefix to use with controller messages. - * @since 1.6 - */ - protected $text_prefix = 'COM_SUBUSERS'; - - /** - * @var null Item data - * @since 1.6 - */ - protected $item = null; - - /** - * Returns a reference to the a Table object, always creating it. - * - * @param string $type The table type to instantiate - * @param string $prefix A prefix for the table class name. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return JTable A database object - * - * @since 1.6 - */ - public function getTable($type = 'Organization', $prefix = 'SubusersTable', $config = array()) - { - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Method to get the record form. - * - * @param array $data An optional array of data for the form to interogate. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * - * @return JForm A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true) - { - // Initialise variables. - $app = JFactory::getApplication(); - - // Get the form. - $form = $this->loadForm( - 'com_subusers.organization', 'organization', - array('control' => 'jform', - 'load_data' => $loadData - ) - ); - - if (empty($form)) - { - return false; - } - - return $form; - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_subusers.edit.organization.data', array()); - - if (empty($data)) - { - if ($this->item === null) - { - $this->item = $this->getItem(); - } - - $data = $this->item; - } - - 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 Organization - * - * @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()); - } - - if (!empty($table->logo)) - { - if (is_array($table->logo)) - { - $table->logo = implode(',', $table->logo); - } - } - else - { - $table->logo = ''; - } - - - // 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_organizations'); - $max = $db->loadResult(); - $table->ordering = $max + 1; - } - } - } -} diff --git a/src/administrator/models/organizations.php b/src/administrator/models/organizations.php deleted file mode 100755 index 0200e71..0000000 --- a/src/administrator/models/organizations.php +++ /dev/null @@ -1,181 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -defined('_JEXEC') or die; - -jimport('joomla.application.component.modellist'); - -/** - * Methods supporting a list of Subusers records. - * - * @since 1.6 - */ -class SubusersModelOrganizations extends JModelList -{ -/** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * - * @see JController - * @since 1.6 - */ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( - 'id', 'a.`id`', - 'name', 'a.`name`', - 'created_by', 'a.`created_by`', - 'ordering', 'a.`ordering`', - 'state', 'a.`state`', - 'email', 'a.`email`', - 'logo', 'a.`logo`', - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering Elements order - * @param string $direction Order direction - * - * @return void - * - * @throws Exception - */ - protected function populateState($ordering = null, $direction = null) - { - // Initialise variables. - $app = JFactory::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'); - $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'); - $id .= ':' . $this->getState('filter.state'); - - return parent::getStoreId($id); - } - - /** - * Build an SQL query to load the list data. - * - * @return JDatabaseQuery - * - * @since 1.6 - */ - protected function getListQuery() - { - // Create a new query object. - $db = $this->getDbo(); - $query = $db->getQuery(true); - - // Select the required fields from the table. - $query->select( - $this->getState( - 'list.select', 'DISTINCT a.*' - ) - ); - $query->from('`#__tjsu_organizations` AS a'); - - // 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)) - { - if (stripos($search, 'id:') === 0) - { - $query->where('a.id = ' . (int) substr($search, 3)); - } - else - { - $search = $db->Quote('%' . $db->escape($search, true) . '%'); - $query->where('( a.`name` LIKE ' . $search . ' OR a.`created_by` LIKE ' . $search . ' OR a.`email` LIKE ' . $search . ' )'); - } - } - - // 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)); - } - - 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 1f0c3a8..5d24833 100755 --- a/src/administrator/models/role.php +++ b/src/administrator/models/role.php @@ -1,33 +1,27 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access. defined('_JEXEC') or die; -jimport('joomla.application.component.modeladmin'); +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\Table\Table; /** * Subusers model. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersModelRole extends JModelAdmin +class SubusersModelRole 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 + * @since 1.0.0 */ protected $item = null; @@ -40,11 +34,11 @@ class SubusersModelRole extends JModelAdmin * * @return JTable A database object * - * @since 1.6 + * @since 1.0.0 */ public function getTable($type = 'Role', $prefix = 'SubusersTable', $config = array()) { - return JTable::getInstance($type, $prefix, $config); + return Table::getInstance($type, $prefix, $config); } /** @@ -55,13 +49,10 @@ public function getTable($type = 'Role', $prefix = 'SubusersTable', $config = ar * * @return JForm 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.role', 'role', @@ -83,7 +74,7 @@ public function getForm($data = array(), $loadData = true) * * @return mixed The data for the form. * - * @since 1.6 + * @since 1.0.0 */ protected function loadFormData() { @@ -106,108 +97,60 @@ protected function loadFormData() /** * Method to get a single record. * - * @param integer $pk The id of the primary key. + * @param integer $roleId The id of the roleId. * * @return mixed Object on success, false on failure. * - * @since 1.6 + * @since 1.0.0 */ - public function getItem($pk = null) + public function getActions($roleId) { - if ($item = parent::getItem($pk)) - { - // Do any procesing on fields here if needed - } - - return $item; + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query->select('action'); + $query->from($db->quoteName('#__tjsu_role_action_map')); + $query->where($db->quoteName('role_id') . " = " . $db->quote($roleId)); + $db->setQuery($query); + $actions = $db->loadColumn(); + + return $actions; } /** - * Method to duplicate an Role + * Method to get a single record. * - * @param array &$pks An array of primary key IDs. + * @param array $data The id of the roleId. * - * @return boolean True if successful. + * @return boolean true on success, false on failure. * - * @throws Exception + * @since 1.0.0 */ - public function duplicate(&$pks) + public function save($data) { - $user = JFactory::getUser(); + $pk = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('role.id'); - // 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(); + $role = SubusersRole::getInstance($pk); - foreach ($pks as $pk) + // Bind the data. + if (!$role->bind($data)) { - if ($table->load($pk, true)) - { - // Reset the id to create a new record. - $table->id = 0; + $this->setError($role->getError()); - if (!$table->check()) - { - throw new Exception($table->getError()); - } - + return false; + } - // Trigger the before save event. - $result = $dispatcher->trigger($this->event_before_save, array($context, &$table, true)); + $result = $role->save(); - if (in_array(false, $result, true) || !$table->store()) - { - throw new Exception($table->getError()); - } + // Store the data. + if (!$result) + { + $this->setError($role->getError()); - // Trigger the after save event. - $dispatcher->trigger($this->event_after_save, array($context, &$table, true)); - } - else - { - throw new Exception($table->getError()); - } + return false; } - // Clean cache - $this->cleanCache(); + $this->setState('role.id', $role->id); 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_roles'); - $max = $db->loadResult(); - $table->ordering = $max + 1; - } - } - } } diff --git a/src/administrator/models/roles.php b/src/administrator/models/roles.php index 36b26ba..b3cb016 100755 --- a/src/administrator/models/roles.php +++ b/src/administrator/models/roles.php @@ -4,7 +4,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @copyright Copyright (C) 2005 - 2014. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; @@ -18,14 +18,14 @@ */ class SubusersModelRoles extends JModelList { -/** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * - * @see JController - * @since 1.6 - */ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * + * @see JController + * @since 1.6 + */ public function __construct($config = array()) { if (empty($config['filter_fields'])) @@ -33,10 +33,8 @@ public function __construct($config = array()) $config['filter_fields'] = array( 'id', 'a.`id`', 'name', 'a.`name`', - 'client', 'a.`client`', 'created_by', 'a.`created_by`', - 'ordering', 'a.`ordering`', - 'state', 'a.`state`', + 'ordering', 'a.`ordering`' ); } @@ -64,9 +62,6 @@ protected function populateState($ordering = null, $direction = null) $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'); $this->setState('params', $params); @@ -92,7 +87,6 @@ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('filter.search'); - $id .= ':' . $this->getState('filter.state'); return parent::getStoreId($id); } @@ -118,26 +112,10 @@ protected function getListQuery() ); $query->from('`#__tjsu_roles` AS a'); - // 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'); @@ -154,6 +132,14 @@ protected function getListQuery() } } + $client = $this->getState('filter.client'); + + // Filter by client + if (!empty($client)) + { + $query->where($db->quoteName('a.client') . ' = ' . $db->quote($client)); + } + // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); diff --git a/src/administrator/models/user.php b/src/administrator/models/user.php index b714cae..70f4e17 100755 --- a/src/administrator/models/user.php +++ b/src/administrator/models/user.php @@ -1,33 +1,28 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// 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 SubusersModelUser extends JModelAdmin +class SubusersModelUser 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 + * @since 1.0.0 */ protected $item = null; @@ -40,11 +35,11 @@ class SubusersModelUser extends JModelAdmin * * @return JTable A database object * - * @since 1.6 + * @since 1.0.0 */ public function getTable($type = 'User', $prefix = 'SubusersTable', $config = array()) { - return JTable::getInstance($type, $prefix, $config); + return Table::getInstance($type, $prefix, $config); } /** @@ -55,13 +50,10 @@ public function getTable($type = 'User', $prefix = 'SubusersTable', $config = ar * * @return JForm 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.user', 'user', @@ -83,7 +75,7 @@ public function getForm($data = array(), $loadData = true) * * @return mixed The data for the form. * - * @since 1.6 + * @since 1.0.0 */ protected function loadFormData() { @@ -104,110 +96,28 @@ protected function loadFormData() } /** - * Method to get a single record. + * This method will return the role id of given client content * - * @param integer $pk The id of the primary key. + * @param integer $userId Id of the user for which to check authorisation. + * @param string $client The name of the client to authorise. com_content + * @param integer $contentId The content key. null check with role and allowed actions. * - * @return mixed Object on success, false on failure. + * @return integer The role id * - * @since 1.6 + * @since __DEPLOY_VERSION__ */ - public function getItem($pk = null) + public function getAssociatedContentRole($userId, $client, $contentId) { - if ($item = parent::getItem($pk)) - { - // Do any procesing on fields here if needed - } - - return $item; - } - - /** - * Method to duplicate an User - * - * @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(); + $db = Factory::getDbo(); + $query = $db->getQuery(true); - return true; - } + $query->select('role_id'); + $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); + $db->setQuery($query); - /** - * 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_users'); - $max = $db->loadResult(); - $table->ordering = $max + 1; - } - } + return $db->loadResult(); } } diff --git a/src/administrator/models/users.php b/src/administrator/models/users.php index 22c9499..3a5e029 100755 --- a/src/administrator/models/users.php +++ b/src/administrator/models/users.php @@ -1,31 +1,30 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ + defined('_JEXEC') or die; -jimport('joomla.application.component.modellist'); +use Joomla\CMS\MVC\Model\ListModel; /** * Methods supporting a list of Subusers records. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersModelUsers extends JModelList +class SubusersModelUsers extends ListModel { -/** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * - * @see JController - * @since 1.6 - */ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * + * @since 1.0.0 + */ public function __construct($config = array()) { if (empty($config['filter_fields'])) @@ -33,12 +32,10 @@ public function __construct($config = array()) $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`', - 'role_id', 'a.`role_id`', 'created_by', 'a.`created_by`', - 'ordering', 'a.`ordering`', - 'state', 'a.`state`', ); } @@ -59,24 +56,16 @@ public function __construct($config = array()) */ protected function populateState($ordering = null, $direction = null) { - // Initialise variables. $app = JFactory::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); - // Filtering user_id - $this->setState('filter.user_id', $app->getUserStateFromRequest($this->context.'.filter.user_id', 'filter_user_id', '', 'string')); + $this->setState('filter.user_id', $app->getUserStateFromRequest($this->context . ' . filter.user_id', 'filter_user_id', '', 'string')); - - // Load the parameters. $params = JComponentHelper::getParams('com_subusers'); $this->setState('params', $params); - // List state information. parent::populateState('a.id', 'desc'); } @@ -91,13 +80,11 @@ protected function populateState($ordering = null, $direction = null) * * @return string A store id. * - * @since 1.6 + * @since 1.0.0 */ protected function getStoreId($id = '') { - // Compile the store id. $id .= ':' . $this->getState('filter.search'); - $id .= ':' . $this->getState('filter.state'); return parent::getStoreId($id); } @@ -107,51 +94,17 @@ protected function getStoreId($id = '') * * @return JDatabaseQuery * - * @since 1.6 + * @since 1.0.0 */ protected function getListQuery() { - // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); - // Select the required fields from the table. - $query->select( - $this->getState( - 'list.select', 'DISTINCT a.*' - ) - ); + $query->select(array('a.*', 'uc.name', 'rl.name as rolename')); $query->from('`#__tjsu_users` AS a'); - - // 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 'user_id' - $query->select('`user_id`.name AS `user_id`'); - $query->join('LEFT', '#__users AS `user_id` ON `user_id`.id = a.`user_id`'); - - // 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`'); - - // Join over the organization field 'name' - $query->select('`o`.name AS `organization_name`'); - $query->join('LEFT', '#__tjsu_organizations AS `o` ON `o`.id = a.`client_id`'); - - // 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 + $query->join('INNER', $db->quoteName('#__users', 'uc') . ' ON (' . $db->quoteName('a.user_id') . ' = ' . $db->quoteName('uc.id') . ')'); + $query->join('INNER', $db->quoteName('#__tjsu_roles', 'rl') . ' ON (' . $db->quoteName('rl.id') . ' = ' . $db->quoteName('a.role_id') . ')'); $search = $this->getState('filter.search'); if (!empty($search)) @@ -163,13 +116,10 @@ protected function getListQuery() else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); - $query->where('( a.`id` LIKE ' . $search . ' OR a.`user_id` LIKE ' . $search . ' OR a.`client_id` LIKE ' . $search . ' )'); + $query->where('( uc.`name` LIKE ' . $search . ' OR a.`user_id` LIKE ' . $search . ' OR a.`client_id` LIKE ' . $search . ' )'); } } - - //Filtering user_id - // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); @@ -180,16 +130,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/sql/install.mysql.utf8.sql b/src/administrator/sql/install.mysql.utf8.sql index 8218630..56e1212 100755 --- a/src/administrator/sql/install.mysql.utf8.sql +++ b/src/administrator/sql/install.mysql.utf8.sql @@ -1,57 +1,32 @@ -- --- Table structure for table `#__tjsu_actions` +-- Table structure for table `#__tjsu_roles` -- -CREATE TABLE IF NOT EXISTS `#__tjsu_actions` ( +CREATE TABLE IF NOT EXISTS `#__tjsu_roles` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `client` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL COMMENT 'The name of the role', + `client` varchar(255) NOT NULL COMMENT 'The client name Eg. com_tjlms, com_jlike', `created_by` int(11) NOT NULL, - `checked_out` int(11) NOT NULL, - `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `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', `ordering` int(11) NOT NULL, - `state` tinyint(1) NOT NULL, PRIMARY KEY (`id`) -) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- --- --- Table structure for table `#__tjsu_organizations` --- - -CREATE TABLE IF NOT EXISTS `#__tjsu_organizations` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `userid` int(11) NOT NULL, - `created_by` varchar(255) NOT NULL, - `checked_out` int(11) NOT NULL, - `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `ordering` int(11) NOT NULL, - `state` tinyint(1) NOT NULL, - `email` varchar(255) NOT NULL, - `logo` text NOT NULL, - `description` text NOT NULL, - PRIMARY KEY (`id`) -) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- -------------------------------------------------------- - --- --- Table structure for table `#__tjsu_roles` +-- Table structure for table `#__tjsu_actions` -- -CREATE TABLE IF NOT EXISTS `#__tjsu_roles` ( +CREATE TABLE IF NOT EXISTS `#__tjsu_actions` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `client` varchar(255) NOT NULL, - `created_by` int(11) NOT NULL, - `checked_out` int(11) NOT NULL, - `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `ordering` int(11) NOT NULL, - `state` tinyint(1) NOT NULL, + `code` varchar(50) NOT NULL COMMENT 'The unique string of the action Eg. core.view.course', + `name` varchar(255) NOT NULL COMMENT 'Short intro of action', + `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`) -) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- @@ -61,16 +36,10 @@ CREATE TABLE IF NOT EXISTS `#__tjsu_roles` ( CREATE TABLE IF NOT EXISTS `#__tjsu_role_action_map` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `role_id` int(11) NOT NULL, - `action_id` int(11) NOT NULL, - `client` varchar(255) NOT NULL, - `created_by` int(11) NOT NULL, - `checked_out` int(11) NOT NULL, - `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `ordering` int(11) NOT NULL, - `state` tinyint(1) NOT NULL, + `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`) -) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; -- -------------------------------------------------------- @@ -80,14 +49,13 @@ CREATE TABLE IF NOT EXISTS `#__tjsu_role_action_map` ( CREATE TABLE IF NOT EXISTS `#__tjsu_users` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `user_id` varchar(255) NOT NULL, - `client` varchar(255) NOT NULL, - `client_id` int(11) NOT NULL, - `role_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL COMMENT 'FK to users table', + `role_id` int(11) NOT NULL COMMENT 'FK to roles table', + `client` varchar(255) NOT NULL COMMENT 'The client name Eg. com_tjlms, com_jlike', + `client_id` int(11) NOT NULL COMMENT 'The client content id.', `created_by` int(11) NOT NULL, - `checked_out` int(11) NOT NULL, - `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `ordering` int(11) NOT NULL, - `state` tinyint(1) NOT NULL, + `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`) -) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; diff --git a/src/administrator/subusers.php b/src/administrator/subusers.php index 386acae..a09811a 100755 --- a/src/administrator/subusers.php +++ b/src/administrator/subusers.php @@ -1,24 +1,25 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Controller\BaseController; + // Access check. -if (!JFactory::getUser()->authorise('core.manage', 'com_subusers')) +if (!Factory::getUser()->authorise('core.manage', 'com_subusers')) { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR')); + throw new \Exception(JText::_('JERROR_ALERTNOAUTHOR')); } -// Include dependancies -jimport('joomla.application.component.controller'); +\JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); -$controller = JControllerLegacy::getInstance('Subusers'); -$controller->execute(JFactory::getApplication()->input->get('task')); +$controller = BaseController::getInstance('Subusers'); +$controller->execute(Factory::getApplication()->input->get('task')); $controller->redirect(); diff --git a/src/administrator/tables/action.php b/src/administrator/tables/action.php index 969f4e8..01c9b52 100755 --- a/src/administrator/tables/action.php +++ b/src/administrator/tables/action.php @@ -1,22 +1,23 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access + defined('_JEXEC') or die; -use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; + /** - * action Table class + * role Table class * - * @since 1.6 + * @since 1.0.0 */ -class SubusersTableaction extends JTable +class SubusersTableaction extends Table { /** * Constructor @@ -29,251 +30,23 @@ public function __construct(&$db) } /** - * Overloaded bind function to pre-process the params. + * Overrides Table::store to set modified data and user id. * - * @param array $array Named array - * @param mixed $ignore Optional array or list of parameters to ignore - * - * @return null|string null is operation was satisfactory, otherwise returns an error - * - * @see JTable:bind - * @since 1.5 - */ - public function bind($array, $ignore = '') - { - - if ($array['id'] == 0) - { - $array['created_by'] = JFactory::getUser()->id; - } - $input = JFactory::getApplication()->input; - $task = $input->getString('task', ''); - - if (($task == 'save' || $task == 'apply') && (!JFactory::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->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - if (!JFactory::getUser()->authorise('core.admin', 'com_subusers.action.' . $array['id'])) - { - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_subusers/access.xml', - "/access/section[@name='action']/" - ); - $default_actions = JAccess::getAssetRules('com_subusers.action.' . $array['id'])->getData(); - $array_jaccess = array(); - - foreach ($actions as $action) - { - $array_jaccess[$action->name] = $default_actions[$action->name]; - } - - $array['rules'] = $this->JAccessRulestoArray($array_jaccess); - } - - // Bind the rules for ACL where supported. - if (isset($array['rules']) && is_array($array['rules'])) - { - $this->setRules($array['rules']); - } - - return parent::bind($array, $ignore); - } - - /** - * This function convert an array of JAccessRule objects into an rules array. + * @param boolean $updateNulls True to update fields even if they are null. * - * @param array $jaccessrules An array of JAccessRule objects. + * @return boolean True on success. * - * @return array + * @since 1.0.0 */ - private function JAccessRulestoArray($jaccessrules) + public function store($updateNulls = false) { - $rules = array(); + $date = Factory::getDate(); - foreach ($jaccessrules as $action => $jaccess) + if (!$this->id) { - $actions = array(); - - foreach ($jaccess->getData() as $group => $allow) - { - $actions[$group] = ((bool) $allow); - } - - $rules[$action] = $actions; + $this->created_date = $date->toSql(); } - return $rules; - } - - /** - * Overloaded check function - * - * @return bool - */ - public function check() - { - // If there is an ordering column and this is a new row then get the next ordering value - if (property_exists($this, 'ordering') && $this->id == 0) - { - $this->ordering = self::getNextOrder(); - } - - - return parent::check(); - } - - /** - * Method to set the publishing state for a row or list of rows in the database - * table. The method respects checked out rows by other users and will attempt - * to checkin rows that it can after adjustments are made. - * - * @param mixed $pks An optional array of primary key values to update. If not - * set the instance property value is used. - * @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] - * @param integer $userId The user id of the user performing the operation. - * - * @return boolean True on success. - * - * @since 1.0.4 - * - * @throws Exception - */ - public function publish($pks = null, $state = 1, $userId = 0) - { - // Initialise variables. - $k = $this->_tbl_key; - - // Sanitize input. - ArrayHelper::toInteger($pks); - $userId = (int) $userId; - $state = (int) $state; - - // If there are no primary keys set check to see if the instance key is set. - if (empty($pks)) - { - if ($this->$k) - { - $pks = array($this->$k); - } - // Nothing to set publishing state on, return false. - else - { - throw new Exception(500, JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); - } - } - - // Build the WHERE clause for the primary keys. - $where = $k . '=' . implode(' OR ' . $k . '=', $pks); - - // Determine if there is checkin support for the table. - if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) - { - $checkin = ''; - } - else - { - $checkin = ' AND (checked_out = 0 OR checked_out = ' . (int) $userId . ')'; - } - - // Update the publishing state for rows with the given primary keys. - $this->_db->setQuery( - 'UPDATE `' . $this->_tbl . '`' . - ' SET `state` = ' . (int) $state . - ' WHERE (' . $where . ')' . - $checkin - ); - $this->_db->execute(); - - // If checkin is supported and all rows were adjusted, check them in. - if ($checkin && (count($pks) == $this->_db->getAffectedRows())) - { - // Checkin each row. - foreach ($pks as $pk) - { - $this->checkin($pk); - } - } - - // If the JTable instance value is in the list of primary keys that were set, set the instance. - if (in_array($this->$k, $pks)) - { - $this->state = $state; - } - - return true; - } - - /** - * Define a namespaced asset name for inclusion in the #__assets table - * - * @return string The asset name - * - * @see JTable::_getAssetName - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - - return 'com_subusers.action.' . (int) $this->$k; - } - - /** - * Returns the parent asset's id. If you have a tree structure, retrieve the parent's id using the external key field - * - * @param JTable $table Table name - * @param integer $id Id - * - * @see JTable::_getAssetParentId - * - * @return mixed The id on success, false on failure. - */ - protected function _getAssetParentId(JTable $table = null, $id = null) - { - // We will retrieve the parent-asset from the Asset-table - $assetParent = JTable::getInstance('Asset'); - - // Default: if no asset-parent can be found we take the global asset - $assetParentId = $assetParent->getRootId(); - - // The item has the component as asset-parent - $assetParent->loadByName('com_subusers'); - - // Return the found asset-parent-id - if ($assetParent->id) - { - $assetParentId = $assetParent->id; - } - - return $assetParentId; - } - - /** - * Delete a record by id - * - * @param mixed $pk Primary key value to delete. Optional - * - * @return bool - */ - public function delete($pk = null) - { - $this->load($pk); - $result = parent::delete($pk); - - return $result; + return parent::store($updateNulls); } } diff --git a/src/administrator/tables/announcement.php b/src/administrator/tables/announcement.php deleted file mode 100755 index ed7fdb2..0000000 --- a/src/administrator/tables/announcement.php +++ /dev/null @@ -1,372 +0,0 @@ - - * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -use Joomla\Utilities\ArrayHelper; -/** - * organization Table class - * - * @since 1.6 - */ -class SubusersTableannouncement extends JTable -{ - /** - * Constructor - * - * @param JDatabase &$db A database connector object - */ - public function __construct(&$db) - { - parent::__construct('#__tjsu_organizations', 'id', $db); - } - - /** - * Overloaded bind function to pre-process the params. - * - * @param array $array Named array - * @param mixed $ignore Optional array or list of parameters to ignore - * - * @return null|string null is operation was satisfactory, otherwise returns an error - * - * @see JTable:bind - * @since 1.5 - */ - public function bind($array, $ignore = '') - { - $input = JFactory::getApplication()->input; - $task = $input->getString('task', ''); - - if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_subusers') && $array['state'] == 1)) - { - $array['state'] = 0; - } - // Support for multi file field: logo - if (!empty($array['logo'])) - { - if (is_array($array['logo'])) - { - $array['logo'] = implode(',', $array['logo']); - } - elseif (strpos($array['logo'], ',') != false) - { - $array['logo'] = explode(',', $array['logo']); - } - } - else - { - $array['logo'] = ''; - } - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - if (!JFactory::getUser()->authorise('core.admin', 'com_subusers.announcement.' . $array['id'])) - { - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_subusers/access.xml', - "/access/section[@name='announcement']/" - ); - $default_actions = JAccess::getAssetRules('com_subusers.announcement.' . $array['id'])->getData(); - $array_jaccess = array(); - - foreach ($actions as $action) - { - $array_jaccess[$action->name] = $default_actions[$action->name]; - } - - $array['rules'] = $this->JAccessRulestoArray($array_jaccess); - } - - // Bind the rules for ACL where supported. - if (isset($array['rules']) && is_array($array['rules'])) - { - $this->setRules($array['rules']); - } - - return parent::bind($array, $ignore); - } - - /** - * This function convert an array of JAccessRule objects into an rules array. - * - * @param array $jaccessrules An array of JAccessRule objects. - * - * @return array - */ - private function JAccessRulestoArray($jaccessrules) - { - $rules = array(); - - foreach ($jaccessrules as $action => $jaccess) - { - $actions = array(); - - foreach ($jaccess->getData() as $group => $allow) - { - $actions[$group] = ((bool) $allow); - } - - $rules[$action] = $actions; - } - - return $rules; - } - - /** - * Overloaded check function - * - * @return bool - */ - public function check() - { - // If there is an ordering column and this is a new row then get the next ordering value - if (property_exists($this, 'ordering') && $this->id == 0) - { - $this->ordering = self::getNextOrder(); - } - - // Support multi file field: logo - $app = JFactory::getApplication(); - $files = $app->input->files->get('jform', array(), 'raw'); - $array = $app->input->get('jform', array(), 'ARRAY'); - - if (!empty($files['logo'])) - { - $this->logo = ""; - - foreach ($files['logo'] as $singleFile ) - { - jimport('joomla.filesystem.file'); - - // Check if the server found any error. - $fileError = $singleFile['error']; - $message = ''; - - if ($fileError > 0 && $fileError != 4) - { - switch ($fileError) - { - case 1: - $message = JText::_('File size exceeds allowed by the server'); - break; - case 2: - $message = JText::_('File size exceeds allowed by the html form'); - break; - case 3: - $message = JText::_('Partial upload error'); - break; - } - - if ($message != '') - { - $app->enqueueMessage($message, 'warning'); - - return false; - } - } - elseif ($fileError == 4) - { - if (isset($array['logo'])) - { - $this->logo = $array['logo']; - } - } - else - { - // Replace any special characters in the filename - jimport('joomla.filesystem.file'); - $filename = JFile::stripExt($singleFile['name']); - $extension = JFile::getExt($singleFile['name']); - $filename = preg_replace("/[^A-Za-z0-9]/i", "-", $filename); - $filename = $filename . '.' . $extension; - $uploadPath = JPATH_ROOT . '/images/com_subusers/partners/' . $filename; - $fileTemp = $singleFile['tmp_name']; - - if (!JFile::exists($uploadPath)) - { - if (!JFile::upload($fileTemp, $uploadPath)) - { - $app->enqueueMessage('Error moving file', 'warning'); - - return false; - } - } - - $this->logo .= (!empty($this->logo)) ? "," : ""; - $this->logo .= $filename; - } - } - } - - return parent::check(); - } - - /** - * Method to set the publishing state for a row or list of rows in the database - * table. The method respects checked out rows by other users and will attempt - * to checkin rows that it can after adjustments are made. - * - * @param mixed $pks An optional array of primary key values to update. If not - * set the instance property value is used. - * @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] - * @param integer $userId The user id of the user performing the operation. - * - * @return boolean True on success. - * - * @since 1.0.4 - * - * @throws Exception - */ - public function publish($pks = null, $state = 1, $userId = 0) - { - // Initialise variables. - $k = $this->_tbl_key; - - // Sanitize input. - ArrayHelper::toInteger($pks); - $userId = (int) $userId; - $state = (int) $state; - - // If there are no primary keys set check to see if the instance key is set. - if (empty($pks)) - { - if ($this->$k) - { - $pks = array($this->$k); - } - // Nothing to set publishing state on, return false. - else - { - throw new Exception(500, JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); - } - } - - // Build the WHERE clause for the primary keys. - $where = $k . '=' . implode(' OR ' . $k . '=', $pks); - - // Determine if there is checkin support for the table. - if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) - { - $checkin = ''; - } - else - { - $checkin = ' AND (checked_out = 0 OR checked_out = ' . (int) $userId . ')'; - } - - // Update the publishing state for rows with the given primary keys. - $this->_db->setQuery( - 'UPDATE `' . $this->_tbl . '`' . - ' SET `state` = ' . (int) $state . - ' WHERE (' . $where . ')' . - $checkin - ); - $this->_db->execute(); - - // If checkin is supported and all rows were adjusted, check them in. - if ($checkin && (count($pks) == $this->_db->getAffectedRows())) - { - // Checkin each row. - foreach ($pks as $pk) - { - $this->checkin($pk); - } - } - - // If the JTable instance value is in the list of primary keys that were set, set the instance. - if (in_array($this->$k, $pks)) - { - $this->state = $state; - } - - return true; - } - - /** - * Define a namespaced asset name for inclusion in the #__assets table - * - * @return string The asset name - * - * @see JTable::_getAssetName - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - - return 'com_subusers.organization.' . (int) $this->$k; - } - - /** - * Returns the parent asset's id. If you have a tree structure, retrieve the parent's id using the external key field - * - * @param JTable $table Table name - * @param integer $id Id - * - * @see JTable::_getAssetParentId - * - * @return mixed The id on success, false on failure. - */ - protected function _getAssetParentId(JTable $table = null, $id = null) - { - // We will retrieve the parent-asset from the Asset-table - $assetParent = JTable::getInstance('Asset'); - - // Default: if no asset-parent can be found we take the global asset - $assetParentId = $assetParent->getRootId(); - - // The item has the component as asset-parent - $assetParent->loadByName('com_subusers'); - - // Return the found asset-parent-id - if ($assetParent->id) - { - $assetParentId = $assetParent->id; - } - - return $assetParentId; - } - - /** - * Delete a record by id - * - * @param mixed $pk Primary key value to delete. Optional - * - * @return bool - */ - public function delete($pk = null) - { - $this->load($pk); - $result = parent::delete($pk); - - if ($result) - { - jimport('joomla.filesystem.file'); - - foreach ($this->logo as $logoFile) - { - JFile::delete(JPATH_ROOT . '/images/partners/' . $logoFile); - } - } - - return $result; - } -} diff --git a/src/administrator/tables/mapping.php b/src/administrator/tables/mapping.php index 0a77c65..6a4d74b 100755 --- a/src/administrator/tables/mapping.php +++ b/src/administrator/tables/mapping.php @@ -4,7 +4,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @copyright Copyright (C) 2005 - 2014. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access @@ -41,11 +41,11 @@ public function __construct(&$db) */ public function bind($array, $ignore = '') { - if ($array['id'] == 0) { $array['created_by'] = JFactory::getUser()->id; } + $input = JFactory::getApplication()->input; $task = $input->getString('task', ''); @@ -132,7 +132,6 @@ public function check() { $this->ordering = self::getNextOrder(); } - return parent::check(); } @@ -273,7 +272,7 @@ public function delete($pk = null) { $this->load($pk); $result = parent::delete($pk); - + return $result; } } diff --git a/src/administrator/tables/organization.php b/src/administrator/tables/organization.php deleted file mode 100755 index 5cee1c1..0000000 --- a/src/administrator/tables/organization.php +++ /dev/null @@ -1,372 +0,0 @@ - - * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -use Joomla\Utilities\ArrayHelper; -/** - * organization Table class - * - * @since 1.6 - */ -class SubusersTableorganization extends JTable -{ - /** - * Constructor - * - * @param JDatabase &$db A database connector object - */ - public function __construct(&$db) - { - parent::__construct('#__tjsu_organizations', 'id', $db); - } - - /** - * Overloaded bind function to pre-process the params. - * - * @param array $array Named array - * @param mixed $ignore Optional array or list of parameters to ignore - * - * @return null|string null is operation was satisfactory, otherwise returns an error - * - * @see JTable:bind - * @since 1.5 - */ - public function bind($array, $ignore = '') - { - $input = JFactory::getApplication()->input; - $task = $input->getString('task', ''); - - if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_subusers') && $array['state'] == 1)) - { - $array['state'] = 0; - } - // Support for multi file field: logo - if (!empty($array['logo'])) - { - if (is_array($array['logo'])) - { - $array['logo'] = implode(',', $array['logo']); - } - elseif (strpos($array['logo'], ',') != false) - { - $array['logo'] = explode(',', $array['logo']); - } - } - else - { - $array['logo'] = ''; - } - - if (isset($array['params']) && is_array($array['params'])) - { - $registry = new JRegistry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - if (!JFactory::getUser()->authorise('core.admin', 'com_subusers.organization.' . $array['id'])) - { - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_subusers/access.xml', - "/access/section[@name='organization']/" - ); - $default_actions = JAccess::getAssetRules('com_subusers.organization.' . $array['id'])->getData(); - $array_jaccess = array(); - - foreach ($actions as $action) - { - $array_jaccess[$action->name] = $default_actions[$action->name]; - } - - $array['rules'] = $this->JAccessRulestoArray($array_jaccess); - } - - // Bind the rules for ACL where supported. - if (isset($array['rules']) && is_array($array['rules'])) - { - $this->setRules($array['rules']); - } - - return parent::bind($array, $ignore); - } - - /** - * This function convert an array of JAccessRule objects into an rules array. - * - * @param array $jaccessrules An array of JAccessRule objects. - * - * @return array - */ - private function JAccessRulestoArray($jaccessrules) - { - $rules = array(); - - foreach ($jaccessrules as $action => $jaccess) - { - $actions = array(); - - foreach ($jaccess->getData() as $group => $allow) - { - $actions[$group] = ((bool) $allow); - } - - $rules[$action] = $actions; - } - - return $rules; - } - - /** - * Overloaded check function - * - * @return bool - */ - public function check() - { - // If there is an ordering column and this is a new row then get the next ordering value - if (property_exists($this, 'ordering') && $this->id == 0) - { - $this->ordering = self::getNextOrder(); - } - - // Support multi file field: logo - $app = JFactory::getApplication(); - $files = $app->input->files->get('jform', array(), 'raw'); - $array = $app->input->get('jform', array(), 'ARRAY'); - - if (!empty($files['logo'])) - { - $this->logo = ""; - - foreach ($files['logo'] as $singleFile ) - { - jimport('joomla.filesystem.file'); - - // Check if the server found any error. - $fileError = $singleFile['error']; - $message = ''; - - if ($fileError > 0 && $fileError != 4) - { - switch ($fileError) - { - case 1: - $message = JText::_('File size exceeds allowed by the server'); - break; - case 2: - $message = JText::_('File size exceeds allowed by the html form'); - break; - case 3: - $message = JText::_('Partial upload error'); - break; - } - - if ($message != '') - { - $app->enqueueMessage($message, 'warning'); - - return false; - } - } - elseif ($fileError == 4) - { - if (isset($array['logo'])) - { - $this->logo = $array['logo']; - } - } - else - { - // Replace any special characters in the filename - jimport('joomla.filesystem.file'); - $filename = JFile::stripExt($singleFile['name']); - $extension = JFile::getExt($singleFile['name']); - $filename = preg_replace("/[^A-Za-z0-9]/i", "-", $filename); - $filename = $filename . '.' . $extension; - $uploadPath = JPATH_ROOT . '/images/com_subusers/partners/' . $filename; - $fileTemp = $singleFile['tmp_name']; - - if (!JFile::exists($uploadPath)) - { - if (!JFile::upload($fileTemp, $uploadPath)) - { - $app->enqueueMessage('Error moving file', 'warning'); - - return false; - } - } - - $this->logo .= (!empty($this->logo)) ? "," : ""; - $this->logo .= $filename; - } - } - } - - return parent::check(); - } - - /** - * Method to set the publishing state for a row or list of rows in the database - * table. The method respects checked out rows by other users and will attempt - * to checkin rows that it can after adjustments are made. - * - * @param mixed $pks An optional array of primary key values to update. If not - * set the instance property value is used. - * @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] - * @param integer $userId The user id of the user performing the operation. - * - * @return boolean True on success. - * - * @since 1.0.4 - * - * @throws Exception - */ - public function publish($pks = null, $state = 1, $userId = 0) - { - // Initialise variables. - $k = $this->_tbl_key; - - // Sanitize input. - ArrayHelper::toInteger($pks); - $userId = (int) $userId; - $state = (int) $state; - - // If there are no primary keys set check to see if the instance key is set. - if (empty($pks)) - { - if ($this->$k) - { - $pks = array($this->$k); - } - // Nothing to set publishing state on, return false. - else - { - throw new Exception(500, JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); - } - } - - // Build the WHERE clause for the primary keys. - $where = $k . '=' . implode(' OR ' . $k . '=', $pks); - - // Determine if there is checkin support for the table. - if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) - { - $checkin = ''; - } - else - { - $checkin = ' AND (checked_out = 0 OR checked_out = ' . (int) $userId . ')'; - } - - // Update the publishing state for rows with the given primary keys. - $this->_db->setQuery( - 'UPDATE `' . $this->_tbl . '`' . - ' SET `state` = ' . (int) $state . - ' WHERE (' . $where . ')' . - $checkin - ); - $this->_db->execute(); - - // If checkin is supported and all rows were adjusted, check them in. - if ($checkin && (count($pks) == $this->_db->getAffectedRows())) - { - // Checkin each row. - foreach ($pks as $pk) - { - $this->checkin($pk); - } - } - - // If the JTable instance value is in the list of primary keys that were set, set the instance. - if (in_array($this->$k, $pks)) - { - $this->state = $state; - } - - return true; - } - - /** - * Define a namespaced asset name for inclusion in the #__assets table - * - * @return string The asset name - * - * @see JTable::_getAssetName - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - - return 'com_subusers.organization.' . (int) $this->$k; - } - - /** - * Returns the parent asset's id. If you have a tree structure, retrieve the parent's id using the external key field - * - * @param JTable $table Table name - * @param integer $id Id - * - * @see JTable::_getAssetParentId - * - * @return mixed The id on success, false on failure. - */ - protected function _getAssetParentId(JTable $table = null, $id = null) - { - // We will retrieve the parent-asset from the Asset-table - $assetParent = JTable::getInstance('Asset'); - - // Default: if no asset-parent can be found we take the global asset - $assetParentId = $assetParent->getRootId(); - - // The item has the component as asset-parent - $assetParent->loadByName('com_subusers'); - - // Return the found asset-parent-id - if ($assetParent->id) - { - $assetParentId = $assetParent->id; - } - - return $assetParentId; - } - - /** - * Delete a record by id - * - * @param mixed $pk Primary key value to delete. Optional - * - * @return bool - */ - public function delete($pk = null) - { - $this->load($pk); - $result = parent::delete($pk); - - if ($result) - { - jimport('joomla.filesystem.file'); - - foreach ($this->logo as $logoFile) - { - JFile::delete(JPATH_ROOT . '/images/com_subusers/partners/' . $logoFile); - } - } - - return $result; - } -} diff --git a/src/administrator/tables/role.php b/src/administrator/tables/role.php index b28494e..2d51399 100755 --- a/src/administrator/tables/role.php +++ b/src/administrator/tables/role.php @@ -1,22 +1,23 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access + defined('_JEXEC') or die; -use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; + /** * role Table class * - * @since 1.6 + * @since 1.0.0 */ -class SubusersTablerole extends JTable +class SubusersTablerole extends Table { /** * Constructor @@ -28,102 +29,10 @@ public function __construct(&$db) parent::__construct('#__tjsu_roles', 'id', $db); } - /** - * Overloaded bind function to pre-process the params. - * - * @param array $array Named array - * @param mixed $ignore Optional array or list of parameters to ignore - * - * @return null|string null is operation was satisfactory, otherwise returns an error - * - * @see JTable:bind - * @since 1.5 - */ - public function bind($array, $ignore = '') - { - - if ($array['id'] == 0) - { - $array['created_by'] = JFactory::getUser()->id; - } - $input = JFactory::getApplication()->input; - $task = $input->getString('task', ''); - - if (($task == 'save' || $task == 'apply') && (!JFactory::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->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - if (!JFactory::getUser()->authorise('core.admin', 'com_subusers.role.' . $array['id'])) - { - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_subusers/access.xml', - "/access/section[@name='role']/" - ); - $default_actions = JAccess::getAssetRules('com_subusers.role.' . $array['id'])->getData(); - $array_jaccess = array(); - - foreach ($actions as $action) - { - $array_jaccess[$action->name] = $default_actions[$action->name]; - } - - $array['rules'] = $this->JAccessRulestoArray($array_jaccess); - } - - // Bind the rules for ACL where supported. - if (isset($array['rules']) && is_array($array['rules'])) - { - $this->setRules($array['rules']); - } - - return parent::bind($array, $ignore); - } - - /** - * This function convert an array of JAccessRule objects into an rules array. - * - * @param array $jaccessrules An array of JAccessRule objects. - * - * @return array - */ - private function JAccessRulestoArray($jaccessrules) - { - $rules = array(); - - foreach ($jaccessrules as $action => $jaccess) - { - $actions = array(); - - foreach ($jaccess->getData() as $group => $allow) - { - $actions[$group] = ((bool) $allow); - } - - $rules[$action] = $actions; - } - - return $rules; - } - /** * Overloaded check function * - * @return bool + * @return boolean */ public function check() { @@ -132,148 +41,35 @@ public function check() { $this->ordering = self::getNextOrder(); } - return parent::check(); } /** - * Method to set the publishing state for a row or list of rows in the database - * table. The method respects checked out rows by other users and will attempt - * to checkin rows that it can after adjustments are made. - * - * @param mixed $pks An optional array of primary key values to update. If not - * set the instance property value is used. - * @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] - * @param integer $userId The user id of the user performing the operation. + * Overrides Table::store to set modified data and user id. * - * @return boolean True on success. + * @param boolean $updateNulls True to update fields even if they are null. * - * @since 1.0.4 + * @return boolean True on success. * - * @throws Exception + * @since 1.0.0 */ - public function publish($pks = null, $state = 1, $userId = 0) + public function store($updateNulls = false) { - // Initialise variables. - $k = $this->_tbl_key; + $date = Factory::getDate(); + $user = Factory::getUser(); - // Sanitize input. - ArrayHelper::toInteger($pks); - $userId = (int) $userId; - $state = (int) $state; - - // If there are no primary keys set check to see if the instance key is set. - if (empty($pks)) + if ($this->id) { - if ($this->$k) - { - $pks = array($this->$k); - } - // Nothing to set publishing state on, return false. - else - { - throw new Exception(500, JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); - } - } - - // Build the WHERE clause for the primary keys. - $where = $k . '=' . implode(' OR ' . $k . '=', $pks); - - // Determine if there is checkin support for the table. - if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) - { - $checkin = ''; + $this->modified_by = $user->id; + $this->modified_date = $date->toSql(); } else { - $checkin = ' AND (checked_out = 0 OR checked_out = ' . (int) $userId . ')'; - } - - // Update the publishing state for rows with the given primary keys. - $this->_db->setQuery( - 'UPDATE `' . $this->_tbl . '`' . - ' SET `state` = ' . (int) $state . - ' WHERE (' . $where . ')' . - $checkin - ); - $this->_db->execute(); - - // If checkin is supported and all rows were adjusted, check them in. - if ($checkin && (count($pks) == $this->_db->getAffectedRows())) - { - // Checkin each row. - foreach ($pks as $pk) - { - $this->checkin($pk); - } - } - - // If the JTable instance value is in the list of primary keys that were set, set the instance. - if (in_array($this->$k, $pks)) - { - $this->state = $state; - } - - return true; - } - - /** - * Define a namespaced asset name for inclusion in the #__assets table - * - * @return string The asset name - * - * @see JTable::_getAssetName - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - - return 'com_subusers.role.' . (int) $this->$k; - } - - /** - * Returns the parent asset's id. If you have a tree structure, retrieve the parent's id using the external key field - * - * @param JTable $table Table name - * @param integer $id Id - * - * @see JTable::_getAssetParentId - * - * @return mixed The id on success, false on failure. - */ - protected function _getAssetParentId(JTable $table = null, $id = null) - { - // We will retrieve the parent-asset from the Asset-table - $assetParent = JTable::getInstance('Asset'); - - // Default: if no asset-parent can be found we take the global asset - $assetParentId = $assetParent->getRootId(); - - // The item has the component as asset-parent - $assetParent->loadByName('com_subusers'); - - // Return the found asset-parent-id - if ($assetParent->id) - { - $assetParentId = $assetParent->id; + $this->created_by = $user->id; + $this->created_date = $date->toSql(); } - return $assetParentId; - } - - /** - * Delete a record by id - * - * @param mixed $pk Primary key value to delete. Optional - * - * @return bool - */ - public function delete($pk = null) - { - $this->load($pk); - $result = parent::delete($pk); - - return $result; + return parent::store($updateNulls); } } diff --git a/src/administrator/tables/user.php b/src/administrator/tables/user.php index f3f14bc..26aee90 100755 --- a/src/administrator/tables/user.php +++ b/src/administrator/tables/user.php @@ -1,22 +1,23 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access + defined('_JEXEC') or die; -use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; + /** * user Table class * - * @since 1.6 + * @since 1.0.0 */ -class SubusersTableuser extends JTable +class SubusersTableuser extends Table { /** * Constructor @@ -28,102 +29,10 @@ public function __construct(&$db) parent::__construct('#__tjsu_users', 'id', $db); } - /** - * Overloaded bind function to pre-process the params. - * - * @param array $array Named array - * @param mixed $ignore Optional array or list of parameters to ignore - * - * @return null|string null is operation was satisfactory, otherwise returns an error - * - * @see JTable:bind - * @since 1.5 - */ - public function bind($array, $ignore = '') - { - - if ($array['id'] == 0) - { - $array['created_by'] = JFactory::getUser()->id; - } - $input = JFactory::getApplication()->input; - $task = $input->getString('task', ''); - - if (($task == 'save' || $task == 'apply') && (!JFactory::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->loadArray($array['params']); - $array['params'] = (string) $registry; - } - - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new JRegistry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - if (!JFactory::getUser()->authorise('core.admin', 'com_subusers.user.' . $array['id'])) - { - $actions = JAccess::getActionsFromFile( - JPATH_ADMINISTRATOR . '/components/com_subusers/access.xml', - "/access/section[@name='user']/" - ); - $default_actions = JAccess::getAssetRules('com_subusers.user.' . $array['id'])->getData(); - $array_jaccess = array(); - - foreach ($actions as $action) - { - $array_jaccess[$action->name] = $default_actions[$action->name]; - } - - $array['rules'] = $this->JAccessRulestoArray($array_jaccess); - } - - // Bind the rules for ACL where supported. - if (isset($array['rules']) && is_array($array['rules'])) - { - $this->setRules($array['rules']); - } - - return parent::bind($array, $ignore); - } - - /** - * This function convert an array of JAccessRule objects into an rules array. - * - * @param array $jaccessrules An array of JAccessRule objects. - * - * @return array - */ - private function JAccessRulestoArray($jaccessrules) - { - $rules = array(); - - foreach ($jaccessrules as $action => $jaccess) - { - $actions = array(); - - foreach ($jaccess->getData() as $group => $allow) - { - $actions[$group] = ((bool) $allow); - } - - $rules[$action] = $actions; - } - - return $rules; - } - /** * Overloaded check function * - * @return bool + * @return boolean */ public function check() { @@ -132,148 +41,35 @@ public function check() { $this->ordering = self::getNextOrder(); } - return parent::check(); } /** - * Method to set the publishing state for a row or list of rows in the database - * table. The method respects checked out rows by other users and will attempt - * to checkin rows that it can after adjustments are made. - * - * @param mixed $pks An optional array of primary key values to update. If not - * set the instance property value is used. - * @param integer $state The publishing state. eg. [0 = unpublished, 1 = published] - * @param integer $userId The user id of the user performing the operation. + * Overrides Table::store to set modified data and user id. * - * @return boolean True on success. + * @param boolean $updateNulls True to update fields even if they are null. * - * @since 1.0.4 + * @return boolean True on success. * - * @throws Exception + * @since 1.0.0 */ - public function publish($pks = null, $state = 1, $userId = 0) + public function store($updateNulls = false) { - // Initialise variables. - $k = $this->_tbl_key; + $date = Factory::getDate(); + $user = Factory::getUser(); - // Sanitize input. - ArrayHelper::toInteger($pks); - $userId = (int) $userId; - $state = (int) $state; - - // If there are no primary keys set check to see if the instance key is set. - if (empty($pks)) + if ($this->id) { - if ($this->$k) - { - $pks = array($this->$k); - } - // Nothing to set publishing state on, return false. - else - { - throw new Exception(500, JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); - } - } - - // Build the WHERE clause for the primary keys. - $where = $k . '=' . implode(' OR ' . $k . '=', $pks); - - // Determine if there is checkin support for the table. - if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) - { - $checkin = ''; + $this->modified_by = $user->id; + $this->modified_date = $date->toSql(); } else { - $checkin = ' AND (checked_out = 0 OR checked_out = ' . (int) $userId . ')'; - } - - // Update the publishing state for rows with the given primary keys. - $this->_db->setQuery( - 'UPDATE `' . $this->_tbl . '`' . - ' SET `state` = ' . (int) $state . - ' WHERE (' . $where . ')' . - $checkin - ); - $this->_db->execute(); - - // If checkin is supported and all rows were adjusted, check them in. - if ($checkin && (count($pks) == $this->_db->getAffectedRows())) - { - // Checkin each row. - foreach ($pks as $pk) - { - $this->checkin($pk); - } - } - - // If the JTable instance value is in the list of primary keys that were set, set the instance. - if (in_array($this->$k, $pks)) - { - $this->state = $state; - } - - return true; - } - - /** - * Define a namespaced asset name for inclusion in the #__assets table - * - * @return string The asset name - * - * @see JTable::_getAssetName - */ - protected function _getAssetName() - { - $k = $this->_tbl_key; - - return 'com_subusers.user.' . (int) $this->$k; - } - - /** - * Returns the parent asset's id. If you have a tree structure, retrieve the parent's id using the external key field - * - * @param JTable $table Table name - * @param integer $id Id - * - * @see JTable::_getAssetParentId - * - * @return mixed The id on success, false on failure. - */ - protected function _getAssetParentId(JTable $table = null, $id = null) - { - // We will retrieve the parent-asset from the Asset-table - $assetParent = JTable::getInstance('Asset'); - - // Default: if no asset-parent can be found we take the global asset - $assetParentId = $assetParent->getRootId(); - - // The item has the component as asset-parent - $assetParent->loadByName('com_subusers'); - - // Return the found asset-parent-id - if ($assetParent->id) - { - $assetParentId = $assetParent->id; + $this->created_by = $user->id; + $this->created_date = $date->toSql(); } - return $assetParentId; - } - - /** - * Delete a record by id - * - * @param mixed $pk Primary key value to delete. Optional - * - * @return bool - */ - public function delete($pk = null) - { - $this->load($pk); - $result = parent::delete($pk); - - return $result; + return parent::store($updateNulls); } } diff --git a/src/administrator/views/action/tmpl/edit.php b/src/administrator/views/action/tmpl/edit.php index 38626b9..a043df5 100755 --- a/src/administrator/views/action/tmpl/edit.php +++ b/src/administrator/views/action/tmpl/edit.php @@ -1,90 +1,52 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 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::_('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="action-form" class="form-validate">
- 'general')); ?> - -
-
-
- - -
-
form->getLabel('name'); ?>
-
form->getInput('name'); ?>
-
- - - item->created_by)){ ?> - - - - - - - - - - - -
+
+ form->renderField('id'); ?> + form->renderField('name'); ?> + form->renderField('code'); ?> + form->renderField('client'); ?> + form->getInput('created_date'); ?>
- - - - - - - - - + +
diff --git a/src/administrator/views/action/view.html.php b/src/administrator/views/action/view.html.php index 6960157..1aad14c 100755 --- a/src/administrator/views/action/view.html.php +++ b/src/administrator/views/action/view.html.php @@ -1,23 +1,23 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access + defined('_JEXEC') or die; -jimport('joomla.application.component.view'); +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\View\HtmlView; /** * View to edit * * @since 1.6 */ -class SubusersViewAction extends JViewLegacy +class SubusersViewAction extends HtmlView { protected $state; @@ -59,14 +59,14 @@ public function display($tpl = null) */ protected function addToolbar() { - JFactory::getApplication()->input->set('hidemainmenu', true); + Factory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); + $user = Factory::getUser(); $isNew = ($this->item->id == 0); if (isset($this->item->checked_out)) { - $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); + $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->id); } else { diff --git a/src/administrator/views/actions/tmpl/default.php b/src/administrator/views/actions/tmpl/default.php index d9c8bf1..5c9369b 100755 --- a/src/administrator/views/actions/tmpl/default.php +++ b/src/administrator/views/actions/tmpl/default.php @@ -1,238 +1,138 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 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=actions.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'actionList', 'adminForm', strtolower($listDirn), $saveOrderingUrl); -} - -$sortFields = $this->getSortFields(); -?> - - -extra_sidebar)) -{ - $this->sidebar .= $this->extra_sidebar; -} - ?> -
- sidebar)): ?> -
- sidebar; ?> -
-
- -
- +
+
+ -
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - + sidebar)) + { + ?> +
+ sidebar; ?>
-
- - +
+ +
+ $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->name); ?> + + + escape($item->name); ?> + + +
+
escape($item->code); ?>escape($item->client); ?>id; ?>
+ - - - items[0]->ordering)) : ?> - - - - - - - - - - - - - - - id); ?> - - items[0]->state)): ?> - - state, $i, 'actions.', $canChange, 'cb'); ?> - - - - - checked_out) && $item->checked_out && ($canEdit || $canChange)) : ?> - editor, $item->checked_out_time, 'actions.', $canCheckin); ?> - - - - escape($item->name); ?> - - escape($item->name); ?> - - - - - items[0]->id)): ?> - - id; ?> - - - - - - - - - - - - -
- + + + +
+ +
+
diff --git a/src/administrator/views/actions/view.html.php b/src/administrator/views/actions/view.html.php index 03124af..107c757 100755 --- a/src/administrator/views/actions/view.html.php +++ b/src/administrator/views/actions/view.html.php @@ -1,30 +1,81 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access + defined('_JEXEC') or die; -jimport('joomla.application.component.view'); +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\View\HtmlView; /** * View class for a list of Subusers. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersViewActions extends JViewLegacy +class SubusersViewActions 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,8 +90,11 @@ 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 = JHelperContent::getActions('com_subusers'); - // Check for errors. if (count($errors = $this->get('Errors'))) { throw new Exception(implode("\n", $errors)); @@ -49,8 +103,8 @@ public function display($tpl = null) SubusersHelper::addSubmenu('actions'); $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); + parent::display($tpl); } @@ -59,107 +113,34 @@ 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_ACTIONS'), 'actions.png'); + JToolBarHelper::title(JText::_('COM_SUBUSERS_TITLE_ACTIONS'), ''); - // Check if the form exists before showing the add/edit buttons - $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/action'; + $canDo = $this->canDo; - if (file_exists($formPath)) + if ($canDo->get('core.create')) { - if ($canDo->get('core.create')) - { - JToolBarHelper::addNew('action.add', 'JTOOLBAR_NEW'); - JToolbarHelper::custom('actions.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); - } - - if ($canDo->get('core.edit') && isset($this->items[0])) - { - JToolBarHelper::editList('action.edit', 'JTOOLBAR_EDIT'); - } + JToolbarHelper::addNew('action.add'); } - if ($canDo->get('core.edit.state')) + if ($canDo->get('core.edit')) { - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::custom('actions.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); - JToolBarHelper::custom('actions.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('', 'actions.delete', 'JTOOLBAR_DELETE'); - } - - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::archiveList('actions.archive', 'JTOOLBAR_ARCHIVE'); - } - - if (isset($this->items[0]->checked_out)) - { - JToolBarHelper::custom('actions.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); - } + JToolbarHelper::editList('actions.edit'); } - // Show trash and delete for components that uses the state field - if (isset($this->items[0]->state)) + if ($canDo->get('core.delete')) { - if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) - { - JToolBarHelper::deleteList('', 'actions.delete', 'JTOOLBAR_EMPTY_TRASH'); - JToolBarHelper::divider(); - } - elseif ($canDo->get('core.edit.state')) - { - JToolBarHelper::trash('actions.trash', 'JTOOLBAR_TRASH'); - JToolBarHelper::divider(); - } + JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'actions.delete', 'JTOOLBAR_DELETE'); + JToolbarHelper::divider(); } - if ($canDo->get('core.admin')) + if ($canDo->get('core.admin') || $canDo->get('core.options')) { - JToolBarHelper::preferences('com_subusers'); + JToolbarHelper::preferences('com_subusers'); + JToolbarHelper::divider(); } - - // Set sidebar action - New in 3.0 - JHtmlSidebar::setAction('index.php?option=com_subusers&view=actions'); - - $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_ACTIONS_NAME'), - 'a.`ordering`' => JText::_('JGRID_HEADING_ORDERING'), - 'a.`state`' => JText::_('JSTATUS'), - ); } } diff --git a/src/administrator/views/mapping/view.html.php b/src/administrator/views/mapping/view.html.php index ed858ac..8557b72 100755 --- a/src/administrator/views/mapping/view.html.php +++ b/src/administrator/views/mapping/view.html.php @@ -4,7 +4,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @copyright Copyright (C) 2005 - 2014. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access diff --git a/src/administrator/views/mappings/view.html.php b/src/administrator/views/mappings/view.html.php index b88de0e..37c23dc 100755 --- a/src/administrator/views/mappings/view.html.php +++ b/src/administrator/views/mappings/view.html.php @@ -4,7 +4,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @copyright Copyright (C) 2005 - 2014. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access @@ -149,9 +149,9 @@ protected function addToolbar() } /** - * Method to order fields + * Method to order fields * - * @return void + * @return void */ protected function getSortFields() { diff --git a/src/administrator/views/organization/tmpl/edit.php b/src/administrator/views/organization/tmpl/edit.php deleted file mode 100755 index a6cb716..0000000 --- a/src/administrator/views/organization/tmpl/edit.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Copyright (C) 2015. 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::_('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'); -?> - - -
- -
- 'general')); ?> - -
-
-
-
-
form->getLabel('id'); ?>
-
form->getInput('id'); ?>
-
- -
-
form->getLabel('name'); ?>
-
form->getInput('name'); ?>
-
- - - - - - - -
-
form->getLabel('email'); ?>
-
form->getInput('email'); ?>
-
- -
-
form->getLabel('logo'); ?>
-
form->getInput('logo'); ?>
-
- - item->logo)) : ?> - item->logo as $fileSingle) : ?> - - | - - - - -
-
-
- - - - -
-
diff --git a/src/administrator/views/organization/view.html.php b/src/administrator/views/organization/view.html.php deleted file mode 100755 index eb3d2a4..0000000 --- a/src/administrator/views/organization/view.html.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View to edit - * - * @since 1.6 - */ -class SubusersViewOrganization extends JViewLegacy -{ - protected $state; - - protected $item; - - protected $form; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $this->state = $this->get('State'); - $this->item = $this->get('Item'); - $this->form = $this->get('Form'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - $this->addToolbar(); - parent::display($tpl); - } - - /** - * Add the page title and toolbar. - * - * @return void - * - * @throws Exception - */ - protected function addToolbar() - { - JFactory::getApplication()->input->set('hidemainmenu', true); - - $user = JFactory::getUser(); - $isNew = ($this->item->id == 0); - - 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_ORGANIZATION'), 'organization.png'); - - // If not checked out, can save the item. - if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) - { - JToolBarHelper::apply('organization.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('organization.save', 'JTOOLBAR_SAVE'); - } - - if (!$checkedOut && ($canDo->get('core.create'))) - { - JToolBarHelper::custom('organization.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('organization.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); - } - - if (empty($this->item->id)) - { - JToolBarHelper::cancel('organization.cancel', 'JTOOLBAR_CANCEL'); - } - else - { - JToolBarHelper::cancel('organization.cancel', 'JTOOLBAR_CLOSE'); - } - } -} diff --git a/src/administrator/views/organizations/index.html b/src/administrator/views/organizations/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/administrator/views/organizations/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/administrator/views/organizations/tmpl/default.php b/src/administrator/views/organizations/tmpl/default.php deleted file mode 100755 index 07dab9d..0000000 --- a/src/administrator/views/organizations/tmpl/default.php +++ /dev/null @@ -1,264 +0,0 @@ - - * @copyright Copyright (C) 2015. 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'); - -// Import CSS -$document = JFactory::getDocument(); -$document->addStyleSheet(JPATH_ROOT . 'media/com_subusers/css/list.css'); - -$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=organizations.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'organizationList', 'adminForm', strtolower($listDirn), $saveOrderingUrl); -} - -$sortFields = $this->getSortFields(); -?> - - -extra_sidebar)) -{ - $this->sidebar .= $this->extra_sidebar; -}?> - -
- sidebar)): ?> -
- sidebar; ?> -
- -
- -
- - -
- - -
- - -
- -
- - pagination->getLimitBox(); ?> -
- -
- - -
- -
- - -
-
- -
- - - - - 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'); - ?> - - items[0]->ordering)) : ?> - - - - items[0]->state)): ?> - - - - - - - - - - items[0]->id)): ?> - - - - - -
- ', 'a.`ordering`', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> - - - - - - - - - - - - -
- pagination->getListFooter(); ?> -
- - - - - - - - - - - - - id); ?> - - state, $i, 'organizations.', $canChange, 'cb'); ?> - - checked_out) && $item->checked_out && ($canEdit || $canChange)) : ?> - editor, $item->checked_out_time, 'organizations.', $canCheckin); ?> - - - - escape($item->name); ?> - - - escape($item->name); ?> - - - created_by; ?> - - email; ?> - - id; ?> -
- - - - - -
- diff --git a/src/administrator/views/organizations/tmpl/index.html b/src/administrator/views/organizations/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/administrator/views/organizations/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/administrator/views/organizations/view.html.php b/src/administrator/views/organizations/view.html.php deleted file mode 100755 index c85903c..0000000 --- a/src/administrator/views/organizations/view.html.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View class for a list of Subusers. - * - * @since 1.6 - */ -class SubusersViewOrganizations extends JViewLegacy -{ - protected $items; - - protected $pagination; - - protected $state; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $this->state = $this->get('State'); - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - SubusersHelper::addSubmenu('organizations'); - - $this->addToolbar(); - - $this->sidebar = JHtmlSidebar::render(); - parent::display($tpl); - } - - /** - * Add the page title and toolbar. - * - * @return void - * - * @since 1.6 - */ - 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_ORGANIZATIONS'), 'organizations.png'); - - // Check if the form exists before showing the add/edit buttons - $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/organization'; - - if (file_exists($formPath)) - { - if ($canDo->get('core.create')) - { - JToolBarHelper::addNew('organization.add', 'JTOOLBAR_NEW'); - JToolbarHelper::custom('organizations.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); - } - - if ($canDo->get('core.edit') && isset($this->items[0])) - { - JToolBarHelper::editList('organization.edit', 'JTOOLBAR_EDIT'); - } - } - - if ($canDo->get('core.edit.state')) - { - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::custom('organizations.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); - JToolBarHelper::custom('organizations.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('', 'organizations.delete', 'JTOOLBAR_DELETE'); - } - - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::archiveList('organizations.archive', 'JTOOLBAR_ARCHIVE'); - } - - if (isset($this->items[0]->checked_out)) - { - JToolBarHelper::custom('organizations.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); - } - } - - // Show trash and delete for components that uses the state field - if (isset($this->items[0]->state)) - { - if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) - { - JToolBarHelper::deleteList('', 'organizations.delete', 'JTOOLBAR_EMPTY_TRASH'); - JToolBarHelper::divider(); - } - elseif ($canDo->get('core.edit.state')) - { - JToolBarHelper::trash('organizations.trash', 'JTOOLBAR_TRASH'); - JToolBarHelper::divider(); - } - } - - if ($canDo->get('core.admin')) - { - JToolbarHelper::custom('database.fix', 'refresh', 'refresh', 'COM_SUBUSERS_TOOLBAR_DATABASE_FIX', false); - JToolBarHelper::preferences('com_subusers'); - } - - // Set sidebar action - New in 3.0 - JHtmlSidebar::setAction('index.php?option=com_subusers&view=organizations'); - - $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_ORGANIZATIONS_NAME'), - 'a.`created_by`' => JText::_('COM_SUBUSERS_ORGANIZATIONS_CREATED_BY'), - 'a.`ordering`' => JText::_('JGRID_HEADING_ORDERING'), - 'a.`state`' => JText::_('JSTATUS'), - 'a.`email`' => JText::_('COM_SUBUSERS_ORGANIZATIONS_EMAIL'), - ); - } -} diff --git a/src/administrator/views/role/tmpl/edit.php b/src/administrator/views/role/tmpl/edit.php index 1a0f39c..c56f964 100755 --- a/src/administrator/views/role/tmpl/edit.php +++ b/src/administrator/views/role/tmpl/edit.php @@ -1,90 +1,55 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 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::_('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="role-form" class="form-validate">
- 'general')); ?> - -
-
-
- - -
-
form->getLabel('name'); ?>
-
form->getInput('name'); ?>
-
- - - item->created_by)){ ?> - - - - - - - - - - - -
+
+ form->renderField('id'); ?> + form->renderField('name'); ?> + form->renderField('client'); ?> + form->getInput('created_by'); ?> + form->getInput('modified_by'); ?> + form->getInput('modified_date'); ?> + form->getInput('created_date'); ?> + form->getInput('ordering'); ?>
- - - - - - - - - + +
- + \ No newline at end of file diff --git a/src/administrator/views/role/view.html.php b/src/administrator/views/role/view.html.php index aa2f34e..7cc65ef 100755 --- a/src/administrator/views/role/view.html.php +++ b/src/administrator/views/role/view.html.php @@ -1,23 +1,23 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access + defined('_JEXEC') or die; -jimport('joomla.application.component.view'); +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\View\HtmlView; /** * View to edit * * @since 1.6 */ -class SubusersViewRole extends JViewLegacy +class SubusersViewRole extends HtmlView { protected $state; @@ -59,14 +59,14 @@ public function display($tpl = null) */ protected function addToolbar() { - JFactory::getApplication()->input->set('hidemainmenu', true); + Factory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); + $user = Factory::getUser(); $isNew = ($this->item->id == 0); if (isset($this->item->checked_out)) { - $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); + $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->id); } else { diff --git a/src/administrator/views/roles/tmpl/default.php b/src/administrator/views/roles/tmpl/default.php index 9ca502a..d6c5680 100755 --- a/src/administrator/views/roles/tmpl/default.php +++ b/src/administrator/views/roles/tmpl/default.php @@ -139,15 +139,10 @@ class="element-invisible"> - items[0]->state)): ?> - - - - - - - + + + items[0]->id)): ?> @@ -201,9 +196,7 @@ class="element-invisible"> id); ?> items[0]->state)): ?> - - state, $i, 'roles.', $canChange, 'cb'); ?> - + @@ -235,4 +228,4 @@ class="element-invisible">
- + diff --git a/src/administrator/views/roles/view.html.php b/src/administrator/views/roles/view.html.php index eda0045..9767b1d 100755 --- a/src/administrator/views/roles/view.html.php +++ b/src/administrator/views/roles/view.html.php @@ -4,7 +4,7 @@ * @version CVS: 1.0.0 * @package Com_Subusers * @author Techjoomla - * @copyright Copyright (C) 2015. All rights reserved. + * @copyright Copyright (C) 2005 - 2014. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access @@ -128,6 +128,12 @@ protected function addToolbar() } } + if ($canDo->get('core.delete')) + { + JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'roles.delete', 'JTOOLBAR_DELETE'); + JToolbarHelper::divider(); + } + if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_subusers'); @@ -149,17 +155,15 @@ protected function addToolbar() } /** - * Method to order fields + * Method to order fields * - * @return void + * @return void */ protected function getSortFields() { return array( 'a.`id`' => JText::_('JGRID_HEADING_ID'), - 'a.`name`' => JText::_('COM_SUBUSERS_ROLES_NAME'), - 'a.`ordering`' => JText::_('JGRID_HEADING_ORDERING'), - 'a.`state`' => JText::_('JSTATUS'), + 'a.`name`' => JText::_('COM_SUBUSERS_ROLES_NAME') ); } } diff --git a/src/administrator/views/user/tmpl/edit.php b/src/administrator/views/user/tmpl/edit.php index 2b7fe11..e191814 100755 --- a/src/administrator/views/user/tmpl/edit.php +++ b/src/administrator/views/user/tmpl/edit.php @@ -1,95 +1,56 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 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::_('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="user-form" class="form-validate">
- 'general')); ?> - -
-
-
- - -
-
form->getLabel('user_id'); ?>
-
form->getInput('user_id'); ?>
-
- -
-
form->getLabel('client_id'); ?>
-
form->getInput('client_id'); ?>
-
- - - item->created_by)){ ?> - - - - - - - - - - - -
+
+ form->renderField('id'); ?> + form->renderField('user_id'); ?> + form->renderField('role_id'); ?> + form->renderField('client'); ?> + form->renderField('client_id'); ?> + form->getInput('created_by'); ?> + form->getInput('created_date'); ?> + form->getInput('modified_by'); ?> + form->getInput('modified_date'); ?>
- - - - - - - - - + +
diff --git a/src/administrator/views/user/view.html.php b/src/administrator/views/user/view.html.php index ac7aa42..5cf56ba 100755 --- a/src/administrator/views/user/view.html.php +++ b/src/administrator/views/user/view.html.php @@ -1,23 +1,23 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access + defined('_JEXEC') or die; -jimport('joomla.application.component.view'); +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\View\HtmlView; /** * View to edit * * @since 1.6 */ -class SubusersViewUser extends JViewLegacy +class SubusersViewUser extends HtmlView { protected $state; @@ -59,14 +59,14 @@ public function display($tpl = null) */ protected function addToolbar() { - JFactory::getApplication()->input->set('hidemainmenu', true); + Factory::getApplication()->input->set('hidemainmenu', true); - $user = JFactory::getUser(); + $user = Factory::getUser(); $isNew = ($this->item->id == 0); if (isset($this->item->checked_out)) { - $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); + $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->id); } else { diff --git a/src/administrator/views/users/tmpl/default.php b/src/administrator/views/users/tmpl/default.php index ecb7c77..bb567f4 100755 --- a/src/administrator/views/users/tmpl/default.php +++ b/src/administrator/views/users/tmpl/default.php @@ -1,249 +1,134 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 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=users.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', 'userList', 'adminForm', strtolower($listDirn), $saveOrderingUrl); -} - -$sortFields = $this->getSortFields(); -?> - - -extra_sidebar)) -{ - $this->sidebar .= $this->extra_sidebar; -} ?> -
- sidebar)): ?> -
- sidebar; ?> -
-
- -
- +
+
+ -
- -
- - -
-
- - pagination->getLimitBox(); ?> + sidebar)) + { + ?> +
+ sidebar; ?>
-
- - +
+ +
+ $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'); - ?> - - items[0]->ordering)) : ?> - + + + + + +
- ', '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'); + ?> + + - - - items[0]->state)): ?> - - + - - - - items[0]->id)): ?> - - - - - -
+ + + + + + + +
+ pagination->getListFooter(); ?> +
+ id); ?> - id); ?> - - state, $i, 'users.', $canChange, 'cb'); ?> - +
+ + + escape($item->name); ?> + + + escape($item->name); ?> + -
- checked_out) && $item->checked_out && ($canEdit || $canChange)) : ?> - editor, $item->checked_out_time, 'users.', $canCheckin); ?> - - - - escape($item->user_id); ?> - - - escape($item->user_id); ?> - - - client_id; ?> - - role_id; ?> - - created_by; ?> - - id; ?> -
- - - - - + +
escape($item->rolename); ?>id; ?>
+ + + + +
+
- +
diff --git a/src/administrator/views/users/view.html.php b/src/administrator/views/users/view.html.php index 35d7bcd..b30707e 100755 --- a/src/administrator/views/users/view.html.php +++ b/src/administrator/views/users/view.html.php @@ -1,30 +1,81 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -// No direct access -defined('_JEXEC') or die; -jimport('joomla.application.component.view'); +defined('_JEXEC') or die(); + +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\View\HtmlView; /** * View class for a list of Subusers. * - * @since 1.6 + * @since 1.0.0 */ -class SubusersViewUsers extends JViewLegacy +class SubusersViewUsers 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,8 +90,11 @@ 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 = JHelperContent::getActions('com_subusers'); - // Check for errors. if (count($errors = $this->get('Errors'))) { throw new Exception(implode("\n", $errors)); @@ -49,8 +103,8 @@ public function display($tpl = null) SubusersHelper::addSubmenu('users'); $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); + parent::display($tpl); } @@ -59,109 +113,34 @@ 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_USERS'), 'users.png'); - // Check if the form exists before showing the add/edit buttons - $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/user'; + $canDo = $this->canDo; - if (file_exists($formPath)) + if ($canDo->get('core.create')) { - if ($canDo->get('core.create')) - { - JToolBarHelper::addNew('user.add', 'JTOOLBAR_NEW'); - JToolbarHelper::custom('users.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); - } - - if ($canDo->get('core.edit') && isset($this->items[0])) - { - JToolBarHelper::editList('user.edit', 'JTOOLBAR_EDIT'); - } + JToolbarHelper::addNew('user.add'); } - if ($canDo->get('core.edit.state')) + if ($canDo->get('core.edit')) { - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::custom('users.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); - JToolBarHelper::custom('users.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('', 'users.delete', 'JTOOLBAR_DELETE'); - } - - if (isset($this->items[0]->state)) - { - JToolBarHelper::divider(); - JToolBarHelper::archiveList('users.archive', 'JTOOLBAR_ARCHIVE'); - } - - if (isset($this->items[0]->checked_out)) - { - JToolBarHelper::custom('users.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); - } + JToolbarHelper::editList('users.edit'); } - // Show trash and delete for components that uses the state field - if (isset($this->items[0]->state)) + if ($canDo->get('core.delete')) { - if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) - { - JToolBarHelper::deleteList('', 'users.delete', 'JTOOLBAR_EMPTY_TRASH'); - JToolBarHelper::divider(); - } - elseif ($canDo->get('core.edit.state')) - { - JToolBarHelper::trash('users.trash', 'JTOOLBAR_TRASH'); - JToolBarHelper::divider(); - } + JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'users.delete', 'JTOOLBAR_DELETE'); + JToolbarHelper::divider(); } - if ($canDo->get('core.admin')) + if ($canDo->get('core.admin') || $canDo->get('core.options')) { - JToolBarHelper::preferences('com_subusers'); + JToolbarHelper::preferences('com_subusers'); + JToolbarHelper::divider(); } - - // Set sidebar action - New in 3.0 - JHtmlSidebar::setAction('index.php?option=com_subusers&view=users'); - - $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.`user_id`' => JText::_('COM_SUBUSERS_USERS_USER_ID'), - 'a.`client_id`' => JText::_('COM_SUBUSERS_USERS_CLIENT_ID'), - 'a.`role_id`' => JText::_('COM_SUBUSERS_USERS_ROLE_ID'), - 'a.`created_by`' => JText::_('COM_SUBUSERS_USERS_CREATED_BY'), - 'a.`state`' => JText::_('JSTATUS'), - ); } } diff --git a/src/installer/index.html b/src/installer/index.html deleted file mode 100644 index 42682b4..0000000 --- a/src/installer/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/installer/structure.xml b/src/installer/structure.xml deleted file mode 100644 index 2dadd24..0000000 --- a/src/installer/structure.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
-
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 beec7ef..9a08e13 100755 --- a/src/languages/administrator/en-GB/en-GB.com_subusers.ini +++ b/src/languages/administrator/en-GB/en-GB.com_subusers.ini @@ -45,7 +45,7 @@ COM_SUBUSERS_USERS_ID="ID" COM_SUBUSERS_USERS_USER_ID="User Name" COM_SUBUSERS_USERS_USER_ID_FILTER="- Select User Name -" COM_SUBUSERS_USERS_CLIENT="Client" -COM_SUBUSERS_USERS_CLIENT_ID="Organization" +COM_SUBUSERS_USERS_CLIENT_ID="Role ID" COM_SUBUSERS_USERS_ROLE_ID="User Role" COM_SUBUSERS_USERS_CREATED_BY="Organization Admin" COM_SUBUSERS_USERS_CHECKED_OUT="Checked_out" @@ -110,13 +110,13 @@ COM_SUBUSERS_TITLE_USER="Add User" COM_SUBUSERS_LEGEND_USER="Add User" COM_SUBUSERS_FORM_LBL_USER_ID="Id" COM_SUBUSERS_FORM_DESC_USER_ID="" -COM_SUBUSERS_FORM_LBL_USER_USER_ID="Name" +COM_SUBUSERS_FORM_LBL_USER_USER_ID=" User ID" COM_SUBUSERS_FORM_DESC_USER_USER_ID="Choose user" COM_SUBUSERS_FORM_LBL_USER_CLIENT="Client" COM_SUBUSERS_FORM_DESC_USER_CLIENT="Client" -COM_SUBUSERS_FORM_LBL_USER_CLIENT_ID="Organization" -COM_SUBUSERS_FORM_DESC_USER_CLIENT_ID="Choose Organization" -COM_SUBUSERS_FORM_LBL_USER_ROLE_ID="0" +COM_SUBUSERS_FORM_LBL_USER_CLIENT_ID="client ID" +COM_SUBUSERS_FORM_DESC_USER_CLIENT_ID="Choose Roll" +COM_SUBUSERS_FORM_LBL_USER_ROLE_ID="Role ID" COM_SUBUSERS_FORM_DESC_USER_ROLE_ID="" COM_SUBUSERS_FORM_LBL_USER_CREATED_BY="Created_by" COM_SUBUSERS_FORM_DESC_USER_CREATED_BY="Creator" @@ -196,16 +196,9 @@ COM_SUBUSERS_FORM_LBL_MAPPING_ORDERING="Order" COM_SUBUSERS_FORM_DESC_MAPPING_ORDERING="" COM_SUBUSERS_FORM_LBL_MAPPING_STATE="State" COM_SUBUSERS_FORM_DESC_MAPPING_STATE="" - - -JCONFIG_ESGROUP_CATEGORY_LABEL="Easysocial group category" +COM_SUBUSERS_FORM_LBL_ACTION_CODE ="Code" +COM_SUBUSERS_FORM_LBL_SELECT_ROLE="Select Role" +COM_SUBUSERS_FORM_DESC_ACTION_CODE="Choose unique code name" ;Component option - -COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_LABEL="New User Registration Group" -COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_DESC="Guest user group" -COM_SUBUSERS_MAX_LOGO_SIZE_LBL="Max image upload size (in MB)" -COM_SUBUSERS_MAX_LOGO_TYPE_DESC="Image types allowed for image upload" -COM_SUBUSERS_MAX_LOGO_SIZE_DESC="Set max image size for upload in MB" -COM_SUBUSERS_MAX_LOGO_TYPE_LBL="Allowed image types" COM_SUBUSERS_TOOLBAR_DATABASE_FIX="Fix Database" diff --git a/src/languages/modules/mod_subusers/en-GB/en-GB.mod_subusers.ini b/src/languages/modules/mod_subusers/en-GB/en-GB.mod_subusers.ini deleted file mode 100644 index 2b11fff..0000000 --- a/src/languages/modules/mod_subusers/en-GB/en-GB.mod_subusers.ini +++ /dev/null @@ -1,71 +0,0 @@ -MOD_SUBUSERS_NAME="Module - Subusers" -MOD_SUBUSERS_DESCRIPTION="Module for showing content of Subusers" -MOD_SUBUSERS_CUSTOM_CONTENT="Custom Content" -MOD_SUBUSERS_LIST="List" -MOD_SUBUSERS_ITEM="Item" -MOD_SUBUSERS_CONTENT_TYPE_TAB_LBL="Content type" -MOD_SUBUSERS_CONTENT_TYPE_LBL="Content type" -MOD_SUBUSERS_CONTENT_TYPE_DESC="Type of content the module should show" -MOD_SUBUSERS_CUSTOM_CONTENT_TAB_LBL="Custom content" -MOD_SUBUSERS_CUSTOM_CONTENT_TAB_DESC="Add you own HTML code to show it as a module" -MOD_SUBUSERS_HTML_LBL="HTML Code" -MOD_SUBUSERS_HTML_DESC="Write your own HTML code to show it as a module" -MOD_SUBUSERS_LIST_CONTENT_TAB_LBL="List Content" -MOD_SUBUSERS_LIST_CONTENT_TAB_DESC="Create a list of items showing the selected field content." -MOD_SUBUSERS_TABLE_LBL="Table" -MOD_SUBUSERS_TABLE_DESC="Table name" -MOD_SUBUSERS_FIELD_LBL="Field" -MOD_SUBUSERS_FIELD_DESC="Which field you want to show" -MOD_SUBUSERS_OFFSET_LBL="Offset" -MOD_SUBUSERS_OFFSET_DESC="How many items you want to skip" -MOD_SUBUSERS_LIMIT_LBL="Limit" -MOD_SUBUSERS_LIMIT_DESC="How many records you want to show" -MOD_SUBUSERS_ITEM_CONTENT_TAB="Item content" -MOD_SUBUSERS_ITEM_CONTENT_TAB_DESC="Show a specific item from one of your component table" -MOD_SUBUSERS_ITEM_ID_LBL="Item ID" -MOD_SUBUSERS_ITEM_ID_DESC="The ID of the item you want to show" -MOD_SUBUSERS_CONTENT_TYPE_TAB_DESC="Configure which type of content you want to show" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ORGANIZATIONS_ID="ID" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ORGANIZATIONS_NAME="Organisation Name" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ORGANIZATIONS_CREATED_BY="Organisation Admin" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ORGANIZATIONS_CHECKED_OUT="N/A" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ORGANIZATIONS_CHECKED_OUT_TIME="N/A" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ORGANIZATIONS_ORDERING="Order" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ORGANIZATIONS_STATE="State" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ORGANIZATIONS_EMAIL="Organisation Email" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ORGANIZATIONS_LOGO="Logo" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_ID="ID" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_USER_ID="User Name" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_CLIENT="Client" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_CLIENT_ID="Organization" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_ROLE_ID="User Role" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_CREATED_BY="Organization Admin" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_CHECKED_OUT="Checked_out" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_CHECKED_OUT_TIME="Checked_out_time" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_ORDERING="Ordering" -MOD_SUBUSERS_HEADER_FIELD_TJSU_USERS_STATE="State" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLES_ID="ID" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLES_NAME="Name" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLES_CLIENT="Client" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLES_CREATED_BY="Created by" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLES_CHECKED_OUT="N/A" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLES_CHECKED_OUT_TIME="N/A" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLES_ORDERING="Order" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLES_STATE="State" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ACTIONS_ID="ID" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ACTIONS_NAME="Name" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ACTIONS_CLIENT="Client" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ACTIONS_CREATED_BY="Created by" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ACTIONS_CHECKED_OUT="N/A" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ACTIONS_CHECKED_OUT_TIME="N/A" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ACTIONS_ORDERING="Order" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ACTIONS_STATE="State" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLE_ACTION_MAP_ID="ID" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLE_ACTION_MAP_ROLE_ID="Role" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLE_ACTION_MAP_ACTION_ID="Action" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLE_ACTION_MAP_CLIENT="Client" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLE_ACTION_MAP_CREATED_BY="Created by" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLE_ACTION_MAP_CHECKED_OUT="N/A" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLE_ACTION_MAP_CHECKED_OUT_TIME="N/A" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLE_ACTION_MAP_ORDERING="Order" -MOD_SUBUSERS_HEADER_FIELD_TJSU_ROLE_ACTION_MAP_STATE="State" diff --git a/src/languages/modules/mod_subusers/en-GB/en-GB.mod_subusers.sys.ini b/src/languages/modules/mod_subusers/en-GB/en-GB.mod_subusers.sys.ini deleted file mode 100644 index 8ff212d..0000000 --- a/src/languages/modules/mod_subusers/en-GB/en-GB.mod_subusers.sys.ini +++ /dev/null @@ -1,2 +0,0 @@ -MOD_SUBUSERS_NAME="Module - Subusers" -MOD_SUBUSERS_DESCRIPTION="Module for showing content of Subusers" \ No newline at end of file diff --git a/src/languages/plugins/search/subusers/en-GB/en-GB.plg_search_subusers.ini b/src/languages/plugins/search/subusers/en-GB/en-GB.plg_search_subusers.ini deleted file mode 100755 index db2e939..0000000 --- a/src/languages/plugins/search/subusers/en-GB/en-GB.plg_search_subusers.ini +++ /dev/null @@ -1,4 +0,0 @@ -PLG_SEARCH_SUBUSERS="Search - Subusers" -PLG_SEARCH_SUBUSERS_XML_DESCRIPTION="This is to sudo-make role based user management easy." -PLG_SEARCH_SUBUSERS_FIELD_SEARCHLIMIT_DESC="Number of search items to return" -PLG_SEARCH_SUBUSERS_FIELD_SEARCHLIMIT_LABEL="Search Limit" \ No newline at end of file diff --git a/src/languages/plugins/search/subusers/en-GB/en-GB.plg_search_subusers.sys.ini b/src/languages/plugins/search/subusers/en-GB/en-GB.plg_search_subusers.sys.ini deleted file mode 100755 index 86d5698..0000000 --- a/src/languages/plugins/search/subusers/en-GB/en-GB.plg_search_subusers.sys.ini +++ /dev/null @@ -1,4 +0,0 @@ -PLG_SEARCH_SUBUSERS="Search - Subusers" -PLG_SEARCH_COM_SUBUSERS_XML_DESCRIPTION="This is to sudo-make role based user management easy." -PLG_SEARCH_COM_SUBUSERS_FIELD_SEARCHLIMIT_DESC="Number of search items to return" -PLG_SEARCH_COM_SUBUSERS_FIELD_SEARCHLIMIT_LABEL="Search Limit" \ No newline at end of file diff --git a/src/plugins/search/subusers/index.html b/src/plugins/search/subusers/index.html deleted file mode 100755 index 2efb97f..0000000 --- a/src/plugins/search/subusers/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/plugins/search/subusers/subusers.php b/src/plugins/search/subusers/subusers.php deleted file mode 100755 index 0fbddbc..0000000 --- a/src/plugins/search/subusers/subusers.php +++ /dev/null @@ -1,289 +0,0 @@ - 'Subusers' - ); - - return $areas; - } - - /** - * Search content (articles). - * The SQL must return the following fields that are used in a common display - * routine: href, title, section, created, text, browsernav. - * - * @param string $text Target search string. - * @param string $phrase Matching option (possible values: exact|any|all). Default is "any". - * @param string $ordering Ordering option (possible values: newest|oldest|popular|alpha|category). Default is "newest". - * @param mixed $areas An array if the search it to be restricted to areas or null to search all areas. - * - * @return array Search results. - * - * @since 1.6 - */ - public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) - { - $db = JFactory::getDbo(); - - if (is_array($areas)) - { - if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) - { - return array(); - } - } - - $limit = $this->params->def('search_limit', 50); - - $text = trim($text); - - if ($text == '') - { - return array(); - } - - $rows = array(); - - -//Search Organizations. -if ($limit > 0) { - switch ($phrase) { - case 'exact': - $text = $db->quote('%' . $db->escape($text, true) . '%', false); - $wheres2 = array(); - $wheres2[] = 'a.name LIKE ' . $text; -$wheres2[] = 'a.created_by LIKE ' . $text; -$wheres2[] = 'a.email LIKE ' . $text; - $where = '(' . implode(') OR (', $wheres2) . ')'; - break; - - case 'all': - case 'any': - default: - $words = explode(' ', $text); - $wheres = array(); - - foreach ($words as $word) { - $word = $db->quote('%' . $db->escape($word, true) . '%', false); - $wheres2 = array(); - $wheres2[] = 'a.name LIKE ' . $word; -$wheres2[] = 'a.created_by LIKE ' . $word; -$wheres2[] = 'a.email LIKE ' . $word; - $wheres[] = implode(' OR ', $wheres2); - } - - $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; - break; - } - - switch ($ordering) { - default: - $order = 'a.id DESC'; - break; - } - - $query = $db->getQuery(true); - - $query - ->clear() - ->select( - array( - 'a.id', - 'a.name AS title', - '"" AS created', - 'a.name AS text', - '"Add Organization" AS section', - '1 AS browsernav' - ) - ) - ->from('#__tjsu_organizations AS a') - - ->where('(' . $where . ')') - ->group('a.id') - ->order($order); - - $db->setQuery($query, 0, $limit); - $list = $db->loadObjectList(); - $limit -= count($list); - - if (isset($list)) { - foreach ($list as $key => $item) { - $list[$key]->href = JRoute::_('index.php?option=com_subusers&view=organization&id=' . $item->id, false, 2); - } - } - - $rows = array_merge($list, $rows); -} - - - -//Search Users. -if ($limit > 0) { - switch ($phrase) { - case 'exact': - $text = $db->quote('%' . $db->escape($text, true) . '%', false); - $wheres2 = array(); - $wheres2[] = 'a.id LIKE ' . $text; -$wheres2[] = 'a.user_id LIKE ' . $text; -$wheres2[] = 'a.client_id LIKE ' . $text; - $where = '(' . implode(') OR (', $wheres2) . ')'; - break; - - case 'all': - case 'any': - default: - $words = explode(' ', $text); - $wheres = array(); - - foreach ($words as $word) { - $word = $db->quote('%' . $db->escape($word, true) . '%', false); - $wheres2 = array(); - $wheres2[] = 'a.id LIKE ' . $word; -$wheres2[] = 'a.user_id LIKE ' . $word; -$wheres2[] = 'a.client_id LIKE ' . $word; - $wheres[] = implode(' OR ', $wheres2); - } - - $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; - break; - } - - switch ($ordering) { - default: - $order = 'a.id DESC'; - break; - } - - $query = $db->getQuery(true); - - $query - ->clear() - ->select( - array( - 'a.id', - 'a.user_id AS title', - '"" AS created', - 'a.user_id AS text', - '"Add User" AS section', - '1 AS browsernav' - ) - ) - ->from('#__tjsu_users AS a') - - ->where('(' . $where . ')') - ->group('a.id') - ->order($order); - - $db->setQuery($query, 0, $limit); - $list = $db->loadObjectList(); - $limit -= count($list); - - if (isset($list)) { - foreach ($list as $key => $item) { - $list[$key]->href = JRoute::_('index.php?option=com_subusers&view=user&id=' . $item->id, false, 2); - } - } - - $rows = array_merge($list, $rows); -} - - - -//Search Roles. -if ($limit > 0) { - switch ($phrase) { - case 'exact': - $text = $db->quote('%' . $db->escape($text, true) . '%', false); - $wheres2 = array(); - $wheres2[] = 'a.name LIKE ' . $text; - $where = '(' . implode(') OR (', $wheres2) . ')'; - break; - - case 'all': - case 'any': - default: - $words = explode(' ', $text); - $wheres = array(); - - foreach ($words as $word) { - $word = $db->quote('%' . $db->escape($word, true) . '%', false); - $wheres2 = array(); - $wheres2[] = 'a.name LIKE ' . $word; - $wheres[] = implode(' OR ', $wheres2); - } - - $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; - break; - } - - switch ($ordering) { - default: - $order = 'a.id DESC'; - break; - } - - $query = $db->getQuery(true); - - $query - ->clear() - ->select( - array( - 'a.id', - 'a.name AS title', - '"" AS created', - 'a.name AS text', - '"Role" AS section', - '1 AS browsernav' - ) - ) - ->from('#__tjsu_roles AS a') - - ->where('(' . $where . ')') - ->group('a.id') - ->order($order); - - $db->setQuery($query, 0, $limit); - $list = $db->loadObjectList(); - $limit -= count($list); - - if (isset($list)) { - foreach ($list as $key => $item) { - $list[$key]->href = JRoute::_('index.php?option=com_subusers&view=role&id=' . $item->id, false, 2); - } - } - - $rows = array_merge($list, $rows); -} - - return $rows; - } -} diff --git a/src/plugins/search/subusers/subusers.xml b/src/plugins/search/subusers/subusers.xml deleted file mode 100755 index c08850c..0000000 --- a/src/plugins/search/subusers/subusers.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - plg_search_subusers - Techjoomla - 2016-01-07 - Copyright (C) 2015. All rights reserved. - GNU General Public License version 2 or later; see LICENSE.txt - contact@techjoomla.com - https://techjoomla.com - CVS: 1.0.0 - PLG_SEARCH_COM_SUBUSERS_XML_DESCRIPTION - - subusers.php - index.html - - - - ../../../languages/plugins/search/subusers/en-GB/en-GB.plg_search_subusers.ini - ../../../languages/plugins/search/subusers/en-GB/en-GB.plg_search_subusers.sys.ini - - - - -
- -
- -
-
-
diff --git a/src/script.php b/src/script.php index 85de37c..a6371d5 100755 --- a/src/script.php +++ b/src/script.php @@ -1,25 +1,20 @@ - * @copyright Copyright (C) 2015. All rights reserved. + * @package Subusers + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -define('MODIFIED', 1); -define('NOT_MODIFIED', 2); - defined('_JEXEC') or die; /** - * Updates the database structure of the component + * Updates the structure of the component * - * @version Release: 0.2b - * @author Component Creator - * @since 0.1b + * @since 1.0.0 */ -class com_subusersInstallerScript +class Com_SubusersInstallerScript { /** * Method called before install/update the component. Note: This method won't be called during uninstall process. @@ -58,663 +53,14 @@ public function preflight($type, $parent) * * @return void * - * @since 0.2b + * @since 1.0.0 */ public function install($parent) { - $this->installDb($parent); $this->installPlugins($parent); $this->installModules($parent); } - /** - * Method to update the DB of the component - * - * @param mixed $parent Object who started the upgrading process - * - * @return void - * - * @since 0.2b - */ - private function installDb($parent) - { - $installation_folder = $parent->getParent()->getPath('source'); - - $app = JFactory::getApplication(); - - if (function_exists('simplexml_load_file') && file_exists($installation_folder . '/installer/structure.xml')) - { - $component_data = simplexml_load_file($installation_folder . '/installer/structure.xml'); - - // Check if there are tables to import. - foreach ($component_data->children() as $table) - { - $this->processTable($app, $table); - } - } - else - { - if (!function_exists('simplexml_load_file')) - { - $app->enqueueMessage(JText::_('This script needs \'simplexml_load_file\' to update the component')); - } - else - { - $app->enqueueMessage(JText::_('Structure file was not found.')); - } - } - } - - /** - * Process a table - * - * @param JApplicationCms $app Application object - * @param SimpleXMLElement $table Table to process - * - * @return void - * - * @since 0.2b - */ - private function processTable($app, $table) - { - $db = JFactory::getDbo(); - - $table_added = false; - - if (isset($table['action'])) - { - switch ($table['action']) - { - case 'add': - - // Check if the table exists before create the statement - if (!$this->existsTable($table['table_name'])) - { - $create_statement = $this->generateCreateTableStatement($table); - $db->setQuery($create_statement); - - try - { - $db->execute(); - $app->enqueueMessage( - JText::sprintf( - 'Table `%s` has been successfully created', - (string) $table['table_name'] - ) - ); - $table_added = true; - } catch (Exception $ex) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error creating the table `%s`. Error: %s', - (string) $table['table_name'], - $ex->getMessage() - ), 'error' - ); - } - } - break; - case 'change': - - // Check if the table exists first to avoid errors. - if ($this->existsTable($table['old_name']) && !$this->existsTable($table['new_name'])) - { - try - { - $db->renameTable($table['old_name'], $table['new_name']); - $app->enqueueMessage( - JText::sprintf( - 'Table `%s` was successfully renamed to `%s`', - $table['old_name'], - $table['new_name'] - ) - ); - } catch (Exception $ex) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error renaming the table `%s`. Error: %s', - $table['old_name'], - $ex->getMessage() - ), 'error' - ); - } - } - else - { - if (!$this->existsTable($table['table_name'])) - { - // If the table does not exists, let's create it. - $create_statement = $this->generateCreateTableStatement($table); - $db->setQuery($create_statement); - - try - { - $db->execute(); - $app->enqueueMessage( - JText::sprintf('Table `%s` has been successfully created', $table['table_name']) - ); - $table_added = true; - } catch (Exception $ex) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error creating the table `%s`. Error: %s', - $table['table_name'], - $ex->getMessage() - ), 'error' - ); - } - } - } - break; - case 'remove': - - try - { - // We make sure that the table will be removed only if it exists specifying ifExists argument as true. - $db->dropTable((string) $table['table_name'], true); - $app->enqueueMessage( - JText::sprintf('Table `%s` was successfully deleted', $table['table_name']) - ); - } catch (Exception $ex) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error deleting Table `%s`. Error: %s', - $table['table_name'], $ex->getMessage() - ), 'error' - ); - } - - break; - } - } - - // If the table wasn't added before, let's process the fields of the table - if (!$table_added) - { - if ($this->existsTable($table['table_name'])) - { - $this->executeFieldsUpdating($app, $table); - } - } - } - - /** - * Checks if a certain exists on the current database - * - * @param string $table_name Name of the table - * - * @return boolean True if it exists, false if it does not. - */ - private function existsTable($table_name) - { - $db = JFactory::getDbo(); - - $table_name = str_replace('#__', $db->getPrefix(), (string) $table_name); - - return in_array($table_name, $db->getTableList()); - } - - /** - * Generates a 'CREATE TABLE' statement for the tables passed by argument. - * - * @param SimpleXMLElement $table Table of the database - * - * @return string 'CREATE TABLE' statement - */ - private function generateCreateTableStatement($table) - { - $create_table_statement = ''; - - if (isset($table->field)) - { - $fields = $table->children(); - - $fields_definitions = array(); - $indexes = array(); - - $db = JFactory::getDbo(); - - foreach ($fields as $field) - { - $field_definition = $this->generateColumnDeclaration($field); - - if ($field_definition !== false) - { - $fields_definitions[] = $field_definition; - } - - if ($field['index'] == 'index') - { - $indexes[] = $field['field_name']; - } - } - - foreach ($indexes as $index) - { - $fields_definitions[] = JText::sprintf( - 'INDEX %s (%s ASC)', - $db->quoteName((string) $index), $index - ); - } - - $fields_definitions[] = 'PRIMARY KEY (`id`)'; - $create_table_statement = JText::sprintf( - 'CREATE TABLE IF NOT EXISTS %s (%s)', - $table['table_name'], - implode(',', $fields_definitions) - ); - } - - return $create_table_statement; - } - - /** - * Generate a column declaration - * - * @param SimpleXMLElement $field Field data - * - * @return string Column declaration - */ - private function generateColumnDeclaration($field) - { - $db = JFactory::getDbo(); - $col_name = $db->quoteName((string) $field['field_name']); - $data_type = $this->getFieldType($field); - - if ($data_type !== false) - { - $default_value = (isset($field['default'])) ? 'DEFAULT ' . $field['default'] : ''; - - $other_data = ''; - - if (isset($field['is_autoincrement']) && $field['is_autoincrement'] == 1) - { - $other_data .= ' AUTO_INCREMENT'; - } - - $comment_value = (isset($field['description'])) ? 'COMMENT ' . $db->quote((string) $field['description']) : ''; - - return JText::sprintf( - '%s %s NOT NULL %s %s %s', $col_name, $data_type, - $default_value, $other_data, $comment_value - ); - } - - return false; - } - - /** - * Generates SQL field type of a field. - * - * @param SimpleXMLElement $field Field information - * - * @return string SQL data type - */ - private function getFieldType($field) - { - $data_type = (string) $field['field_type']; - - if (isset($field['field_length']) && $this->allowsLengthField($data_type)) - { - $data_type .= '(' . ((string) $field['field_length']) . ')'; - } - - if (empty($data_type)) - { - return false; - } - - return (string) $data_type; - } - - /** - * Check if a SQL type allows length values. - * - * @param string $field_type SQL type - * - * @return boolean True if it allows length values, false if it does not. - */ - private function allowsLengthField($field_type) - { - $allow_length = array( - 'INT', - 'VARCHAR', - 'CHAR', - 'TINYINT', - 'SMALLINT', - 'MEDIUMINT', - 'INTEGER', - 'BIGINT', - 'FLOAT', - 'DOUBLE', - 'DECIMAL', - 'NUMERIC' - ); - - return (in_array((string) $field_type, $allow_length)); - } - - /** - * Updates all the fields related to a table. - * - * @param JApplicationCms $app Application Object - * @param SimpleXMLElement $table Table information. - * - * @return void - */ - private function executeFieldsUpdating($app, $table) - { - if (isset($table->field)) - { - foreach ($table->children() as $field) - { - $table_name = (string) $table['table_name']; - - $this->processField($app, $table_name, $field); - } - } - } - - /** - * Process a certain field. - * - * @param JApplicationCms $app Application object - * @param string $table_name The name of the table that contains the field. - * @param SimpleXMLElement $field Field Information. - * - * @return void - */ - private function processField($app, $table_name, $field) - { - $db = JFactory::getDbo(); - - if (isset($field['action'])) - { - switch ($field['action']) - { - case 'add': - $result = $this->addField($table_name, $field); - - if ($result === MODIFIED) - { - $app->enqueueMessage( - JText::sprintf('Field `%s` has been successfully added', $field['field_name']) - ); - } - else - { - if ($result !== NOT_MODIFIED) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error adding the field `%s`. Error: %s', - $field['field_name'], $result - ), 'error' - ); - } - } - break; - case 'change': - - if (isset($field['old_name']) && isset($field['new_name'])) - { - if ($this->existsField($table_name, $field['old_name'])) - { - $renaming_statement = JText::sprintf( - 'ALTER TABLE %s CHANGE %s %s %s', - $table_name, $field['old_name'], - $field['new_name'], - $this->getFieldType($field) - ); - $db->setQuery($renaming_statement); - - try - { - $db->execute(); - $app->enqueueMessage( - JText::sprintf('Field `%s` has been successfully modified', $field['old_name']) - ); - } catch (Exception $ex) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error modifying the field `%s`. Error: %s', - $field['field_name'], - $ex->getMessage() - ), 'error' - ); - } - } - else - { - $result = $this->addField($table_name, $field); - - if ($result === MODIFIED) - { - $app->enqueueMessage( - JText::sprintf('Field `%s` has been successfully modified', $field['field_name']) - ); - } - else - { - if ($result !== NOT_MODIFIED) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error modifying the field `%s`. Error: %s', - $field['field_name'], $result - ), 'error' - ); - } - } - } - } - else - { - $result = $this->addField($table_name, $field); - - if ($result === MODIFIED) - { - $app->enqueueMessage( - JText::sprintf('Field `%s` has been successfully added', $field['field_name']) - ); - } - else - { - if ($result !== NOT_MODIFIED) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error adding the field `%s`. Error: %s', - $field['field_name'], $result - ), 'error' - ); - } - } - } - - break; - case 'remove': - - // Check if the field exists first to prevent issue removing the field - if ($this->existsField($table_name, $field['field_name'])) - { - $drop_statement = JText::sprintf( - 'ALTER TABLE %s DROP COLUMN %s', - $table_name, $field['field_name'] - ); - $db->setQuery($drop_statement); - - try - { - $db->execute(); - $app->enqueueMessage( - JText::sprintf('Field `%s` has been successfully deleted', $field['field_name']) - ); - } catch (Exception $ex) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error deleting the field `%s`. Error: %s', - $field['field_name'], - $ex->getMessage() - ), 'error' - ); - } - } - - break; - } - } - else - { - $result = $this->addField($table_name, $field); - - if ($result === MODIFIED) - { - $app->enqueueMessage( - JText::sprintf('Field `%s` has been successfully added', $field['field_name']) - ); - } - else - { - if ($result !== NOT_MODIFIED) - { - $app->enqueueMessage( - JText::sprintf( - 'There was an error adding the field `%s`. Error: %s', - $field['field_name'], $result - ), 'error' - ); - } - } - } - } - - /** - * Add a field if it does not exists or modify it if it does. - * - * @param string $table_name Table name - * @param SimpleXMLElement $field Field Information - * - * @return mixed Constant on success(self::$MODIFIED | self::$NOT_MODIFIED), error message if an error occurred - */ - private function addField($table_name, $field) - { - $db = JFactory::getDbo(); - - $query_generated = false; - - // Check if the field exists first to prevent issues adding the field - if ($this->existsField($table_name, $field['field_name'])) - { - if ($this->needsToUpdate($table_name, $field)) - { - $change_statement = $this->generateChangeFieldStatement($table_name, $field); - $db->setQuery($change_statement); - $query_generated = true; - } - } - else - { - $add_statement = $this->generateAddFieldStatement($table_name, $field); - $db->setQuery($add_statement); - $query_generated = true; - } - - if ($query_generated) - { - try - { - $db->execute(); - - return MODIFIED; - } catch (Exception $ex) - { - return $ex->getMessage(); - } - } - - return NOT_MODIFIED; - } - - /** - * Checks if a field exists on a table - * - * @param string $table_name Table name - * @param string $field_name Field name - * - * @return boolean True if exists, false if it do - */ - private function existsField($table_name, $field_name) - { - $db = JFactory::getDbo(); - - return in_array((string) $field_name, array_keys($db->getTableColumns($table_name))); - } - - /** - * Check if a field needs to be updated. - * - * @param string $table_name Table name - * @param SimpleXMLElement $field Field information - * - * @return boolean True if the field has to be updated, false otherwise - */ - private function needsToUpdate($table_name, $field) - { - $db = JFactory::getDbo(); - - $query = JText::sprintf( - 'SHOW FULL COLUMNS FROM `%s` WHERE Field LIKE %s', $table_name, $db->quote((string) $field['field_name']) - ); - $db->setQuery($query); - - $field_info = $db->loadObject(); - - if (strripos($field_info->Type, $this->getFieldType($field)) === false) - { - return true; - } - else - { - return false; - } - } - - /** - * Generates an change column statement - * - * @param string $table_name Table name - * @param SimpleXMLElement $field Field Information - * - * @return string Change column statement - */ - private function generateChangeFieldStatement($table_name, $field) - { - $column_declaration = $this->generateColumnDeclaration($field); - - return JText::sprintf('ALTER TABLE %s MODIFY %s', $table_name, $column_declaration); - } - - /** - * Generates an add column statement - * - * @param string $table_name Table name - * @param SimpleXMLElement $field Field Information - * - * @return string Add column statement - */ - private function generateAddFieldStatement($table_name, $field) - { - $column_declaration = $this->generateColumnDeclaration($field); - - return JText::sprintf('ALTER TABLE %s ADD %s', $table_name, $column_declaration); - } /** * Installs plugins for this component @@ -725,10 +71,9 @@ private function generateAddFieldStatement($table_name, $field) */ private function installPlugins($parent) { - $installation_folder = $parent->getParent()->getPath('source'); + $installationFolder = $parent->getParent()->getPath('source'); $app = JFactory::getApplication(); - /* @var $plugins SimpleXMLElement */ $plugins = $parent->get("manifest")->plugins; if (count($plugins->children())) @@ -740,7 +85,7 @@ private function installPlugins($parent) { $pluginName = (string) $plugin['plugin']; $pluginGroup = (string) $plugin['group']; - $path = $installation_folder . '/plugins/' . $pluginGroup; + $path = $installationFolder . '/plugins/' . $pluginGroup; $installer = new JInstaller; if (!$this->isAlreadyInstalled('plugin', $pluginName, $pluginGroup)) @@ -758,8 +103,7 @@ private function installPlugins($parent) } else { - $app->enqueueMessage('There was an issue installing the plugin ' . $pluginName, - 'error'); + $app->enqueueMessage('There was an issue installing the plugin ' . $pluginName, 'error'); } $query @@ -814,7 +158,7 @@ private function isAlreadyInstalled($type, $name, $folder = null) */ private function installModules($parent) { - $installation_folder = $parent->getParent()->getPath('source'); + $installationFolder = $parent->getParent()->getPath('source'); $app = JFactory::getApplication(); if (!empty($parent->get("manifest")->modules)) @@ -826,7 +170,7 @@ private function installModules($parent) foreach ($modules->children() as $module) { $moduleName = (string) $module['module']; - $path = $installation_folder . '/modules/' . $moduleName; + $path = $installationFolder . '/modules/' . $moduleName; $installer = new JInstaller; if (!$this->isAlreadyInstalled('module', $moduleName)) @@ -844,8 +188,7 @@ private function installModules($parent) } else { - $app->enqueueMessage('There was an issue installing the module ' . $moduleName, - 'error'); + $app->enqueueMessage('There was an issue installing the module ' . $moduleName, 'error'); } } } @@ -861,7 +204,6 @@ private function installModules($parent) */ public function update($parent) { - $this->installDb($parent); $this->installPlugins($parent); $this->installModules($parent); } @@ -925,8 +267,7 @@ private function uninstallPlugins($parent) } else { - $app->enqueueMessage('There was an issue uninstalling the plugin ' . $pluginName, - 'error'); + $app->enqueueMessage('There was an issue uninstalling the plugin ' . $pluginName, 'error'); } } } @@ -980,8 +321,7 @@ private function uninstallModules($parent) } else { - $app->enqueueMessage('There was an issue uninstalling the module ' . $moduleName, - 'error'); + $app->enqueueMessage('There was an issue uninstalling the module ' . $moduleName, 'error'); } } } diff --git a/src/site/controller.php b/src/site/controller.php index 809aa5b..3957c4a 100755 --- a/src/site/controller.php +++ b/src/site/controller.php @@ -33,7 +33,7 @@ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/subusers.php'; - $view = JFactory::getApplication()->input->getCmd('view', 'organizations'); + $view = JFactory::getApplication()->input->getCmd('view', 'roles'); JFactory::getApplication()->input->set('view', $view); parent::display($cachable, $urlparams); diff --git a/src/site/controllers/announcementform.php b/src/site/controllers/announcementform.php deleted file mode 100755 index f98f19f..0000000 --- a/src/site/controllers/announcementform.php +++ /dev/null @@ -1,265 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organization controller class. - * - * @since 1.6 - */ -class SubusersControllerAnnouncementForm extends SubusersController -{ - /** - * Method to check out an item for editing and redirect to the edit form. - * - * @return void - * - * @since 1.6 - */ - public function edit() - { - $app = JFactory::getApplication(); - - // Get the previous edit id (if any) and the current edit id. - $previousId = (int) $app->getUserState('com_subusers.edit.organization.id'); - $editId = $app->input->getInt('id', 0); - $org_id = $app->input->getInt('org_id', 0); - - // Set the user id for the user to edit in the session. - $app->setUserState('com_subusers.edit.organization.id', $editId); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Check out the item - if ($editId) - { - $model->checkout($editId); - } - - // Check in the previous user. - if ($previousId) - { - $model->checkin($previousId); - } - - // Redirect to the edit screen. - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcementform&layout=edit&org_id=' . $org_id, false)); - } - - /** - * Method to save a user's profile data. - * - * @return void - * - * @throws Exception - * @since 1.6 - */ - public function save() - { - // Check for request forgeries. - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel('AnnouncementForm', 'SubusersModel'); - - // Get the user data. - $data = JFactory::getApplication()->input->get('jform', array(), 'array'); - - // Get the user data. - $data = JFactory::getApplication()->input->get('jform', array(), 'array'); - /* - Validate the posted data. - $form = $model->getForm(); - - if (!$form) - { - throw new Exception($model->getError(), 500); - } - - Validate the posted data. - $data = $model->validate($form, $data); - - Check for errors. - if ($data === false) - { - Get the validation messages. - $errors = $model->getErrors(); - - Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); - } - else - { - $app->enqueueMessage($errors[$i], 'warning'); - } - } - - $input = $app->input; - $jform = $input->get('jform', array(), 'ARRAY'); - - Save the data in the session. - $app->setUserState('com_subusers.edit.announcement.data', $jform); - - Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.announcement.id'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcementform&layout=edit&id=' . $id, false)); - }*/ - - // Attempt to save the data. - $return = $model->save($data); - - // Check for errors. - if ($return === false) - { - // Save the data in the session. - $app->setUserState('com_subusers.edit.announcement.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.announcement.id'); - $this->setMessage(JText::sprintf('Save failed', $model->getError()), 'warning'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcementform&layout=edit&id=' . $id, false)); - } - - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.announcement.id', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_SAVED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organization' . '/' . $data['orgid'] : $item->link); - $this->setRedirect(JRoute::_($url, false)); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.announcement.data', null); - } - - /** - * Method to abort current operation - * - * @return void - * - * @throws Exception - */ - public function cancel() - { - $app = JFactory::getApplication(); - $id = $app->input->get('orgid'); - - // Get the current edit id. - $editId = (int) $app->getUserState('com_subusers.edit.organization.id'); - - // Get the model. - $model = $this->getModel('AnnouncementForm', 'SubusersModel'); - - // Check in the item - if ($editId) - { - $model->checkin($editId); - } - - $url = 'index.php?option=com_subusers&view=organization' . '/' . $id; - $this->setRedirect(JRoute::_($url, false)); - } - - /** - * Method to remove data - * - * @return void - * - * @throws Exception - */ - public function remove() - { - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel('AnnouncementForm', 'SubusersModel'); - - // Get the user data. - $data = array(); - $data['id'] = $app->input->getInt('id'); - - // Check for errors. - if (empty($data['id'])) - { - // Get the validation messages. - $errors = $model->getErrors(); - - // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); - } - else - { - $app->enqueueMessage($errors[$i], 'warning'); - } - } - - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcement&layout=edit&id=' . $id, false)); - } - - // Attempt to save the data. - $return = $model->delete($data); - - // Check for errors. - if ($return === false) - { - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setMessage(JText::sprintf('Delete failed', $model->getError()), 'warning'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=announcement&layout=edit&id=' . $id, false)); - } - - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_DELETED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organizations&layout=pin' : $item->link); - $this->setRedirect(JRoute::_($url, false)); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - } -} diff --git a/src/site/controllers/announcements.php b/src/site/controllers/announcements.php deleted file mode 100755 index 81249cb..0000000 --- a/src/site/controllers/announcements.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organizations list controller class. - * - * @since 1.6 - */ -class SubusersControllerAnnouncements extends SubusersController -{ - /** - * Proxy for getModel. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional - * @param array $config Configuration array for model. Optional - * - * @return object The model - * - * @since 1.6 - */ - public function &getModel($name = 'Announcements', $prefix = 'SubusersModel', $config = array()) - { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; - } -} diff --git a/src/site/controllers/organization.php b/src/site/controllers/organization.php deleted file mode 100755 index 59f9a77..0000000 --- a/src/site/controllers/organization.php +++ /dev/null @@ -1,207 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organization controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganization extends SubusersController -{ - /** - * Method to check out an item for editing and redirect to the edit form. - * - * @return void - * - * @since 1.6 - */ - public function edit() - { - $app = JFactory::getApplication(); - - // Get the previous edit id (if any) and the current edit id. - $previousId = (int) $app->getUserState('com_subusers.edit.organization.id'); - $editId = $app->input->getInt('id', 0); - - // Set the user id for the user to edit in the session. - $app->setUserState('com_subusers.edit.organization.id', $editId); - - // Get the model. - $model = $this->getModel('Organization', 'SubusersModel'); - - // Check out the item - if ($editId) - { - $model->checkout($editId); - } - - // Check in the previous user. - if ($previousId && $previousId !== $editId) - { - $model->checkin($previousId); - } - - // Redirect to the edit screen. - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizationform&layout=edit', false)); - } - - /** - * Method to save a user's profile data. - * - * @return void - * - * @throws Exception - * @since 1.6 - */ - public function publish() - { - // Initialise variables. - $app = JFactory::getApplication(); - - // Checking if the user can remove object - $user = JFactory::getUser(); - - if ($user->authorise('core.edit', 'com_subusers') || $user->authorise('core.edit.state', 'com_subusers')) - { - $model = $this->getModel('Organization', 'SubusersModel'); - - // Get the user data. - $id = $app->input->getInt('id'); - $state = $app->input->getInt('state'); - - // Attempt to save the data. - $return = $model->publish($id, $state); - - // Check for errors. - if ($return === false) - { - $this->setMessage(JText::sprintf('Save failed: %s', $model->getError()), 'warning'); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_SAVED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - - if (!$item) - { - // If there isn't any menu item active, redirect to list view - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizations', false)); - } - else - { - $this->setRedirect(JRoute::_($item->link . $menuitemid, false)); - } - } - else - { - throw new Exception(500); - } - } - - /** - * Remove data - * - * @return void - * - * @throws Exception - */ - public function remove() - { - // Initialise variables. - $app = JFactory::getApplication(); - - // Checking if the user can remove object - $user = JFactory::getUser(); - - if ($user->authorise('core.delete', 'com_subusers')) - { - $model = $this->getModel('Organization', 'SubusersModel'); - - // Get the user data. - $id = $app->input->getInt('id', 0); - - // Attempt to save the data. - $return = $model->delete($id); - - // Check for errors. - if ($return === false) - { - $this->setMessage(JText::sprintf('Delete failed', $model->getError()), 'warning'); - } - else - { - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_DELETED_SUCCESSFULLY')); - } - - // Redirect to the list screen. - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $this->setRedirect(JRoute::_($item->link, false)); - } - else - { - throw new Exception(500); - } - } - - /** - * Apply for membership - * - * @return void - * - * @throws Exception - */ - public function applymembership() - { - $input = JFactory::getApplication()->input; - $post = $input->post; - $orgid = $post->get('orgid', '', 'INT'); - - if ($orgid) - { - $oluser_id = JFactory::getUser()->id; - $model = $this->getModel('organization'); - $check = $model->applymembership($orgid, $oluser_id); - - if ($check) - { - $msg = JText::_('COM_SUBUSERS_APPLY_SUCCESSFULY'); - } - else - { - $msg = JText::_('COM_SUBUSERS_APPLY_FAILED'); - } - - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organization&layout=details&id=' . $orgid, false), $msg); - } - } -} diff --git a/src/site/controllers/organizationform.php b/src/site/controllers/organizationform.php deleted file mode 100755 index 78422c6..0000000 --- a/src/site/controllers/organizationform.php +++ /dev/null @@ -1,324 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organization controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganizationForm extends SubusersController -{ - /** - * Method to check out an item for editing and redirect to the edit form. - * - * @return void - * - * @since 1.6 - */ - public function edit() - { - $app = JFactory::getApplication(); - - // Get the previous edit id (if any) and the current edit id. - $previousId = (int) $app->getUserState('com_subusers.edit.organization.id'); - $editId = $app->input->getInt('id', 0); - - // Set the user id for the user to edit in the session. - $app->setUserState('com_subusers.edit.organization.id', $editId); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Check out the item - if ($editId) - { - $model->checkout($editId); - } - - // Check in the previous user. - if ($previousId) - { - $model->checkin($previousId); - } - - // Redirect to the edit screen. - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizationform&layout=edit', false)); - } - - /** - * Method to save a user's profile data. - * - * @return void - * - * @throws Exception - * @since 1.6 - */ - public function save() - { - // Check for request forgeries. - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Get the user data. - $data = JFactory::getApplication()->input->get('jform', array(), 'array'); - - // Validate the posted data. - $form = $model->getForm(); - - if (!$form) - { - throw new Exception($model->getError(), 500); - } - - // Validate the posted data. - $data = $model->validate($form, $data); - - // Check for errors. - if ($data === false) - { - // Get the validation messages. - $errors = $model->getErrors(); - - // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); - } - else - { - $app->enqueueMessage($errors[$i], 'warning'); - } - } - - $input = $app->input; - $jform = $input->get('jform', array(), 'ARRAY'); - - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $jform); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizationform&layout=edit&id=' . $id, false)); - } - - // Attempt to save the data. - $return = $model->save($data); - - // Check for errors. - if ($return === false) - { - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setMessage(JText::sprintf('Save failed', $model->getError()), 'warning'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizationform&layout=edit&id=' . $id, false)); - } - - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_SAVED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organizations' : $item->link); - $this->setRedirect(JRoute::_($url, false)); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - } - - /** - * Method to abort current operation - * - * @return void - * - * @throws Exception - */ - public function cancel() - { - $app = JFactory::getApplication(); - - // Get the current edit id. - $editId = (int) $app->getUserState('com_subusers.edit.organization.id'); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Check in the item - if ($editId) - { - $model->checkin($editId); - } - - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organizations' : $item->link); - $this->setRedirect(JRoute::_($url, false)); - } - - /** - * Method to remove data - * - * @return void - * - * @throws Exception - */ - public function remove() - { - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - // Get the user data. - $data = array(); - $data['id'] = $app->input->getInt('id'); - - // Check for errors. - if (empty($data['id'])) - { - // Get the validation messages. - $errors = $model->getErrors(); - - // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); - } - else - { - $app->enqueueMessage($errors[$i], 'warning'); - } - } - - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organization&layout=edit&id=' . $id, false)); - } - - // Attempt to save the data. - $return = $model->delete($data); - - // Check for errors. - if ($return === false) - { - // Save the data in the session. - $app->setUserState('com_subusers.edit.organization.data', $data); - - // Redirect back to the edit screen. - $id = (int) $app->getUserState('com_subusers.edit.organization.id'); - $this->setMessage(JText::sprintf('Delete failed', $model->getError()), 'warning'); - $this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organization&layout=edit&id=' . $id, false)); - } - - // Check in the profile. - if ($return) - { - $model->checkin($return); - } - - // Clear the profile id from the session. - $app->setUserState('com_subusers.edit.organization.id', null); - - // Redirect to the list screen. - $this->setMessage(JText::_('COM_SUBUSERS_ITEM_DELETED_SUCCESSFULLY')); - $menu = JFactory::getApplication()->getMenu(); - $item = $menu->getActive(); - $url = (empty($item->link) ? 'index.php?option=com_subusers&view=organizations' : $item->link); - $this->setRedirect(JRoute::_($url, false)); - - // Flush the data from the session. - $app->setUserState('com_subusers.edit.organization.data', null); - } - - /** - * Method to check out an org id is already exist or not. - * - * @return void - * - * @since 1.6 - */ - public function validateOrgId() - { - $app = JFactory::getApplication(); - $orgId = $app->input->get('id', '', 'STRING'); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - if ( $model->validateOrgId($orgId)) - { - // If already present - echo "failure"; - exit(); - } - else - { - // New email found - echo "success"; - exit(); - } - - exit; - } - - /** - * Method to check out an orgemail is already exist or not. - * - * @return void - * - * @since 1.6 - */ - public function validateOrgEmail() - { - $app = JFactory::getApplication(); - $orgEmail = $app->input->get('email', '', 'STRING'); - - // Get the model. - $model = $this->getModel('OrganizationForm', 'SubusersModel'); - - if ( $model->validateOrgEmail($orgEmail)) - { - // If already present - echo "failure"; - exit(); - } - else - { - // New email found - echo "success"; - exit(); - } - - exit; - } -} diff --git a/src/site/controllers/organizations.php b/src/site/controllers/organizations.php deleted file mode 100755 index 71656d3..0000000 --- a/src/site/controllers/organizations.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -require_once JPATH_COMPONENT . '/controller.php'; - -/** - * Organizations list controller class. - * - * @since 1.6 - */ -class SubusersControllerOrganizations extends SubusersController -{ - /** - * Proxy for getModel. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional - * @param array $config Configuration array for model. Optional - * - * @return object The model - * - * @since 1.6 - */ - public function &getModel($name = 'Organizations', $prefix = 'SubusersModel', $config = array()) - { - $model = parent::getModel($name, $prefix, array('ignore_request' => true)); - - return $model; - } -} diff --git a/src/site/models/announcementform.php b/src/site/models/announcementform.php deleted file mode 100755 index 81f91ff..0000000 --- a/src/site/models/announcementform.php +++ /dev/null @@ -1,423 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -jimport('joomla.application.component.modelform'); -jimport('joomla.event.dispatcher'); - -use Joomla\Utilities\ArrayHelper; -/** - * Subusers model. - * - * @since 1.6 - */ -class SubusersModelAnnouncementForm extends JModelForm -{ - private $item = null; - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - * @since 1.6 - */ - protected function populateState() - { - $app = JFactory::getApplication('com_subusers'); - - // Load state from the request userState on edit or from the passed variable on default - if (JFactory::getApplication()->input->get('layout') == 'edit') - { - $id = JFactory::getApplication()->getUserState('com_subusers.edit.organization.id'); - } - else - { - $id = JFactory::getApplication()->input->get('id'); - JFactory::getApplication()->setUserState('com_subusers.edit.organization.id', $id); - } - - $this->setState('organization.id', $id); - - // Load the parameters. - $params = $app->getParams(); - $params_array = $params->toArray(); - - if (isset($params_array['item_id'])) - { - $this->setState('organization.id', $params_array['item_id']); - } - - $this->setState('params', $params); - } - - /** - * Method to get an ojbect. - * - * @param integer $id The id of the object to get. - * - * @return Object|boolean Object on success, false on failure. - * - * @throws Exception - */ - public function &getData($id = null) - { - if ($this->item === null) - { - $this->item = false; - - if (empty($id)) - { - $id = $this->getState('organization.id'); - } - - // Get a level row instance. - $table = $this->getTable(); - - // Attempt to load the row. - if ($table !== false && $table->load($id)) - { - $user = JFactory::getUser(); - $id = $table->id; - $canEdit = $user->authorise('core.edit', 'com_subusers') || $user->authorise('core.create', 'com_subusers'); - - if (!$canEdit && $user->authorise('core.edit.own', 'com_subusers')) - { - $canEdit = $user->id == $table->created_by; - } - - if (!$canEdit) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 500); - } - - // Check published state. - if ($published = $this->getState('filter.published')) - { - if ($table->state != $published) - { - return $this->item; - } - } - - // Convert the JTable to a clean JObject. - $properties = $table->getProperties(1); - $this->item = ArrayHelper::toObject($properties, 'JObject'); - } - } - - return $this->item; - } - - /** - * Method to get the table - * - * @param string $type Name of the JTable class - * @param string $prefix Optional prefix for the table class name - * @param array $config Optional configuration array for JTable object - * - * @return JTable|boolean JTable if found, boolean false on failure - */ - public function getTable($type = 'Announcement', $prefix = 'SubusersTable', $config = array()) - { - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_subusers/tables'); - - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Get an item by alias - * - * @param string $alias Alias string - * - * @return int Element id - */ - public function getItemIdByAlias($alias) - { - $table = $this->getTable(); - - $table->load(array('alias' => $alias)); - - return $table->id; - } - - /** - * Get an $org_id by alias - * - * @param string $org_id Alias string - * - * @return org id - */ - - public function getCatId($org_id) - { - // Get a db connection. - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - - // Create a new query object. - $query - ->select('a.category_id') - ->from('`#__es_group_xref` AS a'); - $query->where('a.client_id=' . $org_id); - $db->setQuery($query); - $cat_id = $db->loadResult(); - - return $cat_id; - } - - /** - * Method to check in an item. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkin($id = null) - { - // Get the id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Attempt to check the row in. - if (method_exists($table, 'checkin')) - { - if (!$table->checkin($id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to check out an item for editing. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkout($id = null) - { - // Get the user id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Get the current user object. - $user = JFactory::getUser(); - - // Attempt to check the row out. - if (method_exists($table, 'checkout')) - { - if (!$table->checkout($user->get('id'), $id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to get the profile form. - * - * The base form is loaded from XML - * - * @param array $data An optional array of data for the form to interogate. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * - * @return JForm A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true) - { - // Get the form. - $form = $this->loadForm('com_subusers.organization', 'announcementform', array( - 'control' => 'jform', - 'load_data' => $loadData - ) - ); - - if (empty($form)) - { - return false; - } - - return $form; - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - $data = JFactory::getApplication()->getUserState('com_subusers.edit.organization.data', array()); - - if (empty($data)) - { - $data = $this->getData(); - } - - return $data; - } - - /** - * Method to save the form data. - * - * @param array $data The form data - * - * @return bool - * - * @throws Exception - * @since 1.6 - */ - public function save($data) - { - $user = JFactory::getUser(); - $id = ''; - - if ($data['id']) - { - $id = $data['id']; - } - - $org_id = $data['orgid']; - $data['catid'] = $this->getCatId($org_id); - $data['access'] = 1; - $data['state'] = 1; - $data['language'] = '*'; - - // Added to fetch data of organsiation form - $input = JFactory::getApplication()->input; - $formData = new JRegistry($input->get('jform', '', 'array')); - - if ($id) - { - // Check the user can edit this item - $authorised = $user->authorise('core.edit', 'com_subusers') || $authorised = $user->authorise('core.edit.own', 'com_subusers'); - - if ($user->authorise('core.edit.state', 'com_subusers') !== true && $state == 1) - { - // The user cannot edit the state of the item. - $data['state'] = 0; - } - } - else - { - // Check the user can create new items in this section - $authorised = $user->authorise('core.create', 'com_subusers'); - - if ($user->authorise('core.edit.state', 'com_subusers') !== true && $state == 1) - { - // The user cannot edit the state of the item. - $data['state'] = 0; - } - } - - if ($authorised !== true) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); - } - - // Insert data in content table - $db = JFactory::getDBO(); - $table = JTable::getInstance('Content', 'JTable', array('dbo', $db)); - $table->load(array('id' => $id)); - - if ($id) - { - if ($table->save($data) === true) - { - return true; - } - else - { - return false; - } - } - else - { - $data['id'] = ''; - - if ($table->save($data) === true) - { - } - else - { - return false; - } - } - } - - /** - * Method to delete data - * - * @param array $data Data to be deleted - * - * @return bool|int If success returns the id of the deleted item, if not false - * - * @throws Exception - */ - public function delete($data) - { - $id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('organization.id'); - - if (JFactory::getUser()->authorise('core.delete', 'com_subusers') !== true) - { - throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR')); - } - - $table = $this->getTable(); - - if ($table->delete($data['id']) === true) - { - return $id; - } - else - { - return false; - } - } - - /** - * Check if data can be saved - * - * @return bool - */ - public function getCanSave() - { - $table = $this->getTable(); - - return $table !== false; - } -} diff --git a/src/site/models/announcements.php b/src/site/models/announcements.php deleted file mode 100755 index 8c299a0..0000000 --- a/src/site/models/announcements.php +++ /dev/null @@ -1,295 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -defined('_JEXEC') or die; - -jimport('joomla.application.component.modellist'); - -/** - * Methods supporting a list of Subusers records. - * - * @since 1.6 - */ -class SubusersModelAnnouncements extends JModelList -{ - /** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * - * @see JController - * @since 1.6 - */ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( - 'id', 'a.id', - 'name', 'a.name', - 'created_by', 'a.created_by', - 'ordering', 'a.ordering', - 'state', 'a.state', - 'email', 'a.email', - 'logo', 'a.logo', - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering Elements order - * @param string $direction Order direction - * - * @return void - * - * @throws Exception - * - * @since 1.6 - */ - protected function populateState($ordering = null, $direction = null) - { - // Initialise variables. - $app = JFactory::getApplication(); - - // List state information - $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit')); - $this->setState('list.limit', $limit); - - $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0); - $this->setState('list.start', $limitstart); - - if ($list = $app->getUserStateFromRequest($this->context . '.list', 'list', array(), 'array')) - { - foreach ($list as $name => $value) - { - // Extra validations - switch ($name) - { - case 'fullordering': - $orderingParts = explode(' ', $value); - - if (count($orderingParts) >= 2) - { - // Latest part will be considered the direction - $fullDirection = end($orderingParts); - - if (in_array(strtoupper($fullDirection), array('ASC', 'DESC', ''))) - { - $this->setState('list.direction', $fullDirection); - } - - unset($orderingParts[count($orderingParts) - 1]); - - // The rest will be the ordering - $fullOrdering = implode(' ', $orderingParts); - - if (in_array($fullOrdering, $this->filter_fields)) - { - $this->setState('list.ordering', $fullOrdering); - } - } - else - { - $this->setState('list.ordering', $ordering); - $this->setState('list.direction', $direction); - } - break; - - case 'ordering': - if (!in_array($value, $this->filter_fields)) - { - $value = $ordering; - } - break; - - case 'direction': - if (!in_array(strtoupper($value), array('ASC', 'DESC', ''))) - { - $value = $direction; - } - break; - - case 'limit': - $limit = $value; - break; - - // Just to keep the default case - default: - $value = $value; - break; - } - - $this->setState('list.' . $name, $value); - } - } - - // Receive & set filters - if ($filters = $app->getUserStateFromRequest($this->context . '.filter', 'filter', array(), 'array')) - { - foreach ($filters as $name => $value) - { - $this->setState('filter.' . $name, $value); - } - } - - $ordering = $app->input->get('filter_order'); - - if (!empty($ordering)) - { - $list = $app->getUserState($this->context . '.list'); - $list['ordering'] = $app->input->get('filter_order'); - $app->setUserState($this->context . '.list', $list); - } - - $orderingDirection = $app->input->get('filter_order_Dir'); - - if (!empty($orderingDirection)) - { - $list = $app->getUserState($this->context . '.list'); - $list['direction'] = $app->input->get('filter_order_Dir'); - $app->setUserState($this->context . '.list', $list); - } - - $list = $app->getUserState($this->context . '.list'); - - if (empty($list['ordering'])) - { - $list['ordering'] = 'ordering'; - } - - if (empty($list['direction'])) - { - $list['direction'] = 'asc'; - } - - if (isset($list['ordering'])) - { - $this->setState('list.ordering', $list['ordering']); - } - - if (isset($list['direction'])) - { - $this->setState('list.direction', $list['direction']); - } - } - - /** - * Build an SQL query to load the list data for organisation - * - * @return JDatabaseQuery - * - * @since 1.6 - */ - protected function getListQuery() - { - // Create a new query object. - $db = $this->getDbo(); - $query = $db->getQuery(true); - - // Select the required fields from the table. - $query - ->select($this->getState( - 'list.select', 'DISTINCT a.*') - ); - $query->from('`#__content` AS a'); - - // Join over the users for the checked out user. - $query->join('INNER', '#__es_group_xref AS b ON (a.catid = b.category_id)'); - $query->where('a.state = 1'); - - // Filter by search in announcement name - $mainframe = JFactory::getApplication(); - $search = $mainframe->getUserStateFromRequest('.filter.search', 'filter_announcement_search'); - - if (!empty($search)) - { - if (stripos($search, 'id:') === 0) - { - $query->where('a.id = ' . (int) substr($search, 3)); - } - else - { - $search = $db->Quote('%' . $db->escape($search, true) . '%'); - $query->where('( a.title LIKE ' . $search . ' OR a.created_by LIKE ' . $search . ' )'); - } - } - - // 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)); - } - - return $query; - } - - /** - * Method to get an array of data items - * - * @return mixed An array of data on success, false on failure. - */ - public function getItems() - { - $items = parent::getItems(); - - return $items; - } - - /** - * Overrides the default function to check Date fields format, identified by - * "_dateformat" suffix, and erases the field if it's not correct. - * - * @return void - */ - protected function loadFormData() - { - $app = JFactory::getApplication(); - $filters = $app->getUserState($this->context . '.filter', array()); - $error_dateformat = false; - - foreach ($filters as $key => $value) - { - if (strpos($key, '_dateformat') && !empty($value) && $this->isValidDate($value) == null) - { - $filters[$key] = ''; - $error_dateformat = true; - } - } - - if ($error_dateformat) - { - $app->enqueueMessage(JText::_("COM_SUBUSERS_SEARCH_FILTER_DATE_FORMAT"), "warning"); - $app->setUserState($this->context . '.filter', $filters); - } - - return parent::loadFormData(); - } - - /** - * Checks if a given date is valid and in a specified format (YYYY-MM-DD) - * - * @param string $date Date to be checked - * - * @return bool - */ - private function isValidDate($date) - { - $date = str_replace('/', '-', $date); - - return (date_create($date)) ? JFactory::getDate($date)->format("Y-m-d") : null; - } -} diff --git a/src/site/models/forms/announcementform.xml b/src/site/models/forms/announcementform.xml deleted file mode 100755 index 81f2213..0000000 --- a/src/site/models/forms/announcementform.xml +++ /dev/null @@ -1,23 +0,0 @@ - -
-
- - - - - - - - -
- -
diff --git a/src/site/models/forms/filter_organizations.xml b/src/site/models/forms/filter_organizations.xml deleted file mode 100755 index 995dfa5..0000000 --- a/src/site/models/forms/filter_organizations.xml +++ /dev/null @@ -1,11 +0,0 @@ - -
- - - - - - -
\ No newline at end of file diff --git a/src/site/models/forms/organizationform.xml b/src/site/models/forms/organizationform.xml deleted file mode 100755 index bfc3092..0000000 --- a/src/site/models/forms/organizationform.xml +++ /dev/null @@ -1,81 +0,0 @@ - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/src/site/models/organization.php b/src/site/models/organization.php deleted file mode 100755 index dde5d6b..0000000 --- a/src/site/models/organization.php +++ /dev/null @@ -1,396 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access. -defined('_JEXEC') or die; - -require_once JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php'; -jimport('joomla.application.component.modelitem'); -jimport('joomla.event.dispatcher'); - -use Joomla\Utilities\ArrayHelper; -/** - * Subusers model. - * - * @since 1.6 - */ -class SubusersModelOrganization extends JModelItem -{ - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - * @since 1.6 - * - */ - protected function populateState() - { - $app = JFactory::getApplication('com_subusers'); - - // Load state from the request userState on edit or from the passed variable on default - if (JFactory::getApplication()->input->get('layout') == 'edit') - { - $id = JFactory::getApplication()->getUserState('com_subusers.edit.organization.id'); - } - else - { - $id = JFactory::getApplication()->input->get('id'); - JFactory::getApplication()->setUserState('com_subusers.edit.organization.id', $id); - } - - $this->setState('organization.id', $id); - - // Load the parameters. - $params = $app->getParams(); - $params_array = $params->toArray(); - - if (isset($params_array['item_id'])) - { - $this->setState('organization.id', $params_array['item_id']); - } - - $this->setState('params', $params); - } - - /** - * Method to get an object. - * - * @param integer $id The id of the object to get. - * - * @return mixed Object on success, false on failure. - */ - public function &getData($id = null) - { - if ($this->_item === null) - { - $this->_item = false; - - if (empty($id)) - { - $id = $this->getState('organization.id'); - } - - // Get a level row instance. - $table = $this->getTable(); - - // Attempt to load the row. - if ($table->load($id)) - { - // Check published state. - if ($published = $this->getState('filter.published')) - { - if ($table->state != $published) - { - return $this->_item; - } - } - - // Convert the JTable to a clean JObject. - $properties = $table->getProperties(1); - $this->_item = ArrayHelper::toObject($properties, 'JObject'); - } - } - - return $this->_item; - } - - /** - * Get an instance of JTable class - * - * @param string $type Name of the JTable class to get an instance of. - * @param string $prefix Prefix for the table class name. Optional. - * @param array $config Array of configuration values for the JTable object. Optional. - * - * @return JTable|bool JTable if success, false on failure. - */ - public function getTable($type = 'Organization', $prefix = 'SubusersTable', $config = array()) - { - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_subusers/tables'); - - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Get the id of an item by alias - * - * @param string $alias Item alias - * - * @return mixed - */ - public function getItemIdByAlias($alias) - { - $table = $this->getTable(); - $table->load(array('alias' => $alias)); - - return $table->id; - } - - /** - * Method to check in an item. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkin($id = null) - { - // Get the id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Attempt to check the row in. - if (method_exists($table, 'checkin')) - { - if (!$table->checkin($id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to check out an item for editing. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkout($id = null) - { - // Get the user id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Get the current user object. - $user = JFactory::getUser(); - - // Attempt to check the row out. - if (method_exists($table, 'checkout')) - { - if (!$table->checkout($user->get('id'), $id)) - { - return false; - } - } - } - - return true; - } - - /** - * Get the name of a category by id - * - * @param int $id Category id - * - * @return Object|null Object if success, null in case of failure - */ - public function getCategoryName($id) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query - ->select('title') - ->from('#__categories') - ->where('id = ' . $id); - $db->setQuery($query); - - return $db->loadObject(); - } - - /** - * Publish the element - * - * @param int $id Item id - * @param int $state Publish state - * - * @return boolean - */ - public function publish($id, $state) - { - $table = $this->getTable(); - $table->load($id); - $table->state = $state; - - return $table->store(); - } - - /** - * Method to delete an item - * - * @param int $id Element id - * - * @return bool - */ - public function delete($id) - { - $table = $this->getTable(); - - return $table->delete($id); - } - - /** - * Check member - * - * @param int $user_id Element id - * - * @return check - */ - public function checkmember($user_id,$orgid) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select('id') - ->from('#__tjsu_users') - ->where('user_id = ' . $user_id) - ->where('client_id = ' . $orgid); - $db->setQuery($query); - $result = $db->loadResult(); - - return $result; - } - - /** - * check state - * - * @param int $user_id Element id - * - * @return bool - */ - public function checkmemberstate($user_id,$orgid) - { - $table = $this->getTable('user'); - $table->load(array('user_id' => $user_id,'client_id' => $orgid)); - $result = $table->state; - - return $result; - } - - /** - * check state - * - * @param int $orgid Element id - * - * @param int $oluser_id Element id - * - * @return bool - */ - public function applymembership($orgid,$oluser_id) - { - $table = $this->getTable('user'); - $table->load(array('user_id' => $oluser_id)); - $tjsuid = $table->id; - $tjsuid = 0; - - if (!$tjsuid) - { - /*$table->client_id = $orgid; - return $table->store(); - Create the array of new fields.*/ - - $from = array('id' => '', - 'user_id' => $oluser_id, - 'client' => 'com_subusers.organisation', - 'client_id' => $orgid, - 'role_id' => '2', - 'state' => '0' - ); - - // Bind the array to the table object. - $table->bind($from); - - $grpid = $this->getGrpId($orgid); - $group = FD::group($grpid); - - // Get the user's access as we want to limit the number of groups they can join - $user = FD::user($oluser_id); - $access = $user->getAccess(); - $total = $user->getTotalGroups(); - - if ($access->exceeded('groups.join', $total)) - { - $obj->success = 0; - $obj->message = 'group joining limit exceeded'; - - return $obj; - } - - if (!$group->isMember($oluser_id)) - { - // Create a member record for the group - $members = $group->createMember($oluser_id); - } - - return $table->store(); - - return true; - } - - return false; - } - - /** - * Get $orgid - * - * @param int $orgid Org id - * - * @return org id - */ - - public function getGrpId($orgid) - { - // Get a db connection. - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - - // Create a new query object. - $query - ->select('a.grp_id') - ->from('`#__es_group_xref` AS a'); - $query->where('a.client_id=' . $orgid); - $db->setQuery($query); - $grp_id = $db->loadResult(); - - return $grp_id; - } - - /** - * Get $orgid - * - * @param int $orgid Org id - * - * @param int $oluser_id oluser id - * - * @return org id - */ - - public function checkIfOrgAdmin($orgid,$oluser_id) - { - $table = $this->getTable('user'); - $table->load(array('user_id' => $oluser_id,'client_id' => $orgid)); - - return $table->role_id; - } -} diff --git a/src/site/models/organizationform.php b/src/site/models/organizationform.php deleted file mode 100755 index 10d24ba..0000000 --- a/src/site/models/organizationform.php +++ /dev/null @@ -1,584 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -// No direct access. -defined('_JEXEC') or die; - -jimport('joomla.application.component.modelform'); -jimport('joomla.event.dispatcher'); - -use Joomla\Utilities\ArrayHelper; -/** - * Subusers model. - * - * @since 1.6 - */ -class SubusersModelOrganizationForm extends JModelForm -{ - private $item = null; - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @return void - * - * @since 1.6 - */ - protected function populateState() - { - $app = JFactory::getApplication('com_subusers'); - - // Load state from the request userState on edit or from the passed variable on default - if (JFactory::getApplication()->input->get('layout') == 'edit') - { - $id = JFactory::getApplication()->getUserState('com_subusers.edit.organization.id'); - } - else - { - $id = JFactory::getApplication()->input->get('id'); - JFactory::getApplication()->setUserState('com_subusers.edit.organization.id', $id); - } - - $this->setState('organization.id', $id); - - // Load the parameters. - $params = $app->getParams(); - $params_array = $params->toArray(); - - if (isset($params_array['item_id'])) - { - $this->setState('organization.id', $params_array['item_id']); - } - - $this->setState('params', $params); - } - - /** - * Method to get an ojbect. - * - * @param integer $id The id of the object to get. - * - * @return Object|boolean Object on success, false on failure. - * - * @throws Exception - */ - public function &getData($id = null) - { - if ($this->item === null) - { - $this->item = false; - - if (empty($id)) - { - $id = $this->getState('organization.id'); - } - - // Get a level row instance. - $table = $this->getTable(); - - // Attempt to load the row. - if ($table !== false && $table->load($id)) - { - $user = JFactory::getUser(); - $id = $table->id; - $canEdit = $user->authorise('core.edit', 'com_subusers') || $user->authorise('core.create', 'com_subusers'); - - if (!$canEdit && $user->authorise('core.edit.own', 'com_subusers')) - { - $canEdit = $user->id == $table->created_by; - } - - if (!$canEdit) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 500); - } - - // Check published state. - if ($published = $this->getState('filter.published')) - { - if ($table->state != $published) - { - return $this->item; - } - } - - // Convert the JTable to a clean JObject. - $properties = $table->getProperties(1); - $this->item = ArrayHelper::toObject($properties, 'JObject'); - } - } - - return $this->item; - } - - /** - * Method to get the table - * - * @param string $type Name of the JTable class - * @param string $prefix Optional prefix for the table class name - * @param array $config Optional configuration array for JTable object - * - * @return JTable|boolean JTable if found, boolean false on failure - */ - public function getTable($type = 'Organization', $prefix = 'SubusersTable', $config = array()) - { - $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_subusers/tables'); - - return JTable::getInstance($type, $prefix, $config); - } - - /** - * Get an item by alias - * - * @param string $alias Alias string - * - * @return int Element id - */ - public function getItemIdByAlias($alias) - { - $table = $this->getTable(); - - $table->load(array('alias' => $alias)); - - return $table->id; - } - - /** - * Method to check in an item. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkin($id = null) - { - // Get the id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Attempt to check the row in. - if (method_exists($table, 'checkin')) - { - if (!$table->checkin($id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to check out an item for editing. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkout($id = null) - { - // Get the user id. - $id = (!empty($id)) ? $id : (int) $this->getState('organization.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Get the current user object. - $user = JFactory::getUser(); - - // Attempt to check the row out. - if (method_exists($table, 'checkout')) - { - if (!$table->checkout($user->get('id'), $id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to get the profile form. - * - * The base form is loaded from XML - * - * @param array $data An optional array of data for the form to interogate. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * - * @return JForm A JForm object on success, false on failure - * - * @since 1.6 - */ - public function getForm($data = array(), $loadData = true) - { - // Get the form. - $form = $this->loadForm('com_subusers.organization', 'organizationform', array( - 'control' => 'jform', - 'load_data' => $loadData - ) - ); - - if (empty($form)) - { - return false; - } - - return $form; - } - - /** - * Method to get the data that should be injected in the form. - * - * @return mixed The data for the form. - * - * @since 1.6 - */ - protected function loadFormData() - { - $data = JFactory::getApplication()->getUserState('com_subusers.edit.organization.data', array()); - - if (empty($data)) - { - $data = $this->getData(); - } - - return $data; - } - - /** - * Method to save the form data. - * - * @param array $data The form data - * - * @return bool - * - * @throws Exception - * @since 1.6 - */ - public function save($data) - { - $id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('organization.id'); - $state = (!empty($data['state'])) ? 1 : 0; - $user = JFactory::getUser(); - - // Added to fetch data of organsiation form - $input = JFactory::getApplication()->input; - $formData = new JRegistry($input->get('jform', '', 'array')); - - if ($id) - { - // Check the user can edit this item - $authorised = $user->authorise('core.edit', 'com_subusers') || $authorised = $user->authorise('core.edit.own', 'com_subusers'); - - if ($user->authorise('core.edit.state', 'com_subusers') !== true && $state == 1) - { - // The user cannot edit the state of the item. - $data['state'] = 0; - } - } - else - { - // Check the user can create new items in this section - $authorised = $user->authorise('core.create', 'com_subusers'); - - if ($user->authorise('core.edit.state', 'com_subusers') !== true && $state == 1) - { - // The user cannot edit the state of the item. - $data['state'] = 0; - } - } - - if ($authorised !== true) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); - } - - // Insert daat in organisation table - $table = $this->getTable(); - - if ($id) - { - if ($table->save($data) === true) - { - return true; - } - else - { - return false; - } - } - else - { - if ($table->save($data) === true) - { - if ($table->id) - { - $userdata = new stdClass; - $userdata->user_id = $formData->get('userid', 0); - $userdata->client = 'com_subusers.organisation'; - $userdata->client_id = $table->id; - $userdata->role_id = 1; - $userdata->created_by = $user->id; - $userdata->ordering = '2'; - $userdata->state = '1'; - - $result = JFactory::getDBO()->insertObject('#__tjsu_users', $userdata); - - $params = JComponentHelper::getParams('com_subusers'); - $maincatid = $params->get('announementcategory', ''); - - // Set the extension. For content categories, use 'com_content' - $extension = 'com_content'; - - // Set the title for the category - $title = $formData->get('name'); - - // Type the description, this is also the 'body'. HTML allowed here. - $desc = ''; - - // Set the parent category. 1 is the root item. - $parent_id = $maincatid; - - // JTableCategory is autoloaded in J! 3.0, so... - if (version_compare(JVERSION, '3.0', 'lt')) - { - JTable::addIncludePath(JPATH_PLATFORM . 'joomla/database/table'); - } - - // Initialize a new category - $category = JTable::getInstance('Category'); - $category->extension = $extension; - $category->title = $title; - $category->description = $desc; - $category->published = 1; - $category->access = 1; - $category->params = '{"target":"","image":""}'; - $category->metadata = '{"page_title":"","author":"","robots":""}'; - $category->language = '*'; - - // Set the location in the tree - $category->setLocation($parent_id, 'last-child'); - - // Check to make sure our data is valid - if (!$category->check()) - { - JError::raiseNotice(500, $category->getError()); - - return false; - } - - // Now store the category - if (!$category->store(true)) - { - JError::raiseNotice(500, $category->getError()); - - return false; - } - - // Build the path for our category - $category->rebuildPath($category->id); - - // Check if data is inserted correctly in tjsu_users table - if ($result) - { - // Creat easysocial group - jimport('techjoomla.jsocial.jsocial'); - jimport('techjoomla.jsocial.easysocial'); - - $esdata = array(); - $esdata['title'] = $formData->get('name', 'string'); - $esdata['description'] = $formData->get('description', 'string'); - $esdata['uid'] = $formData->get('userid', 0); - - /* Easysocial group type - - 1. Open Group - 2. Closed Group - 3. Invite only groupInvite only */ - $esdata['type'] = '3'; - - $catid = array(); - $params = JComponentHelper::getParams('com_subusers'); - $catid['catId'] = $params->get('escategory', ''); - - // Create object - $jsSocialEasysocialObj = new JSocialEasysocial; - $groupid = $jsSocialEasysocialObj->createGroup($esdata, $catid); - - // @TODO with easy social - $member = $formData->get('userid', 0); - - if ($member) - { - $memberdata = new stdClass; - $memberdata->cluster_id = $groupid; - $memberdata->uid = $member; - $memberdata->type = 'user'; - $memberdata->created = 'user'; - $memberdata->state = '1'; - $memberdata->owner = '1'; - $memberdata->admin = '1'; - $memberdata->invited_by = '0'; - $memberdata->admin = '1'; - $memberdata->reminder_sent = $category->id; - - // Insert data in easysocial cluster table table - $grpMember = JFactory::getDBO()->insertObject('#__social_clusters_nodes', $memberdata); - } - - // Check if data is inserted correctly in tjsu_users table - if ($groupid) - { - $groupdata = new stdClass; - $groupdata->grp_id = $groupid; - $groupdata->client_id = $table->id; - $groupdata->category_id = $category->id; - - // Insert data in easysocial xref table - $grpid = JFactory::getDBO()->insertObject('#__es_group_xref', $groupdata); - - if ($grpid) - { - return true; - } - else - { - return false; - } - } - else - { - return false; - } - } - else - { - return false; - } - } - else - { - return false; - } - } - else - { - return false; - } - } - } - - /** - * Method to delete data - * - * @param array $data Data to be deleted - * - * @return bool|int If success returns the id of the deleted item, if not false - * - * @throws Exception - */ - public function delete($data) - { - $id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('organization.id'); - - if (JFactory::getUser()->authorise('core.delete', 'com_subusers') !== true) - { - throw new Exception(403, JText::_('JERROR_ALERTNOAUTHOR')); - } - - $table = $this->getTable(); - - if ($table->delete($data['id']) === true) - { - return $id; - } - else - { - return false; - } - } - - /** - * Check if data can be saved - * - * @return bool - */ - public function getCanSave() - { - $table = $this->getTable(); - - return $table !== false; - } - - /** - * To check if entered org id is already exists or not - * - * @param string $orgId orgId - * - * @return boolean - * - * @since 1.6 - */ - public function validateOrgId($orgId) - { - $query = "SELECT id FROM #__tjsu_organizations WHERE id = '" . $orgId . "'"; - $this->_db->setQuery($query); - $orgIdExists = $this->_db->loadResult(); - $nameid = ""; - - if ($orgIdExists) - { - return true; - } - else - { - return false; - } - } - - /** - * To check if entered is orgemail - * - * @param string $orgEmail Eamilid - * - * @return boolean - * - * @since 1.6 - */ - public function validateOrgEmail($orgEmail) - { - $query = "SELECT id FROM #__tjsu_organizations WHERE email = '" . $orgEmail . "'"; - $this->_db->setQuery($query); - $emailExists = $this->_db->loadResult(); - $nameid = ""; - - if ($emailExists) - { - return true; - } - else - { - return false; - } - } -} diff --git a/src/site/models/organizations.php b/src/site/models/organizations.php deleted file mode 100755 index 367c1a8..0000000 --- a/src/site/models/organizations.php +++ /dev/null @@ -1,302 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -defined('_JEXEC') or die; - -jimport('joomla.application.component.modellist'); - -/** - * Methods supporting a list of Subusers records. - * - * @since 1.6 - */ -class SubusersModelOrganizations extends JModelList -{ - /** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * - * @see JController - * @since 1.6 - */ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( - 'id', 'a.id', - 'name', 'a.name', - 'created_by', 'a.created_by', - 'ordering', 'a.ordering', - 'state', 'a.state', - 'email', 'a.email', - 'logo', 'a.logo', - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering Elements order - * @param string $direction Order direction - * - * @return void - * - * @throws Exception - * - * @since 1.6 - */ - protected function populateState($ordering = null, $direction = null) - { - // Initialise variables. - $app = JFactory::getApplication(); - - // List state information - $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit')); - $this->setState('list.limit', $limit); - - $limitstart = $app->getUserStateFromRequest('limitstart', 'limitstart', 0); - $this->setState('list.start', $limitstart); - - if ($list = $app->getUserStateFromRequest($this->context . '.list', 'list', array(), 'array')) - { - foreach ($list as $name => $value) - { - // Extra validations - switch ($name) - { - case 'fullordering': - $orderingParts = explode(' ', $value); - - if (count($orderingParts) >= 2) - { - // Latest part will be considered the direction - $fullDirection = end($orderingParts); - - if (in_array(strtoupper($fullDirection), array('ASC', 'DESC', ''))) - { - $this->setState('list.direction', $fullDirection); - } - - unset($orderingParts[count($orderingParts) - 1]); - - // The rest will be the ordering - $fullOrdering = implode(' ', $orderingParts); - - if (in_array($fullOrdering, $this->filter_fields)) - { - $this->setState('list.ordering', $fullOrdering); - } - } - else - { - $this->setState('list.ordering', $ordering); - $this->setState('list.direction', $direction); - } - break; - - case 'ordering': - if (!in_array($value, $this->filter_fields)) - { - $value = $ordering; - } - break; - - case 'direction': - if (!in_array(strtoupper($value), array('ASC', 'DESC', ''))) - { - $value = $direction; - } - break; - - case 'limit': - $limit = $value; - break; - - // Just to keep the default case - default: - $value = $value; - break; - } - - $this->setState('list.' . $name, $value); - } - } - - // Receive & set filters - if ($filters = $app->getUserStateFromRequest($this->context . '.filter', 'filter', array(), 'array')) - { - foreach ($filters as $name => $value) - { - $this->setState('filter.' . $name, $value); - } - } - - $ordering = $app->input->get('filter_order'); - - if (!empty($ordering)) - { - $list = $app->getUserState($this->context . '.list'); - $list['ordering'] = $app->input->get('filter_order'); - $app->setUserState($this->context . '.list', $list); - } - - $orderingDirection = $app->input->get('filter_order_Dir'); - - if (!empty($orderingDirection)) - { - $list = $app->getUserState($this->context . '.list'); - $list['direction'] = $app->input->get('filter_order_Dir'); - $app->setUserState($this->context . '.list', $list); - } - - $list = $app->getUserState($this->context . '.list'); - - if (empty($list['ordering'])) - { - $list['ordering'] = 'ordering'; - } - - if (empty($list['direction'])) - { - $list['direction'] = 'asc'; - } - - if (isset($list['ordering'])) - { - $this->setState('list.ordering', $list['ordering']); - } - - if (isset($list['direction'])) - { - $this->setState('list.direction', $list['direction']); - } - } - - /** - * Build an SQL query to load the list data for organisation - * - * @return JDatabaseQuery - * - * @since 1.6 - */ - protected function getListQuery() - { - $app = JFactory::getApplication(); - - // Create a new query object. - $db = $this->getDbo(); - $query = $db->getQuery(true); - - // Select the required fields from the table. - $query - ->select( - $this->getState( - 'list.select', 'DISTINCT a.*' - ) - ); - - $query->from('`#__tjsu_organizations` As a'); - - // $query->join('LEFT', '#__tjsu_users AS uc ON uc.client_id = a.id'); - - if (!JFactory::getUser()->authorise('core.edit.state', 'com_subusers')) - { - $query->where('a.state = 1'); - } - - // Filter by search in organisation name - $search = $app->getUserStateFromRequest('.filter.search', 'filter_organisation_search'); - - if (!empty($search)) - { - if (stripos($search, 'id:') === 0) - { - $query->where('a.id = ' . (int) substr($search, 3)); - } - else - { - $search = $db->Quote('%' . $db->escape($search, true) . '%'); - $query->where('( a.name LIKE ' . $search . ' OR a.created_by LIKE ' . $search . ' )'); - } - } - - // 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)); - } - - return $query; - } - - /** - * Method to get an array of data items - * - * @return mixed An array of data on success, false on failure. - */ - public function getItems() - { - $items = parent::getItems(); - - return $items; - } - - /** - * Overrides the default function to check Date fields format, identified by - * "_dateformat" suffix, and erases the field if it's not correct. - * - * @return void - */ - protected function loadFormData() - { - $app = JFactory::getApplication(); - $filters = $app->getUserState($this->context . '.filter', array()); - $error_dateformat = false; - - foreach ($filters as $key => $value) - { - if (strpos($key, '_dateformat') && !empty($value) && $this->isValidDate($value) == null) - { - $filters[$key] = ''; - $error_dateformat = true; - } - } - - if ($error_dateformat) - { - $app->enqueueMessage(JText::_("COM_SUBUSERS_SEARCH_FILTER_DATE_FORMAT"), "warning"); - $app->setUserState($this->context . '.filter', $filters); - } - - return parent::loadFormData(); - } - - /** - * Checks if a given date is valid and in a specified format (YYYY-MM-DD) - * - * @param string $date Date to be checked - * - * @return bool - */ - private function isValidDate($date) - { - $date = str_replace('/', '-', $date); - - return (date_create($date)) ? JFactory::getDate($date)->format("Y-m-d") : null; - } -} diff --git a/src/site/views/announcementform/index.html b/src/site/views/announcementform/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/announcementform/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/announcementform/tmpl/default.php b/src/site/views/announcementform/tmpl/default.php deleted file mode 100755 index 6d34e88..0000000 --- a/src/site/views/announcementform/tmpl/default.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -JHtml::_('behavior.keepalive'); -JHtml::_('behavior.tooltip'); -JHtml::_('behavior.formvalidation'); -JHtml::_('formbehavior.chosen', 'select'); - -// Load admin language file -$lang = JFactory::getLanguage(); -$lang->load('com_subusers', JPATH_SITE); -$doc = JFactory::getDocument(); -$doc->addScript(JUri::base() . '/media/com_subusers/js/form.js'); -$user = JFactory::getUser(); -$userId = $user->get('id'); - -?> - - - -
-
-
- item->id)): ?> -

- -

- -
-
- -
-
-
-
- -
form->getInput('title'); ?>
-
- -
- -
form->getInput('introtext'); ?>
-
- - -
-
-
-
-
- canSave): ?> - - - - - -
-
-
-
- - - - - - - - - - -
-
-
-
diff --git a/src/site/views/announcementform/tmpl/default.xml b/src/site/views/announcementform/tmpl/default.xml deleted file mode 100755 index 7a5e1ff..0000000 --- a/src/site/views/announcementform/tmpl/default.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - -
- - -
-
-
diff --git a/src/site/views/announcementform/tmpl/index.html b/src/site/views/announcementform/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/announcementform/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/announcementform/view.html.php b/src/site/views/announcementform/view.html.php deleted file mode 100755 index 55a96c5..0000000 --- a/src/site/views/announcementform/view.html.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View to edit - * - * @since 1.6 - */ -class SubusersViewAnnouncementform extends JViewLegacy -{ - protected $state; - - protected $item; - - protected $form; - - protected $params; - - protected $canSave; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - - $this->state = $this->get('State'); - $this->item = $this->get('Data'); - $this->params = $app->getParams('com_subusers'); - $this->canSave = $this->get('CanSave'); - $this->form = $this->get('Form'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - $jinput = JFactory::getApplication()->input; - $this->org_id = $jinput->get('org_id', '', 'INT'); - - $this->_prepareDocument(); - - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // we need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - $title = $this->params->get('page_title', ''); - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } -} diff --git a/src/site/views/announcements/index.html b/src/site/views/announcements/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/announcements/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/announcements/tmpl/default.php b/src/site/views/announcements/tmpl/default.php deleted file mode 100755 index 2576825..0000000 --- a/src/site/views/announcements/tmpl/default.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @copyright Copyright (C) 2015 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'); - -$mainframe = JFactory::getApplication(); -$search_organisation = $mainframe->getUserStateFromRequest('.filter_organisation_search', 'filter_organisation_search'); -$user = JFactory::getUser(); -$userId = $user->get('id'); -$listOrder = $this->state->get('list.ordering'); -$listDirn = $this->state->get('list.direction'); -$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'); -$canDelete = $user->authorise('core.delete', 'com_subusers'); -?> - - - - - -
-
-
-

-
- -
- - - - - -
-
- -
-
- - -
- - -
- -
- - pagination->getLimitBox(); ?> -
-
- - items)) - { - ?> -
- - - - items[0]->id)): ?> - - - - items[0]->state)): ?> - - - - - - - - - - - - - - items as $i => $item) : ?> - authorise('core.edit', 'com_subusers'); ?> - - authorise('core.edit.own', 'com_subusers')): ?> - id == $item->created_by; ?> - - - - items[0]->id)): ?> - - - - items[0]->state)) : ?> - - - - - - - - - - -
- - - - - - - -
- pagination->getListFooter(); ?> -
- id; ?> - - - state == 1): ?> - - - - - - - - - escape($item->title); ?> - - - escape($item->title); ?> - - - introtext; ?> -
-
- -
- - - - - - - -
-
diff --git a/src/site/views/announcements/tmpl/default.xml b/src/site/views/announcements/tmpl/default.xml deleted file mode 100755 index 5328edd..0000000 --- a/src/site/views/announcements/tmpl/default.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/site/views/announcements/tmpl/default_filter.php b/src/site/views/announcements/tmpl/default_filter.php deleted file mode 100755 index cb8b85f..0000000 --- a/src/site/views/announcements/tmpl/default_filter.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -$data = $displayData; - -// Receive overridable options -$data['options'] = !empty($data['options']) ? $data['options'] : array(); - -// Check if any filter field has been filled -$filters = false; - -if (isset($data['view']->filterForm)) -{ - $filters = $data['view']->filterForm->getGroup('filter'); -} - -// Check if there are filters set. -if ($filters !== false) -{ - $filterFields = array_keys($filters); - $filtered = false; - $filled = false; - - foreach ($filterFields as $filterField) - { - $filterField = substr($filterField, 7); - $filter = $data['view']->getState('filter.' . $filterField); - - if (!empty($filter)) - { - $filled = $filter; - } - - if (!empty($filled)) - { - $filtered = true; - break; - } - } -} - -$options = $data['options']; - -// Set some basic options -$customOptions = array( - 'filtersHidden' => isset($options['filtersHidden']) ? $options['filtersHidden'] : empty($data['view']->activeFilters) && !$filtered, - 'defaultLimit' => isset($options['defaultLimit']) ? $options['defaultLimit'] : JFactory::getApplication()->get('list_limit', 20), - 'searchFieldSelector' => '#filter_search', - 'orderFieldSelector' => '#list_fullordering' -); - -$data['options'] = array_unique(array_merge($customOptions, $data['options'])); - -$formSelector = !empty($data['options']['formSelector']) ? $data['options']['formSelector'] : '#adminForm'; - -// Load search tools -JHtml::_('searchtools.form', $formSelector, $data['options']); -?> - -
-
-
- - -
- input; ?> - -
- -
- -
- - -
- -
-
-
- -
- - - $field) : ?> - -
- input; ?> -
- - - -
-
\ No newline at end of file diff --git a/src/site/views/announcements/tmpl/index.html b/src/site/views/announcements/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/announcements/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/announcements/view.html.php b/src/site/views/announcements/view.html.php deleted file mode 100755 index b5a1192..0000000 --- a/src/site/views/announcements/view.html.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View class for a list of Subusers. - * - * @since 1.6 - */ -class SubusersViewAnnouncements extends JViewLegacy -{ - protected $items; - - protected $pagination; - - protected $state; - - protected $params; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - - $this->state = $this->get('State'); - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->params = $app->getParams('com_subusers'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - $this->_prepareDocument(); - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // we need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - $title = $this->params->get('page_title', ''); - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } - - /** - * Check if state is set - * - * @param mixed $state State - * - * @return bool - */ - public function getState($state) - { - return isset($this->state->{$state}) ? $this->state->{$state} : false; - } -} diff --git a/src/site/views/organization/index.html b/src/site/views/organization/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organization/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organization/tmpl/default.php b/src/site/views/organization/tmpl/default.php deleted file mode 100755 index bbf7678..0000000 --- a/src/site/views/organization/tmpl/default.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; -jimport('joomla.application.module.helper'); -JHTML::_('behavior.modal'); - -$document = JFactory::getDocument(); -$document->addStylesheet(JUri::root(true) . '/media/com_subusers/css/subusers.css'); -$canEdit = JFactory::getUser()->authorise('core.edit', 'com_subusers'); -$pagetitle = $this->item->name; -JFactory::getDocument()->setTitle($pagetitle); -if (!$canEdit && JFactory::getUser()->authorise('core.edit.own', 'com_subusers')) -{ - $canEdit = JFactory::getUser()->id == $this->item->created_by; -} -?> - -item): ?> -
- item):?> -
- -
-

item->name; ?>

-
-
- -
loadTemplate("slider"); ?>
-
 
-
- -
- item->description;?> -
-
-
 
- - - - - - - -
 
-
- - diff --git a/src/site/views/organization/tmpl/default.xml b/src/site/views/organization/tmpl/default.xml deleted file mode 100755 index 9c121d9..0000000 --- a/src/site/views/organization/tmpl/default.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - -
- - -
-
-
diff --git a/src/site/views/organization/tmpl/default_membership.php b/src/site/views/organization/tmpl/default_membership.php deleted file mode 100755 index 2726e70..0000000 --- a/src/site/views/organization/tmpl/default_membership.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; -jimport('joomla.filesystem.file'); -jimport('joomla.filesystem.folder'); -$document = JFactory::getDocument(); -$document->addStylesheet(JUri::root(true) . '/media/com_subusers/css/subusers.css'); -$canEdit = JFactory::getUser()->authorise('core.edit', 'com_subusers'); - -if (!$canEdit && JFactory::getUser()->authorise('core.edit.own', 'com_subusers')) -{ - $canEdit = JFactory::getUser()->id == $this->item->created_by; -} - -?> - oluser_id) - { - if ($this->memberstate == '') - { - ?> -
- - - - - - -
- memberstate == 0) - { - - ?> -
- memberstate == 1) - { - ?> -
- -
- - - - diff --git a/src/site/views/organization/tmpl/default_slider.php b/src/site/views/organization/tmpl/default_slider.php deleted file mode 100755 index 7eba3ee..0000000 --- a/src/site/views/organization/tmpl/default_slider.php +++ /dev/null @@ -1,59 +0,0 @@ - -* @copyright Copyright (C) 2015. All rights reserved. -* @license GNU General Public License version 2 or later; see LICENSE.txt -*/ -// No direct access -defined('_JEXEC') or die; -jimport('joomla.filesystem.file'); -jimport( 'joomla.filesystem.folder' ); - -$document = JFactory::getDocument(); -$document->addStylesheet(JUri::root(true).'/media/com_subusers/css/subusers.css'); -$canEdit = JFactory::getUser()->authorise('core.edit', 'com_subusers'); -if (!$canEdit && JFactory::getUser()->authorise('core.edit.own', 'com_subusers')) { -$canEdit = JFactory::getUser()->id == $this->item->created_by; -} -?> - - diff --git a/src/site/views/organization/tmpl/index.html b/src/site/views/organization/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organization/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organization/view.html.php b/src/site/views/organization/view.html.php deleted file mode 100755 index 4b61306..0000000 --- a/src/site/views/organization/view.html.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @copyright Copyright (C) 2015 Techjoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View to edit - * - * @since 1.6 - */ -class SubusersViewOrganization extends JViewLegacy -{ - protected $state; - - protected $item; - - protected $form; - - protected $params; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - - $this->state = $this->get('State'); - $this->item = $this->get('Data'); - $this->params = $app->getParams('com_subusers'); - $this->oluser_id = $user->id; - $model = $this->getModel(); - - $jinput = JFactory::getApplication()->input; - $orgid = $jinput->get('id', '0', 'INT'); - - $this->memberOrgId = $model->checkmember($this->oluser_id, $orgid); - $this->memberstate = $model->checkmemberstate($this->oluser_id, $orgid); - $this->checkIfOrgAdmin = $model->checkIfOrgAdmin($this->item->id, $this->oluser_id); - - if (!empty($this->item)) - { - $this->form = $this->get('Form'); - } - - if (!$orgid) - { - $app->redirect(JRoute::_('index.php?option=com_subusers&view=organizations&layout=pin', false)); - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - if ($this->_layout == 'edit') - { - $authorised = $user->authorise('core.create', 'com_subusers'); - - if ($authorised !== true) - { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR')); - } - } - - $this->_prepareDocument(); - - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // We need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - $title = $this->params->get('page_title', ''); - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } -} diff --git a/src/site/views/organizationform/index.html b/src/site/views/organizationform/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organizationform/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organizationform/tmpl/default.php b/src/site/views/organizationform/tmpl/default.php deleted file mode 100755 index 4bc39df..0000000 --- a/src/site/views/organizationform/tmpl/default.php +++ /dev/null @@ -1,271 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -JHtml::_('behavior.keepalive'); -JHtml::_('behavior.tooltip'); -JHtml::_('behavior.formvalidation'); -JHtml::_('formbehavior.chosen', 'select'); - -// Create object -$doc = JFactory::getDocument(); -$doc->addScript(JUri::base() . '/media/com_subusers/js/sub.js'); - -// Sweet alerts -$doc->addScript(JUri::root(true) . '/media/com_ekcontent/vendors/sweetalert/sweetalert.min.js'); -$doc->addStyleSheet(JUri::root(true) . '/media/com_ekcontent/vendors/sweetalert/sweetalert.css'); - -// Load admin language file -$lang = JFactory::getLanguage(); -$lang->load('com_subusers', JPATH_SITE); - -$doc->addScript(JUri::base() . '/media/com_subusers/js/form.js'); -$doc->addStylesheet(JUri::root(true) . '/media/com_subusers/css/subusers.css'); -$user = JFactory::getUser(); -$userId = $user->get( 'id' ); - -// Acl helper call -require_once JPATH_COMPONENT . '/helpers/acl.php'; - -// Call static method for language constant -SubusersFrontendHelper::getLanguageConstant(); -$orgId = $this->item->id; -$userdata = SubusersAclHelper::partnerAdminName($orgId); -?> - - - - -
-
-
- item->id)): ?> -

- -

- -
-
- -
- -
-
-
- -
- form->getInput('id'); ?> -
-
- -
- -
- form->getInput('name'); ?>
-
- -
- -
- form->getInput('email'); ?> -
-
- - -
- -
- name; ?> -
-
- - -
- -
- form->getInput('userid'); ?> -
-
- - - -
- form->getLabel('logo'); ?> -
-
- - - - form->getInput('logo'); ?> - - - -
- -

- subusersParams->get('allowed_logo_types')); ?> -
- subusersParams->get('max_logo_size')); ?> -

- -
- item->logo)) : - foreach ((array) $this->item->logo as $singleFile) : - if (!is_array($singleFile)) : - echo ''; - endif; - endforeach; - endif;?> -
- - -
-
- -
- -
- form->getInput('description'); ?> -
-
- -
-
-
-
-
- canSave): ?> - - - - - -
-
-
-
- - - - - - - - - - -
-
-
-
- - diff --git a/src/site/views/organizationform/tmpl/default.xml b/src/site/views/organizationform/tmpl/default.xml deleted file mode 100755 index 0379285..0000000 --- a/src/site/views/organizationform/tmpl/default.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - -
- - -
-
-
diff --git a/src/site/views/organizationform/tmpl/index.html b/src/site/views/organizationform/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organizationform/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organizationform/view.html.php b/src/site/views/organizationform/view.html.php deleted file mode 100755 index 6837c1b..0000000 --- a/src/site/views/organizationform/view.html.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ -// No direct access -defined('_JEXEC') or die; - -jimport('joomla.application.component.view'); - -/** - * View to edit - * - * @since 1.6 - */ -class SubusersViewOrganizationform extends JViewLegacy -{ - protected $state; - - protected $item; - - protected $form; - - protected $params; - - protected $canSave; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - - $this->state = $this->get('State'); - $this->item = $this->get('Data'); - $this->params = $app->getParams('com_subusers'); - $this->canSave = $this->get('CanSave'); - $this->form = $this->get('Form'); - $this->subusersParams = JComponentHelper::getParams('com_subusers'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - $this->_prepareDocument(); - - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // we need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - if (empty($title)) - { - if (!empty($this->item->name)) - { - $title = $this->item->name; - } - else - { - $title = JText::_('COM_SUBUSERS_ORGANIZATION_FORM_PAGE_TITLE'); - } - } - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } -} diff --git a/src/site/views/organizations/index.html b/src/site/views/organizations/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organizations/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organizations/tmpl/default.php b/src/site/views/organizations/tmpl/default.php deleted file mode 100755 index b55bb28..0000000 --- a/src/site/views/organizations/tmpl/default.php +++ /dev/null @@ -1,216 +0,0 @@ - - * @copyright Copyright (C) 2015. 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'); - -// Load js -$doc = JFactory::getDocument(); -$doc->addScript(JUri::base() . '/media/com_subusers/js/sub.js'); - -$mainframe = JFactory::getApplication(); -$search_organisation = $mainframe->getUserStateFromRequest('.filter_organisation_search', 'filter_organisation_search'); - -$user = JFactory::getUser(); -$userId = $user->get('id'); -$listOrder = $this->state->get('list.ordering'); -$listDirn = $this->state->get('list.direction'); -$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'); -$canDelete = $user->authorise('core.delete', 'com_subusers');?> - - - -
-
-
-

-
-
-
-
-
- -
- - -
- isSuperAdmin) - { - if ($canCreate) : ?> - - - -
- - -
- - - items)) - { - ?> -
- - - - items[0]->id)): ?> - - - - items[0]->state)): ?> - - - - - - - - - - - - - - - - - - - items as $i => $item) : ?> - authorise('core.edit', 'com_subusers'); ?> - - authorise('core.edit.own', 'com_subusers')): ?> - id == $item->created_by; ?> - - - - items[0]->id)): ?> - - - - items[0]->state)) : ?> - - - - - - - - - - - -
- - - - - - - - - -
- pagination->getListFooter(); ?> -
- id; ?> - - - state == 1): ?> - - - - - - - - - escape($item->name); ?> - - - escape($item->name); ?> - - - email; ?> - - userid); - echo $user->name; ?> - - - - -
-
- -
- -
- - - - - - -
-
-
-
- - - diff --git a/src/site/views/organizations/tmpl/default.xml b/src/site/views/organizations/tmpl/default.xml deleted file mode 100755 index 5328edd..0000000 --- a/src/site/views/organizations/tmpl/default.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/site/views/organizations/tmpl/default_filter.php b/src/site/views/organizations/tmpl/default_filter.php deleted file mode 100755 index cb8b85f..0000000 --- a/src/site/views/organizations/tmpl/default_filter.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Copyright (C) 2015. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('JPATH_BASE') or die; - -$data = $displayData; - -// Receive overridable options -$data['options'] = !empty($data['options']) ? $data['options'] : array(); - -// Check if any filter field has been filled -$filters = false; - -if (isset($data['view']->filterForm)) -{ - $filters = $data['view']->filterForm->getGroup('filter'); -} - -// Check if there are filters set. -if ($filters !== false) -{ - $filterFields = array_keys($filters); - $filtered = false; - $filled = false; - - foreach ($filterFields as $filterField) - { - $filterField = substr($filterField, 7); - $filter = $data['view']->getState('filter.' . $filterField); - - if (!empty($filter)) - { - $filled = $filter; - } - - if (!empty($filled)) - { - $filtered = true; - break; - } - } -} - -$options = $data['options']; - -// Set some basic options -$customOptions = array( - 'filtersHidden' => isset($options['filtersHidden']) ? $options['filtersHidden'] : empty($data['view']->activeFilters) && !$filtered, - 'defaultLimit' => isset($options['defaultLimit']) ? $options['defaultLimit'] : JFactory::getApplication()->get('list_limit', 20), - 'searchFieldSelector' => '#filter_search', - 'orderFieldSelector' => '#list_fullordering' -); - -$data['options'] = array_unique(array_merge($customOptions, $data['options'])); - -$formSelector = !empty($data['options']['formSelector']) ? $data['options']['formSelector'] : '#adminForm'; - -// Load search tools -JHtml::_('searchtools.form', $formSelector, $data['options']); -?> - -
-
-
- - -
- input; ?> - -
- -
- -
- - -
- -
-
-
- -
- - - $field) : ?> - -
- input; ?> -
- - - -
-
\ No newline at end of file diff --git a/src/site/views/organizations/tmpl/index.html b/src/site/views/organizations/tmpl/index.html deleted file mode 100755 index 42682b4..0000000 --- a/src/site/views/organizations/tmpl/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/site/views/organizations/tmpl/pin.php b/src/site/views/organizations/tmpl/pin.php deleted file mode 100755 index 9673a26..0000000 --- a/src/site/views/organizations/tmpl/pin.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright Copyright (C) 2015 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'); - -$mainframe = JFactory::getApplication(); -$search_organisation = $mainframe->getUserStateFromRequest('.filter_organisation_search', 'filter_organisation_search'); - -$user = JFactory::getUser(); -$userId = $user->get('id'); -$listOrder = $this->state->get('list.ordering'); -$listDirn = $this->state->get('list.direction'); -$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'); -$canDelete = $user->authorise('core.delete', 'com_subusers'); - -$document = JFactory::getDocument(); -$document->addStylesheet(JUri::root(true) . '/media/com_subusers/css/subusers.css'); -?> - - - -
-
-
-
- -
- -
- - -
- -
- -
-
-

- -

-
-
- -
- items) - { - foreach ($this->items as $i => $item) - { - ?> - - - - -
-
- -
-
- -
- -
 
- - - - - - - -
-
-
-
diff --git a/src/site/views/organizations/view.html.php b/src/site/views/organizations/view.html.php deleted file mode 100755 index 6e8c444..0000000 --- a/src/site/views/organizations/view.html.php +++ /dev/null @@ -1,162 +0,0 @@ - - * @package Subusers - * @author Techjoomla - * @copyright Copyright (c) 2009-2015 TechJoomla. All rights reserved - * @license GNU General Public License version 2, or later - */ - -// No direct access -defined('_JEXEC') or die('Restricted access'); - -jimport('joomla.application.component.view'); - -JPATH_SITE . 'components/com_subusers/helpers/subusers.php'; - -/** - * View class for a list of Subusers. - * - * @since 1.6 - */ -class SubusersViewOrganizations extends JViewLegacy -{ - protected $items; - - protected $pagination; - - protected $state; - - protected $params; - - /** - * Display the view - * - * @param string $tpl Template name - * - * @return void - * - * @throws Exception - */ - public function display($tpl = null) - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - $layout = $app->input->get('layout', 'default'); - - $this->state = $this->get('State'); - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->params = $app->getParams('com_subusers'); - - $user = JFactory::getUser(); - $uid = $user->id; - - // Import helper file - require_once JPATH_COMPONENT . '/helpers/acl.php'; - - // Check logged in user is admin of organization - $this->isAdmin = SubusersAclHelper::isOrganisationAdmin($uid); - - // Check logged in user is superuser or not - $this->isSuperAdmin = SubusersAclHelper::isSuperAdmin($uid); - - if ($layout == 'default') - { - if (!$user->id) - { - $mainframe = JFactory::getApplication(); - $mainframe->redirect("index.php?option=com_subusers&view=organizations&layout=pin&Itemid="); - } - elseif(!$this->isSuperAdmin) - { - $mainframe = JFactory::getApplication(); - $mainframe->redirect("index.php?option=com_subusers&view=organizations&layout=pin"); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors)); - } - - $this->_prepareDocument(); - - parent::display($tpl); - } - - /** - * Prepares the document - * - * @return void - * - * @throws Exception - */ - protected function _prepareDocument() - { - $app = JFactory::getApplication(); - $menus = $app->getMenu(); - $title = null; - - // Because the application sets a default page title, - // we need to get it from the menu item itself - $menu = $menus->getActive(); - - if ($menu) - { - $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); - } - else - { - $this->params->def('page_heading', JText::_('COM_SUBUSERS_DEFAULT_PAGE_TITLE')); - } - - if (empty($title)) - { - $title = JText::_('COM_SUBUSERS_ORGANIZATION_LIST_PAGE_TITLE'); - } - - if (empty($title)) - { - $title = $app->get('sitename'); - } - elseif ($app->get('sitename_pagetitles', 0) == 1) - { - $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); - } - elseif ($app->get('sitename_pagetitles', 0) == 2) - { - $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); - } - - $this->document->setTitle($title); - - if ($this->params->get('menu-meta_description')) - { - $this->document->setDescription($this->params->get('menu-meta_description')); - } - - if ($this->params->get('menu-meta_keywords')) - { - $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); - } - - if ($this->params->get('robots')) - { - $this->document->setMetadata('robots', $this->params->get('robots')); - } - } - - /** - * Check if state is set - * - * @param mixed $state State - * - * @return bool - */ - public function getState($state) - { - return isset($this->state->{$state}) ? $this->state->{$state} : false; - } -} diff --git a/src/subusers.xml b/src/subusers.xml index 6d00b26..22ca9dd 100755 --- a/src/subusers.xml +++ b/src/subusers.xml @@ -2,22 +2,22 @@ com_subusers 2016-01-07 - Copyright (C) 2015. All rights reserved. + Copyright (C) 2009 - 2018 Techjoomla. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt Techjoomla contact@techjoomla.com https://techjoomla.com - CVS: 1.0.0 + 1.0.0 This is to sudo-make role based user management easy. script.php - + sql/install.mysql.utf8.sql - + sql/uninstall.mysql.utf8.sql @@ -38,23 +38,15 @@ css - en-GB/en-GB.com_subusers.ini COM_SUBUSERS - - COM_SUBUSERS_TITLE_ORGANIZATIONS - COM_SUBUSERS_TITLE_USERS - COM_SUBUSERS_TITLE_ROLES - COM_SUBUSERS_TITLE_ACTIONS - COM_SUBUSERS_TITLE_MAPPINGS - access.xml @@ -63,6 +55,8 @@ index.html subusers.php controllers + includes + libraries assets helpers models @@ -71,15 +65,8 @@ views - en-GB/en-GB.com_subusers.ini en-GB/en-GB.com_subusers.sys.ini - - - - - -