From 6a7079a594bbfa1238fe0bef0dfe265720c2cb4d Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 12 Oct 2015 18:55:02 -0700 Subject: 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. --- include/attach.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'include/attach.php') 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) { -- cgit v1.2.3