1f21dad39SAndreas Gohr<?php 2f21dad39SAndreas Gohr 3f21dad39SAndreas Gohrnamespace dokuwiki\Action; 4f21dad39SAndreas Gohr 5f21dad39SAndreas Gohruse dokuwiki\Action\Exception\ActionAbort; 6f21dad39SAndreas Gohr 7ab583a1bSAndreas Gohr/** 8ab583a1bSAndreas Gohr * Class Edit 9ab583a1bSAndreas Gohr * 10ab583a1bSAndreas Gohr * Handle editing 11ab583a1bSAndreas Gohr * 12ab583a1bSAndreas Gohr * @package dokuwiki\Action 13ab583a1bSAndreas Gohr */ 14f21dad39SAndreas Gohrclass Edit extends AbstractAction { 15f21dad39SAndreas Gohr 16f21dad39SAndreas Gohr /** @inheritdoc */ 17*ec701221SAndreas Gohr public function minimumPermission() { 18f21dad39SAndreas Gohr global $INFO; 19f21dad39SAndreas Gohr if($INFO['exists']) { 20f21dad39SAndreas Gohr return AUTH_READ; // we check again below 21f21dad39SAndreas Gohr } else { 22f21dad39SAndreas Gohr return AUTH_CREATE; 23f21dad39SAndreas Gohr } 24f21dad39SAndreas Gohr } 25f21dad39SAndreas Gohr 26ab583a1bSAndreas Gohr /** 27ab583a1bSAndreas Gohr * @inheritdoc falls back to 'source' if page not writable 28ab583a1bSAndreas Gohr */ 29f21dad39SAndreas Gohr public function checkPermissions() { 30f21dad39SAndreas Gohr parent::checkPermissions(); 31f21dad39SAndreas Gohr global $INFO; 32f21dad39SAndreas Gohr 33f21dad39SAndreas Gohr // no edit permission? view source 34f21dad39SAndreas Gohr if($INFO['exists'] && !$INFO['writable']) { 35f21dad39SAndreas Gohr throw new ActionAbort('source'); 36f21dad39SAndreas Gohr } 37f21dad39SAndreas Gohr } 38f21dad39SAndreas Gohr 39*ec701221SAndreas Gohr /** @inheritdoc */ 40f21dad39SAndreas Gohr public function preProcess() { 41f21dad39SAndreas Gohr global $ID; 42f21dad39SAndreas Gohr global $INFO; 43f21dad39SAndreas Gohr 44f21dad39SAndreas Gohr global $TEXT; 45f21dad39SAndreas Gohr global $RANGE; 46f21dad39SAndreas Gohr global $PRE; 47f21dad39SAndreas Gohr global $SUF; 48f21dad39SAndreas Gohr global $REV; 49f21dad39SAndreas Gohr global $SUM; 50f21dad39SAndreas Gohr global $lang; 51f21dad39SAndreas Gohr global $DATE; 52f21dad39SAndreas Gohr 53f21dad39SAndreas Gohr if(!isset($TEXT)) { 54f21dad39SAndreas Gohr if($INFO['exists']) { 55f21dad39SAndreas Gohr if($RANGE) { 56f21dad39SAndreas Gohr list($PRE, $TEXT, $SUF) = rawWikiSlices($RANGE, $ID, $REV); 57f21dad39SAndreas Gohr } else { 58f21dad39SAndreas Gohr $TEXT = rawWiki($ID, $REV); 59f21dad39SAndreas Gohr } 60f21dad39SAndreas Gohr } else { 61f21dad39SAndreas Gohr $TEXT = pageTemplate($ID); 62f21dad39SAndreas Gohr } 63f21dad39SAndreas Gohr } 64f21dad39SAndreas Gohr 65f21dad39SAndreas Gohr //set summary default 66f21dad39SAndreas Gohr if(!$SUM) { 67f21dad39SAndreas Gohr if($REV) { 68f21dad39SAndreas Gohr $SUM = sprintf($lang['restored'], dformat($REV)); 69f21dad39SAndreas Gohr } elseif(!$INFO['exists']) { 70f21dad39SAndreas Gohr $SUM = $lang['created']; 71f21dad39SAndreas Gohr } 72f21dad39SAndreas Gohr } 73f21dad39SAndreas Gohr 74f21dad39SAndreas Gohr // Use the date of the newest revision, not of the revision we edit 75f21dad39SAndreas Gohr // This is used for conflict detection 76f21dad39SAndreas Gohr if(!$DATE) $DATE = @filemtime(wikiFN($ID)); 77f21dad39SAndreas Gohr 78f21dad39SAndreas Gohr //check if locked by anyone - if not lock for my self 79f21dad39SAndreas Gohr $lockedby = checklock($ID); 80f21dad39SAndreas Gohr if($lockedby) { 81f21dad39SAndreas Gohr throw new ActionAbort('locked'); 82f21dad39SAndreas Gohr }; 83f21dad39SAndreas Gohr lock($ID); 84f21dad39SAndreas Gohr } 85f21dad39SAndreas Gohr 86*ec701221SAndreas Gohr /** @inheritdoc */ 87f21dad39SAndreas Gohr public function tplContent() { 88f21dad39SAndreas Gohr html_edit(); 89f21dad39SAndreas Gohr } 90f21dad39SAndreas Gohr 91f21dad39SAndreas Gohr} 92