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