Skip to content

Commit

Permalink
added saving to hisoty after save as draft
Browse files Browse the repository at this point in the history
  • Loading branch information
prozb committed Aug 25, 2021
1 parent f2c5dc4 commit f5827ad
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
Expand Up @@ -20,13 +20,13 @@
use Joomla\CMS\Router\Route;
use Joomla\Input\Input;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Versioning;
use Joomla\CMS\Helper\CMSHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Table\TableInterface;
use Joomla\CMS\Tag\TaggableTableInterface;
use Joomla\CMS\Versioning\Versioning;

/**
* Articles list controller class.
Expand Down Expand Up @@ -171,7 +171,7 @@ public function saveAsDraft()
$user = $this->app->getIdentity();
$ids = $this->input->get('cid', array(), 'array');
$redirectUrl = 'index.php?option=com_content&view=' . $this->view_list . $this->getRedirectToListAppend();

$message = '';
// Access checks.
foreach ($ids as $i => $id)
{
Expand Down Expand Up @@ -203,11 +203,16 @@ public function saveAsDraft()
}
$this->setRedirect(Route::_($redirectUrl, false), $message);

/** @var \Joomla\Component\Content\Administrator\Model\ArticleModel $model */
$model = $this->getModel();

$typeAlias = "com_content.article";
$versionNote = "";
//Versioning::store($typeAlias, $ids, $data, $versionNote);
foreach ($ids as $id)
{
$data = $model->getItem($id);
Versioning::store($data->typeAlias, $id, $data);
}

$message = Text::plural('COM_CONTENT_N_ITEMS_DRAFTED', count($ids));
$this->setRedirect(Route::_($redirectUrl, false), $message);
}

}
20 changes: 10 additions & 10 deletions administrator/components/com_content/src/Model/ArticleModel.php
Expand Up @@ -698,21 +698,21 @@ public function save($data)
}


if(!isset($data['draft']) || $data['state'] == -3)
if (!isset($data['draft']) || $data['state'] == -3)

if (!isset($data['draft']) || $data['state'] != 1)
if (!isset($data['draft']) || $data['state'] != 1)

{
$data['draft'] = 1;
}
{
$data['draft'] = 1;
}

if($data['state'] != -3)
if ($data['state'] != -3)

if ($data['state'] == 1)
if ($data['state'] == 1)

{
$data['draft'] = 0;
}
{
$data['draft'] = 0;
}


if (isset($data['created_by_alias']))
Expand Down

0 comments on commit f5827ad

Please sign in to comment.