Skip to content
Closed
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
14 changes: 7 additions & 7 deletions administrator/language/en-GB/en-GB.com_workflow.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

COM_CONTACT_FIELD_CATEGORY_LIST_DESC="Please choose a Category from the list."
COM_CONTACT_FIELD_CATEGORY_LIST_DESC="Please choose a category from the list."
COM_WORKFLOW_ARE_YOU_SURE="Are you sure?"
COM_WORKFLOW_ASC_CONDITION="Condition ascending"
COM_WORKFLOW_AUTHOR="Author"
COM_WORKFLOW_BASIC_TAB="Basic"
COM_WORKFLOW_CONDITION="Condition of items in this State: "
COM_WORKFLOW_CONDITION="Condition of items in this state: "
COM_WORKFLOW_CONDITION_DESC="Defines item behaviour."
COM_WORKFLOW_CONFIGURATION="Workflow: Options"
COM_WORKFLOW_COUNT_STATES="States"
Expand All @@ -27,16 +27,16 @@ COM_WORKFLOW_DESC_TAB="Description"
COM_WORKFLOW_DISABLE_DEFAULT="Cannot change default state of this item."
COM_WORKFLOW_EDIT="Edit"
COM_WORKFLOW_EDIT_TAB="Edit"
COM_WORKFLOW_ERROR_UPDATE_STATE="Error while updating the State."
COM_WORKFLOW_ERROR_UPDATE_STATE="Error while updating the state."
COM_WORKFLOW_FIELD_CATEGORY_LIST_LABEL="Category List"
COM_WORKFLOW_FIELD_IS_DEFAULT_DESC="If set to default, this will be saved for the component."
COM_WORKFLOW_FIELD_IS_DEFAULT_LABEL="Default"
COM_WORKFLOW_FIELD_TITLE_DESC="Title"
COM_WORKFLOW_FIELD_TITLE_LABEL="Title"
COM_WORKFLOW_FILTER_SEARCH_DESC="Filter the list of items."
COM_WORKFLOW_FILTER_SEARCH_LABEL="Search"
COM_WORKFLOW_FROM_STATE="From State"
COM_WORKFLOW_FROM_STATE_DESC="Select current State."
COM_WORKFLOW_FROM_STATE="From state"
COM_WORKFLOW_FROM_STATE_DESC="Select current state."
COM_WORKFLOW_ID="ID"
COM_WORKFLOW_ITEM_MUST_PUBLISHED="Item must be published to set default state."
COM_WORKFLOW_ITEM_SET_DEFAULT="Item set to default."
Expand Down Expand Up @@ -84,14 +84,14 @@ COM_WORKFLOW_TITLE="Title"
COM_WORKFLOW_TOOLBAR_SET_HOME="Default"
COM_WORKFLOW_TO_MANY_ITEMS="Too many items selected."
COM_WORKFLOW_TO_STATE="To State"
COM_WORKFLOW_TO_STATE_DESC="Select target State."
COM_WORKFLOW_TO_STATE_DESC="Select target state."
COM_WORKFLOW_TRANSITION="Transition"
COM_WORKFLOW_TRANSITIONS="Transitions"
COM_WORKFLOW_TRANSITIONS_LIST="%s Transitions List"
COM_WORKFLOW_TRANSITION_ADD="Add Transition"
COM_WORKFLOW_TRANSITION_DUPLICATE="This transition already exists."
COM_WORKFLOW_TRANSITION_EDIT="Edit Transition"
COM_WORKFLOW_TRANSITION_THE_SAME_STATE="Current State and target State are the same."
COM_WORKFLOW_TRANSITION_THE_SAME_STATE="Current state and target state are the same."
COM_WORKFLOW_TRASHED="Trashed"
COM_WORKFLOW_UNPUBLISHED="Unpublished"
COM_WORKFLOW_USER_GROUPS="User Group"
Expand Down
66 changes: 45 additions & 21 deletions libraries/src/MVC/Model/AdminModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ abstract class AdminModel extends FormModel
* @var string
* @since 1.6
*/

protected $event_before_save = null;

/**
Expand Down Expand Up @@ -191,7 +192,7 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu
$this->event_before_delete = 'onContentBeforeDelete';
}

if (isset($config['event_before_save']))
if (isset($config['event_before_save']))
{
$this->event_before_save = $config['event_before_save'];
}
Expand Down Expand Up @@ -957,6 +958,7 @@ protected function populateState()
// Load the parameters.
$value = \JComponentHelper::getParams($this->option);
$this->setState('params', $value);

}

/**
Expand Down Expand Up @@ -995,34 +997,56 @@ public function publish(&$pks, $value = 1)
// Access checks.
foreach ($pks as $i => $pk)
{
$table->reset();
$table->reset();

if ($table->load($pk))
{
if (!$this->canEditState($table))
{
// Prune items that you can't change.
unset($pks[$i]);
if ($table->load($pk))
{

\JLog::add(\JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), \JLog::WARNING, 'jerror');
if (!$this->canEditState($table))
{
// Prune items that you can't change.
unset($pks[$i]);

return false;
}
\JLog::add(\JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), \JLog::WARNING, 'jerror');

// If the table is checked out by another user, drop it and report to the user trying to change its state.
if (property_exists($table, 'checked_out') && $table->checked_out && ($table->checked_out != $user->id))
{
\JLog::add(\JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'), \JLog::WARNING, 'jerror');
return false;
}

// Prune items that you can't change.
unset($pks[$i]);
// If the table is checked out by another user, drop it and report to the user trying to change its state.
if (property_exists($table, 'checked_out') && $table->checked_out && ($table->checked_out != $user->id)) {
\JLog::add(\JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'), \JLog::WARNING, 'jerror');

return false;
}
}
// Prune items that you can't change.
unset($pks[$i]);

return false;
}

// Get the task - if it is "trash" then trigger event_before_delete
$task = \JFactory::getApplication()->input->getCmd('task');

if ($task === 'trash')
{
$context = $this->option . '.' . $this->name;

// Trigger the before delete event so it checks if category is empty.
$resultItem = \JFactory::getApplication()->triggerEvent($this->event_before_delete, array($context, $table));

// If the previously checked category has items associated with it, it cannot be moved to trash.
if (in_array(false, $resultItem, true))
{
// Prune items that you can't change.
unset($pks[$i]);
return false;

}

}
}
}

// Attempt to change the state of the records.

// Attempt to change the state of the records.
if (!$table->publish($pks, $value, $user->get('id')))
{
$this->setError($table->getError());
Expand Down
8 changes: 6 additions & 2 deletions plugins/content/joomla/joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,11 @@ private function _canDeleteStates($pk)
// Now check to see if this is a known core extension
if (isset($tableInfo[$extension]))
{
// See if this category has any content items
$count = $this->_countItemsFromState($extension, $pk, $tableInfo[$extension]);
// Get table name for known core extensions
$table = $tableInfo[$extension]['table_name'];

// See if this category has any content items
$count = $this->_countItemsFromState($extension, $pk, $table);

// Return false if db error
if ($count === false)
Expand Down Expand Up @@ -366,6 +369,7 @@ private function _countItemsInChildren($table, $catid, $data)
*
* @since __DEPLOY_VERSION__
*/

private function _countItemsFromState($extension, $state_id, $table)
{
$query = $this->db->getQuery(true);
Expand Down