diff options
author | Yaco <franco@reevo.org> | 2022-03-08 13:08:34 +0000 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2022-03-08 13:08:34 +0000 |
commit | c985c40d3f3fc6a2be3be3186df3bf2f32189475 (patch) | |
tree | cee11f5e5a7e351ee0fec36d58d72cbee4f7e49b /platform/www/inc/Action/Revert.php |
first commit after acervus codebase
Diffstat (limited to 'platform/www/inc/Action/Revert.php')
-rw-r--r-- | platform/www/inc/Action/Revert.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/platform/www/inc/Action/Revert.php b/platform/www/inc/Action/Revert.php new file mode 100644 index 0000000..07c322c --- /dev/null +++ b/platform/www/inc/Action/Revert.php @@ -0,0 +1,60 @@ +<?php + +namespace dokuwiki\Action; + +use dokuwiki\Action\Exception\ActionAbort; +use dokuwiki\Action\Exception\ActionException; + +/** + * Class Revert + * + * Quick revert to an old revision + * + * @package dokuwiki\Action + */ +class Revert extends AbstractAction { + + /** @inheritdoc */ + public function minimumPermission() { + return AUTH_EDIT; + } + + /** + * + * @inheritdoc + * @throws ActionAbort + * @throws ActionException + * @todo check for writability of the current page ($INFO might do it wrong and check the attic version) + */ + public function preProcess() { + if(!checkSecurityToken()) throw new ActionException(); + + global $ID; + global $REV; + global $lang; + + // when no revision is given, delete current one + // FIXME this feature is not exposed in the GUI currently + $text = ''; + $sum = $lang['deleted']; + if($REV) { + $text = rawWiki($ID, $REV); + if(!$text) throw new ActionException(); //something went wrong + $sum = sprintf($lang['restored'], dformat($REV)); + } + + // spam check + if(checkwordblock($text)) { + msg($lang['wordblock'], -1); + throw new ActionException('edit'); + } + + saveWikiText($ID, $text, $sum, false); + msg($sum, 1); + $REV = ''; + + // continue with draftdel -> redirect -> show + throw new ActionAbort('draftdel'); + } + +} |