Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ INSERT INTO `#__workflows` (`id`, `asset_id`, `published`, `title`, `description

CREATE TABLE IF NOT EXISTS `#__workflow_associations` (
`item_id` int(10) NOT NULL DEFAULT 0 COMMENT 'Extension table id value',
`state_id` int(10) NOT NULL COMMENT 'Foreign Key to #__workflow_states.id',
`stage_id` int(10) NOT NULL COMMENT 'Foreign Key to #__workflow_stages.id',
`extension` varchar(50) NOT NULL,
PRIMARY KEY (`item_id`, `state_id`, `extension`),
PRIMARY KEY (`item_id`, `stage_id`, `extension`),
KEY `idx_item_id` (`item_id`),
KEY `idx_state_id` (`state_id`),
KEY `idx_stage_id` (`stage_id`),
KEY `idx_extension` (`extension`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

--
-- Table structure for table `#__workflow_states`
-- Table structure for table `#__workflow_stages`
--

CREATE TABLE IF NOT EXISTS `#__workflow_states` (
CREATE TABLE IF NOT EXISTS `#__workflow_stages` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`asset_id` int(10) DEFAULT 0,
`ordering` int(11) NOT NULL DEFAULT 0,
Expand All @@ -69,10 +69,10 @@ CREATE TABLE IF NOT EXISTS `#__workflow_states` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `#__workflow_states`
-- Dumping data for table `#__workflow_stages`
--

INSERT INTO `#__workflow_states` (`id`, `asset_id`, `ordering`, `workflow_id`, `published`, `title`, `description`, `condition`, `default`) VALUES
INSERT INTO `#__workflow_stages` (`id`, `asset_id`, `ordering`, `workflow_id`, `published`, `title`, `description`, `condition`, `default`) VALUES
(1, 0, 1, 1, 1, 'Unpublished', '', '0', 0),
(2, 0, 2, 1, 1, 'Published', '', '1', 1),
(3, 0, 3, 1, 1, 'Trashed', '', '-2', 0),
Expand All @@ -90,21 +90,21 @@ CREATE TABLE IF NOT EXISTS `#__workflow_transitions` (
`published` tinyint(1) NOT NULL DEFAULT 0,
`title` varchar(255) NOT NULL,
`description` text NOT NULL,
`from_state_id` int(10) NOT NULL,
`to_state_id` int(10) NOT NULL,
`from_stage_id` int(10) NOT NULL,
`to_stage_id` int(10) NOT NULL,
PRIMARY KEY (`id`),
KEY `title` (`title`(191)),
KEY `asset_id` (`asset_id`),
KEY `from_state_id` (`from_state_id`),
KEY `to_state_id` (`to_state_id`),
KEY `from_stage_id` (`from_stage_id`),
KEY `to_stage_id` (`to_stage_id`),
KEY `workflow_id` (`workflow_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `#__workflow_transitions`
--

INSERT INTO `#__workflow_transitions` (`id`, `asset_id`, `published`, `ordering`, `workflow_id`, `title`, `description`, `from_state_id`, `to_state_id`) VALUES
INSERT INTO `#__workflow_transitions` (`id`, `asset_id`, `published`, `ordering`, `workflow_id`, `title`, `description`, `from_stage_id`, `to_stage_id`) VALUES
(1, 0, 1, 1, 1, 'Unpublish', '', -1, 1),
(2, 0, 1, 2, 1, 'Publish', '', -1, 2),
(3, 0, 1, 3, 1, 'Trash', '', -1, 3),
Expand All @@ -114,11 +114,11 @@ INSERT INTO `#__workflow_transitions` (`id`, `asset_id`, `published`, `ordering`
-- Creating extension entry
--

INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `checked_out`, `checked_out_time`, `ordering`, `state`, `namespace`) VALUES
INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `checked_out`, `checked_out_time`, `ordering`, `stage`, `namespace`) VALUES
Copy link
Contributor

@alikon alikon Aug 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change ??? on the extensions table

did you check all item's affected by this field name change???

please STOP merging things in hurry

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this merge or correct at once.

@wilsonge
PLEASE, PLEASE, PLEASE
STOP merging anything workflow related until the code is heavily corrected to take at least into account the "Enable workflows" parameter!!!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this field (table column) name in the extensions table is definitely wrong.

(35, 0, 'com_workflow', 'component', 'com_workflow', '', 1, 1, 0, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0, 'Joomla\\Component\\Workflow');

--
-- Creating Associations for existing content
--
INSERT INTO `#__workflow_associations` (`item_id`, `state_id`, `extension`)
SELECT `id`, CASE WHEN `state` = -2 THEN 3 WHEN `state` = 0 THEN 1 WHEN `state` = 2 THEN 4 ELSE 2 END, 'com_content' FROM `#__content`;
INSERT INTO `#__workflow_associations` (`item_id`, `stage_id`, `extension`)
SELECT `id`, CASE WHEN `stage` = -2 THEN 3 WHEN `stage` = 0 THEN 1 WHEN `stage` = 2 THEN 4 ELSE 2 END, 'com_content' FROM `#__content`;
10 changes: 5 additions & 5 deletions administrator/components/com_content/Helper/ContentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public static function addSubmenu($vName)
$workflowID = $app->getUserStateFromRequest('filter.workflow_id', 'workflow_id', 1, 'int');

\JHtmlSidebar::addEntry(
Text::_('COM_WORKFLOW_STATES'),
'index.php?option=com_workflow&view=states&workflow_id=' . $workflowID . "&extension=com_content",
Text::_('COM_WORKFLOW_STAGES'),
'index.php?option=com_workflow&view=stages&workflow_id=' . $workflowID . "&extension=com_content",
$vName == 'states`'
);

Expand Down Expand Up @@ -148,10 +148,10 @@ public static function countItems(&$items)
$query ->select($db->quoteName('condition'))
->select('COUNT(*) AS ' . $db->quoteName('count'))
->from($db->quoteName('#__content', 'c'))
->from($db->quoteName('#__workflow_states', 's'))
->from($db->quoteName('#__workflow_stages', 's'))
->from($db->quoteName('#__workflow_associations', 'a'))
->where($db->quoteName('a.item_id') . ' = ' . $db->quoteName('c.id'))
->where($db->quoteName('s.id') . ' = ' . $db->quoteName('a.state_id'))
->where($db->quoteName('s.id') . ' = ' . $db->quoteName('a.stage_id'))
->where('catid = ' . (int) $item->id)
->where('a.extension = ' . $db->quote('com_content'))
->group($db->quoteName('condition'));
Expand Down Expand Up @@ -349,7 +349,7 @@ public static function filterTransitions($transitions, $pk, $workflow_id = 0): a
$transitions,
function ($var) use ($pk, $workflow_id)
{
return in_array($var['from_state_id'], [-1, $pk]) && $var['to_state_id'] != $pk && $workflow_id == $var['workflow_id'];
return in_array($var['from_stage_id'], [-1, $pk]) && $var['to_stage_id'] != $pk && $workflow_id == $var['workflow_id'];
}
)
);
Expand Down
14 changes: 7 additions & 7 deletions administrator/components/com_content/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ public function save($data)
$query = $db->getQuery(true);

$query ->select($db->quoteName(['ws.id', 'ws.condition']))
->from($db->quoteName('#__workflow_states', 'ws'))
->from($db->quoteName('#__workflow_stages', 'ws'))
->from($db->quoteName('#__workflow_transitions', 'wt'))
->where($db->quoteName('wt.to_state_id') . ' = ' . $db->quoteName('ws.id'))
->where($db->quoteName('wt.id') . ' = ' . (int) $data['transition'])
Expand Down Expand Up @@ -1219,7 +1219,7 @@ protected function getWorkflowByCategory($catId)
)
)
->select($db->quoteName('ws.id', 'state_id'))
->from($db->quoteName('#__workflow_states', 'ws'))
->from($db->quoteName('#__workflow_stages', 'ws'))
->from($db->quoteName('#__workflows', 'w'))
->where($db->quoteName('ws.workflow_id') . ' = ' . $db->quoteName('w.id'))
->where($db->quoteName('ws.default') . ' = 1')
Expand All @@ -1246,8 +1246,8 @@ protected function getWorkflowByCategory($catId)
]
)
)
->select($db->quoteName('ws.id', 'state_id'))
->from($db->quoteName('#__workflow_states', 'ws'))
->select($db->quoteName('ws.id', 'stage_id'))
->from($db->quoteName('#__workflow_stages', 'ws'))
->from($db->quoteName('#__workflows', 'w'))
->where($db->quoteName('ws.default') . ' = 1')
->where($db->quoteName('ws.workflow_id') . ' = ' . $db->quoteName('w.id'))
Expand Down Expand Up @@ -1284,18 +1284,18 @@ public function runTransition($pk, $transition_id)

if (!$runTransaction)
{
$this->setError(Text::_('COM_CONTENT_ERROR_UPDATE_STATE'));
$this->setError(Text::_('COM_CONTENT_ERROR_UPDATE_STAGE'));

return false;
}

// B/C state change trigger for UCM
$context = $this->option . '.' . $this->name;

// Include the plugins for the change of state event.
// Include the plugins for the change of stage event.
\JPluginHelper::importPlugin($this->events_map['change_state']);

// Trigger the change state event.
// Trigger the change stage event.
\JFactory::getApplication()->triggerEvent($this->event_change_state, [$context, [$pk], $transition_id]);

return true;
Expand Down
36 changes: 18 additions & 18 deletions administrator/components/com_content/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ protected function getListQuery()
->join('LEFT', '#__users AS ua ON ua.id = a.created_by');

// Join over the associations.
$query ->select($query->quoteName('wa.state_id', 'state_id'))
$query ->select($query->quoteName('wa.stage_id', 'stage_id'))
->innerJoin($query->quoteName('#__workflow_associations', 'wa'))
->where($query->quoteName('wa.item_id') . ' = ' . $query->quoteName('a.id'));

Expand All @@ -237,14 +237,14 @@ protected function getListQuery()
'ws.workflow_id'
],
[
'state_title',
'state_condition',
'stage_title',
'stage_condition',
'workflow_id'
]
)
)
->innerJoin($query->quoteName('#__workflow_states', 'ws'))
->where($query->quoteName('ws.id') . ' = ' . $query->quoteName('wa.state_id'));
->innerJoin($query->quoteName('#__workflow_stages', 'ws'))
->where($query->quoteName('ws.id') . ' = ' . $query->quoteName('wa.stage_id'));

// Join on voting table
$associationsGroupBy = array(
Expand Down Expand Up @@ -275,7 +275,7 @@ protected function getListQuery()
'ws.title',
'ws.workflow_id',
'ws.condition',
'wa.state_id'
'wa.stage_id'
);

if (PluginHelper::isEnabled('content', 'vote'))
Expand Down Expand Up @@ -323,7 +323,7 @@ protected function getListQuery()

if (is_numeric($workflowState))
{
$query->where('wa.state_id = ' . (int) $workflowState);
$query->where('wa.stage_id = ' . (int) $workflowState);
}

$condition = (string) $this->getState('filter.condition');
Expand Down Expand Up @@ -484,7 +484,7 @@ public function getTransitions()

$items = $this->getItems();

$ids = ArrayHelper::getColumn($items, 'state_id');
$ids = ArrayHelper::getColumn($items, 'stage_id');
$ids = ArrayHelper::toInteger($ids);
$ids = array_unique(array_filter($ids));

Expand All @@ -504,8 +504,8 @@ public function getTransitions()
array(
't.id',
't.title',
't.from_state_id',
't.to_state_id',
't.from_stage_id',
't.to_stage_id',
's.id',
's.title',
's.condition',
Expand All @@ -514,19 +514,19 @@ public function getTransitions()
array(
'value',
'text',
'from_state_id',
'to_state_id',
'state_id',
'state_title',
'state_condition',
'from_stage_id',
'to_stage_id',
'stage_id',
'stage_title',
'stage_condition',
'workflow_id'
)
);

$query->select($select)
->from($db->quoteName('#__workflow_transitions', 't'))
->leftJoin($db->quoteName('#__workflow_states', 's') . ' ON ' . $db->quoteName('t.from_state_id') . ' IN(' . implode(',', $ids) . ')')
->where($db->quoteName('t.to_state_id') . ' = ' . $db->quoteName('s.id'))
->leftJoin($db->quoteName('#__workflow_stages', 's') . ' ON ' . $db->quoteName('t.from_stage_id') . ' IN(' . implode(',', $ids) . ')')
->where($db->quoteName('t.to_stage_id') . ' = ' . $db->quoteName('s.id'))
->where($db->quoteName('t.published') . ' = 1')
->where($db->quoteName('s.published') . ' = 1')
->order($db->quoteName('t.ordering'));
Expand All @@ -544,7 +544,7 @@ public function getTransitions()
else
{
// Update the transition text with final state value
$conditionName = $workflow->getConditionName($transition['state_condition']);
$conditionName = $workflow->getConditionName($transition['stage_condition']);

$transitions[$key]['text'] .= ' [' . \JText::_($conditionName) . ']';
}
Expand Down
12 changes: 6 additions & 6 deletions administrator/components/com_content/Model/FeaturedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function getListQuery()
->join('LEFT', '#__users AS ua ON ua.id = a.created_by');

// Join over the states.
$query->select('wa.state_id AS state_id')
$query->select('wa.stage_id AS stage_id')
->join('LEFT', '#__workflow_associations AS wa ON wa.item_id = a.id');

// Join over the states.
Expand All @@ -126,14 +126,14 @@ protected function getListQuery()
'ws.workflow_id'
],
[
'state_title',
'state_condition',
'stage_title',
'stage_condition',
'workflow_id'
]
)
)
->innerJoin($query->quoteName('#__workflow_states', 'ws'))
->where($query->quoteName('ws.id') . ' = ' . $query->quoteName('wa.state_id'));
->innerJoin($query->quoteName('#__workflow_stages', 'ws'))
->where($query->quoteName('ws.id') . ' = ' . $query->quoteName('wa.stage_id'));

// Join on voting table
if (PluginHelper::isEnabled('content', 'vote'))
Expand Down Expand Up @@ -161,7 +161,7 @@ protected function getListQuery()

if (is_numeric($workflowState))
{
$query->where('wa.state_id = ' . (int) $workflowState);
$query->where('wa.stage_id = ' . (int) $workflowState);
}

$condition = (string) $this->getState('filter.condition');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@
$canEditOwn = $user->authorise('core.edit.own', 'com_content.article.' . $item->id) && $item->created_by == $userId;
$canChange = $user->authorise('core.edit.state', 'com_content.article.' . $item->id) && $canCheckin;

$transitions = ContentHelper::filterTransitions($this->transitions, $item->state_id, $item->workflow_id);
$transitions = ContentHelper::filterTransitions($this->transitions, $item->stage_id, $item->workflow_id);

$hasTransitions = count($transitions) > 0;

$default = [
JHtml::_('select.option', '', $this->escape($item->state_title)),
JHtml::_('select.option', '', $this->escape($item->stage_title)),
JHtml::_('select.option', '-1', '--------', ['disable' => true])
];

Expand Down Expand Up @@ -200,7 +200,7 @@

$icon = 'publish';

switch ($item->state_condition) :
switch ($item->stage_condition) :

case Workflow::TRASHED:
$icon = 'trash';
Expand All @@ -220,7 +220,7 @@
<span class="icon-<?php echo $icon; ?>"></span>
<?php endif; ?>
</div>
<div class="mr-auto"><?php echo $this->escape($item->state_title); ?></div>
<div class="mr-auto"><?php echo $this->escape($item->stage_title); ?></div>
<?php if ($hasTransitions) : ?>
<div class="d-none">
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<div class="controls">
<?php
$displayData = ['extension' => 'com_content'];
echo JLayoutHelper::render('joomla.html.batch.workflowstate', $displayData); ?>
echo JLayoutHelper::render('joomla.html.batch.workflowstage', $displayData); ?>
</div>
</div>
<?php endif; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
document.getElementById('batch-language-id').value = '';
document.getElementById('batch-user-id').value = '';
document.getElementById('batch-tag-id').value = '';
document.getElementById('batch-workflowstate-id').value = '';
document.getElementById('batch-workflowstage-id').value = '';
});
");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || $item->checked_out == 0;
$canChange = $user->authorise('core.edit.state', 'com_content.article.' . $item->id) && $canCheckin;

$transitions = ContentHelper::filterTransitions($this->transitions, $item->state_id, $item->workflow_id);
$transitions = ContentHelper::filterTransitions($this->transitions, $item->stage_id, $item->workflow_id);

$hasTransitions = count($transitions) > 0;

$default = [
JHtml::_('select.option', '', $this->escape($item->state_title)),
JHtml::_('select.option', '', $this->escape($item->stage_title)),
JHtml::_('select.option', '-1', '--------', ['disable' => true])
];

Expand Down Expand Up @@ -182,7 +182,7 @@

$icon = 'publish';

switch ($item->state_condition) :
switch ($item->stage_condition) :

case Workflow::TRASHED:
$icon = 'trash';
Expand All @@ -202,7 +202,7 @@
<span class="icon-<?php echo $icon; ?>"></span>
<?php endif; ?>
</div>
<div class="mr-auto"><?php echo $this->escape($item->state_title); ?></div>
<div class="mr-auto"><?php echo $this->escape($item->stage_title); ?></div>
<?php if ($hasTransitions) : ?>
<div class="d-none">
<?php
Expand Down
Loading