aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Wiki.php
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-06-05 16:32:03 -0400
committerAndrew Manning <tamanning@zoho.com>2016-06-05 16:32:03 -0400
commit0a3fbdd128dd3b80868c93cb93901b501edf576c (patch)
treefeff8120476bcc96f5c4c327ac66d0724fcfa2ac /Zotlabs/Module/Wiki.php
parent4bc4fd5b7ebd7c5f25cfc9acfbda5b14a38dedb8 (diff)
downloadvolse-hubzilla-0a3fbdd128dd3b80868c93cb93901b501edf576c.tar.gz
volse-hubzilla-0a3fbdd128dd3b80868c93cb93901b501edf576c.tar.bz2
volse-hubzilla-0a3fbdd128dd3b80868c93cb93901b501edf576c.zip
Basic page reversion implemented. The revert button on the history view replaces the editor text but does not save the page.
Diffstat (limited to 'Zotlabs/Module/Wiki.php')
-rw-r--r--Zotlabs/Module/Wiki.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index e335e8917..5b5bfe87f 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -401,6 +401,41 @@ class Wiki extends \Zotlabs\Web\Controller {
}
}
+ // Revert a page
+ if ((argc() === 4) && (argv(2) === 'revert') && (argv(3) === 'page')) {
+ $nick = argv(1);
+ $resource_id = $_POST['resource_id'];
+ $pageUrlName = $_POST['name'];
+ $commitHash = $_POST['commitHash'];
+ // Determine if observer has permission to revert pages
+ if (local_channel()) {
+ $channel = \App::get_channel();
+ } else {
+ $channel = get_channel_by_nick($nick);
+ $observer_hash = get_observer_hash();
+ // Figure out who the page owner is.
+ $perms = get_all_perms(intval($channel['channel_id']), $observer_hash);
+ // TODO: Create a new permission setting for wiki analogous to webpages. Until
+ // then, use webpage permissions
+ if (!$perms['write_pages']) {
+ logger('Wiki editing permission denied.' . EOL);
+ json_return_and_die(array('success' => false));
+ }
+ $perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash);
+ if(!$perms['write']) {
+ logger('Wiki write permission denied. Read only.' . EOL);
+ json_return_and_die(array('success' => false));
+ }
+ }
+ $reverted = wiki_revert_page(array('commitHash' => $commitHash, 'observer' => \App::get_observer(), 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
+ if($reverted['success']) {
+ json_return_and_die(array('content' => $reverted['content'], 'message' => '', 'success' => true));
+ } else {
+ json_return_and_die(array('content' => '', 'message' => 'Error reverting page', 'success' => false));
+ }
+ }
+
+
//notice('You must be authenticated.');
json_return_and_die(array('message' => 'You must be authenticated.', 'success' => false));