aboutsummaryrefslogtreecommitdiffstats
path: root/include/attach.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-07 18:47:33 -0800
committerfriendica <info@friendica.com>2014-01-07 18:47:33 -0800
commit401183780540812929e35a59348b7f2e347d4b8f (patch)
tree4df2d28c28a0d7af35419ed57f983cc306a674d5 /include/attach.php
parentb8564134aaffc2ebe35fecd5dae4fd0f6523eb53 (diff)
downloadvolse-hubzilla-401183780540812929e35a59348b7f2e347d4b8f.tar.gz
volse-hubzilla-401183780540812929e35a59348b7f2e347d4b8f.tar.bz2
volse-hubzilla-401183780540812929e35a59348b7f2e347d4b8f.zip
more work on dav - deletion and a bit more progress on OS storage
Diffstat (limited to 'include/attach.php')
-rw-r--r--include/attach.php59
1 files changed, 56 insertions, 3 deletions
diff --git a/include/attach.php b/include/attach.php
index c05c39020..93c9a5424 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -569,16 +569,19 @@ function attach_mkdir($channel,$observer_hash,$arr = null) {
$lpath = '';
$lfile = $arr['folder'];
- $sql_options = permissions_sql($channel);
+ $sql_options = permissions_sql($channel['channel_id']);
do {
+
$r = q("select filename, hash, flags, folder from attach where uid = %d and hash = '%s' and ( flags & %d )
$sql_options limit 1",
intval($channel['channel_id']),
dbesc($lfile),
intval(ATTACH_FLAG_DIR)
);
+
if(! $r) {
+ logger('attach_mkdir: hash ' . $lfile . ' not found in ' . $lpath);
$ret['message'] = t('Path not found.');
return $ret;
}
@@ -606,8 +609,8 @@ function attach_mkdir($channel,$observer_hash,$arr = null) {
intval(0),
intval(0),
dbesc($arr['folder']),
- intval(ATTACH_FLAG_DIR),
- dbesc(''),
+ intval(ATTACH_FLAG_DIR|ATTACH_FLAG_OS),
+ dbesc($path),
dbesc($created),
dbesc($created),
dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $channel['channel_allow_cid']),
@@ -672,6 +675,56 @@ function attach_change_permissions($channel_id,$resource,$allow_cid,$allow_gid,$
}
+
+function attach_delete($channel_id,$resource) {
+
+
+ $r = q("select hash, flags from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($resource),
+ intval($channel_id)
+ );
+
+ if(! $r)
+ return;
+
+ if($r[0]['flags'] & ATTACH_FLAG_DIR) {
+ $x = q("select hash, flags from attach where folder = '%s' and uid = %d",
+ dbesc($resource),
+ intval($channel_id)
+ );
+ if($x) {
+ foreach($x as $xx) {
+ attach_delete($channel_id,$xx['hash']);
+ }
+ }
+ }
+ if($r[0]['flags'] & ATTACH_FLAG_OS) {
+ $y = q("select data from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($resource),
+ intval($channel_id)
+ );
+
+ if($y) {
+ if(is_dir($y[0]['data']))
+ @rmdir($y[0]['data']);
+ elseif(file_exists($y[0]['data']))
+ unlink($y[0]['data']);
+ }
+ }
+
+ $z = q("delete from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($resource),
+ intval($channel_id)
+ );
+
+ return;
+}
+
+
+
+
+
+
function pipe_streams($in, $out) {
$size = 0;
while (!feof($in))