1
1
Fork 0

api profiles

This commit is contained in:
Friendika 2011-07-31 20:01:00 -07:00
parent b0a9ec0a73
commit 996425206f
2 changed files with 75 additions and 13 deletions

View file

@ -147,7 +147,26 @@
//echo "<pre>"; var_dump($r); die();
}
}
return false;
$r = '<status><error>not implemented</error></status>';
switch($type){
case "xml":
header ("Content-Type: text/xml");
return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
break;
case "json":
header ("Content-Type: application/json");
return json_encode(array('error' => 'not implemented'));
break;
case "rss":
header ("Content-Type: application/rss+xml");
return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
break;
case "atom":
header ("Content-Type: application/atom+xml");
return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
break;
}
}
/**
@ -222,15 +241,25 @@
return False;
}
// count public wall messages
$r = q("SELECT COUNT(`id`) as `count` FROM `item`
WHERE `uid` = %d
AND `type`='wall'
AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
intval($uinfo[0]['uid'])
);
$countitms = $r[0]['count'];
if($uinfo[0]['self']) {
// count public wall messages
$r = q("SELECT COUNT(`id`) as `count` FROM `item`
WHERE `uid` = %d
AND `type`='wall'
AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
intval($uinfo[0]['uid'])
);
$countitms = $r[0]['count'];
}
else {
$r = q("SELECT COUNT(`id`) as `count` FROM `item`
WHERE `contact-id` = %d
AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
intval($uinfo[0]['id'])
);
$countitms = $r[0]['count'];
}
// count friends
$r = q("SELECT COUNT(`id`) as `count` FROM `contact`
WHERE `uid` = %d
@ -238,7 +267,10 @@
intval($uinfo[0]['uid'])
);
$countfriends = $r[0]['count'];
if(! $uinfo[0]['self']) {
$countfriends = 0;
}
$ret = Array(
'uid' => $uinfo[0]['uid'],
@ -664,6 +696,11 @@
function api_format_items($r,$user_info) {
//logger('api_format_items: ' . print_r($r,true));
//logger('api_format_items: ' . print_r($user_info,true));
$a = get_app();
$ret = Array();

View file

@ -33,11 +33,18 @@ function item_post(&$a) {
call_hooks('post_local_start', $_POST);
/**
* Is this a reply to something?
*/
$parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
$parent_uri = ((x($_POST,'parent_uri')) ? trim($_POST['parent_uri']) : '');
$parent_item = null;
$parent_contact = null;
$thr_parent = '';
$parid = 0;
$r = false;
if($parent || $parent_uri) {
@ -47,11 +54,20 @@ function item_post(&$a) {
);
}
elseif($parent_uri && local_user()) {
$_POST['type'] = 'net-comment';
// This is coming from an API source, we are logged in
// This query will find the immediate parent
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent_uri),
intval(local_user())
);
// now find the real parent of the conversation
if(count($r)) {
$parid = $r[0]['parent'];
$r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
intval($parid)
);
}
}
if(($r === false) || (! count($r))) {
@ -62,6 +78,11 @@ function item_post(&$a) {
}
$parent_item = $r[0];
$parent = $r[0]['id'];
// multi-level threading - preserve the info but re-parent to our single level threading
if(($parid) && ($parid != $parent))
$thr_parent = $parent_uri;
if($parent_item['contact-id'] && $uid) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($parent_item['contact-id']),
@ -195,6 +216,8 @@ function item_post(&$a) {
$contact_record = $r[0];
}
$post_type = notags(trim($_POST['type']));
if($post_type === 'net-comment') {
@ -458,6 +481,7 @@ function item_post(&$a) {
$datarray['private'] = $private;
$datarray['pubmail'] = $pubmail_enable;
$datarray['attach'] = $attachments;
$datarray['thr-parent'] = $thr_parent;
/**
* These fields are for the convenience of plugins...
@ -495,9 +519,9 @@ function item_post(&$a) {
$r = q("INSERT INTO `item` (`uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `received`, `changed`, `uri`, `title`, `body`, `app`, `location`, `coord`,
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
`tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach` )
VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s' )",
VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s' )",
intval($datarray['uid']),
dbesc($datarray['type']),
intval($datarray['wall']),
@ -514,6 +538,7 @@ function item_post(&$a) {
dbesc($datarray['received']),
dbesc($datarray['changed']),
dbesc($datarray['uri']),
dbesc($datarray['thr-parent']),
dbesc($datarray['title']),
dbesc($datarray['body']),
dbesc($datarray['app']),