Skip to content

Commit

Permalink
Resolve issue #97, Resolve issue #84, Resolve partly #95
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Jaracz committed Sep 5, 2017
1 parent dcda9a9 commit e171ac9
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 27 deletions.
16 changes: 13 additions & 3 deletions administrator/components/com_content/Model/Articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,22 @@ protected function getListQuery()
// Filter by published state
$published = (string) $this->getState('filter.state');

if (is_numeric($published) && (int) $published > 0)
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}

$condition = (string) $this->getState('filter.condition');

if (is_numeric($condition))
{
$query->where($db->qn('ws.condition') . '=' . $db->quote($condition));
}
else
{
$query->where($db->qn('ws.condition') . ' IN ("0","1")');
}

// Filter by a single or group of categories.
$baselevel = 1;
$categoryId = $this->getState('filter.category_id');
Expand Down Expand Up @@ -392,8 +403,7 @@ public function getTransitions()

$query->select($select)
->from($db->quoteName('#__workflow_transitions', 't'))
->from($db->quoteName('#__workflow_states', 's'))
->where($db->quoteName('t.from_state_id') . ' IN(' . implode(',', $ids) . ')')
->join('LEFT', $db->quoteName('#__workflow_states', 's') . " ON " . $db->qn('t.from_state_id') . ' IN(' . implode(',', $ids) . ')' )
->where($db->quoteName('t.to_state_id') . ' = ' . $db->quoteName('s.id'))
->where($db->quoteName('t.published') . ' = 1')
->where($db->quoteName('s.published') . ' = 1');
Expand Down
14 changes: 13 additions & 1 deletion administrator/components/com_content/forms/filter_articles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@
query="SELECT id as value, title as state FROM #__workflow_states"
onchange="this.form.submit();"
>
<option value="0">COM_CONTENT_SELECT_STATE</option>
<option value="">COM_CONTENT_SELECT_STATE</option>
</field>

<field
name="condition"
type="list"
label="COM_CONTENT_STATES"
onchange="this.form.submit();"
>
<option value="">COM_CONTENT_SELECT_CONDITION</option>
<option value="-2">COM_CONTENT_TRASHED</option>
<option value="0">COM_CONTENT_UNPUBLISHED</option>
<option value="1">COM_CONTENT_PUBLISHED</option>
</field>

<field
Expand Down
12 changes: 1 addition & 11 deletions administrator/components/com_content/tmpl/articles/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@
<th style="min-width:100px" class="nowrap">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
</th>
<th style="width:10%" class="nowrap hidden-sm-down text-center">
<?php echo JText::_("COM_CONTENT_STATE"); ?>
</th>
<th style="width:10%" class="nowrap hidden-sm-down text-center">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
</th>
Expand Down Expand Up @@ -136,12 +133,8 @@

$transitions = \ContentHelper::filterTransitions($this->transitions, $item->state);

array_unshift($transitions, JText::_("COM_CONTENT_SELECT_TRANSITION"));

if (empty($transitions))
{
$transitions[] = null;
}
$transitions = array_merge(array($item->state_title, "--------"), $transitions);

?>
<tr class="row<?php echo $i % 2; ?>" data-dragable-group="<?php echo $item->catid; ?>">
Expand Down Expand Up @@ -190,9 +183,6 @@
</div>
</div>
</td>
<td class="small hidden-sm-down text-center">
<?php echo $item->state_title; ?>
</td>
<td class="small hidden-sm-down text-center">
<?php echo $this->escape($item->access_level); ?>
</td>
Expand Down
7 changes: 5 additions & 2 deletions administrator/components/com_workflow/Model/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ public function save($data)
->where($db->qn("workflow_id") . '=' . $workflowID)
->andWhere($db->qn("default") . '= 1');
$db->setQuery($query);
$states = $db->loadObjectList();
$states = $db->loadObject();

if (empty($states))
if (empty($states) || $states->id === $data['id'])
{
$data['default'] = '1';
$this->setError(\JText::_("COM_WORKFLOW_DISABLE_DEFAULT"));

return false;
}
}

Expand Down
7 changes: 5 additions & 2 deletions administrator/components/com_workflow/Model/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ public function save($data)
->from($db->qn("#__workflows"))
->where($db->qn("default") . '= 1');
$db->setQuery($query);
$workflows = $db->loadObjectList();
$workflows = $db->loadObject();

if (empty($workflows))
if (empty($workflows) || $workflows->id === $data['id'])
{
$data['default'] = '1';
$this->setError(\JText::_("COM_WORKFLOW_DISABLE_DEFAULT"));

return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ protected function addToolbar()
{
ToolbarHelper::publishList('workflows.publish');
ToolbarHelper::unpublishList('workflows.unpublish');
ToolbarHelper::archiveList('workflows.archive');
ToolbarHelper::makeDefault('workflows.setDefault', 'COM_WORKFLOW_TOOLBAR_SET_HOME');
}

Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_workflow/tmpl/state/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>

<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', !empty($this->item->id) ? JText::_('COM_WORKFLOW_EDIT') : JText::_('COM_WORKFLOW_NEW')); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('COM_WORKFLOW_DESCRIPTION')); ?>
<div class="row">
<div class="col-md-9">
<?php echo $this->form->getInput('description'); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div>
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>

<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', !empty($this->item->id) ? JText::_('COM_WORKFLOW_EDIT') : JText::_('COM_WORKFLOW_NEW')); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('COM_WORKFLOW_DESCRIPTION')); ?>
<div class="row">
<div class="col-md-9">
<?php echo $this->form->getInput('description'); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div>
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>

<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', !empty($this->item->id) ? JText::_('COM_WORKFLOW_EDIT') : JText::_('COM_WORKFLOW_NEW'));?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('COM_WORKFLOW_DESCRIPTION'));?>
<div class="row">
<div class="col-md-9">
<?php echo $this->form->getInput('description'); ?>
Expand Down
4 changes: 4 additions & 0 deletions administrator/language/en-GB/en-GB.com_content.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COM_CONTENT_WORKFLOW="Workflow"
COM_CONTENT_STATE="State"
COM_CONTENT_ERROR_UPDATE_STATE="Can not set state to the item"
COM_CONTENT_SELECT_STATE="- Select State -"
COM_CONTENT_SELECT_CONDITION="- Select Condition -"
COM_CONTENT_SELECT_TRANSITION="- Select Transition -"
COM_CONTENT_RUN_TRANSITIONS="Run Transitions"
COM_CONTENT_DEFAULT_WORKFLOW="- Use default -"
Expand Down Expand Up @@ -160,6 +161,9 @@ COM_CONTENT_URL_FIELD_B_BROWSERNAV_LABEL="URL B Target Window"
COM_CONTENT_URL_FIELD_C_BROWSERNAV_LABEL="URL C Target Window"
COM_CONTENT_WARNING_PROVIDE_VALID_NAME="Please provide a valid, non-blank title."
COM_CONTENT_XML_DESCRIPTION="Article management component."
COM_CONTENT_PUBLISHED="Published"
COM_CONTENT_UNPUBLISHED="Unpublished"
COM_CONTENT_TRASHED="Trashed"

JGLOBAL_NO_ITEM_SELECTED="No articles selected"
JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE="You are not allowed to create new articles in this category."
Expand Down
5 changes: 3 additions & 2 deletions administrator/language/en-GB/en-GB.com_workflow.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ COM_WORKFLOW_DEFAULT="Default"
COM_WORKFLOW_DESC_CONDITION="Condition descending"
COM_WORKFLOW_DESC_TAB="Description"
COM_WORKFLOW_EDIT="Edit"
COM_WORKFLOW_DESCRIPTION="Description"
COM_WORKFLOW_EDIT_TAB="Edit"
COM_WORKFLOW_FIELD_CATEGORY_LIST_LABEL="Category List"
COM_WORKFLOW_FIELD_IS_DEFAULT_DESC="If Workflow is default then is for whole component"
Expand Down Expand Up @@ -90,10 +91,10 @@ COM_WORKFLOW_USER_GROUPS_DESC="Select user group for performing transition"
COM_WORKFLOW_WORKFLOWS_ADD="Add Workflow"
COM_WORKFLOW_WORKFLOWS_EDIT="Edit Workflow"
COM_WORKFLOW_WORKFLOWS_LIST="Workflows List"
COM_WORKFLOW_DISABLE_DEFAULT="Should be one only default item"
COM_WORKFLOW_DISABLE_DEFAULT="Can not change default state of this item."
COM_WORKFLOW_ITEM_MUST_PUBLISHED="To set default, item must be published"
COM_WORKFLOW_DEFAULT_ITEM="Default option is already set for different item"
COM_WORKFLOW_TRANSITION_DUPLICATE="That transition already exist"
COM_WORKFLOW_TRANSITION_THE_SAME_STATE="You choose the same state 'from' and 'to'"
COM_WORKFLOW_MSG_DELETE_IS_ASSIGNED="This item is used in component"
COM_WORKFLOW_ERROR_UPDATE_STATE="Error with updating item to new state"
COM_WORKFLOW_ERROR_UPDATE_STATE="Error with updating item to new state"
4 changes: 2 additions & 2 deletions installation/sql/mysql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2162,8 +2162,8 @@ CREATE TABLE IF NOT EXISTS `#__workflows` (
-- Dumping data for table `#__workflows`
--

INSERT INTO `#__workflows` (`id`, `asset_id`, `published`, `title`, `description`, `extension`, `default`, `created`, `created_by`, `modified`, `modified_by`) VALUES
(1, 56, 1, 'Joomla! Default', '', 'com_content', 1, '0000-00-00 00:00:00', 3, '0000-00-00 00:00:00', 3);
INSERT INTO `#__workflows` (`id`, `asset_id`, `published`, `title`, `description`, `extension`, `default`, `created_by`,`modified_by`) VALUES
(1, 56, 1, 'Joomla! Default', '', 'com_content', 1, 3, 3);

--
-- Dumping data for table `#__workflow_states`
Expand Down

0 comments on commit e171ac9

Please sign in to comment.