[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Action/ -> Save.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 Save
  10   *
  11   * Save at the end of an edit session
  12   *
  13   * @package dokuwiki\Action
  14   */
  15  class Save extends AbstractAction
  16  {
  17      /** @inheritdoc */
  18      public function minimumPermission()
  19      {
  20          global $INFO;
  21          if ($INFO['exists']) {
  22              return AUTH_EDIT;
  23          } else {
  24              return AUTH_CREATE;
  25          }
  26      }
  27  
  28      /** @inheritdoc */
  29      public function preProcess()
  30      {
  31          if (!checkSecurityToken()) throw new ActionException('preview');
  32  
  33          global $ID;
  34          global $DATE;
  35          global $PRE;
  36          global $TEXT;
  37          global $SUF;
  38          global $SUM;
  39          global $lang;
  40          global $INFO;
  41          global $INPUT;
  42  
  43          //spam check
  44          if (checkwordblock()) {
  45              msg($lang['wordblock'], -1);
  46              throw new ActionException('edit');
  47          }
  48          //conflict check
  49          if (
  50              $DATE != 0
  51              && isset($INFO['meta']['date']['modified'])
  52              && $INFO['meta']['date']['modified'] > $DATE
  53          ) {
  54              throw new ActionException('conflict');
  55          }
  56  
  57          //save it
  58          saveWikiText($ID, con($PRE, $TEXT, $SUF, true), $SUM, $INPUT->bool('minor')); //use pretty mode for con
  59          //unlock it
  60          unlock($ID);
  61  
  62          // continue with draftdel -> redirect -> show
  63          throw new ActionAbort('draftdel');
  64      }
  65  }