🤖 Rector and PHPCS fixes
[dokuwiki.git] / inc / Action / Revert.php
blob4a42fe0196146786c2187f33695041e7bd0a2d4d
1 <?php
3 namespace dokuwiki\Action;
5 use dokuwiki\Action\Exception\ActionAbort;
6 use dokuwiki\Action\Exception\ActionException;
8 /**
9 * Class Revert
11 * Quick revert to an old revision
13 * @package dokuwiki\Action
15 class Revert extends AbstractUserAction
17 /** @inheritdoc */
18 public function minimumPermission()
20 return AUTH_EDIT;
23 /**
25 * @inheritdoc
26 * @throws ActionAbort
27 * @throws ActionException
28 * @todo check for writability of the current page ($INFO might do it wrong and check the attic version)
30 public function preProcess()
32 if (!checkSecurityToken()) throw new ActionException();
34 global $ID;
35 global $REV;
36 global $lang;
38 // when no revision is given, delete current one
39 // FIXME this feature is not exposed in the GUI currently
40 $text = '';
41 $sum = $lang['deleted'];
42 if ($REV) {
43 $text = rawWiki($ID, $REV);
44 if (!$text) throw new ActionException(); //something went wrong
45 $sum = sprintf($lang['restored'], dformat($REV));
48 // spam check
49 if (checkwordblock($text)) {
50 msg($lang['wordblock'], -1);
51 throw new ActionException('edit');
54 saveWikiText($ID, $text, $sum, false);
55 msg($sum, 1);
56 $REV = '';
58 // continue with draftdel -> redirect -> show
59 throw new ActionAbort('draftdel');