Skip to content

Commit

Permalink
Merge pull request concretecms#11566 from marcokuoni/feature/configDe…
Browse files Browse the repository at this point in the history
…faultBehavOfKeepLiveVersion

Feature to toggle default behaviour of "Keep Live Version Approved"-Toggle-Button
  • Loading branch information
aembler authored Oct 13, 2023
2 parents 85a506a + 13f2d03 commit 216512b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion concrete/bootstrap/configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,4 @@
* Load some helper functions
* ----------------------------------------------------------------------------.
*/
require dirname(__FILE__) . '/helpers.php';
require dirname(__FILE__) . '/helpers.php';
8 changes: 8 additions & 0 deletions concrete/config/concrete.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,14 @@
'basic_thumbnailer_generation_strategy' => 'now',
'help_overlay' => true,
'require_version_comments' => false,
/*
* Changes the "Keep Live Version Approved"-Toggle-Button behaviour on the site page version scheduling element
* unapproved: removes live or scheduled version of the site page, if the changed site page gets scheduled
* approved: keeps live or scheduled version of the site page approved, if the changed site page gets scheduled
*
* @var string (approved | unapproved)
*/
'live_version_status_on_scheduled_version_approval' => 'unapproved',
/*
* Control whether a block type can me moved to different block type sets
*
Expand Down
9 changes: 8 additions & 1 deletion concrete/controllers/dialog/page/add/compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Concrete\Core\Page\Template;
use Concrete\Core\Page\Type\Type;
use Concrete\Core\View\DialogView;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Config\Repository\Repository;
use Page;
use Permissions;

Expand Down Expand Up @@ -93,7 +95,12 @@ public function submit()
$dateTime = new DateTime();
$publishDateTime = $dateTime->translate('cvPublishDate');
$publishEndDateTime = $dateTime->translate('cvPublishEndDate');
if ($this->request->request->get('keepOtherScheduling')) {
$app = Application::getFacadeApplication();
$appConfig = $app->make(Repository::class);
$liveVersionStatusOnScheduledVersionApproval = (string)$appConfig->get('concrete.misc.live_version_status_on_scheduled_version_approval');
$isUnapproved = $liveVersionStatusOnScheduledVersionApproval === 'unapproved';
$isKeepOtherScheduling = (bool)$this->request->request->get('keepOtherScheduling');
if ($isUnapproved === !$isKeepOtherScheduling) {
$keepOtherScheduling = true;
}
}
Expand Down
9 changes: 8 additions & 1 deletion concrete/controllers/panel/detail/page/composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Concrete\Core\Page\Page;
use Concrete\Core\User\User;
use Concrete\Core\View\View;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Config\Repository\Repository;
use Exception;

class Composer extends BackendInterfacePageController
Expand Down Expand Up @@ -92,7 +94,12 @@ public function publish()
$dateTime = new DateTime();
$publishDateTime = $dateTime->translate('cvPublishDate');
$publishEndDateTime = $dateTime->translate('cvPublishEndDate');
if ($this->request->request->get('keepOtherScheduling')) {
$app = Application::getFacadeApplication();
$appConfig = $app->make(Repository::class);
$liveVersionStatusOnScheduledVersionApproval = (string)$appConfig->get('concrete.misc.live_version_status_on_scheduled_version_approval');
$isUnapproved = $liveVersionStatusOnScheduledVersionApproval === 'unapproved';
$isKeepOtherScheduling = (bool)$this->request->request->get('keepOtherScheduling');
if ($isUnapproved === !$isKeepOtherScheduling) {
$keepOtherScheduling = true;
}
}
Expand Down
9 changes: 8 additions & 1 deletion concrete/controllers/panel/page/check_in.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Concrete\Core\Workflow\Request\ApprovePageRequest as ApprovePagePageWorkflowRequest;
use PageEditResponse;
use Concrete\Core\Http\ResponseFactoryInterface;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Config\Repository\Repository;

class CheckIn extends BackendInterfacePageController
{
Expand Down Expand Up @@ -105,7 +107,12 @@ public function submit()
$dateTime = new DateTime();
$publishDateTime = $dateTime->translate('cvPublishDate');
$publishEndDateTime = $dateTime->translate('cvPublishEndDate');
if ($this->request->request->get('keepOtherScheduling')) {
$app = Application::getFacadeApplication();
$appConfig = $app->make(Repository::class);
$liveVersionStatusOnScheduledVersionApproval = (string)$appConfig->get('concrete.misc.live_version_status_on_scheduled_version_approval');
$isUnapproved = $liveVersionStatusOnScheduledVersionApproval === 'unapproved';
$isKeepOtherScheduling = (bool)$this->request->request->get('keepOtherScheduling');
if ($isUnapproved === !$isKeepOtherScheduling) {
$pkr->setKeepOtherScheduling(true);
}
$pkr->scheduleVersion($publishDateTime, $publishEndDateTime);
Expand Down
18 changes: 15 additions & 3 deletions concrete/elements/pages/schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
use Concrete\Core\Form\Service\Widget\DateTime as DateTimeWidget;
use Concrete\Core\Page\Collection\Version\Version;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Config\Repository\Repository;

defined('C5_EXECUTE') or die("Access Denied.");

$app = Application::getFacadeApplication();
$appConfig = $app->make(Repository::class);
$liveVersionStatusOnScheduledVersionApproval = (string)$appConfig->get('concrete.misc.live_version_status_on_scheduled_version_approval');

/** @var Form $form */
$form = $app->make('helper/form');
/** @var DateTimeWidget $datetime */
Expand Down Expand Up @@ -52,10 +56,18 @@
</div>

<?php if ($activeVersionExists || $scheduledVersionExists) {
if ($scheduledVersionExists) {
$keepOtherScheduling = t('Keep existing scheduling. This version will go live separately.');
if($liveVersionStatusOnScheduledVersionApproval === 'unapproved') {
if ($scheduledVersionExists) {
$keepOtherScheduling = t('Remove current scheduled. This version will go live by itself.');
} else {
$keepOtherScheduling = t('Remove live version in meantime.');
}
} else {
$keepOtherScheduling = t('Keep live version approved.');
if ($scheduledVersionExists) {
$keepOtherScheduling = t('Keep existing scheduling. This version will go live separately.');
} else {
$keepOtherScheduling = t('Keep live version approved.');
}
}
?>
<div class="form-group">
Expand Down

0 comments on commit 216512b

Please sign in to comment.