Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
195851b
Fix errors in renaming state to stage for workflow
chmst Aug 12, 2018
124473e
Fix table
chmst Aug 12, 2018
31a33d3
Rename FormField workflowstate to workflowstage, fix more state to st…
chmst Aug 12, 2018
bc44d7e
Merge branch '4.0-dev' into state-to-stage-fixes
rdeutz Aug 12, 2018
4686b61
Fix Table Stage in Workflow $stage->default
chmst Aug 12, 2018
cf65e4d
Revert "Fix Table Stage in Workflow $stage->default"
chmst Aug 12, 2018
7338ff3
Fixed renaming errors in the workflow component
chmst Aug 12, 2018
e1cc511
oops
chmst Aug 12, 2018
833be56
Revert change in sql update, Rename and fix JHtmlWorkflowState / Stage
chmst Aug 12, 2018
edc87e6
Fixed state-stage renaming in Transition Field and Article Model
chmst Aug 12, 2018
8a83889
fix stage_id
chmst Aug 12, 2018
f758c82
Merge branch '4.0-dev' into state-to-stage-fixes
chmst Aug 12, 2018
63ead51
Merge branch '4.0-dev' into state-to-stage-fixes
chmst Aug 12, 2018
dd9fc63
Fix two more state => stage
bembelimen Aug 13, 2018
8f4de82
Merge pull request #2 from bembelimen/state-to-stage-fixes
chmst Aug 13, 2018
d56a94f
Fix error for createAssocciaton(..stageId), fix submenu
chmst Aug 13, 2018
6ffcc93
Merge branch 'state-to-stage-fixes' of https://github.com/chmst/jooml…
chmst Aug 13, 2018
72972d3
Improve Code - rename Variables and fix comments
chmst Aug 13, 2018
4819380
fix getStage-getState
chmst Aug 13, 2018
aafea67
Merge branch '4.0-dev' into state-to-stage-fixes
chmst Aug 13, 2018
8d6116f
Fix vname in sidebar
chmst Aug 13, 2018
0383ef5
fix insert into workflow_associations
chmst Aug 13, 2018
9d4458c
Merge branch '4.0-dev' into state-to-stage-fixes
chmst Aug 13, 2018
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
34 changes: 17 additions & 17 deletions administrator/components/com_content/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Joomla\CMS\Model\Form;
use Joomla\Component\Content\Administrator\Helper\ContentHelper;
use Joomla\Component\Workflow\Administrator\Helper\WorkflowHelper;
use Joomla\Component\Workflow\Administrator\Table\StateTable;
use Joomla\Component\Workflow\Administrator\Table\StageTable;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\MVC\Model\AdminModel;
Expand Down Expand Up @@ -196,17 +196,17 @@ protected function batchCopy($value, $pks, $contexts)
}

/**
* Batch change workflow state or current.
* Batch change workflow stage or current.
*
* @param integer $value The workflow state ID.
* @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 __DEPLOY_VERSION__
*/
protected function batchWorkflowState($value, $pks, $contexts)
protected function batchWorkflowStage($value, $pks, $contexts)
{
$user = Factory::getUser();

Expand All @@ -215,19 +215,19 @@ protected function batchWorkflowState($value, $pks, $contexts)
$this->setError(Text::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EXECUTE_TRANSITION'));
}

// Get state information
$state = new StateTable($this->_db);
// Get workflow stage information
$stage = new StageTable($this->_db);

if (empty($value) || !$state->load($value))
if (empty($value) || !$stage->load($value))
{
Factory::getApplication()->enqueueMessage(Text::sprintf('JGLOBAL_BATCH_WORKFLOW_STATE_ROW_NOT_FOUND'), 'error');
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_STATE_ROW_NOT_FOUND'), 'error');
Factory::getApplication()->enqueueMessage(Text::sprintf('JGLOBAL_BATCH_WORKFLOW_STAGE_ROW_NOT_FOUND'), 'error');

return false;
}
Expand Down Expand Up @@ -358,13 +358,13 @@ protected function canDelete($record)
{
if (!empty($record->id))
{
$state = new StateTable($this->_db);
$stage = new StageTable($this->_db);

$workflow = new Workflow(['extension' => 'com_content']);

$assoc = $workflow->getAssociation($record->id);

if (!$state->load($assoc->state_id) || $state->condition != Workflow::TRASHED)
if (!$stage->load($assoc->stage_id) || $stage->condition != Workflow::TRASHED)
{
return false;
}
Expand Down Expand Up @@ -541,7 +541,7 @@ public function getForm($data = array(), $loadData = true)
// Transition field
$assoc = $workflow->getAssociation($table->id);

$form->setFieldAttribute('transition', 'workflow_state', (int) $assoc->state_id);
$form->setFieldAttribute('transition', 'workflow_stage', (int) $assoc->stage_id);
}
}
else
Expand Down Expand Up @@ -780,7 +780,7 @@ public function save($data)
}

$workflowId = 0;
$stateId = 0;
$stageId = 0;

// Set status depending on category
if (empty($data['id']))
Expand All @@ -794,7 +794,7 @@ public function save($data)
return false;
}

$stateId = (int) $workflow->state_id;
$stageId = (int) $workflow->stage_id;
$workflowId = (int) $workflow->id;

// B/C state
Expand Down Expand Up @@ -823,14 +823,14 @@ public function save($data)
$query ->select($db->quoteName(['ws.id', 'ws.condition']))
->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.to_stage_id') . ' = ' . $db->quoteName('ws.id'))
->where($db->quoteName('wt.id') . ' = ' . (int) $data['transition'])
->where($db->quoteName('ws.published') . ' = 1')
->where($db->quoteName('wt.published') . ' = 1');

$state = $db->setQuery($query)->loadObject();
$stage = $db->setQuery($query)->loadObject();

if (empty($state->id))
if (empty($stage->id))
{
$this->setError(Text::_('COM_CONTENT_WORKFLOW_TRANSITION_NOT_ALLOWED'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<field
name="state"
type="workflowstate"
type="workflowstage"
label="COM_CONTENT_STATES"
onchange="this.form.submit();"
activeonly="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<field
name="state"
type="workflowstate"
type="workflowstage"
label="COM_CONTENT_STATES"
onchange="this.form.submit();"
activeonly="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public function getListQuery()
't.to_stage_id',
't.published',
't.ordering',
)
);
)

$select[] = $db->quoteName('f_stage.title', 'from_stage');
$select[] = $db->quoteName('t_stage.title', 'to_stage');
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_workflow/forms/transition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<field
name="from_stage_id"
type="sql"
label="COM_WORKFLOW_FROM_STATE"
label="COM_WORKFLOW_FROM_STAGE"
required="true"
sql_select="id as value, title as from_stage_id"
sql_from="#__workflow_stages"
Expand All @@ -31,7 +31,7 @@
<field
name="to_stage_id"
type="sql"
label="COM_WORKFLOW_TO_STATE"
label="COM_WORKFLOW_TO_STAGE"
required="true"
sql_select="id as value, title as to_stage_id"
sql_from="#__workflow_stages"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
use Joomla\CMS\Form\Field\GroupedlistField;

/**
* Workflow States field.
* Workflow Stages field.
*
* @since __DEPLOY_VERSION__
*/
class WorkflowStateField extends GroupedlistField
class WorkflowStageField extends GroupedlistField
{
/**
* The form field type.
*
* @var string
* @since __DEPLOY_VERSION__
*/
protected $type = 'WorkflowState';
protected $type = 'WorkflowStage';

/**
* The extension where we're
Expand All @@ -38,7 +38,7 @@ class WorkflowStateField extends GroupedlistField
protected $extension = 'com_content';

/**
* Show only the states which has an item attached
* Show only the stages which has an item attached
*
* @var boolean
* @since __DEPLOY_VERSION__
Expand Down Expand Up @@ -91,10 +91,10 @@ protected function getGroups()
$db = Factory::getDbo();
$query = $db->getQuery(true);

// Select distinct states for existing articles
// Select distinct stages for existing articles
$query
->select('DISTINCT ' . $db->quoteName('ws.id', 'workflow_stage_id'))
->select($db->quoteName(['ws.title', 'w.title', 'w.id', 'w.ordering'], ['workflow_state_title', 'workflow_title', 'workflow_id', 'ordering']))
->select($db->quoteName(['ws.title', 'w.title', 'w.id', 'w.ordering'], ['workflow_stage_title', 'workflow_title', 'workflow_id', 'ordering']))
->from($db->quoteName('#__workflow_stages', 'ws'))
->from($db->quoteName('#__workflows', 'w'))
->where($db->quoteName('ws.workflow_id') . ' = ' . $db->quoteName('w.id'))
Expand All @@ -110,25 +110,25 @@ protected function getGroups()

}

$states = $db->setQuery($query)->loadObjectList();
$stages = $db->setQuery($query)->loadObjectList();

$workflowStates = array();
$workflowStages = array();

// Grouping the states by workflow
foreach ($states as $state)
// Grouping the stages by workflow
foreach ($stages as $stage)
{
// Using workflow ID to differentiate workflows having same title
$workflowStateKey = $state->workflow_title . ' (' . $state->workflow_id . ')';
$workflowStageKey = $stage->workflow_title . ' (' . $stage->workflow_id . ')';

if (!array_key_exists($workflowStateKey, $workflowStates))
if (!array_key_exists($workflowStageKey, $workflowStages))
{
$workflowStates[$workflowStateKey] = array();
$workflowStages[$workflowStageKey] = array();
}

$workflowStates[$workflowStateKey][] = HTMLHelper::_('select.option', $state->workflow_stage_id, $state->workflow_state_title);
$workflowStages[$workflowStageKey][] = HTMLHelper::_('select.option', $stage->workflow_stage_id, $stage->workflow_stage_title);
}

// Merge any additional options in the XML definition.
return array_merge(parent::getGroups(), $workflowStates);
return array_merge(parent::getGroups(), $workflowStages);
}
}
2 changes: 1 addition & 1 deletion libraries/src/MVC/Model/AdminModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ abstract class AdminModel extends FormModel
'assetgroup_id' => 'batchAccess',
'language_id' => 'batchLanguage',
'tag' => 'batchTag',
'workflowstage_id' => 'batchWorkflowState',
'workflowstage_id' => 'batchWorkflowStage',
);

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/mod_articles_archive/mod_articles_archive.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<field
name="state"
type="workflowstate"
type="workflowstage"
multiple="true"
size="5"
label="MOD_ARTICLES_ARCHIVE_CHOOSE_STATE"
Copy link
Member

Choose a reason for hiding this comment

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

MOD_ARTICLES_ARCHIVE_CHOOSE_STATE should be MOD_ARTICLES_ARCHIVE_CHOOSE_STAGE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thx

Expand Down