xref: /dokuwiki/inc/Action/Save.php (revision f21dad3906d4ec6b3d86685599409894630abdc1)
1*f21dad39SAndreas Gohr<?php
2*f21dad39SAndreas Gohr/**
3*f21dad39SAndreas Gohr * Created by IntelliJ IDEA.
4*f21dad39SAndreas Gohr * User: andi
5*f21dad39SAndreas Gohr * Date: 2/11/17
6*f21dad39SAndreas Gohr * Time: 10:06 AM
7*f21dad39SAndreas Gohr */
8*f21dad39SAndreas Gohr
9*f21dad39SAndreas Gohrnamespace dokuwiki\Action;
10*f21dad39SAndreas Gohr
11*f21dad39SAndreas Gohruse dokuwiki\Action\Exception\ActionAbort;
12*f21dad39SAndreas Gohruse dokuwiki\Action\Exception\ActionException;
13*f21dad39SAndreas Gohr
14*f21dad39SAndreas Gohrclass Save extends AbstractAction {
15*f21dad39SAndreas Gohr
16*f21dad39SAndreas Gohr    /** @inheritdoc */
17*f21dad39SAndreas Gohr    function minimumPermission() {
18*f21dad39SAndreas Gohr        global $INFO;
19*f21dad39SAndreas Gohr        if($INFO['exists']) {
20*f21dad39SAndreas Gohr            return AUTH_EDIT;
21*f21dad39SAndreas Gohr        } else {
22*f21dad39SAndreas Gohr            return AUTH_CREATE;
23*f21dad39SAndreas Gohr        }
24*f21dad39SAndreas Gohr    }
25*f21dad39SAndreas Gohr
26*f21dad39SAndreas Gohr    public function preProcess() {
27*f21dad39SAndreas Gohr        if(!checkSecurityToken()) throw new ActionException('preview');
28*f21dad39SAndreas Gohr
29*f21dad39SAndreas Gohr        global $ID;
30*f21dad39SAndreas Gohr        global $DATE;
31*f21dad39SAndreas Gohr        global $PRE;
32*f21dad39SAndreas Gohr        global $TEXT;
33*f21dad39SAndreas Gohr        global $SUF;
34*f21dad39SAndreas Gohr        global $SUM;
35*f21dad39SAndreas Gohr        global $lang;
36*f21dad39SAndreas Gohr        global $INFO;
37*f21dad39SAndreas Gohr        global $INPUT;
38*f21dad39SAndreas Gohr
39*f21dad39SAndreas Gohr        //spam check
40*f21dad39SAndreas Gohr        if(checkwordblock()) {
41*f21dad39SAndreas Gohr            msg($lang['wordblock'], -1);
42*f21dad39SAndreas Gohr            throw new ActionException('edit');
43*f21dad39SAndreas Gohr        }
44*f21dad39SAndreas Gohr        //conflict check
45*f21dad39SAndreas Gohr        if($DATE != 0 && $INFO['meta']['date']['modified'] > $DATE) {
46*f21dad39SAndreas Gohr            throw new ActionException('conflict');
47*f21dad39SAndreas Gohr        }
48*f21dad39SAndreas Gohr
49*f21dad39SAndreas Gohr        //save it
50*f21dad39SAndreas Gohr        saveWikiText($ID, con($PRE, $TEXT, $SUF, true), $SUM, $INPUT->bool('minor')); //use pretty mode for con
51*f21dad39SAndreas Gohr        //unlock it
52*f21dad39SAndreas Gohr        unlock($ID);
53*f21dad39SAndreas Gohr
54*f21dad39SAndreas Gohr        //delete draft
55*f21dad39SAndreas Gohr        act_draftdel('fixme'); // FIXME replace this utility function
56*f21dad39SAndreas Gohr        //session_write_close(); // FIXME close session higher up
57*f21dad39SAndreas Gohr
58*f21dad39SAndreas Gohr        // when done, show page
59*f21dad39SAndreas Gohr        throw new ActionAbort();
60*f21dad39SAndreas Gohr    }
61*f21dad39SAndreas Gohr
62*f21dad39SAndreas Gohr}
63