Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task#16 chore: Modified the query and table engines #17

Merged
merged 1 commit into from
Jan 9, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') . ')');
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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` (
Expand All @@ -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`
Expand Down