Skip to content

Commit

Permalink
[4.0] Replace filter.condition by filter.published in com_content (#3…
Browse files Browse the repository at this point in the history
…0467)

In com_content and related modules, filter.condition is used for filtering published, unpublished, archived, trashed data.
This might cause problems when 3rd party extension set filters for articles.
This PR sets back the name to filter.published in J3. It does not change the behaviour in any way.
  • Loading branch information
chmst authored Nov 14, 2020
1 parent abf5cf4 commit 13973de
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function displayList()

if (array_key_exists('state', $apiFilterInfo))
{
$this->modelState->set('filter.condition', $filter->clean($apiFilterInfo['state'], 'INT'));
$this->modelState->set('filter.published', $filter->clean($apiFilterInfo['state'], 'INT'));
}

if (array_key_exists('language', $apiFilterInfo))
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/src/Model/ArchiveModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function populateState($ordering = null, $direction = null)
$params = $this->state->get('params');

// Filter on archived articles
$this->setState('filter.condition', ContentComponent::CONDITION_ARCHIVED);
$this->setState('filter.published', ContentComponent::CONDITION_ARCHIVED);

// Filter on month, year
$this->setState('filter.month', $app->input->getInt('month'));
Expand Down
6 changes: 3 additions & 3 deletions components/com_content/src/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected function populateState($ordering = 'ordering', $direction = 'ASC')
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content')))
{
// Filter on published for those who do not have edit or edit.state rights.
$this->setState('filter.condition', ContentComponent::CONDITION_PUBLISHED);
$this->setState('filter.published', ContentComponent::CONDITION_PUBLISHED);
}

$this->setState('filter.language', Multilanguage::isEnabled());
Expand Down Expand Up @@ -159,7 +159,7 @@ protected function populateState($ordering = 'ordering', $direction = 'ASC')
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . serialize($this->getState('filter.condition'));
$id .= ':' . serialize($this->getState('filter.published'));
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.featured');
$id .= ':' . serialize($this->getState('filter.article_id'));
Expand Down Expand Up @@ -327,7 +327,7 @@ protected function getListQuery()
}

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

if (is_numeric($condition) && $condition == 2)
{
Expand Down
6 changes: 3 additions & 3 deletions components/com_content/src/Model/CategoriesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ protected function populateState($ordering = null, $direction = null)
$params = $app->getParams();
$this->setState('params', $params);

$this->setState('filter.condition', 1);
$this->setState('filter.access', true);
$this->setState('filter.published', 1);
$this->setState('filter.access', true);
}

/**
Expand All @@ -88,7 +88,7 @@ protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.extension');
$id .= ':' . $this->getState('filter.condition');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.parentId');

Expand Down
6 changes: 3 additions & 3 deletions components/com_content/src/Model/CategoryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ protected function populateState($ordering = null, $direction = null)
if ((!$user->authorise('core.edit.state', $asset)) && (!$user->authorise('core.edit', $asset)))
{
// Limit to published for people who can't edit or edit.state.
$this->setState('filter.condition', 1);
$this->setState('filter.published', 1);
}
else
{
$this->setState('filter.condition', [0, 1]);
$this->setState('filter.published', [0, 1]);
}

// Process show_noauth parameter
Expand Down Expand Up @@ -263,7 +263,7 @@ public function getItems()
->createModel('Articles', 'Site', ['ignore_request' => true]);
$model->setState('params', Factory::getApplication()->getParams());
$model->setState('filter.category_id', $category->id);
$model->setState('filter.condition', $this->getState('filter.condition'));
$model->setState('filter.published', $this->getState('filter.published'));
$model->setState('filter.access', $this->getState('filter.access'));
$model->setState('filter.language', $this->getState('filter.language'));
$model->setState('filter.featured', $this->getState('filter.featured'));
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/src/Model/FeaturedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ protected function populateState($ordering = null, $direction = null)
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content')))
{
// Filter on published for those who do not have edit or edit.state rights.
$this->setState('filter.condition', ContentComponent::CONDITION_PUBLISHED);
$this->setState('filter.published', ContentComponent::CONDITION_PUBLISHED);
}
else
{
$this->setState('filter.condition', [ContentComponent::CONDITION_UNPUBLISHED, ContentComponent::CONDITION_PUBLISHED]);
$this->setState('filter.published', [ContentComponent::CONDITION_UNPUBLISHED, ContentComponent::CONDITION_PUBLISHED]);
}

// Process show_noauth parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function getList(&$params)
$articles->setState('params', $appParams);

$articles->setState('list.start', 0);
$articles->setState('filter.condition', ContentComponent::CONDITION_PUBLISHED);
$articles->setState('filter.published', ContentComponent::CONDITION_PUBLISHED);

// Set the filters based on the module params
$articles->setState('list.limit', (int) $params->get('count', 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function getList(&$params)
$model->setState('params', $appParams);

$model->setState('list.start', 0);
$model->setState('filter.condition', ContentComponent::CONDITION_PUBLISHED);
$model->setState('filter.published', ContentComponent::CONDITION_PUBLISHED);

// Set the filters based on the module params
$model->setState('list.limit', (int) $params->get('count', 5));
Expand Down

0 comments on commit 13973de

Please sign in to comment.