1<?php 2 3namespace dokuwiki\Action; 4 5use dokuwiki\Action\Exception\ActionAbort; 6use dokuwiki\Action\Exception\ActionException; 7 8/** 9 * Class Revert 10 * 11 * Quick revert to an old revision 12 * 13 * @package dokuwiki\Action 14 */ 15class Revert extends AbstractAction { 16 17 /** @inheritdoc */ 18 public function minimumPermission() { 19 global $INFO; 20 if($INFO['ismanager']) { 21 return AUTH_EDIT; 22 } else { 23 return AUTH_ADMIN; 24 } 25 } 26 27 /** 28 * 29 * @inheritdoc 30 * @throws ActionAbort 31 * @throws ActionException 32 * @todo check for writability of the current page ($INFO might do it wrong and check the attic version) 33 */ 34 public function preProcess() { 35 if(!checkSecurityToken()) throw new ActionException(); 36 37 global $ID; 38 global $REV; 39 global $lang; 40 41 // when no revision is given, delete current one 42 // FIXME this feature is not exposed in the GUI currently 43 $text = ''; 44 $sum = $lang['deleted']; 45 if($REV) { 46 $text = rawWiki($ID, $REV); 47 if(!$text) throw new ActionException(); //something went wrong 48 $sum = sprintf($lang['restored'], dformat($REV)); 49 } 50 51 // spam check 52 if(checkwordblock($text)) { 53 msg($lang['wordblock'], -1); 54 throw new ActionException('edit'); 55 } 56 57 saveWikiText($ID, $text, $sum, false); 58 msg($sum, 1); 59 $REV = ''; 60 61 // continue with draftdel -> redirect -> show 62 throw new ActionAbort('draftdel'); 63 } 64 65} 66