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

Release 1.0.0 #18

Open
wants to merge 20 commits into
base: release-1.0.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a19167d
Task #10 feat: Add function to get list of cluster to which a given h…
ankush-maherwal Aug 14, 2019
a89059f
Task #114 feat: Cluster awareness in related field
ankush-maherwal Aug 19, 2019
4ba67fd
Task #114 feat: Cluster awareness in related field
ankush-maherwal Aug 19, 2019
984ac6e
Merge pull request #11 from ankush-maherwal/release-1.0.0
thite-amol Aug 19, 2019
d4eff8b
#12 chore: Update query, added joins based on filters & introduce new…
pravinTek Aug 20, 2019
248822f
#12 chore: Update query, added joins based on filters & introduce new…
pravinTek Aug 20, 2019
bd293d6
#12 chore: change variable name
pravinTek Aug 20, 2019
b81b0df
Task#12 chore: Resolve comments
pravinTek Aug 22, 2019
5cc9683
Merge pull request #13 from pravinTek/release1.0.0
thite-amol Aug 26, 2019
e489367
Task #14 chore: Improvement made in cluster package - updating querie…
pravinTek Sep 4, 2019
b0ce829
Merge branch 'release-1.0.0' of github.com:techjoomla/com_cluster int…
pravinTek Sep 4, 2019
ef93b1b
Task #14 chore: resolve MR comments
pravinTek Oct 14, 2019
1a26a5b
Task #14 chore: Improvement made in cluster package (#15)
thite-amol Oct 14, 2019
0bc94de
Task#16 chore: Modified the query and table engines
pravinTek Jan 9, 2020
763d5cb
Merge pull request #17 from pravinTek/release1.0.0
thite-amol Jan 9, 2020
47895d9
Task #189184 feat: com_cluster improvements
KishoriBKarale Oct 10, 2022
ede348e
Merge pull request #20 from KishoriBKarale/codeImprovements
vijaykhollam Oct 11, 2022
9b17e41
Task #189184 chore: Updated Indexing for tables
KishoriBKarale Nov 5, 2022
52306bd
Task #189184 chore: Updated Indexing for tables
KishoriBKarale Nov 5, 2022
ccafbba
Merge pull request #21 from KishoriBKarale/codeImprovements
vijaykhollam Nov 5, 2022
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
1 change: 1 addition & 0 deletions src/components/com_cluster/administrator/access.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
<action name="core.manageall" title="JACTION_MANAGE_ALL_CLUSTER" description="JACTION_MANAGE_ALL_CLUSTER_DESC" />
</section>
</access>
5 changes: 3 additions & 2 deletions src/components/com_cluster/administrator/helpers/cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;

/**
* Cluster helper.
Expand All @@ -33,13 +34,13 @@ public static function addSubmenu($vName = '')
if ($layout != "default")
{
JHtmlSidebar::addEntry(
JText::_('COM_CLUSTERS_VIEW_CLUSTERS'),
Text::_('COM_CLUSTERS_VIEW_CLUSTERS'),
'index.php?option=com_cluster&view=clusters',
$vName == 'clusters'
);

JHtmlSidebar::addEntry(
JText::_('COM_CLUSTERS_VIEW_CLUSTER_USERS'),
Text::_('COM_CLUSTERS_VIEW_CLUSTER_USERS'),
'index.php?option=com_cluster&view=clusterusers',
$vName == 'clusterusers'
);
Expand Down
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 @@ -92,3 +92,6 @@ COM_CLUSTER_PAGE_VIEW_USER = "Cluster user: View"
COM_CLUSTER_USER_LIST_VIEW_NAME="User"
COM_CLUSTER_USER_LIST_VIEW_CLUSTER="Cluster Name"
COM_CLUSTER_USERLIST_VIEW_ID="ID"

JACTION_MANAGE_ALL_CLUSTER="Manage All Clusters"
JACTION_MANAGE_ALL_CLUSTER_DESC="Manage All Clusters"
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ COM_CLUSTER_CLUSTER_VIEW_EDIT_DESC="Shows a form to create a New Cluster."
COM_CLUSTER_CLUSTERS_VIEW_DEFAULT_TITLE="List all Clusters"
COM_CLUSTER_CLUSTERS_VIEW_DEFAULT_DESC="Shows a list of all the Clusters."
COM_CLUSTER_TITLE_ITEM_VIEW_CLUSTER="Single Cluster"
COM_CLUSTER_TITLE_CLUSTER="Cluster"
COM_CLUSTER_TITLE_CLUSTER="Cluster"
COM_CLUSTERS_VIEW_CLUSTER_USERS="Cluster users"
39 changes: 37 additions & 2 deletions src/components/com_cluster/administrator/libraries/cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Language\Text;

/**
* Cluster class. Handles all application interaction with a Cluster
Expand Down Expand Up @@ -192,15 +193,15 @@ public function bind(&$array)
{
if (empty($array))
{
$this->setError(JText::_('COM_CLUSTER_EMPTY_DATA'));
$this->setError(Text::_('COM_CLUSTER_EMPTY_DATA'));

return false;
}

// Bind the array
if (!$this->setProperties($array))
{
$this->setError(\JText::_('COM_CLUSTER_BINDING_ERROR'));
$this->setError(Text::_('COM_CLUSTER_BINDING_ERROR'));

return false;
}
Expand Down Expand Up @@ -231,4 +232,38 @@ public function isOwner($userId = null)

return false;
}

/**
* Function isMember to check user associated with passed cluster_id
*
* @param INT $userId User Id
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public function isMember($userId = null)
{
$userId = Factory::getuser($userId)->id;

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);

// Check user associated with passed cluster_id
$clusters = $ClusterModel->getItems();

if (!empty($clusters))
{
return true;
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function getListQuery()
$query = $db->getQuery(true);

// Create the base select statement.
$query->select(array('cl.*','users.name as uname'));
$query->select(array('cl.*','users.name as uname','cl.id as cluster_id'));
$query->from($db->quoteName('#__tj_clusters', 'cl'));
$query->join('LEFT', $db->quoteName('#__users', 'users') . ' ON (' . $db->quoteName('cl.created_by') . ' = ' . $db->quoteName('users.id') . ')');

Expand Down
75 changes: 75 additions & 0 deletions src/components/com_cluster/administrator/models/clusteruser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Component\ComponentHelper;

/**
* Item Model for an Cluster.
Expand Down Expand Up @@ -110,4 +111,78 @@ public function save($data)

return parent::save($data);
}

/**
* Method to get the list of clusters to which user have access
*
* @param INT $userId Users Id.
*
* @return ARRAY List of clusters.
*
* @since 1.0.0
*/
public function getUsersClusters($userId = null)
{
$user = empty($userId) ? Factory::getUser() : Factory::getUser($userId);

$clusters = array();

// Load cluster library file
JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR);

// 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', 'com_cluster'))
{
$clusterUsersModel = ClusterFactory::model('ClusterUsers', array('ignore_request' => true));
$clusterUsersModel->setState('list.group_by_client_id', 1);
$clusterUsersModel->setState('filter.published', 1);
$clusterUsersModel->setState('list.ordering', 'cl.name');
$clusterUsersModel->setState('list.direction', 'ASC');
$clusterUsersModel->setState('filter.user_id', $user->id);

// Get all assigned cluster entries
$clusters = $clusterUsersModel->getItems();
}
else
{
$clusterModel = ClusterFactory::model('Clusters', array('ignore_request' => true));

// Get all cluster entries
$clusterModel->setState('filter.state', 1);
$clusterModel->setState('list.ordering', 'cl.name');
$clusterModel->setState('list.direction', 'ASC');
$clusters = $clusterModel->getItems();
}

// Get com_subusers component status
$subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled;

if ($subUserExist)
{
JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR);
}

$usersClusters = array();

if (!empty($clusters))
{
if ($subUserExist && (!$user->authorise('core.manageall', 'com_cluster')))
{
foreach ($clusters as $cluster)
{
// Check user has permission for mentioned cluster
if (RBACL::authorise($user->id, 'com_cluster', 'core.manage', $cluster->cluster_id))
{
$usersClusters[] = $cluster;
}
}
}
else
{
$usersClusters = $clusters;
}
}

return $usersClusters;
}
}
77 changes: 69 additions & 8 deletions src/components/com_cluster/administrator/models/clusterusers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Component\ComponentHelper;

/**
* Methods supporting a list of records.
Expand All @@ -34,7 +36,7 @@ public function __construct($config = array())
$config['filter_fields'] = array(
'id', 'cu.id',
'cluster_id', 'cu.cluster_id',
'state', 'cu.state',
'state', 'cu.state','cl.name','cl.client_id'
);
}

Expand All @@ -54,9 +56,12 @@ protected function getListQuery()
$db = $this->getDbo();
$query = $db->getQuery(true);

$query->select(array('cu.*','cl.name', 'users.name as uname'));
$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') . ')');
$query->join('INNER', $db->quoteName('#__users', 'users') . ' ON (' . $db->quoteName('cu.user_id') . ' = '
. $db->quoteName('users.id') . ')');
$query->join('INNER', $db->quoteName('#__tj_clusters', 'cl') . ' ON (' . $db->quoteName('cl.id') . ' = ' . $db->quoteName('cu.cluster_id') . ')');

// Filter by search in title.
Expand All @@ -75,11 +80,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
Expand All @@ -102,9 +107,65 @@ protected function getListQuery()
$query->where('cu.cluster_id = ' . (int) $cluster);
}

// Filter by user
$clusterUser = $this->getState('filter.user_id');

if (is_numeric($clusterUser))
{
$query->where('cu.user_id = ' . (int) $clusterUser);
}

// Filter by client_id
$clusterClientId = $this->getState('filter.client_id');

if (is_numeric($clusterClientId))
{
$query->where('cl.client_id = ' . (int) $clusterClientId);
}
elseif (is_array($clusterClientId))
{
$query->where("cl.client_id IN ('" . implode("','", $clusterClientId) . "')");
}

// Filter by cluster table state
$published = $this->getState('filter.published');

if (is_numeric($published))
{
$query->where('cl.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(cl.state = 0 OR cl.state = 1)');
}

// Filter users by block
$blockUser = $this->getState('filter.block');

if (is_numeric($blockUser))
{
$query->where($db->quoteName('users.block') . ' = ' . (int) $blockUser);
}

// Group by cluster
$clientID = $this->getState('list.group_by_client_id');

if (is_numeric($clientID))
{
$query->group('cl.client_id');
}

// Group by user
$userID = $this->getState('list.group_by_user_id');

if (is_numeric($userID))
{
$query->group('users.id');
}

// 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
Loading