aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-27 20:20:33 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-27 20:20:33 -0400
commit97e6b7c4ba1938a46ea18d3ef96eba2d6246dab0 (patch)
tree13e90b240d74f1a79d223fbe732a2571c641c5e9
parentd554681174084e1715dfae4c21af9f6edcbad59e (diff)
downloadvolse-hubzilla-97e6b7c4ba1938a46ea18d3ef96eba2d6246dab0.tar.gz
volse-hubzilla-97e6b7c4ba1938a46ea18d3ef96eba2d6246dab0.tar.bz2
volse-hubzilla-97e6b7c4ba1938a46ea18d3ef96eba2d6246dab0.zip
Wiki deletion works
-rw-r--r--include/wiki.php16
-rw-r--r--view/tpl/wiki.tpl2
2 files changed, 12 insertions, 6 deletions
diff --git a/include/wiki.php b/include/wiki.php
index 0f00cd122..828121ba9 100644
--- a/include/wiki.php
+++ b/include/wiki.php
@@ -103,7 +103,7 @@ function wiki_create_wiki($channel, $observer_hash, $name, $acl) {
}
function wiki_delete_wiki($resource_id) {
- $item = q("SELECT id FROM item WHERE resource_type = '%s' AND resource_id = '%s' AND item_deleted = 0 limit 1",
+ $item = q("SELECT id, object FROM item WHERE resource_type = '%s' AND resource_id = '%s' AND item_deleted = 0 limit 1",
dbesc(WIKI_ITEM_RESOURCE_TYPE),
dbesc($resource_id)
);
@@ -112,11 +112,15 @@ function wiki_delete_wiki($resource_id) {
} else {
$drop = drop_item($item[0]['id'],false,DROPITEM_NORMAL,true);
$object = json_decode($item[0]['object'], true);
- $abs_path = __DIR__ . '/../' . $object['path'];
- logger('path to delete: ' . $abs_path);
- $pathdel = true;
- //$pathdel = rrmdir($abs_path);
-
+ if(!realpath(__DIR__ . '/../' . $object['path'])) {
+ return array('items' => null, 'success' => false);
+ }
+ // Path to wiki exists
+ $abs_path = realpath(__DIR__ . '/../' . $object['path']);
+ $pathdel = rrmdir($abs_path);
+ if($pathdel) {
+ info('Wiki deleted successfully');
+ }
return array('item' => $item, 'success' => (($drop === 1 && $pathdel) ? true : false));
}
}
diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl
index 6ee4a7f89..652434c3e 100644
--- a/view/tpl/wiki.tpl
+++ b/view/tpl/wiki.tpl
@@ -105,7 +105,9 @@ function wiki_delete_wiki(wikiName, resource_id) {
if (data.success) {
window.console.log('Wiki deleted');
// Refresh list and redirect page as necessary
+ window.location = 'wiki/{{$channel}}';
} else {
+ alert('Error deleting wiki!');
window.console.log('Error deleting wiki.');
}
}, 'json');