aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-10-13 16:16:51 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-10-13 16:16:51 -0700
commit7e03f612b3e814d209b94712103d535fabe7ae91 (patch)
treec4331f92cc039cc6067dba5510b3ffd3f3e35832 /include
parent136e5fdf951f42c95a77d66d7fec9e95a1186e76 (diff)
downloadvolse-hubzilla-7e03f612b3e814d209b94712103d535fabe7ae91.tar.gz
volse-hubzilla-7e03f612b3e814d209b94712103d535fabe7ae91.tar.bz2
volse-hubzilla-7e03f612b3e814d209b94712103d535fabe7ae91.zip
file migration - continued
Diffstat (limited to 'include')
-rw-r--r--include/attach.php33
1 files changed, 29 insertions, 4 deletions
diff --git a/include/attach.php b/include/attach.php
index 48a88d6a5..266efee53 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -455,9 +455,25 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$src = $arr['src'];
$filename = $arr['filename'];
$filesize = @filesize($src);
+
$hash = $arr['resource_id'];
+
+ if(array_key_exists('hash',$arr))
+ $hash = $arr['hash'];
+ if(array_key_exists('type',$arr))
+ $type = $arr['type'];
+
if($arr['preserve_original'])
$remove_when_processed = false;
+
+ // if importing a directory, just do it now and go home - we're done.
+
+ if(array_key_exists('is_dir',$arr) && intval($arr['is_dir'])) {
+ $x = attach_mkdir($channel,$observer_hash,$arr);
+ if($x['message'])
+ logger('import_directory: ' . $x['message']);
+ return;
+ }
}
elseif($options !== 'update') {
$f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
@@ -536,10 +552,20 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$pathname = '';
if($is_photo) {
- if($newalbum)
+ if($newalbum) {
$pathname = filepath_macro($newalbum);
- else
+ }
+ elseif(array_key_exists('folder',$arr)) {
+ $x = q("select filename from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($arr['folder']),
+ intval($channel['channel_id'])
+ );
+ if($x)
+ $pathname = $x[0]['filename'];
+ }
+ else {
$pathname = filepath_macro($album);
+ }
}
else {
$pathname = filepath_macro($upload_path);
@@ -569,7 +595,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
}
}
else {
- $folder_hash = '';
+ $folder_hash = ((array_key_exists('folder',$args)) ? $args['folder'] : '');
}
if((! $options) || ($options === 'import')) {
@@ -968,7 +994,6 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
intval($channel['channel_id']),
dbesc($lfile)
);
-
if(! $r) {
logger('attach_mkdir: hash ' . $lfile . ' not found in ' . $lpath);
$ret['message'] = t('Path not found.');