about summary refs log tree commit diff stats
path: root/wiki/inc/Action/Revert.php
diff options
context:
space:
mode:
Diffstat (limited to 'wiki/inc/Action/Revert.php')
-rw-r--r--wiki/inc/Action/Revert.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/wiki/inc/Action/Revert.php b/wiki/inc/Action/Revert.php
new file mode 100644
index 0000000..ca35374
--- /dev/null
+++ b/wiki/inc/Action/Revert.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace dokuwiki\Action;
+
+use dokuwiki\Action\Exception\ActionAbort;
+use dokuwiki\Action\Exception\ActionException;
+
+/**
+ * Class Revert
+ *
+ * Quick revert to an old revision
+ *
+ * @package dokuwiki\Action
+ */
+class Revert extends AbstractAction {
+
+    /** @inheritdoc */
+    public function minimumPermission() {
+        global $INFO;
+        if($INFO['ismanager']) {
+            return AUTH_EDIT;
+        } else {
+            return AUTH_ADMIN;
+        }
+    }
+
+    /**
+     *
+     * @inheritdoc
+     * @throws ActionAbort
+     * @throws ActionException
+     * @todo check for writability of the current page ($INFO might do it wrong and check the attic version)
+     */
+    public function preProcess() {
+        if(!checkSecurityToken()) throw new ActionException();
+
+        global $ID;
+        global $REV;
+        global $lang;
+
+        // when no revision is given, delete current one
+        // FIXME this feature is not exposed in the GUI currently
+        $text = '';
+        $sum = $lang['deleted'];
+        if($REV) {
+            $text = rawWiki($ID, $REV);
+            if(!$text) throw new ActionException(); //something went wrong
+            $sum = sprintf($lang['restored'], dformat($REV));
+        }
+
+        // spam check
+        if(checkwordblock($text)) {
+            msg($lang['wordblock'], -1);
+            throw new ActionException('edit');
+        }
+
+        saveWikiText($ID, $text, $sum, false);
+        msg($sum, 1);
+        $REV = '';
+
+        // continue with draftdel -> redirect -> show
+        throw new ActionAbort('draftdel');
+    }
+
+}
1.9.2&id=811b7c282fdb3032659626190b936c3365fa4dc1'>811b7c28 ^
a0b6b9e0 ^
e07d8b03 ^
5c6c5ad5 ^
65cb1a32 ^
e07d8b03 ^
a36bfd7b ^
7bf5f967 ^

8d6c23f7 ^
7bf5f967 ^
0d60aaaa ^
085ea1e9 ^
a385c76a ^
bc5de8b1 ^
7bf5f967 ^
24d5eb06 ^
2132b95f ^



24d5eb06 ^
2132b95f ^
24d5eb06 ^
2132b95f ^
24d5eb06 ^
7bf5f967 ^



0d1b5bac ^



b68d28c1 ^
d1a1173d ^








0d1b5bac ^


d1a1173d ^



0d1b5bac ^
7bf5f967 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68