$contact = $contacts[0];
// load current friends if possible.
- if (($contact['poco'] != "") AND ($contact['success_update'] > $contact['failure_update'])) {
- $r = q("SELECT count(*) as total from glink
- where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
+ if (($contact['poco'] != "") && ($contact['success_update'] > $contact['failure_update'])) {
+ $r = q("SELECT count(*) AS total FROM glink
+ WHERE `cid` = %d AND updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
intval($contact['id'])
);
if (dbm::is_result($r)) {
unlink($cookiejar);
} elseif ($contact['network'] === NETWORK_MAIL || $contact['network'] === NETWORK_MAIL2) {
- logger("Mail: Fetching", LOGGER_DEBUG);
+ logger("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG);
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if ($mail_disabled)
}
if ($mbox) {
- $msgs = email_poll($mbox,$contact['addr']);
+ $msgs = email_poll($mbox, $contact['addr']);
if (count($msgs)) {
- logger("Mail: Parsing ".count($msgs)." mails for ".$mailconf[0]['user'], LOGGER_DEBUG);
+ logger("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf[0]['user'], LOGGER_DEBUG);
$metas = email_msg_meta($mbox,implode(',',$msgs));
if (count($metas) != count($msgs)) {
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 (($mailconf[0]['action'] != 1) && ($mailconf[0]['action'] != 3))
if ($meta->deleted && ! $r[0]['deleted']) {
q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
$datarray['created'] = datetime_convert('UTC','UTC',$meta->date);
// Is it a reply?
- $reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") or
- (substr(strtolower($datarray['title']), 0, 3) == "re-") or
+ $reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") ||
+ (substr(strtolower($datarray['title']), 0, 3) == "re-") ||
($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) {
+ if (!x($datarray,'parent-uri') && $reply) {
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `title` = \"%s\" AND `uid` = %d AND `network` = '%s' ORDER BY `created` DESC LIMIT 1",
dbesc(protect_sprintf($datarray['title'])),
intval($importer_uid),
logger("Mail: Importing ".$msg_uid." for ".$mailconf[0]['user']);
- // some mailing lists have the original author as 'from' - add this sender info to msg body.
/// @TODO Adding a gravatar for the original author would be cool
- if (! stristr($meta->from,$contact['addr'])) {
- $from = imap_mime_header_decode($meta->from);
- $fromdecoded = "";
- foreach ($from as $frompart) {
- if ($frompart->charset != "default") {
- $fromdecoded .= iconv($frompart->charset, 'UTF-8//IGNORE', $frompart->text);
- } else {
- $fromdecoded .= $frompart->text;
- }
- }
-
- $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;
+ $from = imap_mime_header_decode($meta->from);
+ $fromdecoded = "";
+ foreach ($from as $frompart) {
+ if ($frompart->charset != "default") {
+ $fromdecoded .= iconv($frompart->charset, 'UTF-8//IGNORE', $frompart->text);
} else {
- $fromname = $frommail;
+ $fromdecoded .= $frompart->text;
}
+ }
- //$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'];
+ $fromarr = imap_rfc822_parse_adrlist($fromdecoded, $a->get_hostname());
- $datarray['owner-name'] = $contact['name'];
- $datarray['owner-link'] = "mailto:".$contact['addr'];
- $datarray['owner-avatar'] = $contact['photo'];
+ $frommail = $fromarr[0]->mailbox."@".$fromarr[0]->host;
+ if (isset($fromarr[0]->personal)) {
+ $fromname = $fromarr[0]->personal;
} else {
- $datarray['author-name'] = $contact['name'];
- $datarray['author-link'] = 'mailbox';
- $datarray['author-avatar'] = $contact['photo'];
+ $fromname = $frommail;
}
+ $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'];
+
$datarray['uid'] = $importer_uid;
$datarray['contact-id'] = $contact['id'];
if ($datarray['parent-uri'] === $datarray['uri'])