aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-10-12 18:55:02 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-10-12 18:55:02 -0700
commit6a7079a594bbfa1238fe0bef0dfe265720c2cb4d (patch)
treee7e42faee68877050c94160f8bac9592d9b9e4d5 /include
parent42db2bc93d4ac0f90de1789fbf6df797c45b679e (diff)
downloadvolse-hubzilla-6a7079a594bbfa1238fe0bef0dfe265720c2cb4d.tar.gz
volse-hubzilla-6a7079a594bbfa1238fe0bef0dfe265720c2cb4d.tar.bz2
volse-hubzilla-6a7079a594bbfa1238fe0bef0dfe265720c2cb4d.zip
small change to allow a person with sufficient privileges the ability to import a file into their cloud storage from elsewhere in the server filesystem - without nuking it in the process.
Diffstat (limited to 'include')
-rw-r--r--include/attach.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/include/attach.php b/include/attach.php
index 39fdb5c3a..50f1d2be7 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -447,11 +447,17 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
// revise or update must provide $arr['hash'] of the thing to revise/update
+ // By default remove $src when finished
+
+ $remove_when processed = true;
+
if($options === 'import') {
$src = $arr['src'];
$filename = $arr['filename'];
$filesize = @filesize($src);
$hash = $arr['resource_id'];
+ if($arr['preserve_original'])
+ $remove_when_processed = false;
}
elseif($options !== 'update') {
$f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
@@ -630,7 +636,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if(($maxfilesize) && ($filesize > $maxfilesize)) {
$ret['message'] = sprintf( t('File exceeds size limit of %d'), $maxfilesize);
- @unlink($src);
+ if($remove_when_processed)
+ @unlink($src);
call_hooks('photo_upload_end',$ret);
return $ret;
}
@@ -643,7 +650,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
);
if(($r) && (($r[0]['total'] + $filesize) > ($limit - $existing_size))) {
$ret['message'] = upgrade_message(true) . sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."), $limit / 1024000);
- @unlink($src);
+ if($remove_when_processed)
+ @unlink($src);
+
call_hooks('photo_upload_end',$ret);
return $ret;
}
@@ -786,7 +795,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
}
}
- if($options !== 'update')
+ if(($options !== 'update') && ($remove_when_processed))
@unlink($src);
if(! $r) {