1f21dad39SAndreas Gohr<?php 2f21dad39SAndreas Gohr 3f21dad39SAndreas Gohrnamespace dokuwiki\Action; 4f21dad39SAndreas Gohr 5f21dad39SAndreas Gohruse dokuwiki\Action\Exception\ActionAbort; 6f21dad39SAndreas Gohr 7ab583a1bSAndreas Gohr/** 8ab583a1bSAndreas Gohr * Class Draftdel 9ab583a1bSAndreas Gohr * 10ab583a1bSAndreas Gohr * Delete a draft 11ab583a1bSAndreas Gohr * 12ab583a1bSAndreas Gohr * @package dokuwiki\Action 13ab583a1bSAndreas Gohr */ 14f1246b76SAndreas Gohrclass Draftdel extends AbstractAction { 15f21dad39SAndreas Gohr 16f21dad39SAndreas Gohr /** @inheritdoc */ 17ec701221SAndreas Gohr public function minimumPermission() { 18f21dad39SAndreas Gohr return AUTH_EDIT; 19f21dad39SAndreas Gohr } 20f21dad39SAndreas Gohr 21231f749dSAndreas Gohr /** 220aabe6f8SMichael Große * Delete an existing draft for the current page and user if any 23231f749dSAndreas Gohr * 240aabe6f8SMichael Große * Redirects to show, afterwards. 25231f749dSAndreas Gohr * 26231f749dSAndreas Gohr * @throws ActionAbort 27231f749dSAndreas Gohr */ 28f21dad39SAndreas Gohr public function preProcess() { 290aabe6f8SMichael Große global $INFO, $ID; 300aabe6f8SMichael Große $draft = new \dokuwiki\Draft($ID, $INFO['client']); 31*e6699927SAndreas Gohr if ($draft->isDraftAvailable() && checkSecurityToken()) { 320aabe6f8SMichael Große $draft->deleteDraft(); 330aabe6f8SMichael Große } 34231f749dSAndreas Gohr 3558528803SAndreas Gohr throw new ActionAbort('redirect'); 36f21dad39SAndreas Gohr } 37f21dad39SAndreas Gohr 38f21dad39SAndreas Gohr} 39