- if ($item) {
- $body = $item["body"];
- $str_tags = $item["tag"];
- $app = $item["app"];
- $orig_created = $item["created"];
- $orig_author = $item["author"];
- $orig_guid = $item["guid"];
- $orig_plink = diaspora_plink($orig_author, $orig_guid);
- $orig_uri = $orig_author.':'.$orig_guid;
- $create_original_post = ($body != "");
- $object = $item["object"];
- $objecttype = $item["object-type"];
- }
- }
-
- $plink = diaspora_plink($diaspora_handle, $guid);
-
- $person = find_diaspora_person_by_handle($orig_author);
-
- $created = unxmlify($xml->created_at);
- $private = ((unxmlify($xml->public) == 'false') ? 1 : 0);
-
- $datarray = array();
-
- $datarray['uid'] = $importer['uid'];
- $datarray['contact-id'] = $contact['id'];
- $datarray['wall'] = 0;
- $datarray['network'] = NETWORK_DIASPORA;
- $datarray['guid'] = $guid;
- $datarray['uri'] = $datarray['parent-uri'] = $message_id;
- $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
- $datarray['private'] = $private;
- $datarray['parent'] = 0;
- $datarray['plink'] = $plink;
- $datarray['owner-name'] = $contact['name'];
- $datarray['owner-link'] = $contact['url'];
- $datarray['owner-avatar'] = ((x($contact,'thumb')) ? $contact['thumb'] : $contact['photo']);
- if (!intval(get_config('system','wall-to-wall_share'))) {
- $prefix = share_header($person['name'], $person['url'], ((x($person,'thumb')) ? $person['thumb'] : $person['photo']), $orig_guid, $orig_created, $orig_url);
-
- $datarray['author-name'] = $contact['name'];
- $datarray['author-link'] = $contact['url'];
- $datarray['author-avatar'] = $contact['thumb'];
- $datarray['body'] = $prefix.$body."[/share]";
- } else {
- // Let reshared messages look like wall-to-wall posts
- $datarray['author-name'] = $person['name'];
- $datarray['author-link'] = $person['url'];
- $datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
- $datarray['body'] = $body;
- }
-
- $datarray["object"] = json_encode($xml);
- $datarray['object-type'] = $objecttype;
-
- $datarray['tag'] = $str_tags;
- $datarray['app'] = $app;
-
- // if empty content it might be a photo that hasn't arrived yet. If a photo arrives, we'll make it visible. (testing)
- $datarray['visible'] = ((strlen($body)) ? 1 : 0);
-
- // Store the original item of a reshare
- if ($create_original_post) {
- require_once("include/Contact.php");
-
- $datarray2 = $datarray;
-
- $datarray2['uid'] = 0;
- $datarray2['contact-id'] = get_contact($person['url'], 0);
- $datarray2['guid'] = $orig_guid;
- $datarray2['uri'] = $datarray2['parent-uri'] = $orig_uri;
- $datarray2['changed'] = $datarray2['created'] = $datarray2['edited'] = $datarray2['commented'] = $datarray2['received'] = datetime_convert('UTC','UTC',$orig_created);
- $datarray2['parent'] = 0;
- $datarray2['plink'] = $orig_plink;
-
- $datarray2['author-name'] = $person['name'];
- $datarray2['author-link'] = $person['url'];
- $datarray2['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
- $datarray2['owner-name'] = $datarray2['author-name'];
- $datarray2['owner-link'] = $datarray2['author-link'];
- $datarray2['owner-avatar'] = $datarray2['author-avatar'];
- $datarray2['body'] = $body;
- $datarray2["object"] = $object;
-
- DiasporaFetchGuid($datarray2);
- $message_id = item_store($datarray2);
-
- logger("Store original item ".$orig_guid." under message id ".$message_id);
- }
-
- DiasporaFetchGuid($datarray);
- $message_id = item_store($datarray);
-
- return;
-
-}
+ q("INSERT INTO `mail` (`uid`, `guid`, `convid`, `from-name`,`from-photo`,`from-url`,`contact-id`,`title`,`body`,`seen`,`reply`,`uri`,`parent-uri`,`created`)
+ VALUES (%d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s','%s','%s')",
+ intval($importer["uid"]),
+ dbesc($msg_guid),
+ intval($conversation["id"]),
+ dbesc($person["name"]),
+ dbesc($person["photo"]),
+ dbesc($person["url"]),
+ intval($contact["id"]),
+ dbesc($subject),
+ dbesc($body),
+ 0,
+ 0,
+ dbesc($message_uri),
+ dbesc($author.":".$guid),
+ dbesc($msg_created_at)
+ );