diff --git a/administrator/components/com_content/src/Model/ArticleModel.php b/administrator/components/com_content/src/Model/ArticleModel.php
index c4839991de16c..c969e4bf991fd 100644
--- a/administrator/components/com_content/src/Model/ArticleModel.php
+++ b/administrator/components/com_content/src/Model/ArticleModel.php
@@ -13,12 +13,16 @@
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
+use Joomla\CMS\Form\FormFactoryInterface;
use Joomla\CMS\Helper\TagsHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
+use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\AdminModel;
+use Joomla\CMS\MVC\Model\WorkflowBehaviorTrait;
+use Joomla\CMS\MVC\Model\WorkflowModelInterface;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\String\PunycodeHelper;
use Joomla\CMS\Table\Category;
@@ -41,8 +45,10 @@
* @since 1.6
*/
-class ArticleModel extends AdminModel
+class ArticleModel extends AdminModel implements WorkflowModelInterface
{
+ use WorkflowBehaviorTrait;
+
/**
* The prefix to use with controller messages.
*
@@ -67,6 +73,13 @@ class ArticleModel extends AdminModel
*/
protected $associationsContext = 'com_content.item';
+ public function __construct($config = array(), MVCFactoryInterface $factory = null, FormFactoryInterface $formFactory = null) {
+
+ parent::__construct($config, $factory, $formFactory);
+
+ $this->setUpWorkflow('com_content.article');
+ }
+
/**
* Function that can be overriden to do any data cleanup after batch copying data
*
@@ -1274,6 +1287,8 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
}
}
+ $this->preprocessFormWorkflow($form, $data);
+
parent::preprocessForm($form, $data, $group);
}
diff --git a/components/com_content/src/Model/ArchiveModel.php b/components/com_content/src/Model/ArchiveModel.php
index 83ee2e9c274e7..162d014815f93 100644
--- a/components/com_content/src/Model/ArchiveModel.php
+++ b/components/com_content/src/Model/ArchiveModel.php
@@ -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',
[
diff --git a/components/com_content/src/Model/ArticleModel.php b/components/com_content/src/Model/ArticleModel.php
index 614c1d08d1515..c856d5ae0e97a 100644
--- a/components/com_content/src/Model/ArticleModel.php
+++ b/components/com_content/src/Model/ArticleModel.php
@@ -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'),
@@ -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'),
@@ -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',
]
)
@@ -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);
@@ -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);
}
diff --git a/components/com_content/src/Model/ArticlesModel.php b/components/com_content/src/Model/ArticlesModel.php
index 29f523ce54d93..9b28bf79b8735 100644
--- a/components/com_content/src/Model/ArticlesModel.php
+++ b/components/com_content/src/Model/ArticlesModel.php
@@ -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',
@@ -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'),
@@ -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'))
@@ -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);
@@ -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)) . ')'
);
}
diff --git a/components/com_content/src/Model/CategoryModel.php b/components/com_content/src/Model/CategoryModel.php
index 4070055ae7c6a..0dd8b69b3d8ca 100644
--- a/components/com_content/src/Model/CategoryModel.php
+++ b/components/com_content/src/Model/CategoryModel.php
@@ -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
diff --git a/components/com_content/src/Model/FeaturedModel.php b/components/com_content/src/Model/FeaturedModel.php
index df200a6debca7..604379498d4c5 100644
--- a/components/com_content/src/Model/FeaturedModel.php
+++ b/components/com_content/src/Model/FeaturedModel.php
@@ -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
diff --git a/components/com_content/tmpl/article/default.php b/components/com_content/tmpl/article/default.php
index e0dc72cb9a08b..3b54c1c4f2581 100644
--- a/components/com_content/tmpl/article/default.php
+++ b/components/com_content/tmpl/article/default.php
@@ -53,7 +53,7 @@
escape($this->item->title); ?>
- item->condition == ContentComponent::CONDITION_UNPUBLISHED) : ?>
+ item->state == ContentComponent::CONDITION_UNPUBLISHED) : ?>
item->publish_up) > strtotime(Factory::getDate())) : ?>
diff --git a/components/com_content/tmpl/category/blog_item.php b/components/com_content/tmpl/category/blog_item.php
index 684404121ca6d..d2c07719042aa 100644
--- a/components/com_content/tmpl/category/blog_item.php
+++ b/components/com_content/tmpl/category/blog_item.php
@@ -30,7 +30,7 @@
item); ?>
- item->stage_condition == ContentComponent::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate())
+ 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()))) : ?>
@@ -86,7 +86,7 @@
- item->stage_condition == ContentComponent::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate())
+ 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()))) : ?>
diff --git a/components/com_content/tmpl/category/default_articles.php b/components/com_content/tmpl/category/default_articles.php
index 522fd600e0b11..829fdd0660b50 100644
--- a/components/com_content/tmpl/category/default_articles.php
+++ b/components/com_content/tmpl/category/default_articles.php
@@ -180,7 +180,7 @@
items as $i => $article) : ?>
- items[$i]->stage_condition == ContentComponent::CONDITION_UNPUBLISHED) : ?>
+ items[$i]->state == ContentComponent::CONDITION_UNPUBLISHED) : ?>
@@ -225,7 +225,7 @@
- stage_condition == ContentComponent::CONDITION_UNPUBLISHED) : ?>
+ state == ContentComponent::CONDITION_UNPUBLISHED) : ?>
diff --git a/libraries/src/Helper/ContentHelper.php b/libraries/src/Helper/ContentHelper.php
index 8a11123651dec..566f1a265d408 100644
--- a/libraries/src/Helper/ContentHelper.php
+++ b/libraries/src/Helper/ContentHelper.php
@@ -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();
@@ -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)
@@ -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
diff --git a/libraries/src/MVC/Model/WorkflowBehaviorTrait.php b/libraries/src/MVC/Model/WorkflowBehaviorTrait.php
new file mode 100644
index 0000000000000..98e7ab4b47b6d
--- /dev/null
+++ b/libraries/src/MVC/Model/WorkflowBehaviorTrait.php
@@ -0,0 +1,106 @@
+extension = $extension;
+ }
+
+ /**
+ * Method to allow derived classes to preprocess the form.
+ *
+ * @param Form $form A Form object.
+ * @param mixed $data The data expected for the form.
+ *
+ * @return void
+ *
+ * @throws \Exception if there is an error in the form event.
+ * @since 4.0.0
+ * @see FormField
+ */
+ public function preprocessFormWorkflow(Form $form, $data) {
+
+ // Import the appropriate plugin group.
+ PluginHelper::importPlugin('workflow');
+ }
+
+ /**
+ * Batch change workflow stage or current.
+ *
+ * @param integer $value The workflow stage ID.
+ * @param array $pks An array of row IDs.
+ * @param array $contexts An array of item contexts.
+ *
+ * @return mixed An array of new IDs on success, boolean false on failure.
+ *
+ * @since 4.0.0
+ */
+ public function batchWorkflowStage(int $value, array $pks, array $contexts) {
+
+ $user = Factory::getApplication()->getIdentity();
+ /** @var $workflow */
+ $workflow = Factory::getApplication()->bootComponent('com_workflow');
+
+ if (!$user->authorise('core.admin', $this->option))
+ {
+ $this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EXECUTE_TRANSITION'));
+ }
+
+ // Get workflow stage information
+ $stage = $workflow->createTable('Stage', 'Administrator');
+
+ if (empty($value) || !$stage->load($value))
+ {
+ Factory::getApplication()->enqueueMessage(Text::sprintf('JGLOBAL_BATCH_WORKFLOW_STAGE_ROW_NOT_FOUND'), 'error');
+
+ return false;
+ }
+
+ if (empty($pks))
+ {
+ Factory::getApplication()->enqueueMessage(Text::sprintf('JGLOBAL_BATCH_WORKFLOW_STAGE_ROW_NOT_FOUND'), 'error');
+
+ return false;
+ }
+
+ $workflow = new Workflow(['extension' => $this->option]);
+
+ // Update workflow associations
+ return $workflow->updateAssociations($pks, $value);
+ }
+
+}
diff --git a/libraries/src/MVC/Model/WorkflowModelInterface.php b/libraries/src/MVC/Model/WorkflowModelInterface.php
new file mode 100644
index 0000000000000..cba3aef197647
--- /dev/null
+++ b/libraries/src/MVC/Model/WorkflowModelInterface.php
@@ -0,0 +1,36 @@
+ true,
+ 'joomla.featured' => true,
+ ];
+
+ /**
+ * Check if the functionality is supported by the context
+ *
+ * @param string $feature The functionality
+ * @param string $context The context of the functionality
+ *
+ * @return bool
+ */
+ public function supportFunctionality($functionality, $context): bool {
+
+ if (empty($this->supportedFunctionality[$functionality]))
+ {
+ return false;
+ }
+
+ if (!is_array($this->supportedFunctionality[$functionality]))
+ {
+ return true;
+ }
+
+ return in_array($context, $this->supportedFunctionality[$functionality]);
+ }
+
/**
* Returns an array of possible conditions for the component.
*
@@ -26,8 +60,25 @@ trait WorkflowServiceTrait
*
* @since 4.0.0
*/
- public static function getConditions(string $extension): array
- {
+ public static function getConditions(string $extension): array {
+
return \defined('self::CONDITION_NAMES') ? self::CONDITION_NAMES : Workflow::CONDITION_NAMES;
}
+
+ public function isWorkflowActive($context): bool {
+
+ $parts = explode('.', $context);
+ $config = ComponentHelper::getParams($parts[0]);
+
+ if (!$config->get('workflows_enable', 1))
+ {
+ return false;
+ }
+
+ $component = $this->getMVCFactory();
+ $appName = Factory::getApplication()->getName();
+ $model = $component->createModel($parts[1], $appName, ['ignore_request' => true]);
+
+ return $model instanceof WorkflowModelInterface;
+ }
}
diff --git a/modules/mod_articles_archive/src/Helper/ArticlesArchiveHelper.php b/modules/mod_articles_archive/src/Helper/ArticlesArchiveHelper.php
index f0671a1d561ed..f06e1cc4cc083 100644
--- a/modules/mod_articles_archive/src/Helper/ArticlesArchiveHelper.php
+++ b/modules/mod_articles_archive/src/Helper/ArticlesArchiveHelper.php
@@ -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())
diff --git a/modules/mod_related_items/src/Helper/RelatedItemsHelper.php b/modules/mod_related_items/src/Helper/RelatedItemsHelper.php
index 6bdacc709dea5..53e707a3e6f91 100644
--- a/modules/mod_related_items/src/Helper/RelatedItemsHelper.php
+++ b/modules/mod_related_items/src/Helper/RelatedItemsHelper.php
@@ -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 */
@@ -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 = [];
diff --git a/modules/mod_stats/src/Helper/StatsHelper.php b/modules/mod_stats/src/Helper/StatsHelper.php
index 76a5f125a5e13..a502f32b1a181 100644
--- a/modules/mod_stats/src/Helper/StatsHelper.php
+++ b/modules/mod_stats/src/Helper/StatsHelper.php
@@ -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
@@ -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
@@ -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
diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php
index 1510a23d19766..321a57ecd393d 100644
--- a/plugins/content/pagenavigation/pagenavigation.php
+++ b/plugins/content/pagenavigation/pagenavigation.php
@@ -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;
/**
@@ -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) . ')';
@@ -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')
{