From c943ecf0c93033e0bbe04218d2c010352d086907 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Wed, 4 Sep 2019 15:45:56 +0530 Subject: [PATCH 1/3] Task #188 feat: Added ACL check for cluster on form view page --- .../site/views/itemform/view.html.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 98292ec6..b42646a7 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,25 @@ public function display($tpl = null) if ($this->id && !$clusterId) { $input->set('cluster_id', $this->item->cluster_id); + $clusterId = $this->item->cluster_id; + } + + // 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 From bc4c38dbbd48d85aa487639c5d0571ae44475aa4 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Tue, 10 Dec 2019 11:08:25 +0530 Subject: [PATCH 2/3] Task #284 fix: Cluster not getting update in UCM main record --- .../com_tjucm/site/controllers/itemform.json.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index ee1cd581..7f2e0337 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -280,9 +280,11 @@ public function saveFormData() $formData['fieldsvalue'] = $data; $formData['client'] = $client; $formData['created_by'] = $table->created_by; + $isNew = $table->draft; // If data is valid then save the data into DB $response = $model->saveFieldsData($formData); + $msg = null; if ($response && empty($section)) @@ -296,7 +298,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(); @@ -307,7 +310,7 @@ public function saveFormData() // TJ-ucm plugin trigger after save $dispatcher = JEventDispatcher::getInstance(); PluginHelper::importPlugin("content"); - $dispatcher->trigger('onUcmItemAfterSave', array($table->getProperties(), $data)); + $dispatcher->trigger('onUcmItemAfterSave', array($table->getProperties(), $data, $isNew)); } } From c87e7cc6c49c7259db4de44bae37844b1e1ec74e Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Thu, 12 Dec 2019 18:40:09 +0530 Subject: [PATCH 3/3] Task #285 chore: Resolve feedback comments --- .../site/controllers/itemform.json.php | 3 +-- .../site/views/itemform/view.html.php | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 7f2e0337..aab5f4fd 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -280,7 +280,6 @@ public function saveFormData() $formData['fieldsvalue'] = $data; $formData['client'] = $client; $formData['created_by'] = $table->created_by; - $isNew = $table->draft; // If data is valid then save the data into DB $response = $model->saveFieldsData($formData); @@ -310,7 +309,7 @@ public function saveFormData() // TJ-ucm plugin trigger after save $dispatcher = JEventDispatcher::getInstance(); PluginHelper::importPlugin("content"); - $dispatcher->trigger('onUcmItemAfterSave', array($table->getProperties(), $data, $isNew)); + $dispatcher->trigger('onUcmItemAfterSave', array($table->getProperties(), $data)); } } 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 7f847501..98657315 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -119,21 +119,25 @@ public function display($tpl = null) $clusterId = $this->item->cluster_id; } - // 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')) + // Get com_cluster component status + if (ComponentHelper::getComponent('com_cluster', true)->enabled) { - JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; - // Check user has permission for mentioned cluster - if (!RBACL::authorise($user->id, 'com_cluster', 'core.manage', $clusterId)) + // Check user have permission to edit record of assigned cluster + if ($subUserExist && !empty($clusterId) && !$user->authorise('core.manageall', 'com_cluster')) { - $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error'); - $app->setHeader('status', 403, true); + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); - return; + // 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; + } } }