When commenting on comments, the comment now appears again under the comment
This commit is contained in:
parent
465e1d6a5c
commit
220106c90a
1 changed files with 21 additions and 29 deletions
34
mod/item.php
34
mod/item.php
|
@ -81,7 +81,6 @@ function item_post(App $a) {
|
||||||
|
|
||||||
$parent_item = null;
|
$parent_item = null;
|
||||||
$parent_contact = null;
|
$parent_contact = null;
|
||||||
$thr_parent = '';
|
|
||||||
$parid = 0;
|
$parid = 0;
|
||||||
$r = false;
|
$r = false;
|
||||||
$objecttype = null;
|
$objecttype = null;
|
||||||
|
@ -104,18 +103,17 @@ function item_post(App $a) {
|
||||||
dbesc($parent_uri),
|
dbesc($parent_uri),
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// if this isn't the real parent of the conversation, find it
|
// if this isn't the real parent of the conversation, find it
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$parid = $r[0]['parent'];
|
$parid = $r[0]['parent'];
|
||||||
$parent_uri = $r[0]['uri'];
|
|
||||||
if ($r[0]['id'] != $r[0]['parent']) {
|
if ($r[0]['id'] != $r[0]['parent']) {
|
||||||
$r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
|
$r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
|
||||||
intval($parid)
|
intval($parid)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBM::is_result($r)) {
|
||||||
notice(t('Unable to locate original post.') . EOL);
|
notice(t('Unable to locate original post.') . EOL);
|
||||||
|
@ -125,22 +123,19 @@ function item_post(App $a) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
$parent_item = $r[0];
|
$parent_item = $r[0];
|
||||||
$parent = $r[0]['id'];
|
$parent = $parent_item['id'];
|
||||||
|
$parent_uri = $parent_item['uri'];
|
||||||
|
|
||||||
// multi-level threading - preserve the info but re-parent to our single level threading
|
if ($parent_item['contact-id']) {
|
||||||
$thr_parent = $parent_uri;
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||||
|
intval($parent_item['contact-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']),
|
|
||||||
intval($uid)
|
|
||||||
);
|
);
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$parent_contact = $r[0];
|
$parent_contact = $r[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the contact id doesn't fit with the contact, then set the contact to null
|
// If the contact id doesn't fit with the contact, then set the contact to null
|
||||||
$thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent));
|
$thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($parent_uri));
|
||||||
if (DBM::is_result($thrparent) && ($thrparent[0]["network"] === NETWORK_OSTATUS)
|
if (DBM::is_result($thrparent) && ($thrparent[0]["network"] === NETWORK_OSTATUS)
|
||||||
&& (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) {
|
&& (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) {
|
||||||
$parent_contact = Contact::getDetailsByURL($thrparent[0]["author-link"]);
|
$parent_contact = Contact::getDetailsByURL($thrparent[0]["author-link"]);
|
||||||
|
@ -690,9 +685,9 @@ function item_post(App $a) {
|
||||||
|
|
||||||
$uri = ($message_id ? $message_id : item_new_uri($a->get_hostname(), $profile_uid, $guid));
|
$uri = ($message_id ? $message_id : item_new_uri($a->get_hostname(), $profile_uid, $guid));
|
||||||
|
|
||||||
// Fallback so that we alway have a thr-parent
|
// Fallback so that we alway have a parent uri
|
||||||
if (!$thr_parent) {
|
if (!$parent_uri || !$parent) {
|
||||||
$thr_parent = $uri;
|
$parent_uri = $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
$datarray = array();
|
$datarray = array();
|
||||||
|
@ -736,13 +731,14 @@ function item_post(App $a) {
|
||||||
$datarray['pubmail'] = $pubmail_enable;
|
$datarray['pubmail'] = $pubmail_enable;
|
||||||
$datarray['attach'] = $attachments;
|
$datarray['attach'] = $attachments;
|
||||||
$datarray['bookmark'] = intval($bookmark);
|
$datarray['bookmark'] = intval($bookmark);
|
||||||
$datarray['thr-parent'] = $thr_parent;
|
$datarray['parent-uri'] = $parent_uri;
|
||||||
$datarray['postopts'] = $postopts;
|
$datarray['postopts'] = $postopts;
|
||||||
$datarray['origin'] = $origin;
|
$datarray['origin'] = $origin;
|
||||||
$datarray['moderated'] = $allow_moderated;
|
$datarray['moderated'] = $allow_moderated;
|
||||||
$datarray['gcontact-id'] = GContact::getId(array("url" => $datarray['author-link'], "network" => $datarray['network'],
|
$datarray['gcontact-id'] = GContact::getId(array("url" => $datarray['author-link'], "network" => $datarray['network'],
|
||||||
"photo" => $datarray['author-avatar'], "name" => $datarray['author-name']));
|
"photo" => $datarray['author-avatar'], "name" => $datarray['author-name']));
|
||||||
$datarray['object'] = $object;
|
$datarray['object'] = $object;
|
||||||
|
$datarray['last-child'] = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These fields are for the convenience of plugins...
|
* These fields are for the convenience of plugins...
|
||||||
|
@ -755,11 +751,7 @@ function item_post(App $a) {
|
||||||
// This triggers posts via API and the mirror functions
|
// This triggers posts via API and the mirror functions
|
||||||
$datarray['api_source'] = $api_source;
|
$datarray['api_source'] = $api_source;
|
||||||
|
|
||||||
$datarray['parent-uri'] = ($parent == 0) ? $uri : $parent_item['uri'];
|
// This field is for storing the raw conversation data
|
||||||
$datarray['plink'] = System::baseUrl() . '/display/' . urlencode($datarray['guid']);
|
|
||||||
$datarray['last-child'] = 1;
|
|
||||||
$datarray['visible'] = 1;
|
|
||||||
|
|
||||||
$datarray['protocol'] = PROTOCOL_DFRN;
|
$datarray['protocol'] = PROTOCOL_DFRN;
|
||||||
|
|
||||||
$r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $datarray['parent-uri']);
|
$r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $datarray['parent-uri']);
|
||||||
|
|
Loading…
Reference in a new issue