From 5ca88ca10a11a76237aa34d1d93ba3e878567767 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 31 Jan 2013 23:56:46 -0800 Subject: debugging of file attachment api - somewhat functional but the attachment info structure in the item table needs to be re-done. --- include/attach.php | 13 +++++++------ include/items.php | 4 ++-- mod/channel.php | 3 ++- mod/item.php | 3 ++- mod/network.php | 11 ++++++----- mod/wall_attach.php | 2 ++ 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/include/attach.php b/include/attach.php index 3775d840c..b2c57f36f 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1,5 +1,6 @@ '), - dbesc((array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : ''), - dbesc((array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : ''), - dbesc((array_key_exists('deny_gid',$arr)) ? $arr['deny_gid'] : '') + dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : '<' . $channel['channel_hash'] . '>'), + 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'] : '') ); } diff --git a/include/items.php b/include/items.php index 92e256ea9..6618fe876 100755 --- a/include/items.php +++ b/include/items.php @@ -496,7 +496,7 @@ function get_item_elements($x) { $arr['object'] = activity_sanitise($x['object']); $arr['target'] = activity_sanitise($x['target']); - $arr['attach'] = activity_sanitise($x['attach']); + $arr['attach'] = implode(',',activity_sanitise($x['attach'])); $arr['term'] = decode_tags($x['tags']); $arr['item_private'] = ((array_key_exists('flags',$x) && is_array($x['flags']) && in_array('private',$x['flags'])) ? 1 : 0); @@ -588,7 +588,7 @@ function encode_item($item) { if($item['target']) $x['target'] = json_decode($item['target'],true); if($item['attach']) - $x['attach'] = json_decode($item['attach'],true); + $x['attach'] = explode(',', $item['attach']); if($y = encode_item_flags($item)) $x['flags'] = $y; if($item['term']) diff --git a/mod/channel.php b/mod/channel.php index 3f92539ae..c74b40c00 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -118,8 +118,9 @@ function channel_content(&$a, $update = 0, $load = false) { $x = array( 'is_owner' => $is_owner, +// FIXME 'allow_location' => ((($is_owner || $observer) && $a->profile['allow_location']) ? true : false), - 'default_location' => (($is_owner) ? $a->user['default-location'] : ''), + 'default_location' => (($is_owner) ? $a->profile['default_location'] : ''), 'nickname' => $a->profile['channel_address'], 'lockstate' => (((strlen($a->profile['channel_allow_cid'])) || (strlen($a->profile['channel_allow_gid'])) || (strlen($a->profile['channel_deny_cid'])) || (strlen($a->profile['channel_deny_gid']))) ? 'lock' : 'unlock'), 'acl' => (($is_owner) ? populate_acl($channel, false) : ''), diff --git a/mod/item.php b/mod/item.php index dba325e19..c482f3ea9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -18,6 +18,7 @@ require_once('include/crypto.php'); require_once('include/enotify.php'); require_once('include/items.php'); +require_once('include/attach.php'); function item_post(&$a) { @@ -477,7 +478,7 @@ function item_post(&$a) { if($r['success']) { if(strlen($attachments)) $attachments .= ','; - $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r['data']['hash'] . '" length="' . $r['data']['filesize'] . '" type="' . $r['data']['filetype'] . '" title="' . $r['data']['filename'] . '"[/attach]'; + $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r['data']['hash'] . '" length="' . $r['data']['filesize'] . '" type="' . $r['data']['filetype'] . '" title="' . urlencode($r['data']['filename']) . '" revision="' . $r['data']['revision'] . '"[/attach]'; } $body = str_replace($match[1],'',$body); } diff --git a/mod/network.php b/mod/network.php index 91b4228c9..cca69dc52 100644 --- a/mod/network.php +++ b/mod/network.php @@ -400,11 +400,12 @@ function network_content(&$a, $update = 0, $load = false) { $x = array( 'is_owner' => true, - 'allow_location' => $a->user['allow_location'], - 'default_location' => $a->user['default-location'], - 'nickname' => $a->user['nickname'], - 'lockstate' => ((($group) || ($cid) || ($nets) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'), - 'acl' => populate_acl((($group || $cid || $nets) ? $def_acl : $a->user), $celeb), + 'allow_location' => $a->user['allow_location'], // FIXME + 'default_location' => $channel['channel_location'], + 'nickname' => $channel['channel_address'], + 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), +// FIXME + 'acl' => populate_acl((($group || $cid || $nets) ? $def_acl : $channel), $celeb), 'bang' => (($group || $cid) ? '!' : ''), 'visitor' => 'block', 'profile_uid' => local_user() diff --git a/mod/wall_attach.php b/mod/wall_attach.php index 5797531e8..6e9443f12 100644 --- a/mod/wall_attach.php +++ b/mod/wall_attach.php @@ -17,10 +17,12 @@ function wall_attach_post(&$a) { $channel = $r[0]; } + else killme(); $r = attach_store($channel,get_observer_hash()); + if(! $r['success']) { notice( $r['message'] . EOL); killme(); -- cgit v1.2.3