Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/administrator/controllers/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@

defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Router\Route;

/**
* Installer Database Controller
*
* @since 2.5
*/
class SubusersControllerDatabase extends JControllerLegacy
class SubusersControllerDatabase extends BaseController
{
/**
* Tries to fix missing database updates
Expand All @@ -28,19 +33,19 @@ class SubusersControllerDatabase extends JControllerLegacy
public function fix()
{
// Get a handle to the Joomla! application object
$application = JFactory::getApplication();
$application = Factory::getApplication();

$model = $this->getModel('database');
$model->fix();

// Purge updates
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_joomlaupdate/models', 'JoomlaupdateModel');
$updateModel = JModelLegacy::getInstance('default', 'JoomlaupdateModel');
BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_joomlaupdate/models', 'JoomlaupdateModel');
$updateModel = BaseDatabaseModel::getInstance('default', 'JoomlaupdateModel');
$updateModel->purge();

// Refresh versionable assets cache
JFactory::getApplication()->flushAssets();
Factory::getApplication()->flushAssets();

$this->setRedirect(JRoute::_('index.php?option=com_subusers&view=organizations', false));
$this->setRedirect(Route::_('index.php?option=com_subusers&view=organizations', false));
}
}
9 changes: 5 additions & 4 deletions src/administrator/helpers/subusers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

defined('_JEXEC') or die();
use Joomla\CMS\Language\Text;

/**
* Subusers helper.
Expand All @@ -26,9 +27,9 @@ class SubusersHelper
*/
public static function addSubmenu($vName = '')
{
JHtmlSidebar::addEntry(JText::_('COM_SUBUSERS_TITLE_ROLES'), 'index.php?option=com_subusers&view=roles', $vName == 'roles');
JHtmlSidebar::addEntry(JText::_('COM_SUBUSERS_TITLE_ACTIONS'), 'index.php?option=com_subusers&view=actions', $vName == 'actions');
JHtmlSidebar::addEntry(JText::_('COM_SUBUSERS_TITLE_MAPPINGS'), 'index.php?option=com_subusers&view=mappings', $vName == 'mappings');
JHtmlSidebar::addEntry(JText::_('COM_SUBUSERS_TITLE_USERS'), 'index.php?option=com_subusers&view=users', $vName == 'users');
JHtmlSidebar::addEntry(Text::_('COM_SUBUSERS_TITLE_ROLES'), 'index.php?option=com_subusers&view=roles', $vName == 'roles');
JHtmlSidebar::addEntry(Text::_('COM_SUBUSERS_TITLE_ACTIONS'), 'index.php?option=com_subusers&view=actions', $vName == 'actions');
JHtmlSidebar::addEntry(Text::_('COM_SUBUSERS_TITLE_MAPPINGS'), 'index.php?option=com_subusers&view=mappings', $vName == 'mappings');
JHtmlSidebar::addEntry(Text::_('COM_SUBUSERS_TITLE_USERS'), 'index.php?option=com_subusers&view=users', $vName == 'users');
}
}
5 changes: 3 additions & 2 deletions src/administrator/libraries/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Language\Text;

/**
* Action class. Handles all application interaction with a Action
Expand Down Expand Up @@ -160,15 +161,15 @@ public function bind(&$array)
{
if (empty($array))
{
$this->setError(JText::_('COM_SUBUSER_EMPTY_DATA'));
$this->setError(Text::_('COM_SUBUSER_EMPTY_DATA'));

return false;
}

// Bind the array
if (!$this->setProperties($array))
{
$this->setError(\JText::_('COM_SUBUSER_BINDING_ERROR'));
$this->setError(Text::_('COM_SUBUSER_BINDING_ERROR'));

return false;
}
Expand Down
5 changes: 3 additions & 2 deletions src/administrator/libraries/role.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Language\Text;

/**
* Role class. Handles all application interaction with a Role
Expand Down Expand Up @@ -168,15 +169,15 @@ public function bind(&$array)
{
if (empty($array))
{
$this->setError(JText::_('COM_CLUSTER_EMPTY_DATA'));
$this->setError(Text::_('COM_CLUSTER_EMPTY_DATA'));

return false;
}

// Bind the array
if (!$this->setProperties($array))
{
$this->setError(\JText::_('COM_CLUSTER_BINDING_ERROR'));
$this->setError(Text::_('COM_CLUSTER_BINDING_ERROR'));

return false;
}
Expand Down
6 changes: 4 additions & 2 deletions src/administrator/models/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/

defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Schema\ChangeSet;

require_once JPATH_ADMINISTRATOR . '/components/com_installer/models/database.php';

Expand All @@ -30,11 +32,11 @@ public function getItems()

try
{
$changeSet = JSchemaChangeset::getInstance($this->getDbo(), $folder);
$changeSet = ChangeSet::getInstance($this->getDbo(), $folder);
}
catch (RuntimeException $e)
{
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'warning');
Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning');

return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/administrator/models/fields/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\FormHelper;

JFormHelper::loadFieldClass('list');
FormHelper::loadFieldClass('list');

/**
* Supports an HTML select list of Roles
Expand Down
3 changes: 2 additions & 1 deletion src/administrator/models/fields/role.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\FormHelper;

JFormHelper::loadFieldClass('list');
FormHelper::loadFieldClass('list');

/**
* Supports an HTML select list of Roles
Expand Down
4 changes: 2 additions & 2 deletions src/administrator/models/role.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getForm($data = array(), $loadData = true)
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_subusers.edit.role.data', array());
$data = Factory::getApplication()->getUserState('com_subusers.edit.role.data', array());

if (empty($data))
{
Expand All @@ -107,7 +107,7 @@ protected function loadFormData()
*/
public function getActions($roleId)
{
$db = JFactory::getDbo();
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('action');
$query->from($db->quoteName('#__tjsu_role_action_map'));
Expand Down
3 changes: 2 additions & 1 deletion src/administrator/models/roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Component\ComponentHelper;

/**
* Methods supporting a list of Subusers records.
Expand Down Expand Up @@ -63,7 +64,7 @@ protected function populateState($ordering = 'a.id', $direction = 'desc')
$this->setState('filter.search', $search);

// Load the parameters.
$params = JComponentHelper::getParams('com_subusers');
$params = ComponentHelper::getParams('com_subusers');
$this->setState('params', $params);

parent::populateState($ordering, $direction);
Expand Down
2 changes: 1 addition & 1 deletion src/administrator/models/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getForm($data = array(), $loadData = true)
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_subusers.edit.user.data', array());
$data = Factory::getApplication()->getUserState('com_subusers.edit.user.data', array());

if (empty($data))
{
Expand Down
6 changes: 4 additions & 2 deletions src/administrator/models/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Component\ComponentHelper;

/**
* Methods supporting a list of Subusers records.
Expand Down Expand Up @@ -57,14 +59,14 @@ public function __construct($config = array())
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication('administrator');
$app = Factory::getApplication('administrator');

$search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);

$this->setState('filter.user_id', $app->getUserStateFromRequest($this->context . ' . filter.user_id', 'filter_user_id', '', 'string'));

$params = JComponentHelper::getParams('com_subusers');
$params = ComponentHelper::getParams('com_subusers');
$this->setState('params', $params);

parent::populateState('a.id', 'desc');
Expand Down
6 changes: 6 additions & 0 deletions src/administrator/sql/install.mysql.utf8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ CREATE TABLE IF NOT EXISTS `#__tjsu_users` (
`modified_by` int(11) NOT NULL,
`modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
KEY `user_id_idx` (`user_id`)
KEY `client_id_idx` (`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

INSERT INTO `#__tjsu_roles` (`id`, `name`, `client`, `created_by`, `created_date`, `modified_by`, `modified_date`, `ordering`) VALUES
(1, 'Organization Manager', 'com_multiagency', 0, '0000-00-00 00:00:00', 0, '0000-00-00 00:00:00', 1),
(2, 'Organization User', 'com_multiagency', 0, '0000-00-00 00:00:00', 0, '0000-00-00 00:00:00', 2);

INSERT INTO `#__tjsu_actions` (`id`, `code`, `name`, `client`, `created_date`) VALUES
(1, 'core.agency.user.delete', 'Remove user from agency', 'com_multiagency', '0000-00-00 00:00:00'),
(2, 'core.agency.delete', 'Remove agency', 'com_multiagency', '0000-00-00 00:00:00');
1 change: 0 additions & 1 deletion src/administrator/sql/updates/mysql/1.0.sql

This file was deleted.

13 changes: 13 additions & 0 deletions src/administrator/sql/updates/mysql/1.1.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

ALTER TABLE `#__tjsu_roles` ENGINE = InnoDB;
ALTER TABLE `#__tjsu_actions` ENGINE = InnoDB;
ALTER TABLE `#__tjsu_role_action_map` ENGINE = InnoDB;
ALTER TABLE `#__tjsu_users` ENGINE = InnoDB;

ALTER TABLE `#__tjsu_roles` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__tjsu_actions` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__tjsu_role_action_map` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__tjsu_users` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

ALTER TABLE #__tjsu_users ADD INDEX user_id_idx (user_id);
ALTER TABLE #__tjsu_users ADD INDEX client_id_idx (client_id);
3 changes: 2 additions & 1 deletion src/administrator/subusers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Language\Text;

// Access check.
if (!Factory::getUser()->authorise('core.manage', 'com_subusers'))
{
throw new \Exception(JText::_('JERROR_ALERTNOAUTHOR'));
throw new \Exception(Text::_('JERROR_ALERTNOAUTHOR'));
}

\JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR);
Expand Down
33 changes: 21 additions & 12 deletions src/administrator/tables/mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@
defined('_JEXEC') or die;

use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Language\Text;
use Joomla\Registry\Registry;

/**
* mapping Table class
*
* @since 1.6
*/
class SubusersTablemapping extends JTable
class SubusersTablemapping extends Table
{
/**
* Constructor
Expand All @@ -45,38 +50,38 @@ public function bind($array, $ignore = '')
{
if ($array['id'] == 0)
{
$array['created_by'] = JFactory::getUser()->id;
$array['created_by'] = Factory::getUser()->id;
}

$input = JFactory::getApplication()->input;
$input = Factory::getApplication()->input;
$task = $input->getString('task', '');

if (($task == 'save' || $task == 'apply') && (!JFactory::getUser()->authorise('core.edit.state', 'com_subusers') && $array['state'] == 1))
if (($task == 'save' || $task == 'apply') && (!Factory::getUser()->authorise('core.edit.state', 'com_subusers') && $array['state'] == 1))
{
$array['state'] = 0;
}

if (isset($array['params']) && is_array($array['params']))
{
$registry = new JRegistry;
$registry = new Registry;
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}

if (isset($array['metadata']) && is_array($array['metadata']))
{
$registry = new JRegistry;
$registry = new Registry;
$registry->loadArray($array['metadata']);
$array['metadata'] = (string) $registry;
}

if (!JFactory::getUser()->authorise('core.admin', 'com_subusers.mapping.' . $array['id']))
if (!Factory::getUser()->authorise('core.admin', 'com_subusers.mapping.' . $array['id']))
{
$actions = JAccess::getActionsFromFile(
$actions = Access::getActionsFromFile(
JPATH_ADMINISTRATOR . '/components/com_subusers/access.xml',
"/access/section[@name='mapping']/"
);
$default_actions = JAccess::getAssetRules('com_subusers.mapping.' . $array['id'])->getData();
$default_actions = Access::getAssetRules('com_subusers.mapping.' . $array['id'])->getData();
$array_jaccess = array();

foreach ($actions as $action)
Expand Down Expand Up @@ -174,7 +179,9 @@ public function publish($pks = null, $state = 1, $userId = 0)
// Nothing to set publishing state on, return false.
else
{
throw new Exception(500, JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));

return false;
}
}

Expand Down Expand Up @@ -216,6 +223,8 @@ public function publish($pks = null, $state = 1, $userId = 0)
$this->state = $state;
}

$this->setError('');

return true;
}

Expand Down Expand Up @@ -243,10 +252,10 @@ protected function _getAssetName()
*
* @return mixed The id on success, false on failure.
*/
protected function _getAssetParentId(JTable $table = null, $id = null)
protected function _getAssetParentId(Table $table = null, $id = null)
{
// We will retrieve the parent-asset from the Asset-table
$assetParent = JTable::getInstance('Asset');
$assetParent = Table::getInstance('Asset');

// Default: if no asset-parent can be found we take the global asset
$assetParentId = $assetParent->getRootId();
Expand Down
Loading