debugging of file attachment api - somewhat functional but the attachment info structure in the item table needs to be re-done.
This commit is contained in:
parent
6b3d36c36d
commit
5ca88ca10a
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once('include/permissions.php');
|
||||||
|
|
||||||
function z_mime_content_type($filename) {
|
function z_mime_content_type($filename) {
|
||||||
|
|
||||||
@ -255,7 +256,7 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) {
|
|||||||
$channel_id = $channel['channel_id'];
|
$channel_id = $channel['channel_id'];
|
||||||
$sql_options = '';
|
$sql_options = '';
|
||||||
|
|
||||||
if(! perm_is_allowed($channel_id,$observer_hash(),'write_storage')) {
|
if(! perm_is_allowed($channel_id,get_observer_hash(),'write_storage')) {
|
||||||
$ret['message'] = t('Permission denied.');
|
$ret['message'] = t('Permission denied.');
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@ -299,7 +300,7 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) {
|
|||||||
if($options === 'update' && $arr && array_key_exists('revision',$arr))
|
if($options === 'update' && $arr && array_key_exists('revision',$arr))
|
||||||
$sql_options = " and revision = " . intval($arr['revision']) . " ";
|
$sql_options = " and revision = " . intval($arr['revision']) . " ";
|
||||||
|
|
||||||
$x =q("select id, aid, uid, hash, revision, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where hash = '%s' and uid = %d $sql_options limit 1",
|
$x =q("select id, aid, uid, filename, filetype, filesize, hash, revision, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where hash = '%s' and uid = %d $sql_options limit 1",
|
||||||
dbesc($arr['hash']),
|
dbesc($arr['hash']),
|
||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
@ -397,10 +398,10 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) {
|
|||||||
dbesc(@file_get_contents($src)),
|
dbesc(@file_get_contents($src)),
|
||||||
dbesc($created),
|
dbesc($created),
|
||||||
dbesc($created),
|
dbesc($created),
|
||||||
dbesc((array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : '<' . $channel['channel_hash'] . '>'),
|
dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : '<' . $channel['channel_hash'] . '>'),
|
||||||
dbesc((array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : ''),
|
dbesc(($arr && array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : ''),
|
||||||
dbesc((array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : ''),
|
dbesc(($arr && array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : ''),
|
||||||
dbesc((array_key_exists('deny_gid',$arr)) ? $arr['deny_gid'] : '')
|
dbesc(($arr && array_key_exists('deny_gid',$arr)) ? $arr['deny_gid'] : '')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ function get_item_elements($x) {
|
|||||||
$arr['object'] = activity_sanitise($x['object']);
|
$arr['object'] = activity_sanitise($x['object']);
|
||||||
$arr['target'] = activity_sanitise($x['target']);
|
$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['term'] = decode_tags($x['tags']);
|
||||||
|
|
||||||
$arr['item_private'] = ((array_key_exists('flags',$x) && is_array($x['flags']) && in_array('private',$x['flags'])) ? 1 : 0);
|
$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'])
|
if($item['target'])
|
||||||
$x['target'] = json_decode($item['target'],true);
|
$x['target'] = json_decode($item['target'],true);
|
||||||
if($item['attach'])
|
if($item['attach'])
|
||||||
$x['attach'] = json_decode($item['attach'],true);
|
$x['attach'] = explode(',', $item['attach']);
|
||||||
if($y = encode_item_flags($item))
|
if($y = encode_item_flags($item))
|
||||||
$x['flags'] = $y;
|
$x['flags'] = $y;
|
||||||
if($item['term'])
|
if($item['term'])
|
||||||
|
@ -118,8 +118,9 @@ function channel_content(&$a, $update = 0, $load = false) {
|
|||||||
|
|
||||||
$x = array(
|
$x = array(
|
||||||
'is_owner' => $is_owner,
|
'is_owner' => $is_owner,
|
||||||
|
// FIXME
|
||||||
'allow_location' => ((($is_owner || $observer) && $a->profile['allow_location']) ? true : false),
|
'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'],
|
'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'),
|
'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) : ''),
|
'acl' => (($is_owner) ? populate_acl($channel, false) : ''),
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
require_once('include/crypto.php');
|
require_once('include/crypto.php');
|
||||||
require_once('include/enotify.php');
|
require_once('include/enotify.php');
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
|
require_once('include/attach.php');
|
||||||
|
|
||||||
function item_post(&$a) {
|
function item_post(&$a) {
|
||||||
|
|
||||||
@ -477,7 +478,7 @@ function item_post(&$a) {
|
|||||||
if($r['success']) {
|
if($r['success']) {
|
||||||
if(strlen($attachments))
|
if(strlen($attachments))
|
||||||
$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);
|
$body = str_replace($match[1],'',$body);
|
||||||
}
|
}
|
||||||
|
@ -400,11 +400,12 @@ function network_content(&$a, $update = 0, $load = false) {
|
|||||||
|
|
||||||
$x = array(
|
$x = array(
|
||||||
'is_owner' => true,
|
'is_owner' => true,
|
||||||
'allow_location' => $a->user['allow_location'],
|
'allow_location' => $a->user['allow_location'], // FIXME
|
||||||
'default_location' => $a->user['default-location'],
|
'default_location' => $channel['channel_location'],
|
||||||
'nickname' => $a->user['nickname'],
|
'nickname' => $channel['channel_address'],
|
||||||
'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'),
|
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
|
||||||
'acl' => populate_acl((($group || $cid || $nets) ? $def_acl : $a->user), $celeb),
|
// FIXME
|
||||||
|
'acl' => populate_acl((($group || $cid || $nets) ? $def_acl : $channel), $celeb),
|
||||||
'bang' => (($group || $cid) ? '!' : ''),
|
'bang' => (($group || $cid) ? '!' : ''),
|
||||||
'visitor' => 'block',
|
'visitor' => 'block',
|
||||||
'profile_uid' => local_user()
|
'profile_uid' => local_user()
|
||||||
|
@ -17,10 +17,12 @@ function wall_attach_post(&$a) {
|
|||||||
$channel = $r[0];
|
$channel = $r[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
killme();
|
killme();
|
||||||
|
|
||||||
$r = attach_store($channel,get_observer_hash());
|
$r = attach_store($channel,get_observer_hash());
|
||||||
|
|
||||||
if(! $r['success']) {
|
if(! $r['success']) {
|
||||||
notice( $r['message'] . EOL);
|
notice( $r['message'] . EOL);
|
||||||
killme();
|
killme();
|
||||||
|
Reference in New Issue
Block a user