1f21dad39SAndreas Gohr<?php 2f21dad39SAndreas Gohr 3f21dad39SAndreas Gohrnamespace dokuwiki\Action; 4f21dad39SAndreas Gohr 56723156fSAndreas Gohruse dokuwiki\Draft; 6f21dad39SAndreas Gohruse dokuwiki\Action\Exception\ActionAbort; 7f21dad39SAndreas Gohr 8ab583a1bSAndreas Gohr/** 9ab583a1bSAndreas Gohr * Class Draftdel 10ab583a1bSAndreas Gohr * 11ab583a1bSAndreas Gohr * Delete a draft 12ab583a1bSAndreas Gohr * 13ab583a1bSAndreas Gohr * @package dokuwiki\Action 14ab583a1bSAndreas Gohr */ 158c7c53b0SAndreas Gohrclass Draftdel extends AbstractAction 168c7c53b0SAndreas Gohr{ 17f21dad39SAndreas Gohr 18f21dad39SAndreas Gohr /** @inheritdoc */ 19*d868eb89SAndreas Gohr public function minimumPermission() 20*d868eb89SAndreas Gohr { 21f21dad39SAndreas Gohr return AUTH_EDIT; 22f21dad39SAndreas Gohr } 23f21dad39SAndreas Gohr 24231f749dSAndreas Gohr /** 250aabe6f8SMichael Große * Delete an existing draft for the current page and user if any 26231f749dSAndreas Gohr * 270aabe6f8SMichael Große * Redirects to show, afterwards. 28231f749dSAndreas Gohr * 29231f749dSAndreas Gohr * @throws ActionAbort 30231f749dSAndreas Gohr */ 31*d868eb89SAndreas Gohr public function preProcess() 32*d868eb89SAndreas Gohr { 330aabe6f8SMichael Große global $INFO, $ID; 346723156fSAndreas Gohr $draft = new Draft($ID, $INFO['client']); 35e6699927SAndreas Gohr if ($draft->isDraftAvailable() && checkSecurityToken()) { 360aabe6f8SMichael Große $draft->deleteDraft(); 370aabe6f8SMichael Große } 38231f749dSAndreas Gohr 3958528803SAndreas Gohr throw new ActionAbort('redirect'); 40f21dad39SAndreas Gohr } 41f21dad39SAndreas Gohr} 42