aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-10-23 17:48:33 -0700
committerzotlabs <mike@macgirvin.com>2016-10-23 17:48:33 -0700
commit5fbba27d17c78081e784fc2f8e9bb1907b79b4b7 (patch)
tree3c956cc1cddfce4fb32751ae1656c64791e3d844 /Zotlabs
parent5c891bcfb55c662bfb5d86b0d5695bd03523e842 (diff)
parent0b5d5507800b2e1122eb2432929c203538b2e835 (diff)
downloadvolse-hubzilla-5fbba27d17c78081e784fc2f8e9bb1907b79b4b7.tar.gz
volse-hubzilla-5fbba27d17c78081e784fc2f8e9bb1907b79b4b7.tar.bz2
volse-hubzilla-5fbba27d17c78081e784fc2f8e9bb1907b79b4b7.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Wiki.php30
-rw-r--r--Zotlabs/Storage/Directory.php6
2 files changed, 34 insertions, 2 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index bb4e9179c..8cf106b33 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -90,6 +90,35 @@ class Wiki extends \Zotlabs\Web\Controller {
// Not the channel owner
$channel_acl = $x = array();
}
+
+ // Download a wiki
+ if ((argc() > 3) && (argv(2) === 'download') && (argv(3) === 'wiki')) {
+ $resource_id = argv(4);
+ $w = wiki_get_wiki($resource_id);
+ if (!$w['path']) {
+ notice('Error retrieving wiki' . EOL);
+ }
+ $zip_folder_name = random_string(10);
+ $zip_folderpath = '/tmp/' . $zip_folder_name;
+ if (!mkdir($zip_folderpath, 0770, false)) {
+ logger('Error creating zip file export folder: ' . $zip_folderpath, LOGGER_NORMAL);
+ notice('Error creating zip file export folder' . EOL);
+ }
+ $zip_filename = $w['urlName'];
+ $zip_filepath = '/tmp/' . $zip_folder_name . '/' . $zip_filename;
+ // Generate the zip file
+ \Zotlabs\Lib\ExtendedZip::zipTree($w['path'], $zip_filepath, \ZipArchive::CREATE);
+ // Output the file for download
+ header('Content-disposition: attachment; filename="' . $zip_filename . '.zip"');
+ header("Content-Type: application/zip");
+ $success = readfile($zip_filepath);
+ if ($success) {
+ rrmdir($zip_folderpath); // delete temporary files
+ } else {
+ rrmdir($zip_folderpath); // delete temporary files
+ logger('Error downloading wiki: ' . $resource_id);
+ }
+ }
switch (argc()) {
case 2:
@@ -297,6 +326,7 @@ class Wiki extends \Zotlabs\Web\Controller {
}
}
+
// Create a page
if ((argc() === 4) && (argv(2) === 'create') && (argv(3) === 'page')) {
$nick = argv(1);
diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php
index ad450b2dd..5d078b04e 100644
--- a/Zotlabs/Storage/Directory.php
+++ b/Zotlabs/Storage/Directory.php
@@ -244,8 +244,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$deny_gid = $c[0]['channel_deny_gid'];
}
- $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, os_storage, filetype, filesize, revision, is_photo, content, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+ $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, os_storage, filetype, filesize, revision, is_photo, content, created, edited, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($c[0]['channel_account_id']),
intval($c[0]['channel_id']),
dbesc($hash),
@@ -260,6 +260,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
dbesc($f),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
+ '', //TODO: use os_path
+ '', //TODO: use display_path
dbesc($allow_cid),
dbesc($allow_gid),
dbesc($deny_cid),