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