X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fitems.php;h=549027671d5e11c827c81ca43454a23acd0ee95f;hb=a0f3fe6fde55a61291ce96f657262c6b084b5894;hp=1e68787d2435416d2aa1638c177862ecbde7d9e8;hpb=39b37281a78b58b50503056e69b2aaa9885257b0;p=friendica.git
diff --git a/include/items.php b/include/items.php
index 1e68787d24..549027671d 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1097,10 +1097,13 @@ function add_guid($item) {
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 ?
@@ -1110,7 +1113,7 @@ function item_add_language_opt(&$arr) {
if ( strstr($arr['postopts'], 'lang=') )
{
// do not override
- // TODO: add parameter to request overriding
+ /// @TODO Add parameter to request overriding
return;
}
$postopts = $arr['postopts'];
@@ -1250,8 +1253,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
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));
@@ -1333,6 +1338,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
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);
@@ -2320,6 +2329,9 @@ function edited_timestamp_is_newer($existing, $update) {
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);
}
@@ -2760,20 +2772,20 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$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;
@@ -3223,11 +3235,11 @@ function local_delivery($importer,$data) {
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;
}
@@ -3709,7 +3721,7 @@ function local_delivery($importer,$data) {
$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)
@@ -3720,19 +3732,18 @@ function local_delivery($importer,$data) {
$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'])
@@ -3902,7 +3913,7 @@ function local_delivery($importer,$data) {
$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)
@@ -3911,20 +3922,20 @@ function local_delivery($importer,$data) {
$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;
@@ -4397,7 +4408,7 @@ function atom_author($tag,$name,$uri,$h,$w,$photo,$geo) {
$o .= "\t".xmlify($r[0]["nick"])."\r\n";
$o .= "\t".xmlify($r[0]["name"])."\r\n";
- $o .= "\t".xmlify($r[0]["about"])."\r\n";
+ $o .= "\t".xmlify(bbcode($r[0]["about"]))."\r\n";
$o .= "\t\r\n";
$o .= "\t\t".xmlify($location)."\r\n";
$o .= "\t\r\n";
@@ -4510,11 +4521,11 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
$o .= '' . "\r\n";
}
- // To-Do:
- // To support these elements, the API needs to be enhanced
- //$o .= ''."\r\n";
- //$o .= "\t".''."\r\n";
- //$o .= "\t".''."\r\n";
+ /// @TODO
+ /// To support these elements, the API needs to be enhanced
+ /// $o .= ''."\r\n";
+ /// $o .= "\t".''."\r\n";
+ /// $o .= "\t".''."\r\n";
// Deactivated since it was meant only for OStatus
//$o .= item_get_attachment($item);