Save.php 1.4 KB

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