diff --git a/database.sql b/database.sql index bb326fbdd2..84bb42ff39 100644 --- a/database.sql +++ b/database.sql @@ -195,6 +195,7 @@ CREATE TABLE IF NOT EXISTS `item` ( `deny_cid` mediumtext NOT NULL, `deny_gid` mediumtext NOT NULL, `private` tinyint(1) NOT NULL DEFAULT '0', + `pubmail` tinyint(1) NOT NULL DEFAULT '0', `visible` tinyint(1) NOT NULL DEFAULT '0', `unseen` tinyint(1) NOT NULL DEFAULT '1', `deleted` tinyint(1) NOT NULL DEFAULT '0', @@ -515,6 +516,7 @@ CREATE TABLE IF NOT EXISTS `mailacct` ( `user` CHAR( 255 ) NOT NULL , `pass` TEXT NOT NULL , `reply_to` CHAR( 255 ) NOT NULL , +`pubmail` TINYINT(1) NOT NULL DEFAULT '0', `last_check` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' ) ENGINE = MYISAM DEFAULT CHARSET=utf8; diff --git a/include/Scrape.php b/include/Scrape.php index 05a53e5386..a6bb5f728c 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -322,7 +322,7 @@ function probe_url($url) { $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval(local_user()) ); - $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval(local_user()) ); if(count($x) && count($r)) { @@ -341,8 +341,8 @@ function probe_url($url) { $profile = 'http://' . substr($url,strpos($url,'@')+1); // fix nick character range $vcard = array('fn' => $name, 'nick' => $name, 'photo' => gravatar_img($url)); - $notify = 'smtp'; - $poll = 'email'; + $notify = 'smtp ' . random_string(); + $poll = 'email ' . random_string(); $priority = 0; $x = email_msg_meta($mbox,$msgs[0]); $adr = imap_rfc822_parse_adrlist($x->from,''); diff --git a/include/conversation.php b/include/conversation.php index b2d20300f7..4c858d8187 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -85,6 +85,8 @@ function conversation(&$a, $items, $mode, $update) { $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']); $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']); $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); + if($profile_link === 'mailbox') + $profile_link = ''; $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; @@ -360,6 +362,9 @@ function conversation(&$a, $items, $mode, $update) { else $profile_link = $item['url']; + if($profile_link === 'mailbox') + $profile_link = ''; + $like = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : ''); $dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : ''); @@ -483,6 +488,9 @@ function item_photo_menu($item){ $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + if($profile_link === 'mailbox') + $profile_link = ''; + // $item['contact-uid'] is only set on profile page and indicates the uid of the user who owns the profile. $profile_owner = ((x($item,'contact-uid')) && intval($item['contact-uid']) ? intval($item['contact-uid']) : 0); @@ -503,6 +511,8 @@ function item_photo_menu($item){ $redir = $a->get_baseurl() . '/redir/' . $a->authors[$item['author-link']]['id']; $cid = $a->authors[$item['author-link']]['id']; } + if($item['author-link'] === 'mailbox') + $cid = $item['cid']; if((isset($cid)) && (! $item['self'])) { $contact_url = $a->get_baseurl() . '/contacts/' . $cid; diff --git a/include/email.php b/include/email.php index c0fe17cc6b..91aafd45ed 100644 --- a/include/email.php +++ b/include/email.php @@ -32,6 +32,27 @@ function email_msg_meta($mbox,$uid) { return ((count($ret)) ? $ret[0] : array()); } +function email_msg_headers($mbox,$uid) { + $raw_header = (($mbox && $uid) ? imap_fetchheader($mbox,$uid,FT_UID) : ''); + $raw_header = str_replace("\r",'',$raw_header); + $ret = array(); + $h = split("\n",$raw_header); + if(count($h)) + foreach($h as $line ) { + if (preg_match("/^[a-zA-Z]/", $line)) { + $key = substr($line,0,strpos($line,':')); + $value = substr($line,strpos($line,':')+1); + + $last_entry = strtolower($key); + $ret[$last_entry] = trim($value); + } + else { + $ret[$last_entry] .= ' ' . trim($line); + } + } + return $ret; +} + function email_get_msg($mbox,$uid) { $ret = array(); @@ -129,3 +150,42 @@ function email_get_part($mbox,$uid,$p,$partno) { +function email_header_encode($in_str, $charset) { + $out_str = $in_str; + if ($out_str && $charset) { + + // define start delimimter, end delimiter and spacer + $end = "?="; + $start = "=?" . $charset . "?B?"; + $spacer = $end . "\r\n " . $start; + + // determine length of encoded text within chunks + // and ensure length is even + $length = 75 - strlen($start) - strlen($end); + + /* + [EDIT BY danbrown AT php DOT net: The following + is a bugfix provided by (gardan AT gmx DOT de) + on 31-MAR-2005 with the following note: + "This means: $length should not be even, + but divisible by 4. The reason is that in + base64-encoding 3 8-bit-chars are represented + by 4 6-bit-chars. These 4 chars must not be + split between two encoded words, according + to RFC-2047. + */ + $length = $length - ($length % 4); + + // encode the string and split it into chunks + // with spacers after each chunk + $out_str = base64_encode($out_str); + $out_str = chunk_split($out_str, $length, $spacer); + + // remove trailing spacer and + // add start and end delimiters + $spacer = preg_quote($spacer); + $out_str = preg_replace("/" . $spacer . "$/", "", $out_str); + $out_str = $start . $out_str . $end; + } + return $out_str; +} \ No newline at end of file diff --git a/include/group.php b/include/group.php index 065c2241fe..5dca08c76b 100644 --- a/include/group.php +++ b/include/group.php @@ -123,7 +123,8 @@ function group_public_members($gid) { if(intval($gid)) { $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` - WHERE `gid` = %d AND `group_member`.`uid` = %d AND `contact`.`network` != 'dfrn' ", + WHERE `gid` = %d AND `group_member`.`uid` = %d + AND `contact`.`network` != 'dfrn' AND `contact`.`network` != 'mail' ", intval($gid), intval(local_user()) ); diff --git a/include/notifier.php b/include/notifier.php index 9d74f8b9b5..80f0e67c71 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -72,7 +72,7 @@ function notifier_run($argv, $argc){ else { // find ancestors - $r = q("SELECT `parent`, `uid`, `edited` FROM `item` WHERE `id` = %d LIMIT 1", + $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($item_id) ); @@ -80,6 +80,7 @@ function notifier_run($argv, $argc){ return; } + $parent_item = $r[0]; $parent_id = intval($r[0]['parent']); $uid = $r[0]['uid']; $updated = $r[0]['edited']; @@ -267,12 +268,25 @@ function notifier_run($argv, $argc){ logger('notifier: slaps: ' . print_r($slaps,true), LOGGER_DATA); + // If this is a public message and pubmail is set on the parent, include all your email contacts + + if((! strlen($parent_item['allow_cid'])) && (! strlen($parent_item['allow_gid'])) && (! strlen($parent_item['deny_cid'])) && (! strlen($parent_item['deny_gid'])) + && (intval($parent_item['pubmail']))) { + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `network` = '%s'", + intval($uid), + dbesc(NETWORK_MAIL) + ); + if(count($r)) { + foreach($r as $rr) + $recipients[] = $rr['id']; + } + } + if($followup) $recip_str = $parent['contact-id']; else $recip_str = implode(', ', $recipients); - $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ", dbesc($recip_str) ); @@ -352,6 +366,79 @@ function notifier_run($argv, $argc){ } break; case 'mail': + + // WARNING: does not currently convert to RFC2047 header encodings, etc. + + $addr = $contact['addr']; + if(! strlen($addr)) + break; + + if($cmd === 'wall-new' || $cmd === 'comment-new') { + + $it = null; + if($cmd === 'wall-new') + $it = $items[0]; + else { + $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($argv[2]), + intval($uid) + ); + if(count($r)) + $it = $r[0]; + } + if(! $it) + break; + + + + $local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", + intval($uid) + ); + if(! count($local_user)) + break; + + $reply_to = ''; + $r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", + intval($uid) + ); + if($r1 && $r1[0]['reply_to']) + $reply_to = $r1[0]['reply_to']; + + $subject = (($it['title']) ? $it['title'] : t("\x28no subject\x29")) ; + $headers = 'From: ' . $local_user[0]['username'] . ' <' . $local_user[0]['email'] . '>' . "\n"; + + if($reply_to) + $headers .= 'Reply-to: ' . $reply_to . "\n"; + + $headers .= 'Message-id: <' . $it['uri'] . '>' . "\n"; + + if($it['uri'] !== $it['parent-uri']) { + $header .= 'References: <' . $it['parent-uri'] . '>' . "\n"; + if(! strlen($it['title'])) { + $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1", + dbesc($it['parent-uri']) + ); + if(count($r)) { + $subtitle = $r[0]['title']; + if($subtitle) { + if(strncasecmp($subtitle,'RE:',3)) + $subject = $subtitle; + else + $subject = 'Re: ' . $subtitle; + } + } + } + } + + $headers .= 'MIME-Version: 1.0' . "\n"; + $headers .= 'Content-Type: text/html; charset=UTF-8' . "\n"; + $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n"; + $html = prepare_body($it); + $message = '' . $html . ''; + logger('notifier: email delivery to ' . $addr); + mail($addr, $subject, $message, $headers); + } + break; case 'dspr': case 'feed': case 'face': diff --git a/include/poller.php b/include/poller.php index b8bd0b7081..4e1e30ad5c 100644 --- a/include/poller.php +++ b/include/poller.php @@ -292,31 +292,63 @@ function poller_run($argv, $argc){ $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer_uid) ); - $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", + $mailconf = q("SELECT * FROM `mailacct` WHERE `server` != '' AND `uid` = %d LIMIT 1", intval($importer_uid) ); - if(count($x) && count($r)) { - $mailbox = construct_mailbox_name($r[0]); + if(count($x) && count($mailconf)) { + $mailbox = construct_mailbox_name($mailconf[0]); $password = ''; - openssl_private_decrypt(hex2bin($r[0]['pass']),$password,$x[0]['prvkey']); - $mbox = email_connect($mailbox,$r[0]['user'],$password); + openssl_private_decrypt(hex2bin($mailconf[0]['pass']),$password,$x[0]['prvkey']); + $mbox = email_connect($mailbox,$mailconf[0]['user'],$password); unset($password); + if($mbox) { + q("UPDATE `mailacct` SET `last_check` = '%d' WHERE `id` = %d AND `uid` = %d LIMIT 1", + dbesc(datetime_convert()), + intval($mailconf[0]['id']), + intval($importer_uid) + ); + } } } if($mbox) { + $msgs = email_poll($mbox,$contact['addr']); + if(count($msgs)) { foreach($msgs as $msg_uid) { $datarray = array(); $meta = email_msg_meta($mbox,$msg_uid); + $headers = email_msg_headers($mbox,$msg_uid); + + // look for a 'references' header and try and match with a parent item we have locally. + + $raw_refs = ((x($headers,'references')) ? str_replace("\t",'',$headers['references']) : ''); $datarray['uri'] = trim($meta->message_id,'<>'); -//FIXME - $datarray['parent-uri'] = $datarray['uri']; + + if($raw_refs) { + $refs_arr = explode(' ', $raw_refs); + if(count($refs_arr)) { + for($x = 0; $x < count($refs_arr); $x ++) + $refs_arr[$x] = "'" . str_replace(array('<','>',' '),array('','',''),dbesc($refs_arr[$x])) . "'"; + } + $qstr = implode(',',$refs_arr); + $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `uri` IN ( $qstr ) AND `uid` = %d LIMIT 1", + intval($importer_uid) + ); + if(count($r)) + $datarray['parent-uri'] = $r[0]['uri']; + } + + + if(! x($datarray,'parent-uri')) + $datarray['parent-uri'] = $datarray['uri']; + // Have we seen it before? $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1", intval($importer_uid), dbesc($datarray['uri']) ); + if(count($r)) { if($meta->deleted && ! $r[0]['deleted']) { q("UPDATE `item` SET `deleted` = `, `changed` = '%s' WHERE `id` = %d LIMIT 1", @@ -335,12 +367,20 @@ function poller_run($argv, $argc){ $datarray['body'] = escape_tags($r['body']); $datarray['uid'] = $importer_uid; $datarray['contact-id'] = $contact['id']; - $datarray['private'] = 1; + if($datarray['parent-uri'] === $datarray['uri']) + $datarray['private'] = 1; $datarray['author-name'] = $contact['name']; $datarray['author-link'] = 'mailbox'; $datarray['author-avatar'] = $contact['photo']; - item_store($datarray); + $stored_item = item_store($datarray); + q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d", + dbesc($datarray['parent-uri']), + intval($importer_uid) + ); + q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1", + intval($stored_item) + ); } } } diff --git a/mod/contacts.php b/mod/contacts.php index ee7177d48e..18eedbe9b3 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -284,7 +284,7 @@ function contacts_content(&$a) { '$contact_id' => $r[0]['id'], '$block_text' => (($r[0]['blocked']) ? t('Unblock this contact') : t('Block this contact') ), '$ignore_text' => (($r[0]['readonly']) ? t('Unignore this contact') : t('Ignore this contact') ), - '$insecure' => (($r[0]['network'] !== 'dfrn') ? $insecure : ''), + '$insecure' => (($r[0]['network'] !== NETWORK_DFRN && $r[0]['network'] !== NETWORK_MAIL) ? $insecure : ''), '$info' => $r[0]['info'], '$blocked' => (($r[0]['blocked']) ? '
' . t('Currently blocked') . '
' : ''), '$ignored' => (($r[0]['readonly']) ? '
' . t('Currently ignored') . '
' : ''), diff --git a/mod/editpost.php b/mod/editpost.php index 862ba937f0..7a102119ba 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -51,6 +51,28 @@ function editpost_content(&$a) { $jotplugins = ''; $jotnets = ''; + + $mail_enabled = false; + $pubmail_enabled = false; + + + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", + intval(local_user()) + ); + if(count($r)) { + $mail_enabled = true; + if(intval($r[0]['pubmail'])) + $pubmail_enabled = true; + } + + if($mail_enabled) { + $selected = (($pubmail_enabled) ? ' checked="checked" ' : ''); + $jotnets .= '
' + . t("Post to Email") . '
'; + } + + + call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); diff --git a/mod/item.php b/mod/item.php index 26afec2f44..e53cfb0331 100644 --- a/mod/item.php +++ b/mod/item.php @@ -96,6 +96,7 @@ function item_post(&$a) { $body = escape_tags(trim($_POST['body'])); $private = $orig_post['private']; + $pubmail_enable = $orig_post['pubmail']; } else { $str_group_allow = perms2str($_POST['group_allow']); @@ -121,6 +122,7 @@ function item_post(&$a) { $private = 1; } + $pubmail_enable = ((x($_POST,'pubmail_enable') && intval($_POST['pubmail_enable']) && (! $private)) ? 1 : 0); if(! strlen($body)) { notice( t('Empty post discarded.') . EOL ); @@ -362,6 +364,7 @@ function item_post(&$a) { $datarray['deny_cid'] = $str_contact_deny; $datarray['deny_gid'] = $str_group_deny; $datarray['private'] = $private; + $datarray['pubmail'] = $pubmail_enable; /** * These fields are for the convenience of plugins... @@ -399,8 +402,8 @@ function item_post(&$a) { $r = q("INSERT INTO `item` (`uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `changed`, `uri`, `title`, `body`, `location`, `coord`, - `tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private` ) - VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )", + `tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail` ) + VALUES( %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )", intval($datarray['uid']), dbesc($datarray['type']), intval($datarray['wall']), @@ -427,7 +430,8 @@ function item_post(&$a) { dbesc($datarray['allow_gid']), dbesc($datarray['deny_cid']), dbesc($datarray['deny_gid']), - intval($datarray['private']) + intval($datarray['private']), + intval($datarray['pubmail']) ); $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", @@ -545,11 +549,10 @@ function item_post(&$a) { $addr = trim($recip); if(! strlen($addr)) continue; - $disclaimer = '
' . sprintf(t('This message was sent to you by %s, a member of the Friendika social network.'),$a->user['username']) + $disclaimer = '
' . sprintf( t('This message was sent to you by %s, a member of the Friendika social network.'),$a->user['username']) . '
'; - $disclaimer .= t('You may visit them online at') . ' ' - . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . '
'; - $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . '
'; + $disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL; + $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL; $subject = '[Friendika]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']); $headers = 'From: ' . $a->user['username'] . ' <' . $a->user['email'] . '>' . "\n"; diff --git a/mod/network.php b/mod/network.php index f0a071cbfa..746206031c 100644 --- a/mod/network.php +++ b/mod/network.php @@ -94,6 +94,28 @@ function network_content(&$a, $update = 0) { $jotplugins = ''; $jotnets = ''; + + + $mail_enabled = false; + $pubmail_enabled = false; + + + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", + intval(local_user()) + ); + if(count($r)) { + $mail_enabled = true; + if(intval($r[0]['pubmail'])) + $pubmail_enabled = true; + } + + if($mail_enabled) { + $selected = (($pubmail_enabled) ? ' checked="checked" ' : ''); + $jotnets .= '
' + . t("Post to Email") . '
'; + } + + call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); diff --git a/mod/profile.php b/mod/profile.php index 923f4fb90d..fa2c261df8 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -147,6 +147,26 @@ function profile_content(&$a, $update = 0) { $jotplugins = ''; $jotnets = ''; + + $mail_enabled = false; + $pubmail_enabled = false; + + if($is_owner) { + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", + intval(local_user()) + ); + if(count($r)) { + $mail_enabled = true; + if(intval($r[0]['pubmail'])) + $pubmail_enabled = true; + } + } + if($mail_enabled) { + $selected = (($pubmail_enabled) ? ' checked="checked" ' : ''); + $jotnets .= '
' + . t("Post to Email") . '
'; + } + call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); diff --git a/mod/settings.php b/mod/settings.php index caf29df357..8b7e3c5d69 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -73,6 +73,41 @@ function settings_post(&$a) { $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0); $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted! + $mail_server = ((x($_POST,'mail_server')) ? $_POST['mail_server'] : ''); + $mail_port = ((x($_POST,'mail_port')) ? $_POST['mail_port'] : ''); + $mail_ssl = ((x($_POST,'mail_ssl')) ? strtolower(trim($_POST['mail_ssl'])) : ''); + $mail_user = ((x($_POST,'mail_user')) ? $_POST['mail_user'] : ''); + $mail_pass = ((x($_POST,'mail_pass')) ? trim($_POST['mail_pass']) : ''); + $mail_replyto = ((x($_POST,'mail_replyto')) ? $_POST['mail_replyto'] : ''); + $mail_pubmail = ((x($_POST,'mail_pubmail')) ? $_POST['mail_pubmail'] : ''); + + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", + intval(local_user()) + ); + if(! count($r)) { + q("INSERT INTO `mailacct` (`uid`) VALUES (%d)", + intval(local_user()) + ); + } + if(strlen($mail_pass)) { + $pass = ''; + openssl(private_encrypt($mail_pass,$pass,$a->user['pubkey'])); + q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d LIMIT 1", + dbesc(hex2bin($pass)), + intval(local_user()) + ); + } + $r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s', + `mailbox` = 'INBOX', `reply_to` = '%s', `pubmail` = %d WHERE `uid` = %d LIMIT 1", + dbesc($mail_server), + intval($mail_port), + dbesc($mail_ssl), + dbesc($mail_user), + dbesc($mail_replyto), + intval($mail_pubmail), + intval(local_user()) + ); + $notify = 0; if(x($_POST,'notify1')) @@ -249,6 +284,19 @@ function settings_content(&$a) { if(! strlen($a->user['timezone'])) $timezone = date_default_timezone_get(); + + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", + local_user() + ); + + $mail_server = ((count($r)) ? $r[0]['server'] : ''); + $mail_port = ((count($r)) ? $r[0]['port'] : ''); + $mail_ssl = ((count($r)) ? $r[0]['ssltype'] : ''); + $mail_user = ((count($r)) ? $r[0]['user'] : ''); + $mail_replyto = ((count($r)) ? $r[0]['reply_to'] : ''); + $mail_pubmail = ((count($r)) ? $r[0]['pubmail'] : 0); + + $pageset_tpl = load_view_file('view/pagetypes.tpl'); $pagetype = replace_macros($pageset_tpl,array( '$normal' => (($a->user['page-flags'] == PAGE_NORMAL) ? " checked=\"checked\" " : ""), @@ -408,7 +456,23 @@ function settings_content(&$a) { '$expire' => $expire, '$blockw_checked' => (($blockwall) ? '' : ' checked="checked" ' ), '$theme' => $theme_selector, - '$pagetype' => $pagetype + '$pagetype' => $pagetype, + '$lbl_imap0' => t('Email/Mailbox Setup'), + '$imap_desc' => t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."), + '$lbl_imap1' => t('IMAP server name:'), + '$imap_server' => $mail_server, + '$lbl_imap2' => t('IMAP port:'), + '$imap_port' => $mail_port, + '$lbl_imap3' => t("Security \x28TLS or SSL\x29:"), + '$imap_ssl' => $mail_ssl, + '$lbl_imap4' => t('Email login name:'), + '$imap_user' => $mail_user, + '$lbl_imap5' => t('Email password:'), + '$lbl_imap6' => t("Reply-to address \x28Optional\x29:"), + '$imap_replyto' => $mail_replyto, + '$lbl_imap7' => t('Send public posts to all email contacts:'), + '$pubmail_checked' => (($mail_pubmail) ? ' checked="checked" ' : ''), + )); call_hooks('settings_form',$o); diff --git a/update.php b/update.php index 103be3b80b..a8140fe911 100644 --- a/update.php +++ b/update.php @@ -471,6 +471,8 @@ function update_1051() { function update_1052() { q("ALTER TABLE `mailacct` CHANGE `pass` `pass` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); + q("ALTER TABLE `mailacct` ADD `pubmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `reply_to` "); + q("ALTER TABLE `item` ADD `pubmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `private` "); } diff --git a/view/settings.tpl b/view/settings.tpl index e87853d45f..5876cdeeb7 100644 --- a/view/settings.tpl +++ b/view/settings.tpl @@ -164,7 +164,35 @@ $profile_in_net_dir +

$lbl_imap0

+

+$imap_desc +

+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+
+ +

$lbl_advn

diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 6658cd94a3..0e361ad46d 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -402,7 +402,14 @@ input#dfrn-url { #notify2-end, #notify3-end, #notify4-end, -#notify5-end { +#notify5-end, +#imap-server-end, +#imap-port-end, +#imap-ssl-end, +#imap-user-end, +#imap-pass-end, +#imap-replyto-end, +#imap-pubmail-end { margin-bottom: 5px; clear: both; } @@ -423,7 +430,14 @@ input#dfrn-url { #settings-label-notify2, #settings-label-notify3, #settings-label-notify4, -#settings-label-notify5 { +#settings-label-notify5, +#settings-label-imap1, +#settings-label-imap2, +#settings-label-imap3, +#settings-label-imap4, +#settings-label-imap5, +#settings-label-imap6, +#settings-label-imap7 { float: left; width: 200px; } @@ -443,7 +457,14 @@ input#dfrn-url { #notify2, #notify3, #notify4, -#notify5 { +#notify5, +#imap-server, +#imap-port, +#imap-ssl, +#imap-user, +#imap-pass, +#imap-replyto, +#imap-pubmail { float: left; margin-bottom: 20px; } diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css index fd909666fa..f4d31e93f2 100644 --- a/view/theme/loozah/style.css +++ b/view/theme/loozah/style.css @@ -529,7 +529,14 @@ input#dfrn-url { #notify2-end, #notify3-end, #notify4-end, -#notify5-end { +#notify5-end, +#imap-server-end, +#imap-port-end, +#imap-ssl-end, +#imap-user-end, +#imap-pass-end, +#imap-replyto-end, +#imap-pubmail-end { margin-bottom: 5px; clear: both; } @@ -550,7 +557,14 @@ input#dfrn-url { #settings-label-notify2, #settings-label-notify3, #settings-label-notify4, -#settings-label-notify5 { +#settings-label-notify5, +#settings-label-imap1, +#settings-label-imap2, +#settings-label-imap3, +#settings-label-imap4, +#settings-label-imap5, +#settings-label-imap6, +#settings-label-imap7 { float: left; width: 200px; } @@ -570,7 +584,14 @@ input#dfrn-url { #notify2, #notify3, #notify4, -#notify5 { +#notify5, +#imap-server, +#imap-port, +#imap-ssl, +#imap-user, +#imap-pass, +#imap-replyto, +#imap-pubmail { float: left; margin-bottom: 20px; }