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