diff options
author | Friendika <info@friendika.com> | 2011-07-31 20:01:00 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-07-31 20:01:00 -0700 |
commit | 996425206f86967a50923cf61e18776749a49e52 (patch) | |
tree | a4bf2fe712185d98e2622b22a88482f6b0e25a84 | |
parent | b0a9ec0a73183e48158a4e42db49943c56db9098 (diff) | |
download | volse-hubzilla-996425206f86967a50923cf61e18776749a49e52.tar.gz volse-hubzilla-996425206f86967a50923cf61e18776749a49e52.tar.bz2 volse-hubzilla-996425206f86967a50923cf61e18776749a49e52.zip |
api profiles
-rw-r--r-- | include/api.php | 59 | ||||
-rw-r--r-- | mod/item.php | 29 |
2 files changed, 75 insertions, 13 deletions
diff --git a/include/api.php b/include/api.php index 0d446d1a7..45ca6f1a8 100644 --- a/include/api.php +++ b/include/api.php @@ -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(); diff --git a/mod/item.php b/mod/item.php index c4b4351c1..4b9f3d091 100644 --- a/mod/item.php +++ b/mod/item.php @@ -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']), |