From 0bc94de5294899adcd581d560c2e3a0b61ef380d Mon Sep 17 00:00:00 2001 From: Prav Date: Thu, 9 Jan 2020 11:39:28 +0530 Subject: [PATCH] Task#16 chore: Modified the query and table engines --- .../com_cluster/administrator/includes/cluster.php | 2 +- .../com_cluster/administrator/libraries/cluster.php | 6 +++++- .../com_cluster/administrator/models/clusterusers.php | 8 +++++--- .../com_cluster/administrator/sql/install.mysql.utf8.sql | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/com_cluster/administrator/includes/cluster.php b/src/components/com_cluster/administrator/includes/cluster.php index 6ad7222..12f9bf6 100644 --- a/src/components/com_cluster/administrator/includes/cluster.php +++ b/src/components/com_cluster/administrator/includes/cluster.php @@ -54,7 +54,7 @@ public static function table($name) **/ public static function model($name, $config = array()) { - BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_cluster/models'); + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_cluster/models', 'ClusterModel'); // @TODO Add support for cache return BaseDatabaseModel::getInstance($name, 'ClusterModel', $config); diff --git a/src/components/com_cluster/administrator/libraries/cluster.php b/src/components/com_cluster/administrator/libraries/cluster.php index 3052c92..e2877c3 100644 --- a/src/components/com_cluster/administrator/libraries/cluster.php +++ b/src/components/com_cluster/administrator/libraries/cluster.php @@ -245,8 +245,12 @@ public function isMember($userId = null) { $userId = Factory::getuser($userId)->id; - $ClusterModel = ClusterFactory::model('ClusterUsers', array('ignore_request' => true)); + if (empty($userId)) + { + return false; + } + $ClusterModel = ClusterFactory::model('ClusterUsers', array('ignore_request' => true)); $ClusterModel->setState('filter.published', 1); $ClusterModel->setState('filter.cluster_id', (int) $this->id); $ClusterModel->setState('filter.user_id', $userId); diff --git a/src/components/com_cluster/administrator/models/clusterusers.php b/src/components/com_cluster/administrator/models/clusterusers.php index c4de463..b024aa5 100644 --- a/src/components/com_cluster/administrator/models/clusterusers.php +++ b/src/components/com_cluster/administrator/models/clusterusers.php @@ -56,7 +56,9 @@ protected function getListQuery() $db = $this->getDbo(); $query = $db->getQuery(true); - $query->select(array('cu.*','cl.name', 'users.name as uname', 'users.username','cl.name as title', 'cl.client_id as client_id')); + $query->select( + array('cu.*','cl.name', 'users.name as uname', 'users.email as uemail', 'users.username','cl.name as title', 'cl.client_id as client_id') + ); $query->from($db->quoteName('#__tj_cluster_nodes', 'cu')); $query->join('INNER', $db->quoteName('#__users', 'users') . ' ON (' . $db->quoteName('cu.user_id') . ' = ' . $db->quoteName('users.id') . ')'); @@ -162,8 +164,8 @@ protected function getListQuery() } // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering'); - $orderDirn = $this->state->get('list.direction'); + $orderCol = $this->state->get('list.ordering', 'users.name'); + $orderDirn = $this->state->get('list.direction', 'asc'); if ($orderCol && $orderDirn) { diff --git a/src/components/com_cluster/administrator/sql/install.mysql.utf8.sql b/src/components/com_cluster/administrator/sql/install.mysql.utf8.sql index 3983260..4f64310 100644 --- a/src/components/com_cluster/administrator/sql/install.mysql.utf8.sql +++ b/src/components/com_cluster/administrator/sql/install.mysql.utf8.sql @@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS `#__tj_clusters` ( `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `description` text NOT NULL DEFAULT '', `params` text NOT NULL DEFAULT '', - `client` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '', + `client` varchar(400) NOT NULL DEFAULT '', `client_id` int(11) NOT NULL DEFAULT '0', `ordering` int(11) NOT NULL DEFAULT '0', `state` tinyint(3) NOT NULL DEFAULT '0', @@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `#__tj_clusters` ( `modified_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified_by` int(11) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE = MyISAM CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; CREATE TABLE IF NOT EXISTS `#__tj_cluster_nodes` ( @@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS `#__tj_cluster_nodes` ( `modified_by` int(11) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (`id`), FOREIGN KEY (`cluster_id`) REFERENCES `#__tj_clusters` (`id`) -) ENGINE = MyISAM CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; -- -- Indexes for table `__tj_cluster_nodes`