Skip to content

Commit

Permalink
Workflow remove (#51)
Browse files Browse the repository at this point in the history
* Remove workflow from com_content frontend

* Remove workflow from content helper

* Remove workflow from modules

* Remove workflow from plugin pagenavigation
  • Loading branch information
HLeithner authored Mar 14, 2020
1 parent f7db0e2 commit 5a32050
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 95 deletions.
16 changes: 2 additions & 14 deletions components/com_content/src/Model/ArchiveModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,8 @@ public function getYears()
$years = $query->year($db->quoteName('c.created'));

$query->select('DISTINCT ' . $years)
->from(
[
$db->quoteName('#__content', 'c'),
$db->quoteName('#__workflow_associations', 'wa'),
$db->quoteName('#__workflow_stages', 'ws'),
]
)
->where(
[
$db->quoteName('c.id') . ' = ' . $db->quoteName('wa.item_id'),
$db->quoteName('ws.id') . ' = ' . $db->quoteName('wa.stage_id'),
$db->quoteName('ws.condition') . ' = ' . ContentComponent::CONDITION_ARCHIVED,
]
)
->from($db->quoteName('#__content', 'c'))
->where($db->quoteName('c.state') . ' = ' . ContentComponent::CONDITION_ARCHIVED)
->extendWhere(
'AND',
[
Expand Down
16 changes: 2 additions & 14 deletions components/com_content/src/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public function getItem($pk = null)
[
$db->quoteName('fp.featured_up'),
$db->quoteName('fp.featured_down'),
$db->quoteName('ws.condition'),
$db->quoteName('c.title', 'category_title'),
$db->quoteName('c.alias', 'category_alias'),
$db->quoteName('c.access', 'category_access'),
Expand All @@ -156,16 +155,6 @@ public function getItem($pk = null)
]
)
->from($db->quoteName('#__content', 'a'))
->join(
'INNER',
$db->quoteName('#__workflow_associations', 'wa'),
$db->quoteName('a.id') . ' = ' . $db->quoteName('wa.item_id')
)
->join(
'INNER',
$db->quoteName('#__workflow_stages', 'ws'),
$db->quoteName('wa.stage_id') . ' = ' . $db->quoteName('ws.id')
)
->join(
'INNER',
$db->quoteName('#__categories', 'c'),
Expand All @@ -178,7 +167,6 @@ public function getItem($pk = null)
->where(
[
$db->quoteName('a.id') . ' = :pk',
$db->quoteName('wa.extension') . ' = ' . $db->quote('com_content'),
$db->quoteName('c.published') . ' > 0',
]
)
Expand Down Expand Up @@ -222,7 +210,7 @@ public function getItem($pk = null)

if (is_numeric($published))
{
$query->whereIn($db->quoteName('ws.condition'), [(int) $published, (int) $archived]);
$query->whereIn($db->quoteName('a.state'), [(int) $published, (int) $archived]);
}

$db->setQuery($query);
Expand All @@ -235,7 +223,7 @@ public function getItem($pk = null)
}

// Check for published state if filter set.
if ((is_numeric($published) || is_numeric($archived)) && ($data->condition != $published && $data->condition != $archived))
if ((is_numeric($published) || is_numeric($archived)) && ($data->state != $published && $data->state != $archived))
{
throw new \Exception(Text::_('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND'), 404);
}
Expand Down
20 changes: 7 additions & 13 deletions components/com_content/src/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function __construct($config = array())
'checked_out_time', 'a.checked_out_time',
'catid', 'a.catid', 'category_title',
'state', 'a.state',
'stage_condition', 'ws.condition',
'access', 'a.access', 'access_level',
'created', 'a.created',
'created_by', 'a.created_by',
Expand Down Expand Up @@ -243,13 +242,10 @@ protected function getListQuery()
[
$db->quoteName('fp.featured_up'),
$db->quoteName('fp.featured_down'),
$db->quoteName('wa.stage_id', 'stage_id'),
$db->quoteName('ws.title', 'state_title'),
$db->quoteName('ws.condition', 'stage_condition'),
// Published/archived article in archived category is treated as archived article. If category is not published then force 0.
'CASE WHEN ' . $db->quoteName('c.published') . ' = 2 AND ' . $db->quoteName('ws.condition') . ' > 0 THEN ' . $conditionArchived
'CASE WHEN ' . $db->quoteName('c.published') . ' = 2 AND ' . $db->quoteName('a.state') . ' > 0 THEN ' . $conditionArchived
. ' WHEN ' . $db->quoteName('c.published') . ' != 1 THEN ' . $conditionUnpublished
. ' ELSE ' . $db->quoteName('ws.condition') . ' END AS ' . $db->quoteName('state'),
. ' ELSE ' . $db->quoteName('a.state') . ' END AS ' . $db->quoteName('state'),
$db->quoteName('c.title', 'category_title'),
$db->quoteName('c.path', 'category_route'),
$db->quoteName('c.access', 'category_access'),
Expand All @@ -270,8 +266,6 @@ protected function getListQuery()
]
)
->from($db->quoteName('#__content', 'a'))
->join('LEFT', $db->quoteName('#__workflow_associations', 'wa'), $db->quoteName('wa.item_id') . ' = ' . $db->quoteName('a.id'))
->join('LEFT', $db->quoteName('#__workflow_stages', 'ws'), $db->quoteName('ws.id') . ' = ' . $db->quoteName('wa.stage_id'))
->join('LEFT', $db->quoteName('#__categories', 'c'), $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid'))
->join('LEFT', $db->quoteName('#__users', 'ua'), $db->quoteName('ua.id') . ' = ' . $db->quoteName('a.created_by'))
->join('LEFT', $db->quoteName('#__users', 'uam'), $db->quoteName('uam.id') . ' = ' . $db->quoteName('a.modified_by'))
Expand Down Expand Up @@ -341,8 +335,8 @@ protected function getListQuery()
* If category is archived then article has to be published or archived.
* Or categogy is published then article has to be archived.
*/
$query->where('((' . $db->quoteName('c.published') . ' = 2 AND ' . $db->quoteName('ws.condition') . ' > :conditionUnpublished)'
. ' OR (' . $db->quoteName('c.published') . ' = 1 AND ' . $db->quoteName('ws.condition') . ' = :conditionArchived))'
$query->where('((' . $db->quoteName('c.published') . ' = 2 AND ' . $db->quoteName('a.state') . ' > :conditionUnpublished)'
. ' OR (' . $db->quoteName('c.published') . ' = 1 AND ' . $db->quoteName('a.state') . ' = :conditionArchived))'
)
->bind(':conditionUnpublished', $conditionUnpublished, ParameterType::INTEGER)
->bind(':conditionArchived', $conditionArchived, ParameterType::INTEGER);
Expand All @@ -352,14 +346,14 @@ protected function getListQuery()
$condition = (int) $condition;

// Category has to be published
$query->where($db->quoteName('c.published') . ' = 1 AND ' . $db->quoteName('ws.condition') . ' = :wsCondition')
->bind(':wsCondition', $condition, ParameterType::INTEGER);
$query->where($db->quoteName('c.published') . ' = 1 AND ' . $db->quoteName('a.state') . ' = :condition')
->bind(':condition', $condition, ParameterType::INTEGER);
}
elseif (is_array($condition))
{
// Category has to be published
$query->where(
$db->quoteName('c.published') . ' = 1 AND ' . $db->quoteName('ws.condition')
$db->quoteName('c.published') . ' = 1 AND ' . $db->quoteName('a.state')
. ' IN (' . implode(',', $query->bindArray($condition)) . ')'
);
}
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/src/Model/CategoryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected function populateState($ordering = null, $direction = null)
}
else
{
$this->setState('filter.condition', array(0, 1));
$this->setState('filter.condition', [0, 1]);
}

// Process show_noauth parameter
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/src/Model/FeaturedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function populateState($ordering = null, $direction = null)
}
else
{
$this->setState('filter.condition', array(ContentComponent::CONDITION_UNPUBLISHED, ContentComponent::CONDITION_PUBLISHED));
$this->setState('filter.condition', [ContentComponent::CONDITION_UNPUBLISHED, ContentComponent::CONDITION_PUBLISHED]);
}

// Process show_noauth parameter
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/tmpl/article/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<h2 itemprop="headline">
<?php echo $this->escape($this->item->title); ?>
</h2>
<?php if ($this->item->condition == ContentComponent::CONDITION_UNPUBLISHED) : ?>
<?php if ($this->item->state == ContentComponent::CONDITION_UNPUBLISHED) : ?>
<span class="badge badge-warning"><?php echo Text::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<?php if (strtotime($this->item->publish_up) > strtotime(Factory::getDate())) : ?>
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/tmpl/category/blog_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<?php echo LayoutHelper::render('joomla.content.intro_image', $this->item); ?>

<div class="item-content">
<?php if ($this->item->stage_condition == ContentComponent::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate())
<?php if ($this->item->state == ContentComponent::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate())
|| (!is_null($this->item->publish_down) && strtotime($this->item->publish_down) < strtotime(Factory::getDate()))) : ?>
<div class="system-unpublished">
<?php endif; ?>
Expand Down Expand Up @@ -86,7 +86,7 @@

<?php endif; ?>

<?php if ($this->item->stage_condition == ContentComponent::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate())
<?php if ($this->item->state == ContentComponent::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate())
|| (!is_null($this->item->publish_down) && strtotime($this->item->publish_down) < strtotime(Factory::getDate()))) : ?>
</div>
<?php endif; ?>
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/tmpl/category/default_articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<?php endif; ?>
<tbody>
<?php foreach ($this->items as $i => $article) : ?>
<?php if ($this->items[$i]->stage_condition == ContentComponent::CONDITION_UNPUBLISHED) : ?>
<?php if ($this->items[$i]->state == ContentComponent::CONDITION_UNPUBLISHED) : ?>
<tr class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
<?php else : ?>
<tr class="cat-list-row<?php echo $i % 2; ?>" >
Expand Down Expand Up @@ -225,7 +225,7 @@
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
<?php if ($article->stage_condition == ContentComponent::CONDITION_UNPUBLISHED) : ?>
<?php if ($article->state == ContentComponent::CONDITION_UNPUBLISHED) : ?>
<span class="list-published badge badge-warning">
<?php echo Text::_('JUNPUBLISHED'); ?>
</span>
Expand Down
22 changes: 1 addition & 21 deletions libraries/src/Helper/ContentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public static function countRelations(&$items, $config)
'2' => 'count_archived',
);

$usesWorkflows = (isset($config->uses_workflows) && $config->uses_workflows === true);

// Index category objects by their ID
$records = array();

Expand All @@ -87,7 +85,7 @@ public static function countRelations(&$items, $config)

// Table alias for related data table below will be 'c', and state / condition column is inside related data table
$related_tbl = '#__' . $config->related_tbl;
$state_col = ($usesWorkflows ? 's.' : 'c.') . $config->state_col;
$state_col = 'c.' . $config->state_col;

// Supported cases
switch ($config->relation_type)
Expand Down Expand Up @@ -117,24 +115,6 @@ public static function countRelations(&$items, $config)
return $items;
}

if ($usesWorkflows)
{
$query->from(
[
$db->quoteName('#__workflow_stages', 's'),
$db->quoteName('#__workflow_associations', 'a'),
]
)
->where(
[
$db->quoteName('s.id') . ' = ' . $db->quoteName('a.stage_id'),
$db->quoteName('a.extension') . ' = :component',
$db->quoteName('a.item_id') . ' = ' . $db->quoteName('c.id'),
]
)
->bind(':component', $config->workflows_component);
}

/**
* Get relation counts for all category objects with single query
* NOTE: 'state IN', allows counting specific states / conditions only, also prevents warnings with custom states / conditions, do not remove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,15 @@ public static function getList(&$params)
{
$app = Factory::getApplication();
$db = Factory::getDbo();
$condition = ContentComponent::CONDITION_ARCHIVED;
$query = $db->getQuery(true);

$query->select($query->month($db->quoteName('created')) . ' AS created_month')
->select('MIN(' . $db->quoteName('created') . ') AS created')
->select($query->year($db->quoteName('created')) . ' AS created_year')
->from($db->quoteName('#__content', 'c'))
->innerJoin($db->quoteName('#__workflow_associations', 'wa'), $db->quoteName('wa.item_id') . ' = ' . $db->quoteName('c.id'))
->innerJoin($db->quoteName('#__workflow_stages', 'ws'), $db->quoteName('wa.stage_id') . ' = ' . $db->quoteName('ws.id'))
->where($db->quoteName('ws.condition') . ' = :condition')
->where($db->quoteName('c.state') . ' = ' . ContentComponent::CONDITION_ARCHIVED)
->group($query->year($db->quoteName('c.created')) . ', ' . $query->month($db->quoteName('c.created')))
->order($query->year($db->quoteName('c.created')) . ' DESC, ' . $query->month($db->quoteName('c.created')) . ' DESC')
->bind(':condition', $condition, ParameterType::INTEGER);
->order($query->year($db->quoteName('c.created')) . ' DESC, ' . $query->month($db->quoteName('c.created')) . ' DESC');

// Filter by language
if ($app->getLanguageFilter())
Expand Down
8 changes: 2 additions & 6 deletions modules/mod_related_items/src/Helper/RelatedItemsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static function getList(&$params)
$groups = Factory::getUser()->getAuthorisedViewLevels();
$maximum = (int) $params->get('maximum', 5);
$factory = $app->bootComponent('com_content')->getMVCFactory();
$condition = ContentComponent::CONDITION_PUBLISHED;

// Get an instance of the generic articles model
/** @var \Joomla\Component\Content\Site\Model\ArticlesModel $articles */
Expand Down Expand Up @@ -107,13 +106,10 @@ public static function getList(&$params)
$query->clear()
->select($db->quoteName('a.id'))
->from($db->quoteName('#__content', 'a'))
->join('LEFT', $db->quoteName('#__workflow_associations', 'wa'), $db->quoteName('wa.item_id') . ' = ' . $db->quoteName('a.id'))
->join('LEFT', $db->quoteName('#__workflow_stages', 'ws'), $db->quoteName('ws.id') . ' = ' . $db->quoteName('wa.stage_id'))
->where($db->quoteName('a.id') . ' != :id')
->where($db->quoteName('ws.condition') . ' = :condition')
->where($db->quoteName('a.state') . ' = ' . ContentComponent::CONDITION_PUBLISHED)
->whereIn($db->quoteName('a.access'), $groups)
->bind(':id', $id, ParameterType::INTEGER)
->bind(':condition', $condition, ParameterType::INTEGER);
->bind(':id', $id, ParameterType::INTEGER);

$binds = [];
$wheres = [];
Expand Down
13 changes: 3 additions & 10 deletions modules/mod_stats/src/Helper/StatsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Component\Content\Administrator\Extension\ContentComponent;

/**
* Helper for mod_stats
Expand Down Expand Up @@ -94,11 +95,7 @@ public static function &getList(&$params)
$query->clear()
->select('COUNT(' . $db->quoteName('c.id') . ') AS count_items')
->from($db->quoteName('#__content', 'c'))
->leftJoin(
$db->quoteName('#__workflow_stages', 'ws')
. ' ON ' . $db->quoteName('ws.id') . ' = ' . $db->quoteName('c.state')
)
->where($db->quoteName('ws.condition') . ' = 1');
->where($db->quoteName('c.state') . ' = ' . ContentComponent::CONDITION_PUBLISHED);
$db->setQuery($query);

try
Expand Down Expand Up @@ -132,11 +129,7 @@ public static function &getList(&$params)
$query->clear()
->select('SUM(' . $db->quoteName('hits') . ') AS count_hits')
->from($db->quoteName('#__content'))
->leftJoin(
$db->quoteName('#__workflow_stages', 'ws')
. ' ON ' . $db->quoteName('ws.id') . ' = ' . $db->quoteName('state')
)
->where($db->quoteName('ws.condition') . ' = 1');
->where($db->quoteName('state') . ' = ' . ContentComponent::CONDITION_PUBLISHED);
$db->setQuery($query);

try
Expand Down
7 changes: 3 additions & 4 deletions plugins/content/pagenavigation/pagenavigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Component\Content\Administrator\Extension\ContentComponent;
use Joomla\Component\Content\Site\Helper\RouteHelper;

/**
Expand Down Expand Up @@ -123,7 +124,7 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0)
break;
}

$xwhere = ' AND (ws.condition = 1 OR ws.condition = -2)'
$xwhere = ' AND (a.state IN (' . ContentComponent::CONDITION_PUBLISHED . ', ' . ContentComponent::CONDITION_ARCHIVED . '))'
. ' AND (publish_up IS NULL OR publish_up <= ' . $db->quote($now) . ')'
. ' AND (publish_down IS NULL OR publish_down >= ' . $db->quote($now) . ')';

Expand All @@ -142,9 +143,7 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0)
->select($case_when)
->select($case_when1)
->from('#__content AS a')
->join('LEFT', '#__categories AS cc ON cc.id = a.catid')
->join('LEFT', '#__workflow_associations AS wa', 'wa.item_id = a.id')
->join('LEFT', '#__workflow_stages AS ws', 'wa.stage_id = ws.id');
->join('LEFT', '#__categories AS cc ON cc.id = a.catid');

if ($order_method === 'author' || $order_method === 'rauthor')
{
Expand Down

0 comments on commit 5a32050

Please sign in to comment.