diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index ee1cd581..aab5f4fd 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -283,6 +283,7 @@ public function saveFormData() // If data is valid then save the data into DB $response = $model->saveFieldsData($formData); + $msg = null; if ($response && empty($section)) @@ -296,7 +297,8 @@ public function saveFormData() $msg = ($response) ? Text::_("COM_TJUCM_ITEM_SAVED_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED"); } - // Disable the draft mode of the item if full f)orm is submitted + // Disable the draft mode of the item if full form is submitted + $table->load($recordId); $table->draft = $draft; $table->modified_date = Factory::getDate()->toSql(); $table->store(); diff --git a/src/components/com_tjucm/site/views/itemform/view.html.php b/src/components/com_tjucm/site/views/itemform/view.html.php index 9c159387..98657315 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -18,6 +18,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Component\ComponentHelper; /** * View to edit @@ -115,6 +116,29 @@ public function display($tpl = null) if ($this->id && !$clusterId) { $input->set('cluster_id', $this->item->cluster_id); + $clusterId = $this->item->cluster_id; + } + + // Get com_cluster component status + if (ComponentHelper::getComponent('com_cluster', true)->enabled) + { + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; + + // Check user have permission to edit record of assigned cluster + if ($subUserExist && !empty($clusterId) && !$user->authorise('core.manageall', 'com_cluster')) + { + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + + // Check user has permission for mentioned cluster + if (!RBACL::authorise($user->id, 'com_cluster', 'core.manage', $clusterId)) + { + $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error'); + $app->setHeader('status', 403, true); + + return; + } + } } // Get a copy record id