1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
<?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 AbstractUserAction
{
/** @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');
}
}
|