diff --git a/redaxo/src/addons/structure/plugins/history/assets/history.js b/redaxo/src/addons/structure/plugins/history/assets/history.js index 977dfc0194..feefc65402 100644 --- a/redaxo/src/addons/structure/plugins/history/assets/history.js +++ b/redaxo/src/addons/structure/plugins/history/assets/history.js @@ -226,6 +226,7 @@ this.currentFrame = $('#content-history-iframe-1', this.el); this.targetFrame = $('#content-history-iframe-2', this.el); this.submit = $('[data-history-layer="snap"]', this.el); + this.submitDraft = $('[data-history-layer="snap_draft"]', this.el); this.cancel = $('[data-history-layer="cancel"]', this.el); // fix layout for browsers having flexbox issues (Safari < 11 most notably) @@ -255,6 +256,7 @@ this.selectPrev.on('click', $.proxy(this.onSelectPrev, this)); this.selectNext.on('click', $.proxy(this.onSelectNext, this)); this.submit.on('click', $.proxy(this.onSubmit, this)); + this.submitDraft.on('click', $.proxy(this.onSubmitDraft, this)); this.cancel.on('click', $.proxy(this.onCancel, this)); if (this.sliderSelect) { @@ -315,6 +317,33 @@ })); }, + /** + * on submit draft button toggle + */ + onSubmitDraft: function () { + var that = this; + var historyDate = that.dates.getCurrent().historyDate; + var confirmMsg = this.submitDraft.data('draft-warning'); + if (confirmMsg && !window.confirm(confirmMsg)) { + return; + } + if (!historyDate) { // "Current live version" is selected: copy live → draft via version addon + that.remove(); + var url = 'index.php?page=content/edit&article_id=' + that.articleId + '&clang=' + that.clangId + '&ctype=' + that.ctypeId + '&rex_version_func=copy_live_to_work'; + debug.log('copy live to draft: ' + url); + $.pjax({url: url, container: '#rex-js-page-main-content', fragment: '#rex-js-page-main-content'}); + return; + } + debug.log('submit draft: ' + historyDate); + $.when(this.snapDraftVersion(historyDate).then(function () { + that.remove(); + + // reload redaxo page + var url = 'index.php?page=content/edit&article_id=' + that.articleId + '&clang_id=' + that.clangId + '&ctype=' + that.ctypeId; + $.pjax({url: url, container: '#rex-js-page-main-content', fragment: '#rex-js-page-main-content'}) + })); + }, + /** * on cancel button toggle */ @@ -450,6 +479,25 @@ }).fail(function (jqXHR, textStatus) { debug.error('snap failure: ' + textStatus); }); + }, + + /** + * snap history to draft version + * + * @param date + * @returns {*} + */ + snapDraftVersion: function (date) { + var url = 'index.php?rex_history_function=snap_draft&history_article_id=' + this.articleId + '&history_clang_id=' + this.clangId + '&history_date=' + date; + debug.info('snap draft version: ' + url); + return $.ajax({ + url: url, + context: document.body + }).done(function () { + debug.info('snap draft success'); + }).fail(function (jqXHR, textStatus) { + debug.error('snap draft failure: ' + textStatus); + }); } }; diff --git a/redaxo/src/addons/structure/plugins/history/boot.php b/redaxo/src/addons/structure/plugins/history/boot.php index d4c31405d8..2013a18855 100644 --- a/redaxo/src/addons/structure/plugins/history/boot.php +++ b/redaxo/src/addons/structure/plugins/history/boot.php @@ -10,7 +10,11 @@ $historyDate = rex_request('rex_history_date', 'string'); +rex_perm::register('history[read]', null, rex_perm::OPTIONS); rex_perm::register('history[article_rollback]', null, rex_perm::OPTIONS); +if (rex_plugin::get('structure', 'version')->isAvailable()) { + rex_perm::register('history[article_draft_rollback]', null, rex_perm::OPTIONS); +} if ('' != $historyDate) { $historySession = rex_request('rex_history_session', 'string'); @@ -40,7 +44,7 @@ throw new rex_http_exception(new rex_exception('no permission'), rex_response::HTTP_UNAUTHORIZED); } - if (!$user->hasPerm('history[article_rollback]')) { + if (!$user->hasPerm('history[read]')) { throw new rex_http_exception(new rex_exception('no permission for the slice version'), rex_response::HTTP_FORBIDDEN); } @@ -105,7 +109,7 @@ static function (rex_extension_point $ep) { }, ); -if (rex::isBackend() && rex::getUser()?->hasPerm('history[article_rollback]')) { +if (rex::isBackend() && rex::getUser()?->hasPerm('history[read]')) { rex_view::addCssFile($plugin->getAssetsUrl('noUiSlider/nouislider.css')); rex_view::addJsFile($plugin->getAssetsUrl('noUiSlider/nouislider.js'), [rex_view::JS_IMMUTABLE => true]); rex_view::addCssFile($plugin->getAssetsUrl('history.css')); @@ -113,11 +117,26 @@ static function (rex_extension_point $ep) { switch (rex_request('rex_history_function', 'string')) { case 'snap': + if (!rex::requireUser()->hasPerm('history[article_rollback]')) { + throw new rex_http_exception(new rex_exception('no permission for article rollback'), rex_response::HTTP_FORBIDDEN); + } $articleId = rex_request('history_article_id', 'int'); $clangId = rex_request('history_clang_id', 'int'); $historyDate = rex_request('history_date', 'string'); rex_article_slice_history::restoreSnapshot($historyDate, $articleId, $clangId); + // no break + case 'snap_draft': + if ('snap_draft' === rex_request('rex_history_function', 'string')) { + if (!rex::requireUser()->hasPerm('history[article_draft_rollback]')) { + throw new rex_http_exception(new rex_exception('no permission for draft rollback'), rex_response::HTTP_FORBIDDEN); + } + $articleId = rex_request('history_article_id', 'int'); + $clangId = rex_request('history_clang_id', 'int'); + $historyDate = rex_request('history_date', 'string'); + rex_article_slice_history::restoreDraftSnapshot($historyDate, $articleId, $clangId); + } + // no break case 'layer': $articleId = rex_request('history_article_id', 'int'); @@ -125,13 +144,15 @@ static function (rex_extension_point $ep) { $versions = rex_article_slice_history::getSnapshots($articleId, $clangId); $select1 = []; - $select1[] = ''; - if (rex_plugin::get('structure', 'version')->isAvailable()) { + $versionAvailable = rex_plugin::get('structure', 'version')->isAvailable(); + $currentVersionLabel = $versionAvailable ? $plugin->i18n('current_live_version') : $plugin->i18n('current_version'); + $select1[] = ''; + if ($versionAvailable) { $select1[] = ''; } $select2 = []; - $select2[] = ''; + $select2[] = ''; foreach ($versions as $version) { $historyInfo = $version['history_date']; if ('' != $version['history_user']) { @@ -152,6 +173,9 @@ static function (rex_extension_point $ep) { $fragment->setVar('content1iframe', $content1iframe, false); $fragment->setVar('content2select', $content2select, false); $fragment->setVar('content2iframe', $content2iframe, false); + $fragment->setVar('allow_rollback', rex::requireUser()->hasPerm('history[article_rollback]')); + $fragment->setVar('allow_draft_rollback', $versionAvailable && rex::requireUser()->hasPerm('history[article_draft_rollback]')); + $fragment->setVar('version_available', $versionAvailable); echo $fragment->parse('history/layer.php'); exit; diff --git a/redaxo/src/addons/structure/plugins/history/fragments/history/layer.php b/redaxo/src/addons/structure/plugins/history/fragments/history/layer.php index f83c1376ec..e645551b55 100644 --- a/redaxo/src/addons/structure/plugins/history/fragments/history/layer.php +++ b/redaxo/src/addons/structure/plugins/history/fragments/history/layer.php @@ -48,7 +48,12 @@
- + getVar('allow_draft_rollback')): ?> + + + getVar('allow_rollback')): ?> + +
diff --git a/redaxo/src/addons/structure/plugins/history/lang/de_de.lang b/redaxo/src/addons/structure/plugins/history/lang/de_de.lang index c5ff6562e9..13a427f5a7 100644 --- a/redaxo/src/addons/structure/plugins/history/lang/de_de.lang +++ b/redaxo/src/addons/structure/plugins/history/lang/de_de.lang @@ -1,14 +1,20 @@ structure_history = Historie structure_history_title_info = Kurzerklärung structure_history_snapshot_reactivate = Diese Version übernehmen +structure_history_snapshot_live_reactivate = Diese Version in Liveversion übernehmen +structure_history_snapshot_draft_reactivate = Diese Version in Arbeitsversion übernehmen +structure_history_draft_warning = Achtung: Die Arbeitsversion ist nicht versioniert. Wenn Sie die rechts ausgewählte Version in die Arbeitsversion wiederherstellen, geht der Inhalt der aktuellen Arbeitsversion unwiderruflich verloren. Sind Sie sicher? structure_history_snapshot_reactivated = Version wurde übernommen structure_history_overview_versions = history_overview_versions structure_history_current_version = Aktuelle Version +structure_history_current_live_version = Aktuelle Liveversion structure_history_info_content =

Ein History PlugIn mit welchem man Änderungen in den Artikelinhalten aufnehmen kann. Es wird jeweils ein Snapshot der Version erstellt und mit einem Datum versehen. Nachträglich können dann ältere Versionen wieder aktiviert werden.

structure_history_todos = Todos structure_history_todos_content = -perm_options_history[article_rollback] = Artikel wiederherstellen (Historie) +perm_options_history[read] = Artikel-Historie anzeigen +perm_options_history[article_rollback] = Frühere Artikel-Snapshots wiederherstellen (Historie) +perm_options_history[article_draft_rollback] = Frühere Artikel-Snapshots in Arbeitsversion wiederherstellen (Historie) structure_history_button_delete_history = Historie komplett löschen structure_history_deleted = Historie wurde komplett gelöscht. diff --git a/redaxo/src/addons/structure/plugins/history/lang/en_gb.lang b/redaxo/src/addons/structure/plugins/history/lang/en_gb.lang index 5a8bde8419..d866f7b2e2 100644 --- a/redaxo/src/addons/structure/plugins/history/lang/en_gb.lang +++ b/redaxo/src/addons/structure/plugins/history/lang/en_gb.lang @@ -1,14 +1,20 @@ structure_history = History structure_history_title_info = Short explanation structure_history_snapshot_reactivate = Revert to this version +structure_history_snapshot_live_reactivate = Revert live version to this version +structure_history_snapshot_draft_reactivate = Revert draft version to this version +structure_history_draft_warning = Warning: The draft version is not versioned. Restoring the selected version to the draft will permanently overwrite the current draft content. Are you sure? structure_history_snapshot_reactivated = Version has been revertet structure_history_overview_versions = History overview structure_history_current_version = Current version +structure_history_current_live_version = Current live version structure_history_info_content =

The History PlugIn records all changes made to an article and creates snapshots which can later be used to restore a specific article to a previous state.

structure_history_todos = To do structure_history_todos_content = -perm_options_history[article_rollback] = Restore article (History) +perm_options_history[read] = View article history +perm_options_history[article_rollback] = Restore previous article snapshots (History) +perm_options_history[article_draft_rollback] = Restore previous article snapshots to draft version (History) structure_history_button_delete_history = Delete all snapshots from History structure_history_deleted = All snapshots have been deleted. diff --git a/redaxo/src/addons/structure/plugins/history/lang/es_es.lang b/redaxo/src/addons/structure/plugins/history/lang/es_es.lang index 9b3b5924aa..1cac54d577 100644 --- a/redaxo/src/addons/structure/plugins/history/lang/es_es.lang +++ b/redaxo/src/addons/structure/plugins/history/lang/es_es.lang @@ -1,14 +1,20 @@ structure_history = Historia structure_history_title_info = Breve explicación structure_history_snapshot_reactivate = Aceptar esta versión +structure_history_snapshot_live_reactivate = Aceptar esta versión en la versión en vivo +structure_history_snapshot_draft_reactivate = Aceptar esta versión en la versión de trabajo +structure_history_draft_warning = Atención: La versión de trabajo no está versionada. Si restaura la versión seleccionada a la versión de trabajo, el contenido actual de la versión de trabajo se perderá de forma irrecuperable. ¿Está seguro? structure_history_snapshot_reactivated = Se adoptó la versión structure_history_overview_versions = Versiones generales de la historia structure_history_current_version = Versión actual +structure_history_current_live_version = Versión en vivo actual structure_history_info_content =

Un plug-in de la historia con la que puede registrar los cambios en el contenido del artículo. En cada caso, una versión instantánea y dado una fecha. Posteriormente versiones anteriores pueden entonces ser re-activados.

structure_history_todos = Todos structure_history_todos_content = -perm_options_history[article_rollback] = Restablecimiento del artículo (Historia) +perm_options_history[read] = Ver historial del artículo +perm_options_history[article_rollback] = Restaurar instantáneas anteriores del artículo (Historia) +perm_options_history[article_draft_rollback] = Restaurar instantáneas anteriores del artículo en versión de trabajo (Historia) structure_history_button_delete_history = Borrar por completo la historia structure_history_deleted = La historia ha sido completamente borrada. diff --git a/redaxo/src/addons/structure/plugins/history/lang/it_it.lang b/redaxo/src/addons/structure/plugins/history/lang/it_it.lang index 29a7fcd541..25776a69b3 100644 --- a/redaxo/src/addons/structure/plugins/history/lang/it_it.lang +++ b/redaxo/src/addons/structure/plugins/history/lang/it_it.lang @@ -1,16 +1,21 @@ -structure_history = -structure_history_title_info = -structure_history_snapshot_reactivate = -structure_history_snapshot_reactivated = -structure_history_overview_versions = -structure_history_current_version = -structure_history_info_content = -structure_history_todos = -structure_history_todos_content = +structure_history = +structure_history_title_info = +structure_history_snapshot_reactivate = +structure_history_snapshot_live_reactivate = +structure_history_snapshot_draft_reactivate = +structure_history_draft_warning = +structure_history_snapshot_reactivated = +structure_history_overview_versions = +structure_history_current_version = +structure_history_current_live_version = +structure_history_info_content = +structure_history_todos = +structure_history_todos_content = -perm_options_history[article_rollback] = - -structure_history_button_delete_history = -structure_history_deleted = -structure_history_savedby = -structure_history_close = +perm_options_history[read] = Visualizza cronologia articolo +perm_options_history[article_rollback] = +perm_options_history[article_draft_rollback] = +structure_history_button_delete_history = +structure_history_deleted = +structure_history_savedby = +structure_history_close = diff --git a/redaxo/src/addons/structure/plugins/history/lang/pt_br.lang b/redaxo/src/addons/structure/plugins/history/lang/pt_br.lang index 25b7de3893..daeb88f556 100644 --- a/redaxo/src/addons/structure/plugins/history/lang/pt_br.lang +++ b/redaxo/src/addons/structure/plugins/history/lang/pt_br.lang @@ -1,14 +1,20 @@ structure_history = História structure_history_title_info = Explicação curta structure_history_snapshot_reactivate = Reverter para essa versão +structure_history_snapshot_live_reactivate = Reverter versão ao vivo para esta versão +structure_history_snapshot_draft_reactivate = Reverter versão de rascunho para esta versão +structure_history_draft_warning = Atenção: A versão de rascunho não é versionada. Restaurar a versão selecionada para o rascunho irá substituir permanentemente o conteúdo atual do rascunho. Tem certeza? structure_history_snapshot_reactivated = Versão foi revertida structure_history_overview_versions = Panorama da história structure_history_current_version = Versão atual +structure_history_current_live_version = Versão ao vivo atual structure_history_info_content =

O PlugIn história grava todas as alterações feitas em um produto e cria snapshots que podem ser utilizados posteriormente para restaurar um status anterior de produto específico.

structure_history_todos = A ser feito structure_history_todos_content =