Skip to content

Commit

Permalink
Merge branch 'release-1.2.4' of github.com:techjoomla/com_tjucm into …
Browse files Browse the repository at this point in the history
…latestVersion
  • Loading branch information
pravinTek committed Dec 12, 2019
2 parents c87e7cc + 7cdd71c commit b813844
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 58 deletions.
11 changes: 10 additions & 1 deletion src/components/com_tjucm/site/models/itemform.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,16 @@ public function saveFieldsData($fieldData)

if (!empty($fieldData['fieldsvalue'][$ownerShipFieldName]))
{
$ucmItemTable->created_by = $fieldData['fieldsvalue'][$ownerShipFieldName];
JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR);
$fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', JFactory::getDbo()));
$fieldTable->load(array('name' => $ownerShipFieldName));
$fieldParams = new Registry($fieldTable->params);

// If enabled then the selected user will be set as creator of the UCM type item
if ($fieldParams->get('ucmItemOwner'))
{
$ucmItemTable->created_by = $fieldData['fieldsvalue'][$ownerShipFieldName];
}
}

if (!empty($fieldData['fieldsvalue'][$itemCategoryFieldName]))
Expand Down
112 changes: 57 additions & 55 deletions src/components/com_tjucm/site/models/items.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
*/
class TjucmModelItems extends JModelList
{
private $client;

/**
* Constructor.
*
Expand Down Expand Up @@ -69,34 +67,31 @@ protected function populateState($ordering = "a.id", $direction = "DESC")
$user = JFactory::getUser();
$db = JFactory::getDbo();

// Load the filter state.
$search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'STRING');
$this->setState('filter.search', $search);

JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/models');
$tjUcmModelType = JModelLegacy::getInstance('Type', 'TjucmModel');

$typeId = $app->input->get('id', "", "INT");
$typeId = $app->input->get('id', 0, "INT");
$ucmType = $app->input->get('client', '', "STRING");

JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjucm/tables');
$typeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', $db));
$typeTable->load(array('id' => $typeId));
$ucmType = $typeTable->unique_identifier;
if (empty($typeId) || empty($ucmType))
{
JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjucm/tables');
$typeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', $db));

// Set state for field filters
JLoader::import('components.com_tjfields.models.fields', JPATH_ADMINISTRATOR);
$fieldsModel = JModelLegacy::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true));
$fieldsModel->setState('filter.client', $this->client);
$fieldsModel->setState('filter.filterable', 1);
$fields = $fieldsModel->getItems();
if ($typeId && empty($ucmType))
{
$typeTable->load(array('id' => $typeId));
$ucmType = $typeTable->unique_identifier;
}

foreach ($fields as $field)
{
$filterValue = $app->getUserStateFromRequest($this->context . '.' . $field->name, $field->name, '', 'STRING');
$this->setState('filter.field.' . $field->name, $filterValue);
if ($ucmType && empty($typeId))
{
$typeTable->load(array('unique_identifier' => $ucmType));
$typeId = $typeTable->id;
}
}

if (empty($ucmType))
if (empty($ucmType) && empty($typeId))
{
// Get the active item
$menuitem = $app->getMenu()->getActive();
Expand All @@ -106,34 +101,41 @@ protected function populateState($ordering = "a.id", $direction = "DESC")

if (!empty($this->menuparams))
{
$this->ucm_type = $this->menuparams->get('ucm_type');
$ucmTypeAlias = $this->menuparams->get('ucm_type');

if (!empty($this->ucm_type))
if (!empty($ucmTypeAlias))
{
JLoader::import('components.com_tjfields.tables.type', JPATH_ADMINISTRATOR);
$ucmTypeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', JFactory::getDbo()));
$ucmTypeTable->load(array('alias' => $this->ucm_type));
$ucmTypeTable->load(array('alias' => $ucmTypeAlias));
$ucmType = $ucmTypeTable->unique_identifier;
$typeId = $ucmTypeTable->id;
}
}
}

if (empty($ucmType))
{
// Get UCM type id from uniquue identifier
$ucmType = $app->input->get('client', '', 'STRING');
}
// Load the filter state.
$search = $app->getUserStateFromRequest($this->context . '.' . $ucmType . '.filter.search', 'filter_search', '', 'STRING');
$this->setState($ucmType . '.filter.search', $search);

if (empty($typeId))
// Set state for field filters
JLoader::import('components.com_tjfields.models.fields', JPATH_ADMINISTRATOR);
$fieldsModel = JModelLegacy::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true));
$fieldsModel->setState('filter.client', $ucmType);
$fieldsModel->setState('filter.filterable', 1);
$fields = $fieldsModel->getItems();

foreach ($fields as $field)
{
$typeId = $tjUcmModelType->getTypeId($ucmType);
$filterValue = $app->getUserStateFromRequest($this->context . '.' . $field->name, $field->name, '', 'STRING');
$this->setState('filter.field.' . $field->name, $filterValue);
}

$clusterId = $app->getUserStateFromRequest($this->context . '.cluster', 'cluster');
$clusterId = $app->getUserStateFromRequest($this->context . '.' . $ucmType . '.cluster', 'cluster');

if ($clusterId)
{
$this->setState('filter.cluster_id', $clusterId);
$this->setState($ucmType . '.filter.cluster_id', $clusterId);
}

$this->setState('ucm.client', $ucmType);
Expand All @@ -149,14 +151,14 @@ protected function populateState($ordering = "a.id", $direction = "DESC")

$this->setState("created_by", $createdBy);

if ($this->getUserStateFromRequest($this->context . '.filter.order', 'filter_order', '', 'string'))
if ($this->getUserStateFromRequest($this->context . $ucmType . '.filter.order', 'filter_order', '', 'string'))
{
$ordering = $this->getUserStateFromRequest($this->context . '.filter.order', 'filter_order', '', 'string');
$ordering = $this->getUserStateFromRequest($this->context . $ucmType . '.filter.order', 'filter_order', '', 'string');
}

if ($this->getUserStateFromRequest($this->context . '.filter.order_Dir', 'filter_order_Dir', '', 'string'))
if ($this->getUserStateFromRequest($this->context . $ucmType . '.filter.order_Dir', 'filter_order_Dir', '', 'string'))
{
$direction = $this->getUserStateFromRequest($this->context . '.filter.order_Dir', 'filter_order_Dir', '', 'string');
$direction = $this->getUserStateFromRequest($this->context . $ucmType . '.filter.order_Dir', 'filter_order_Dir', '', 'string');
}

// List state information.
Expand Down Expand Up @@ -196,18 +198,18 @@ protected function getListQuery()
$query->select($db->quoteName('uc.name', 'uEditor'));
$query->join("LEFT", $db->quoteName('#__users', 'uc') . ' ON (' . $db->quoteName('uc.id') . ' = ' . $db->quoteName('a.checked_out') . ')');

$this->client = $this->getState('ucm.client');
$client = $this->getState('ucm.client');

if (!empty($this->client))
if (!empty($client))
{
$query->where($db->quoteName('a.client') . ' = ' . $db->quote($db->escape($this->client)));
$query->where($db->quoteName('a.client') . ' = ' . $db->quote($db->escape($client)));
}

$ucmType = $this->getState('ucmType.id', '', 'INT');
$ucmTypeId = $this->getState('ucmType.id', '', 'INT');

if (!empty($ucmType))
if (!empty($ucmTypeId))
{
$query->where($db->quoteName('a.type_id') . ' = ' . (INT) $ucmType);
$query->where($db->quoteName('a.type_id') . ' = ' . (INT) $ucmTypeId);
}

$createdBy = $this->getState('created_by', '', 'INT');
Expand All @@ -232,7 +234,7 @@ protected function getListQuery()
{
JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR);
$fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', $db));
$fieldTable->load(array('client' => $this->client, 'type' => 'cluster'));
$fieldTable->load(array('client' => $client, 'type' => 'cluster'));

if ($fieldTable->id)
{
Expand Down Expand Up @@ -275,7 +277,7 @@ protected function getListQuery()
}

// Search by content id
$search = $this->getState('filter.search');
$search = $this->getState($client . '.filter.search');

if (!empty($search))
{
Expand All @@ -288,7 +290,7 @@ protected function getListQuery()
}

// Search on fields data
$filteredItemIds = $this->filterContent();
$filteredItemIds = $this->filterContent($client);

if (is_array($filteredItemIds))
{
Expand All @@ -305,7 +307,7 @@ protected function getListQuery()
}

// Filter by cluster
$clusterId = (int) $this->getState('filter.cluster_id');
$clusterId = (int) $this->getState($client . '.filter.cluster_id');

if ($clusterId)
{
Expand All @@ -331,7 +333,7 @@ protected function getListQuery()
*
* @since 1.2.1
*/
private function filterContent()
private function filterContent($client)
{
// Flag to mark if field specific search is done from the search box
$filterFieldFound = 0;
Expand All @@ -349,10 +351,10 @@ private function filterContent()
$query->from($db->quoteName('#__tjfields_fields_value', 'fv1'));
$query->join('INNER', $db->qn('#__tjfields_fields', 'f') . ' ON (' . $db->qn('fv1.field_id') . ' = ' . $db->qn('f.id') . ')');
$query->where($db->quoteName('f.state') . ' =1');
$query->where($db->quoteName('f.client') . ' = ' . $db->quote($this->client));
$query->where($db->quoteName('f.client') . ' = ' . $db->quote($client));

// Filter by field value
$search = $this->getState('filter.search');
$search = $this->getState($client . '.filter.search');

if (!empty($this->fields) && (stripos($search, 'id:') !== 0))
{
Expand Down Expand Up @@ -398,7 +400,7 @@ private function filterContent()
// For filterable fields
JLoader::import('components.com_tjfields.models.fields', JPATH_ADMINISTRATOR);
$fieldsModel = JModelLegacy::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true));
$fieldsModel->setState('filter.client', $this->client);
$fieldsModel->setState('filter.client', $client);
$fieldsModel->setState('filter.filterable', 1);
$fields = $fieldsModel->getItems();

Expand Down Expand Up @@ -450,11 +452,11 @@ public function getFields()
$fieldsModel = JModelLegacy::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true));
$fieldsModel->setState('filter.showonlist', 1);
$fieldsModel->setState('filter.state', 1);
$this->client = $this->getState('ucm.client');
$client = $this->getState('ucm.client');

if (!empty($this->client))
if (!empty($client))
{
$fieldsModel->setState('filter.client', $this->client);
$fieldsModel->setState('filter.client', $client);
}

$items = $fieldsModel->getItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="pull-left">
<input type="text" name="filter_search" id="filter_search"
title="<?php echo empty($firstListColumn) ? JText::_('JSEARCH_FILTER') : JText::sprintf('COM_TJUCM_ITEMS_SEARCH_TITLE', $this->listcolumn[$firstListColumn]); ?>"
value="<?php echo $this->escape($this->state->get('filter.search')); ?>"
value="<?php echo $this->escape($this->state->get($this->client . '.filter.search')); ?>"
placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>"/>
</div>
<div class="pull-left">
Expand All @@ -47,7 +47,7 @@
?>
<div class="btn-group pull-right hidden-xs">
<?php
echo JHtml::_('select.genericlist', $this->clusterList, "cluster", 'class="input-medium" size="1" onchange="this.form.submit();"', "value", "text", $this->state->get('filter.cluster_id', '', 'INT'));
echo JHtml::_('select.genericlist', $this->clusterList, "cluster", 'class="input-medium" size="1" onchange="this.form.submit();"', "value", "text", $this->state->get($this->client . '.filter.cluster_id', '', 'INT'));
?>
</div>
<?php
Expand Down

0 comments on commit b813844

Please sign in to comment.