From 2adc7a51ad0e3893efc9aac852e3b80d75d9a65d Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 15 Jun 2015 19:52:17 -0700 Subject: photo upload: pass in the contact_allow and resource_id via include/attach.php --- include/RedDAV/RedDirectory.php | 2 +- include/RedDAV/RedFile.php | 2 +- include/attach.php | 8 ++++++-- mod/wall_attach.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/RedDAV/RedDirectory.php b/include/RedDAV/RedDirectory.php index dba857cdc..c41056ac9 100644 --- a/include/RedDAV/RedDirectory.php +++ b/include/RedDAV/RedDirectory.php @@ -298,7 +298,7 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { if($is_photo) { require_once('include/photos.php'); - $args = array( 'data' => @file_get_contents($f)); + $args = array( 'data' => @file_get_contents($f), 'resource_id' => $hash); $p = photo_upload($c[0],get_app()->get_observer(),$args); } diff --git a/include/RedDAV/RedFile.php b/include/RedDAV/RedFile.php index 1fd2dab8f..156acde4a 100644 --- a/include/RedDAV/RedFile.php +++ b/include/RedDAV/RedFile.php @@ -155,7 +155,7 @@ class RedFile extends DAV\Node implements DAV\IFile { ); if($is_photo) { - $args = array( 'data' => @file_get_contents($fname)); + $args = array( 'data' => @file_get_contents($fname), 'resource_id' => $this->data['hash']); $p = photo_upload($c[0],$this->auth->observer,$args); } diff --git a/include/attach.php b/include/attach.php index 5e8dd592e..1860d3364 100644 --- a/include/attach.php +++ b/include/attach.php @@ -347,6 +347,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $sql_options = ''; $source = (($arr) ? $arr['source'] : ''); + $str_contact_allow = perms2str(((is_array($arr['contact_allow'])) ? $arr['contact_allow'] : explode(',',$arr['contact_allow']))); + if(! perm_is_allowed($channel_id,get_observer_hash(), 'write_storage')) { $ret['message'] = t('Permission denied.'); return $ret; @@ -509,7 +511,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { dbescbin(@file_get_contents($src)), dbesc($created), dbesc($created), - dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : '<' . $channel['channel_hash'] . '>'), + dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $str_contact_allow), dbesc(($arr && array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : ''), dbesc(($arr && array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : ''), dbesc(($arr && array_key_exists('deny_gid',$arr)) ? $arr['deny_gid'] : '') @@ -517,7 +519,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { } if($is_photo) { - $args = array( 'source' => $source, 'visible' => 0, 'contact_allow' => array($channel['channel_hash']), 'data' => @file_get_contents($src)); + $args = array( 'source' => $source, 'visible' => 0, 'resource_id' => $hash, 'data' => @file_get_contents($src)); + if($arr['contact_allow']) + $args['contact_allow'] = $arr['contact_allow']; $p = photo_upload($channel,get_app()->get_observer(),$args); if($p['success']) { $ret['body'] = $p['body']; diff --git a/mod/wall_attach.php b/mod/wall_attach.php index c3c0bff03..04ab59146 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -38,7 +38,7 @@ function wall_attach_post(&$a) { // } // } - $r = attach_store($channel,(($observer) ? $observer['xchan_hash'] : ''),array('source' => 'editor')); + $r = attach_store($channel,(($observer) ? $observer['xchan_hash'] : ''),array('source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash']))); if(! $r['success']) { notice( $r['message'] . EOL); -- cgit v1.2.3