if(is_null($db)) {
@include(".htconfig.php");
- require_once("dba.php");
+ require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
};
$stat_writeable = ((($contact['notify']) && ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['rel'] == CONTACT_IS_FRIEND)) ? 1 : 0);
+ if($contact['network'] === NETWORK_OSTATUS && get_pconfig($importer_uid,'system','ostatus_autofriend'))
+ $stat_writeable = 1;
+
if($stat_writeable != $contact['writable']) {
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d LIMIT 1",
intval($stat_writeable),
);
if(count($r)) {
- logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user'],LOGGER_DEBUG);
- if($meta->deleted && ! $r[0]['deleted']) {
- q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
- dbesc(datetime_convert()),
- intval($r[0]['id'])
- );
- }
- /*switch ($mailconf[0]['action']) {
+ logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user']." UID: ".$importer_uid." URI: ".$datarray['uri'],LOGGER_DEBUG);
+
+ // Only delete when mails aren't automatically moved or deleted
+ if (($mailconf[0]['action'] != 1) AND ($mailconf[0]['action'] != 3))
+ if($meta->deleted && ! $r[0]['deleted']) {
+ q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc(datetime_convert()),
+ intval($r[0]['id'])
+ );
+ }
+
+ switch ($mailconf[0]['action']) {
case 0:
logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user'].". Doing nothing.", LOGGER_DEBUG);
break;
if ($mailconf[0]['movetofolder'] != "")
imap_mail_move($mbox, $msg_uid, $mailconf[0]['movetofolder'], FT_UID);
break;
- }*/
+ }
continue;
}
// Is it a reply?
$reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") or
(substr(strtolower($datarray['title']), 0, 3) == "re-") or
- (raw_refs != ""));
+ ($raw_refs != ""));
// Remove Reply-signs in the subject
$datarray['title'] = RemoveReply($datarray['title']);
// If it seems to be a reply but a header couldn't be found take the last message with matching subject
if(!x($datarray,'parent-uri') and $reply) {
- $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) ORDER BY `created` DESC LIMIT 1",
- dbesc(protect_sprintf($datarray['title'])));
+ //$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
+ $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
+ dbesc(protect_sprintf($datarray['title'])),
+ intval($importer_uid));
if(count($r))
$datarray['parent-uri'] = $r[0]['parent-uri'];
}
continue;
}
$datarray['body'] = escape_tags($r['body']);
+ $datarray['body'] = limit_body_size($datarray['body']);
logger("Mail: Importing ".$msg_uid." for ".$mailconf[0]['user']);
else
$fromdecoded .= $frompart->text;
- $datarray['body'] = "[b]".t('From: ') . escape_tags($fromdecoded) . "[/b]\n\n" . $datarray['body'];
+ $fromarr = imap_rfc822_parse_adrlist($fromdecoded, $a->get_hostname());
+
+ $frommail = $fromarr[0]->mailbox."@".$fromarr[0]->host;
+
+ if (isset($fromarr[0]->personal))
+ $fromname = $fromarr[0]->personal;
+ else
+ $fromname = $frommail;
+
+ //$datarray['body'] = "[b]".t('From: ') . escape_tags($fromdecoded) . "[/b]\n\n" . $datarray['body'];
+
+ $datarray['author-name'] = $fromname;
+ $datarray['author-link'] = "mailto:".$frommail;
+ $datarray['author-avatar'] = $contact['photo'];
+
+ $datarray['owner-name'] = $contact['name'];
+ $datarray['owner-link'] = "mailto:".$contact['addr'];
+ $datarray['owner-avatar'] = $contact['photo'];
+
+ } else {
+ $datarray['author-name'] = $contact['name'];
+ $datarray['author-link'] = 'mailbox';
+ $datarray['author-avatar'] = $contact['photo'];
}
$datarray['uid'] = $importer_uid;
$datarray['private'] = 1;
$datarray['allow_cid'] = '<' . $contact['id'] . '>';
}
- $datarray['author-name'] = $contact['name'];
- $datarray['author-link'] = 'mailbox';
- $datarray['author-avatar'] = $contact['photo'];
$stored_item = item_store($datarray);
q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d",