[ 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 AbstractUserAction
  16  {
  17  
  18      /** @inheritdoc */
  19      public function minimumPermission()
  20      {
  21          return AUTH_EDIT;
  22      }
  23  
  24      /**
  25       *
  26       * @inheritdoc
  27       * @throws ActionAbort
  28       * @throws ActionException
  29       * @todo check for writability of the current page ($INFO might do it wrong and check the attic version)
  30       */
  31      public function preProcess()
  32      {
  33          if (!checkSecurityToken()) throw new ActionException();
  34  
  35          global $ID;
  36          global $REV;
  37          global $lang;
  38  
  39          // when no revision is given, delete current one
  40          // FIXME this feature is not exposed in the GUI currently
  41          $text = '';
  42          $sum = $lang['deleted'];
  43          if ($REV) {
  44              $text = rawWiki($ID, $REV);
  45              if (!$text) throw new ActionException(); //something went wrong
  46              $sum = sprintf($lang['restored'], dformat($REV));
  47          }
  48  
  49          // spam check
  50          if (checkwordblock($text)) {
  51              msg($lang['wordblock'], -1);
  52              throw new ActionException('edit');
  53          }
  54  
  55          saveWikiText($ID, $text, $sum, false);
  56          msg($sum, 1);
  57          $REV = '';
  58  
  59          // continue with draftdel -> redirect -> show
  60          throw new ActionAbort('draftdel');
  61      }
  62  
  63  }