diff --git a/src/components/com_cluster/administrator/models/clusteruser.php b/src/components/com_cluster/administrator/models/clusteruser.php index 40e2309..52e88a5 100644 --- a/src/components/com_cluster/administrator/models/clusteruser.php +++ b/src/components/com_cluster/administrator/models/clusteruser.php @@ -121,17 +121,17 @@ public function save($data) * * @since 1.0.0 */ - public function getUsersClusters($userId) + public function getUsersClusters($userId = null) { - $user = Factory::getUser($userId); - $superUser = $user->authorise('core.admin'); + $user = empty($userId) ? Factory::getUser() : Factory::getUser($userId); $clusters = array(); // Load cluster library file JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR); - if (!$superUser && !$user->authorise('core.manageall.cluster', 'com_cluster')) + // If user is not allowed to view all the clusters then return the clusters in which user is a part else return al cluster + if (!$user->authorise('core.manageall.cluster', 'com_cluster')) { $clusterUsersModel = ClusterFactory::model('ClusterUsers', array('ignore_request' => true)); $clusterUsersModel->setState('list.group_by_client_id', 1); @@ -141,9 +141,9 @@ public function getUsersClusters($userId) // Get all assigned cluster entries $clusters = $clusterUsersModel->getItems(); } - - if ($superUser) + else { + $clusterModel = $this->setState('filter.state', 1); $clusterModel = ClusterFactory::model('Clusters', array('ignore_request' => true)); // Get all cluster entries @@ -162,7 +162,7 @@ public function getUsersClusters($userId) if (!empty($clusters)) { - if ($subUserExist && (!$superUser && !$user->authorise('core.manageall.cluster', 'com_cluster'))) + if ($subUserExist && (!$user->authorise('core.manageall.cluster', 'com_cluster'))) { foreach ($clusters as $cluster) { diff --git a/src/components/com_cluster/administrator/models/clusterusers.php b/src/components/com_cluster/administrator/models/clusterusers.php index 86fb1e1..005c8ea 100644 --- a/src/components/com_cluster/administrator/models/clusterusers.php +++ b/src/components/com_cluster/administrator/models/clusterusers.php @@ -75,11 +75,11 @@ protected function getListQuery() } } - $created_by = $this->getState('filter.created_by'); + $createdBy = $this->getState('filter.created_by'); - if (!empty($created_by)) + if (!empty($createdBy)) { - $query->where($db->quoteName('cu.created_by') . ' = ' . (int) $created_by); + $query->where($db->quoteName('cu.created_by') . ' = ' . (int) $createdBy); } // Filter by state @@ -103,11 +103,11 @@ protected function getListQuery() } // Filter by user - $cluster_user = $this->getState('filter.user_id'); + $clusterUser = $this->getState('filter.user_id'); - if (is_numeric($cluster_user)) + if (is_numeric($clusterUser)) { - $query->where('cu.user_id = ' . (int) $cluster_user); + $query->where('cu.user_id = ' . (int) $clusterUser); } // Filter by client_id