1<?php 2/** 3 * Created by IntelliJ IDEA. 4 * User: andi 5 * Date: 2/11/17 6 * Time: 9:56 AM 7 */ 8 9namespace dokuwiki\Action; 10 11use dokuwiki\Action\Exception\ActionAbort; 12use dokuwiki\Action\Exception\ActionException; 13 14class Revert extends AbstractAction { 15 16 /** @inheritdoc */ 17 function minimumPermission() { 18 global $INFO; 19 if($INFO['ismanager']) { 20 return AUTH_EDIT; 21 } else { 22 return AUTH_ADMIN; 23 } 24 } 25 26 // fixme check for writability of the current page ($INFO might do it wrong and check the attic version) 27 28 public function preProcess() { 29 if(!checkSecurityToken()) throw new ActionException(); 30 31 global $ID; 32 global $REV; 33 global $lang; 34 global $INPUT; 35 36 // when no revision is given, delete current one 37 // FIXME this feature is not exposed in the GUI currently 38 $text = ''; 39 $sum = $lang['deleted']; 40 if($REV){ 41 $text = rawWiki($ID,$REV); 42 if(!$text) throw new ActionException(); //something went wrong 43 $sum = sprintf($lang['restored'], dformat($REV)); 44 } 45 46 // spam check 47 if (checkwordblock($text)) { 48 msg($lang['wordblock'], -1); 49 throw new ActionException('edit'); 50 } 51 52 saveWikiText($ID,$text,$sum,false); 53 msg($sum,1); 54 55 //delete any draft 56 act_draftdel('fixme'); // FIXME replace this utility function 57 //session_write_close(); // FIXME sessions should be close somewhere higher up, maybe ActionRouter 58 59 // when done, show current page 60 $INPUT->server->set('REQUEST_METHOD','post'); //should force a redirect // FIXME should we have a RedirectException? 61 $REV = ''; 62 63 throw new ActionAbort(); 64 } 65 66} 67