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

Merge Release 1.0.0 into master #19

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 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
7e41a94
AI auto code review .coderabbit.yaml
vijaykhollam Nov 8, 2024
a19e2b7
Merge pull request #23 from vijaykhollam/AICodeReview
vaibhavsTekdi Nov 11, 2024
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
74 changes: 74 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
language: "en"

early_access: false

reviews:
request_changes_workflow: true
high_level_summary: true
poem: false
review_status: true
collapse_walkthrough: false
path_filters:
# Exclude XML files for manifest and configuration
- "!**/*.xml"
# Exclude language files (translations)
- "!**/language/**/*.ini"
# Exclude asset files that don’t need review
- "!**/*.svg"
- "!**/*.png"
- "!**/*.jpg"
- "!**/*.jpeg"
- "!**/*.gif"
- "!**/*.ico"
# Exclude compiled and minified files
- "!**/*.min.js"
- "!**/*.min.css"
# Exclude SCSS files if they are intermediate and do not need review
- "!**/templates/**/*.scss"
# Exclude libraries and vendor code (third-party dependencies)
- "!**/node_modules/**"
- "!**/vendor/**"
# Exclude build files
- "!**/build/**"
# Exclude configuration files that are environment-specific
- "!**/configuration.php"
path_instructions:
# JavaScript files: front-end interactivity and functionality
- path: "**/*.js"
instructions: |
"Review JavaScript code to ensure:
- Adherence to Google JavaScript style guide.
- Efficient DOM manipulation suitable for Joomla’s frontend.
- Use of Joomla’s core JavaScript libraries where applicable (e.g., jQuery compatibility).
- Best practices for asynchronous requests if AJAX is used."
- path: "**/*.php"
instructions: |
"Review the PHP code for Joomla coding standards compliance, ensuring:
- Code follows Joomla's coding standards, validated using PHPCS with the Joomla standard.
- Adherence to Joomla’s MVC structure for extensions.
- Proper use of Joomla’s built-in functions (e.g., Input, Factory).
- SQL queries use Joomla’s database API to prevent SQL injection.
- Code is well-documented, with clear function and class descriptions."
- path: "**/*.ts"
instructions: |
"Review the JavaScript code for conformity with the Google JavaScript style guide, highlighting any deviations. Ensure that:
- The code adheres to best practices associated with nodejs.
- The code adheres to best practices associated with nestjs framework.
- The code adheres to best practices recommended for performance.
- The code adheres to similar naming conventions for controllers, models, services, methods, variables."
auto_review:
enabled: true
ignore_title_keywords:
- "WIP"
- "DO NOT MERGE"
drafts: false
base_branches:
- "master"
- "dev"
- "j4x"
- "feat/*"
- "feat-*"
- "release-*"

chat:
auto_reply: true
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;
}
}
Loading