aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Wiki.php
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-24 06:15:42 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-24 06:15:42 -0400
commite00b8a70829213a4333a53a097c2c498d529f5d6 (patch)
tree74bd9a90a24671287106b85050480f9cc45fe79c /Zotlabs/Module/Wiki.php
parenta36bef7979aecd72751d319f85b7037991979e35 (diff)
downloadvolse-hubzilla-e00b8a70829213a4333a53a097c2c498d529f5d6.tar.gz
volse-hubzilla-e00b8a70829213a4333a53a097c2c498d529f5d6.tar.bz2
volse-hubzilla-e00b8a70829213a4333a53a097c2c498d529f5d6.zip
Delete wiki (in progress)
Diffstat (limited to 'Zotlabs/Module/Wiki.php')
-rw-r--r--Zotlabs/Module/Wiki.php52
1 files changed, 45 insertions, 7 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 53a3eb26b..221068e0a 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -21,7 +21,7 @@ class Wiki extends \Zotlabs\Web\Controller {
}
if(! $which) {
notice( t('You must be logged in to see this page.') . EOL );
- return;
+ goaway('/login');
}
}
@@ -91,6 +91,12 @@ class Wiki extends \Zotlabs\Web\Controller {
json_return_and_die(array('html' => $html, 'success' => true));
}
+ // Check if specified wiki exists and redirect if not
+ if((argc() > 2)) {
+ $wikiname = argv(2);
+ // TODO: Check if specified wiki exists and redirect if not
+ }
+
// Create a new wiki
if ((argc() > 3) && (argv(2) === 'create') && (argv(3) === 'wiki')) {
$which = argv(1);
@@ -102,20 +108,23 @@ class Wiki extends \Zotlabs\Web\Controller {
$observer_hash = get_observer_hash();
// Figure out who the page owner is.
$perms = get_all_perms(intval($channel['channel_id']), $observer_hash);
-
- if (!$perms['write_wiki']) {
+ // TODO: Create a new permission setting for wiki analogous to webpages. Until
+ // then, use webpage permissions
+ if (!$perms['write_pages']) {
notice(t('Permission denied.') . EOL);
- json_return_and_die(array('success' => false));
+ goaway(argv(0).'/'.argv(1).'/'.argv(2));
}
}
- $name = escape_tags(urlencode($_REQUEST['wikiName'])); //Get new wiki name
+ $name = escape_tags(urlencode($_POST['wikiName'])); //Get new wiki name
if($name === '') {
notice('Error creating wiki. Invalid name.');
goaway('/wiki');
}
// Get ACL for permissions
$acl = new \Zotlabs\Access\AccessList($channel);
- $acl->set_from_array($_REQUEST);
+ logger('POST: ' . json_encode($_POST));
+ $acl->set_from_array($_POST);
+ logger('acl: ' . json_encode($acl));
$r = wiki_create_wiki($channel, $observer_hash, $name, $acl);
if ($r['success']) {
goaway('/wiki/'.$which.'/'.$name);
@@ -125,7 +134,36 @@ class Wiki extends \Zotlabs\Web\Controller {
}
}
- json_return_and_die(array('success' => false));
+ // Delete a wiki
+ if ((argc() > 3) && (argv(2) === 'delete') && (argv(3) === 'wiki')) {
+ $which = argv(1);
+ // Determine if observer has permission to create wiki
+ if (local_channel()) {
+ $channel = \App::get_channel();
+ } else {
+ $channel = get_channel_by_nick($which);
+ $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 delete permission denied.' . EOL);
+ json_return_and_die(array('success' => false));
+ }
+ }
+ $resource_id = $_POST['resource_id'];
+ $deleted = wiki_delete_wiki($resource_id);
+ if ($deleted['success']) {
+ json_return_and_die(array('success' => true));
+ } else {
+ logger('Error deleting wiki: ' . $resource_id);
+ json_return_and_die(array('success' => false));
+ }
+ }
+
+ notice('You must be authenticated.');
+ goaway('/wiki');
}
}