aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-04-17 23:27:11 -0700
committerFriendika <info@friendika.com>2011-04-17 23:27:11 -0700
commitab099e91028122dfb6b10cf9510b1b061f6f547f (patch)
tree126742a2c75edd037b52de9e2525f1cffd630604 /mod
parent7cc5a9bba9ee892bac41fe3af4ae00da846ca96a (diff)
downloadvolse-hubzilla-ab099e91028122dfb6b10cf9510b1b061f6f547f.tar.gz
volse-hubzilla-ab099e91028122dfb6b10cf9510b1b061f6f547f.tar.bz2
volse-hubzilla-ab099e91028122dfb6b10cf9510b1b061f6f547f.zip
email integration, cont.
Diffstat (limited to 'mod')
-rw-r--r--mod/contacts.php2
-rw-r--r--mod/editpost.php22
-rw-r--r--mod/item.php17
-rw-r--r--mod/network.php22
-rw-r--r--mod/profile.php20
-rw-r--r--mod/settings.php66
6 files changed, 140 insertions, 9 deletions
diff --git a/mod/contacts.php b/mod/contacts.php
index ee7177d48..18eedbe9b 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']) ? '<div id="block-message">' . t('Currently blocked') . '</div>' : ''),
'$ignored' => (($r[0]['readonly']) ? '<div id="ignore-message">' . t('Currently ignored') . '</div>' : ''),
diff --git a/mod/editpost.php b/mod/editpost.php
index 862ba937f..7a102119b 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 .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . 'value="1" /> '
+ . t("Post to Email") . '</div>';
+ }
+
+
+
call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets);
diff --git a/mod/item.php b/mod/item.php
index 26afec2f4..e53cfb033 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 = '<hr />' . sprintf(t('This message was sent to you by %s, a member of the Friendika social network.'),$a->user['username'])
+ $disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendika social network.'),$a->user['username'])
. '<br />';
- $disclaimer .= t('You may visit them online at') . ' '
- . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . '<br />';
- $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . '<br />';
+ $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 f0a071cbf..746206031 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 .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . 'value="1" /> '
+ . t("Post to Email") . '</div>';
+ }
+
+
call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets);
diff --git a/mod/profile.php b/mod/profile.php
index 923f4fb90..fa2c261df 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 .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . 'value="1" /> '
+ . t("Post to Email") . '</div>';
+ }
+
call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets);
diff --git a/mod/settings.php b/mod/settings.php
index caf29df35..8b7e3c5d6 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);