diff options
author | Friendika <info@friendika.com> | 2011-07-31 17:52:36 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-07-31 17:52:36 -0700 |
commit | b0a9ec0a73183e48158a4e42db49943c56db9098 (patch) | |
tree | c15f2723a0c73365514710922b1267fc6acbe90a /mod/item.php | |
parent | 0c9f033505be5dbc2303d8758894e57c616c6534 (diff) | |
download | volse-hubzilla-b0a9ec0a73183e48158a4e42db49943c56db9098.tar.gz volse-hubzilla-b0a9ec0a73183e48158a4e42db49943c56db9098.tar.bz2 volse-hubzilla-b0a9ec0a73183e48158a4e42db49943c56db9098.zip |
better handling of api comments/replies
Diffstat (limited to 'mod/item.php')
-rw-r--r-- | mod/item.php | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/mod/item.php b/mod/item.php index f6f665a18..c4b4351c1 100644 --- a/mod/item.php +++ b/mod/item.php @@ -34,21 +34,34 @@ function item_post(&$a) { call_hooks('post_local_start', $_POST); $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0); + $parent_uri = ((x($_POST,'parent_uri')) ? trim($_POST['parent_uri']) : ''); $parent_item = null; $parent_contact = null; + $r = false; - if($parent) { - $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", - intval($parent) - ); - if(! count($r)) { + if($parent || $parent_uri) { + if($parent) { + $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", + intval($parent) + ); + } + elseif($parent_uri && local_user()) { + // This is coming from an API source, we are logged in + $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + dbesc($parent_uri), + intval(local_user()) + ); + } + + if(($r === false) || (! count($r))) { notice( t('Unable to locate original post.') . EOL); if(x($_POST,'return')) goaway($a->get_baseurl() . "/" . $_POST['return'] ); killme(); } $parent_item = $r[0]; + $parent = $r[0]['id']; if($parent_item['contact-id'] && $uid) { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($parent_item['contact-id']), @@ -59,6 +72,8 @@ function item_post(&$a) { } } + if($parent) logger('mod_post: parent=' . $parent); + $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0); $post_id = ((x($_POST['post_id'])) ? intval($_POST['post_id']) : 0); $app = ((x($_POST['source'])) ? strip_tags($_POST['source']) : ''); |