You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

66 lines
1.4 KiB

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