Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f64c9ca
Prevent trashing of active items
bembelimen Aug 13, 2018
61d9c0b
Fix wrong method name
bembelimen Aug 13, 2018
6be26a1
Improve translation
bembelimen Aug 13, 2018
b25c0b3
Improve translation
bembelimen Aug 13, 2018
647092d
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into workflow-…
bembelimen Aug 13, 2018
b1eebd6
Reorder xml structure
bembelimen Aug 13, 2018
ab6369e
Remove blank line
bembelimen Aug 13, 2018
0a2cb77
Order use statements
bembelimen Aug 13, 2018
f21b84b
Add point
bembelimen Aug 13, 2018
d4428d7
Merge branch '4.0-dev' into workflow-prevent-trashing
wilsonge Aug 13, 2018
974c564
Merge branch '4.0-dev' into workflow-prevent-trashing
wilsonge Aug 14, 2018
272fcf8
Sniffer satisfaction
bembelimen Aug 14, 2018
fac863e
Sniffer satisfaction
bembelimen Aug 14, 2018
102d260
Merge branch '4.0-dev' into workflow-prevent-trashing
wilsonge Aug 14, 2018
85b4ff1
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into workflow-…
bembelimen Aug 18, 2018
069fc8b
Remove parameter check
bembelimen Aug 18, 2018
899805c
Fix comment
bembelimen Aug 18, 2018
85223e5
Code sniffer
bembelimen Aug 19, 2018
07b7a44
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into workflow-…
bembelimen Aug 20, 2018
9305a49
Merge branch '4.0-dev' into workflow-prevent-trashing
bembelimen Aug 23, 2018
ff70dc6
Merge branch '4.0-dev' into workflow-prevent-trashing
bembelimen Aug 24, 2018
e93e017
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into workflow-…
bembelimen Sep 8, 2018
e762553
Merge branch '4.0-dev' into workflow-prevent-trashing
wilsonge Sep 8, 2018
d9b2b2d
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into workflow-…
bembelimen Sep 9, 2018
e204edf
Merge branch 'workflow-prevent-trashing' of github.com:bembelimen/joo…
bembelimen Sep 9, 2018
22b2446
Fix trashing over edit view
bembelimen Sep 9, 2018
9c066cc
Remove unused string
bembelimen Sep 9, 2018
10d8bc0
Merge branch '4.0-dev' into workflow-prevent-trashing
bembelimen Sep 9, 2018
14fcc14
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into workflow-…
bembelimen Sep 10, 2018
0843fbc
Remove unused "use statement"
bembelimen Sep 10, 2018
4e68625
Merge branch '4.0-dev' into workflow-prevent-trashing
bembelimen Sep 22, 2018
5f31e9f
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into workflow-…
bembelimen Nov 19, 2018
a9b60ff
Merge branch '4.0-dev' into workflow-prevent-trashing
wilsonge Dec 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ protected function getTableNameForSection(string $section = null)
return '#__content';
}

/**
* Returns a table name for the state association
*
* @param string $section An optional section to separate different areas in the component
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
public function getWorkflowTableBySection(string $section = null) : string
{
return '#__content';
}

/**
* Method to filter transitions by given id of state.
*
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_workflow/Model/StageModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public function publish(&$pks, $value = 1)
{
foreach ($pks as $i => $pk)
{
if ($table->load(array('id' => $pk)) && $table->default)
if ($table->load($pk) && $table->default)
{
// Prune items that you can't change.
$app->enqueueMessage(Text::_('COM_WORKFLOW_MSG_DELETE_DEFAULT'), 'error');
Expand Down
4 changes: 3 additions & 1 deletion administrator/language/en-GB/en-GB.com_workflow.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ COM_WORKFLOW_MODIFIED_AT_DESC="Date Modified descending"
COM_WORKFLOW_MODIFIED_DESC="Date Modified"
COM_WORKFLOW_MODIFIED_LABEL="Date Modified"
COM_WORKFLOW_MSG_DELETE_DEFAULT="You are trying to delete the default item."
COM_WORKFLOW_MSG_DELETE_IS_ASSIGNED="This item is in use by the component."
COM_WORKFLOW_MSG_DELETE_IS_DEFAULT="You can't delete the default item."
COM_WORKFLOW_MSG_DELETE_STAGE_IS_ASSIGNED="This stage is in use by the component."
COM_WORKFLOW_MSG_DELETE_WORKFLOW_IS_ASSIGNED="This workflow is in use by the component."
COM_WORKFLOW_MSG_FROM_TO_STAGE="From Stage and To Stage must have different names."
COM_WORKFLOW_MSG_WORKFLOWS_DELETE_ERROR="There was a problem while deleting the item: "
COM_WORKFLOW_NA="N/A"
Expand Down
2 changes: 0 additions & 2 deletions administrator/language/en-GB/en-GB.plg_content_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
PLG_CONTENT_JOOMLA="Content - Joomla"
PLG_CONTENT_JOOMLA_FIELD_CHECK_CATEGORIES_DESC="Check that categories are fully empty before they are deleted."
PLG_CONTENT_JOOMLA_FIELD_CHECK_CATEGORIES_LABEL="Check Category Deletion"
PLG_CONTENT_JOOMLA_FIELD_CHECK_STAGES_DESC="Check that stages are not assigned to an item before they are deleted."
PLG_CONTENT_JOOMLA_FIELD_CHECK_STAGES_LABEL="Check Stages Deletion"
PLG_CONTENT_JOOMLA_FIELD_EMAIL_NEW_FE_DESC="Email users if 'Send email' is on when there is a new article submitted via the Frontend."
PLG_CONTENT_JOOMLA_FIELD_EMAIL_NEW_FE_LABEL="Email on New Site Article"
PLG_CONTENT_JOOMLA_FIELD_EMAIL_NEW_STAGE_DESC="Email users if 'Send email' is on when there is a status change of an article."
Expand Down
31 changes: 29 additions & 2 deletions libraries/src/MVC/Model/AdminModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ abstract class AdminModel extends FormModel
*/
protected $event_before_save = null;

/**
* The event to trigger before changing the published state of the data.
*
* @var string
* @since __DEPLOY_VERSION__
*/
protected $event_before_change_state = null;

/**
* The event to trigger after changing the published state of the data.
*
Expand Down Expand Up @@ -214,6 +222,15 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu
$this->event_before_save = 'onContentBeforeSave';
}

if (isset($config['event_before_change_state']))
{
$this->event_before_change_state = $config['event_before_change_state'];
}
elseif (empty($this->event_before_change_state))
{
$this->event_before_change_state = 'onContentBeforeChangeState';
}

if (isset($config['event_change_state']))
{
$this->event_change_state = $config['event_change_state'];
Expand Down Expand Up @@ -1004,6 +1021,8 @@ public function publish(&$pks, $value = 1)
$table = $this->getTable();
$pks = (array) $pks;

$context = $this->option . '.' . $this->name;

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

Expand Down Expand Up @@ -1037,6 +1056,16 @@ public function publish(&$pks, $value = 1)
}
}

// Trigger the change state event.
$result = Factory::getApplication()->triggerEvent($this->event_before_change_state, array($context, $pks, $value));

if (in_array(false, $result, true))
{
$this->setError($table->getError());

return false;
}

// Attempt to change the state of the records.
if (!$table->publish($pks, $value, $user->get('id')))
{
Expand All @@ -1045,8 +1074,6 @@ public function publish(&$pks, $value = 1)
return false;
}

$context = $this->option . '.' . $this->name;

// Trigger the change state event.
$result = Factory::getApplication()->triggerEvent($this->event_change_state, array($context, $pks, $value));

Expand Down
11 changes: 11 additions & 0 deletions libraries/src/Workflow/WorkflowServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,15 @@ public static function updateContentState($pks, $condition): bool;
* @since 4.0.0
*/
public static function getConditions($extension): array;

/**
* Returns a table name for the state association
*
* @param string $section An optional section to differ different areas in the component
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
public function getWorkflowTableBySection(string $section = null) : string;
}
Loading