issue #538 continued

This commit is contained in:
redmatrix 2016-09-29 16:20:26 -07:00
parent fcd7dc8744
commit 3727bea29a
5 changed files with 8 additions and 8 deletions

View File

@ -14,7 +14,7 @@ class Attach extends \Zotlabs\Web\Controller {
return; return;
} }
$r = attach_by_hash(argv(1),((argc() > 2) ? intval(argv(2)) : 0)); $r = attach_by_hash(argv(1),get_observer_hash(),((argc() > 2) ? intval(argv(2)) : 0));
if(! $r['success']) { if(! $r['success']) {
notice( $r['message'] . EOL); notice( $r['message'] . EOL);

View File

@ -63,7 +63,7 @@ class Getfile extends \Zotlabs\Web\Controller {
killme(); killme();
} }
$r = attach_by_hash($resource,$revision); $r = attach_by_hash($resource,$channel['channel_hash'],$revision);
if(! $r['success']) { if(! $r['success']) {
logger('attach_by_hash failed: ' . $r['message']); logger('attach_by_hash failed: ' . $r['message']);

View File

@ -229,7 +229,7 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
* @param int $rev Revision * @param int $rev Revision
* @return array * @return array
*/ */
function attach_by_hash($hash, $rev = 0) { function attach_by_hash($hash, $observer_hash, $rev = 0) {
$ret = array('success' => false); $ret = array('success' => false);
@ -249,7 +249,7 @@ function attach_by_hash($hash, $rev = 0) {
return $ret; return $ret;
} }
if(! perm_is_allowed($r[0]['uid'], get_observer_hash(), 'view_storage')) { if(! perm_is_allowed($r[0]['uid'], $observer_hash, 'view_storage')) {
$ret['message'] = t('Permission denied.'); $ret['message'] = t('Permission denied.');
return $ret; return $ret;
} }
@ -315,7 +315,7 @@ function attach_can_view_folder($uid,$ob_hash,$folder_hash) {
* * \e string \b message (optional) only when success is false * * \e string \b message (optional) only when success is false
* * \e array \b data array of attach DB entry without data component * * \e array \b data array of attach DB entry without data component
*/ */
function attach_by_hash_nodata($hash, $rev = 0) { function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
$ret = array('success' => false); $ret = array('success' => false);
@ -335,7 +335,7 @@ function attach_by_hash_nodata($hash, $rev = 0) {
return $ret; return $ret;
} }
if(! perm_is_allowed($r[0]['uid'],get_observer_hash(),'view_storage')) { if(! perm_is_allowed($r[0]['uid'],$observer_hash,'view_storage')) {
$ret['message'] = t('Permission denied.'); $ret['message'] = t('Permission denied.');
return $ret; return $ret;
} }

View File

@ -1036,7 +1036,7 @@ function sync_files($channel,$files) {
} }
$attach_exists = false; $attach_exists = false;
$x = attach_by_hash($att['hash']); $x = attach_by_hash($att['hash'],$channel['channel_hash']);
logger('sync_files duplicate check: attach_exists=' . $attach_exists, LOGGER_DEBUG); logger('sync_files duplicate check: attach_exists=' . $attach_exists, LOGGER_DEBUG);
logger('sync_files duplicate check: att=' . print_r($att,true), LOGGER_DEBUG); logger('sync_files duplicate check: att=' . print_r($att,true), LOGGER_DEBUG);
logger('sync_files duplicate check: attach_by_hash() returned ' . print_r($x,true), LOGGER_DEBUG); logger('sync_files duplicate check: attach_by_hash() returned ' . print_r($x,true), LOGGER_DEBUG);

View File

@ -166,7 +166,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
foreach($match[2] as $mtch) { foreach($match[2] as $mtch) {
$hash = substr($mtch,0,strpos($mtch,',')); $hash = substr($mtch,0,strpos($mtch,','));
$rev = intval(substr($mtch,strpos($mtch,','))); $rev = intval(substr($mtch,strpos($mtch,',')));
$r = attach_by_hash_nodata($hash,$rev); $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev);
if($r['success']) { if($r['success']) {
$attachments[] = array( $attachments[] = array(
'href' => z_root() . '/attach/' . $r['data']['hash'], 'href' => z_root() . '/attach/' . $r['data']['hash'],