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