forked from techjoomla/com_cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task techjoomla#14 chore: Improvement made in cluster package - updat…
…ing queries, removed unwanted code and also added JSON controller to get all associated users
- Loading branch information
Showing
4 changed files
with
75 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/components/com_cluster/site/controllers/clusterusers.json.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* @package Com_Cluster | ||
* @author Techjoomla <extensions@techjoomla.com> | ||
* @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
// No direct access | ||
defined('_JEXEC') or die; | ||
|
||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Language\Text; | ||
use Joomla\CMS\HTML\HTMLHelper; | ||
use Joomla\CMS\Component\ComponentHelper; | ||
use Joomla\CMS\MVC\Controller\BaseController; | ||
use Joomla\CMS\Session\Session; | ||
|
||
JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR); | ||
|
||
/** | ||
* Get Cluster Users controller class. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class ClusterControllerClusterUsers extends BaseController | ||
{ | ||
/** | ||
* Method to get user list depending on the client chosen. | ||
* | ||
* @return null | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function getUsersByClientId() | ||
{ | ||
// Check for request forgeries. | ||
Session::checkToken() or jexit(JText::_('JINVALID_TOKEN')); | ||
|
||
$clusterIds = Factory::getApplication()->input->getInt('cluster_id', 0); | ||
$userOptions = $allUsers = array(); | ||
|
||
// Initialize array to store dropdown options | ||
$userOptions[] = HTMLHelper::_('select.option', "", Text::_('COM_TJFIELDS_OWNERSHIP_USER')); | ||
|
||
// Check cluster selected or not | ||
if ($clusterIds) | ||
{ | ||
$clusterObj = ClusterFactory::model('ClusterUsers', array('ignore_request' => true)); | ||
$clusterObj->setState('filter.block', 0); | ||
$clusterObj->setState('filter.cluster_id', $clusterIds); | ||
$clusterObj->setState('list.group_by_user_id', 1); | ||
$allUsers = $clusterObj->getItems(); | ||
} | ||
|
||
if (!empty($allUsers)) | ||
{ | ||
foreach ($allUsers as $user) | ||
{ | ||
$userOptions[] = HTMLHelper::_('select.option', $user->user_id, trim($user->uname . ' (' . $user->uemail . ')')); | ||
} | ||
} | ||
|
||
echo new JResponseJson($userOptions); | ||
jexit(); | ||
} | ||
} |