diff options
author | zotlabs <mike@macgirvin.com> | 2017-11-06 21:55:58 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-11-06 21:55:58 -0800 |
commit | 5e47b767ea6ed92f6f7ea0a3368762827937a5d8 (patch) | |
tree | 7e115ff8ec962cd52f64b60c5cebb2520d776ace /include/attach.php | |
parent | 7ef641e256aba64978ea9a41a31b78e4af5c68b0 (diff) | |
parent | d16bbfb224c218b04676d890c647b6d1c5d92273 (diff) | |
download | volse-hubzilla-5e47b767ea6ed92f6f7ea0a3368762827937a5d8.tar.gz volse-hubzilla-5e47b767ea6ed92f6f7ea0a3368762827937a5d8.tar.bz2 volse-hubzilla-5e47b767ea6ed92f6f7ea0a3368762827937a5d8.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'include/attach.php')
-rw-r--r-- | include/attach.php | 95 |
1 files changed, 30 insertions, 65 deletions
diff --git a/include/attach.php b/include/attach.php index bfe3d5d46..179a57a90 100644 --- a/include/attach.php +++ b/include/attach.php @@ -947,9 +947,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { } if($notify) { - //$cloudPath = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['0']['display_path']; - //$object = get_file_activity_object($channel['channel_id'], $r['0']['hash'], $cloudPath); - //file_activity($channel['channel_id'], $object, $r['0']['allow_cid'], $r['0']['allow_gid'], $r['0']['deny_cid'], $r['0']['deny_gid'], 'post', $notify); + $cloudPath = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['0']['display_path']; + $object = get_file_activity_object($channel['channel_id'], $r['0']['hash'], $cloudPath); + file_activity($channel['channel_id'], $object, $r['0']['allow_cid'], $r['0']['allow_gid'], $r['0']['deny_cid'], $r['0']['deny_gid'], 'post', $notify); } return $ret; @@ -1421,7 +1421,7 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { intval($channel_id) ); - file_activity($channel_id, $object, $object['allow_cid'], $object['allow_gid'], $object['deny_cid'], $object['deny_gid'], 'update', $notify=1); + file_activity($channel_id, $object, $object['allow_cid'], $object['allow_gid'], $object['deny_cid'], $object['deny_gid'], 'update', true); return; } @@ -2341,6 +2341,11 @@ function attach_move($channel_id, $resource_id, $new_folder_hash) { } +/** + * Used to generate a select input box of all your folders + */ + + function attach_folder_select_list($channel_id) { $r = q("select * from attach where is_dir = 1 and uid = %d", @@ -2391,6 +2396,10 @@ function attach_folder_rpaths($all_folders,$that_folder) { return (($error) ? false : [ $current_hash , $path ]); } +/** + * @brief Given a channel_id and attach_hash, return an array with the full relative path and os_path + */ + function attach_syspaths($channel_id,$attach_hash) { @@ -2414,6 +2423,17 @@ function attach_syspaths($channel_id,$attach_hash) { return [ 'os_path' => $os_path, 'path' => $path ]; } +/** + * in earlier releases we did not fill in os_path and display_path in the attach DB structure. + * (It was not needed or used). Going forward we intend to make use of these fields. + * A cron task checks for empty values (as older attachments may have arrived at our site + * in a clone operation) and executes attach_syspaths() to generate these field values and correct + * the attach table entry. The operation is limited to 100 DB entries at a time so as not to + * overload the system in any cron run. Eventually it will catch up with old attach structures + * and switch into maintenance mode to correct any that might arrive in clone packets from older + * sites. + */ + function attach_upgrade() { @@ -2440,6 +2460,12 @@ function attach_upgrade() { } +/** + * Chunked uploader for integration with the blueimp jquery-uploader + * This is currently used. + */ + + function save_chunk($channel,$start,$end,$len) { $result = []; @@ -2478,64 +2504,3 @@ function save_chunk($channel,$start,$end,$len) { } -/** - * @brief Submit handler for chunked uploads. - * - * @param array $channel - * @param array $arr - * @return array - */ -function chunkloader($channel, $arr) { - - logger('request: ' . print_r($arr,true), LOGGER_DEBUG); - logger('files: ' . print_r($_FILES,true), LOGGER_DEBUG); - - $result = []; - - $tmp_path = $_FILES['file']['tmp_name']; - $new_base = 'store/[data]/' . $channel['channel_address'] . '/tmp'; - os_mkdir($new_base,STORAGE_DEFAULT_PERMISSIONS,true); - - $new_path = $new_base . '/' . $arr['resumableFilename']; - - rename($tmp_path,$new_path . '.' . intval($arr['resumableChunkNumber'])); - - $missing_parts = false; - for($x = 1; $x <= intval($arr['resumableTotalChunks']); $x ++) { - if(! file_exists($new_path . '.' . $x)) { - $missing_parts = true; - break; - } - } - - if($missing_parts) { - $result['partial'] = true; - return $result; - } - - if(intval($arr['resumableTotalChunks']) === 1) { - rename($new_path . '.' . '1', $new_path); - } - else { - for($x = 1; $x <= intval($arr['resumableTotalChunks']); $x ++) { - $istream = fopen($new_path . '.' . $x,'rb'); - $ostream = fopen($new_path,'ab'); - if($istream && $ostream) { - pipe_streams($istream,$ostream); - fclose($istream); - fclose($ostream); - } - unlink($new_path . '.' . $x); - } - } - - $result['name'] = $arr['resumableFilename']; - $result['type'] = $arr['resumableType']; - $result['tmp_name'] = $new_path; - $result['error'] = 0; - $result['size'] = $arr['resumableTotalSize']; - $result['complete'] = true; - - return $result; -} - |