more work on api media uploads
This commit is contained in:
parent
2cceca49e9
commit
fdd2da905a
@ -855,15 +855,26 @@ require_once('include/api_auth.php');
|
|||||||
$_REQUEST['type'] = 'wall';
|
$_REQUEST['type'] = 'wall';
|
||||||
|
|
||||||
if(x($_FILES,'media')) {
|
if(x($_FILES,'media')) {
|
||||||
$_FILES['userfile'] = $_FILES['media'];
|
$num_uploads = count($_FILES['media']['name']);
|
||||||
// upload the image if we have one
|
for($x = 0; $x < $num_uploads; $x ++) {
|
||||||
|
$_FILES['userfile'] = array();
|
||||||
|
$_FILES['userfile']['name'] = $_FILES['media']['name'][$x];
|
||||||
|
$_FILES['userfile']['type'] = $_FILES['media']['type'][$x];
|
||||||
|
$_FILES['userfile']['tmp_name'] = $_FILES['media']['tmp_name'][$x];
|
||||||
|
$_FILES['userfile']['error'] = $_FILES['media']['error'][$x];
|
||||||
|
$_FILES['userfile']['size'] = $_FILES['media']['size'][$x];
|
||||||
|
|
||||||
|
// upload each image if we have any
|
||||||
$_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo
|
$_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo
|
||||||
require_once('mod/wall_attach.php');
|
require_once('mod/wall_attach.php');
|
||||||
|
$a->data['api_info'] = $user_info;
|
||||||
$media = wall_attach_post($a);
|
$media = wall_attach_post($a);
|
||||||
|
|
||||||
if(strlen($media)>0)
|
if(strlen($media)>0)
|
||||||
$_REQUEST['body'] .= "\n\n" . $media;
|
$_REQUEST['body'] .= "\n\n" . $media;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// call out normal post function
|
// call out normal post function
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
|
|||||||
$observer = $x[0];
|
$observer = $x[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('arr: ' . print_r($arr,true));
|
logger('arr: ' . print_r($arr,true), LOGGER_DATA);
|
||||||
|
|
||||||
if(! perm_is_allowed($channel_id,$observer_hash, 'write_storage')) {
|
if(! perm_is_allowed($channel_id,$observer_hash, 'write_storage')) {
|
||||||
$ret['message'] = t('Permission denied.');
|
$ret['message'] = t('Permission denied.');
|
||||||
|
@ -377,7 +377,7 @@ function photo_upload($channel, $observer, $args) {
|
|||||||
$arr['item_thread_top'] = 1;
|
$arr['item_thread_top'] = 1;
|
||||||
$arr['item_private'] = intval($acl->is_private());
|
$arr['item_private'] = intval($acl->is_private());
|
||||||
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
|
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
|
||||||
$arr['body'] = (($object) ? $args['body'] : $body . "\r\n" . $args['body']);
|
$arr['body'] = (($args['body']) ? $body . "\r\n" . $args['body'] : $body);
|
||||||
|
|
||||||
|
|
||||||
// this one is tricky because the item and the photo have the same permissions, those of the photo.
|
// this one is tricky because the item and the photo have the same permissions, those of the photo.
|
||||||
|
@ -6,14 +6,16 @@ require_once('include/photos.php');
|
|||||||
|
|
||||||
function wall_attach_post(&$a) {
|
function wall_attach_post(&$a) {
|
||||||
|
|
||||||
if(argc() > 1)
|
$using_api = false;
|
||||||
$channel = get_channel_by_nick(argv(1));
|
|
||||||
elseif($_FILES['media']) {
|
if($a->data['api_info'] && array_key_exists('media',$_FILES)) {
|
||||||
require_once('include/api.php');
|
$using_api = true;
|
||||||
$user_info = api_get_user($a);
|
$user_info = $a->data['api_info'];
|
||||||
$nick = $user_info['screen_name'];
|
$nick = $user_info['screen_name'];
|
||||||
$channel = get_channel_by_nick($user_info['screen_name']);
|
$channel = get_channel_by_nick($user_info['screen_name']);
|
||||||
}
|
}
|
||||||
|
elseif(argc() > 1)
|
||||||
|
$channel = get_channel_by_nick(argv(1));
|
||||||
|
|
||||||
if(! $channel)
|
if(! $channel)
|
||||||
killme();
|
killme();
|
||||||
@ -49,12 +51,16 @@ function wall_attach_post(&$a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(intval($r['data']['is_photo'])) {
|
if(intval($r['data']['is_photo'])) {
|
||||||
echo "\n\n" . $r['body'] . "\n\n";
|
$s = "\n\n" . $r['body'] . "\n\n";
|
||||||
if($using_api)
|
|
||||||
return;
|
|
||||||
killme();
|
|
||||||
}
|
}
|
||||||
echo "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n";
|
else {
|
||||||
|
$s = "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($using_api)
|
||||||
|
return $s;
|
||||||
|
|
||||||
|
echo $s;
|
||||||
killme();
|
killme();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user