[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Action/ -> Revert.php (source)

   1  <?php
   2  
   3  namespace dokuwiki\Action;
   4  
   5  use dokuwiki\Action\Exception\ActionAbort;
   6  use dokuwiki\Action\Exception\ActionException;
   7  
   8  /**
   9   * Class Revert
  10   *
  11   * Quick revert to an old revision
  12   *
  13   * @package dokuwiki\Action
  14   */
  15  class Revert extends AbstractAction {
  16  
  17      /** @inheritdoc */
  18      public function minimumPermission() {
  19          return AUTH_EDIT;
  20      }
  21  
  22      /**
  23       *
  24       * @inheritdoc
  25       * @throws ActionAbort
  26       * @throws ActionException
  27       * @todo check for writability of the current page ($INFO might do it wrong and check the attic version)
  28       */
  29      public function preProcess() {
  30          if(!checkSecurityToken()) throw new ActionException();
  31  
  32          global $ID;
  33          global $REV;
  34          global $lang;
  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          $REV = '';
  55  
  56          // continue with draftdel -> redirect -> show
  57          throw new ActionAbort('draftdel');
  58      }
  59  
  60  }