dbesc($item["uri"]), dbesc($item["network"]));
}
-// Adds a "lang" specification in a "postopts" element of given $arr,
-// if possible and not already present.
-// Expects "body" element to exist in $arr.
-// TODO: add a parameter to request forcing override
+/**
+ * Adds a "lang" specification in a "postopts" element of given $arr,
+ * if possible and not already present.
+ * Expects "body" element to exist in $arr.
+ *
+ * @todo Add a parameter to request forcing override
+ */
function item_add_language_opt(&$arr) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) return; // LanguageDetect.php not available ?
if ( strstr($arr['postopts'], 'lang=') )
{
// do not override
- // TODO: add parameter to request overriding
+ /// @TODO Add parameter to request overriding
return;
}
$postopts = $arr['postopts'];
if ($notify)
$guid_prefix = "";
- else
- $guid_prefix = $arr['network'];
+ else {
+ $parsed = parse_url($arr["author-link"]);
+ $guid_prefix = hash("crc32", $parsed["host"]);
+ }
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);
$arr['guid'] = ((x($arr,'guid')) ? notags(trim($arr['guid'])) : get_guid(32, $guid_prefix));
logger("item_store: Set network to ".$arr["network"]." for ".$arr["uri"], LOGGER_DEBUG);
}
+ if ($arr["gcontact-id"] == 0)
+ $arr["gcontact-id"] = get_gcontact_id(array("url" => $arr['author-link'], "network" => $arr['network'],
+ "photo" => $arr['author-avatar'], "name" => $arr['author-name']));
+
if ($arr['guid'] != "") {
// Checking if there is already an item with the same guid
logger('checking for an item for user '.$arr['uid'].' on network '.$arr['network'].' with the guid '.$arr['guid'], LOGGER_DEBUG);
function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) {
if ($contact['network'] === NETWORK_OSTATUS) {
if ($pass < 2) {
+ // Test - remove before flight
+ //$tempfile = tempnam(get_temppath(), "ostatus2");
+ //file_put_contents($tempfile, $xml);
logger("Consume OStatus messages ", LOGGER_DEBUG);
ostatus_import($xml,$importer,$contact, $hub);
}
$datarray['gravity'] = GRAVITY_LIKE;
// only one like or dislike per person
// splitted into two queries for performance issues
- $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent-uri` = '%s') limit 1",
+ $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `parent-uri` = '%s' AND NOT `deleted` LIMIT 1",
intval($datarray['uid']),
- intval($datarray['contact-id']),
+ dbesc($datarray['author-link']),
dbesc($datarray['verb']),
- dbesc($parent_uri)
+ dbesc($datarray['parent-uri'])
);
if($r && count($r))
continue;
- $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`thr-parent` = '%s') limit 1",
+ $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
intval($datarray['uid']),
- intval($datarray['contact-id']),
+ dbesc($datarray['author-link']),
dbesc($datarray['verb']),
- dbesc($parent_uri)
+ dbesc($datarray['parent-uri'])
);
if($r && count($r))
continue;
return 1;
}
- // TODO
- // merge with current record, current contents have priority
- // update record, set url-updated
- // update profile photos
- // schedule a scan?
+ /// @TODO
+ /// merge with current record, current contents have priority
+ /// update record, set url-updated
+ /// update profile photos
+ /// schedule a scan?
return 0;
}
$datarray['owner-avatar'] = $own[0]['thumb'];
$datarray['contact-id'] = $importer['id'];
- if(($datarray['verb'] === ACTIVITY_LIKE)
+ if(($datarray['verb'] === ACTIVITY_LIKE)
|| ($datarray['verb'] === ACTIVITY_DISLIKE)
|| ($datarray['verb'] === ACTIVITY_ATTEND)
|| ($datarray['verb'] === ACTIVITY_ATTENDNO)
$datarray['last-child'] = 0;
// only one like or dislike per person
// splitted into two queries for performance issues
- $r = q("select id from item where uid = %d and `contact-id` = %d and verb = '%s' and (`parent-uri` = '%s') and deleted = 0 limit 1",
+ $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `parent-uri` = '%s' AND NOT `deleted` LIMIT 1",
intval($datarray['uid']),
- intval($datarray['contact-id']),
+ dbesc($datarray['author-link']),
dbesc($datarray['verb']),
dbesc($datarray['parent-uri'])
-
);
if($r && count($r))
continue;
- $r = q("select id from item where uid = %d and `contact-id` = %d and verb = '%s' and (`thr-parent` = '%s') and deleted = 0 limit 1",
+ $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
intval($datarray['uid']),
- intval($datarray['contact-id']),
+ dbesc($datarray['author-link']),
dbesc($datarray['verb']),
dbesc($datarray['parent-uri'])
$datarray['parent-uri'] = $parent_uri;
$datarray['uid'] = $importer['importer_uid'];
$datarray['contact-id'] = $importer['id'];
- if(($datarray['verb'] === ACTIVITY_LIKE)
+ if(($datarray['verb'] === ACTIVITY_LIKE)
|| ($datarray['verb'] === ACTIVITY_DISLIKE)
|| ($datarray['verb'] === ACTIVITY_ATTEND)
|| ($datarray['verb'] === ACTIVITY_ATTENDNO)
$datarray['gravity'] = GRAVITY_LIKE;
// only one like or dislike per person
// splitted into two queries for performance issues
- $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent-uri` = '%s') limit 1",
+ $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `parent-uri` = '%s' AND NOT `deleted` LIMIT 1",
intval($datarray['uid']),
- intval($datarray['contact-id']),
+ dbesc($datarray['author-link']),
dbesc($datarray['verb']),
- dbesc($parent_uri)
+ dbesc($datarray['parent-uri'])
);
if($r && count($r))
continue;
- $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`thr-parent` = '%s') limit 1",
+ $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
intval($datarray['uid']),
- intval($datarray['contact-id']),
+ dbesc($datarray['author-link']),
dbesc($datarray['verb']),
- dbesc($parent_uri)
+ dbesc($datarray['parent-uri'])
);
if($r && count($r))
continue;
$o .= "\t<poco:preferredUsername>".xmlify($r[0]["nick"])."</poco:preferredUsername>\r\n";
$o .= "\t<poco:displayName>".xmlify($r[0]["name"])."</poco:displayName>\r\n";
- $o .= "\t<poco:note>".xmlify($r[0]["about"])."</poco:note>\r\n";
+ $o .= "\t<poco:note>".xmlify(bbcode($r[0]["about"]))."</poco:note>\r\n";
$o .= "\t<poco:address>\r\n";
$o .= "\t\t<poco:formatted>".xmlify($location)."</poco:formatted>\r\n";
$o .= "\t</poco:address>\r\n";
$o .= '<category scheme="X-DFRN:' . xmlify($t[0]) . ':' . xmlify($t[1]) . '" term="' . xmlify($t[2]) . '" />' . "\r\n";
}
- // To-Do:
- // To support these elements, the API needs to be enhanced
- //$o .= '<link rel="ostatus:conversation" href="'.xmlify($a->get_baseurl().'/display/'.$owner['nickname'].'/'.$item['parent']).'"/>'."\r\n";
- //$o .= "\t".'<link rel="self" type="application/atom+xml" href="'.xmlify($a->get_baseurl().'/api/statuses/show/'.$item['id'].'.atom').'"/>'."\r\n";
- //$o .= "\t".'<link rel="edit" type="application/atom+xml" href="'.xmlify($a->get_baseurl().'/api/statuses/show/'.$item['id'].'.atom').'"/>'."\r\n";
+ /// @TODO
+ /// To support these elements, the API needs to be enhanced
+ /// $o .= '<link rel="ostatus:conversation" href="'.xmlify($a->get_baseurl().'/display/'.$owner['nickname'].'/'.$item['parent']).'"/>'."\r\n";
+ /// $o .= "\t".'<link rel="self" type="application/atom+xml" href="'.xmlify($a->get_baseurl().'/api/statuses/show/'.$item['id'].'.atom').'"/>'."\r\n";
+ /// $o .= "\t".'<link rel="edit" type="application/atom+xml" href="'.xmlify($a->get_baseurl().'/api/statuses/show/'.$item['id'].'.atom').'"/>'."\r\n";
// Deactivated since it was meant only for OStatus
//$o .= item_get_attachment($item);