diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/editpost.php | 19 | ||||
-rw-r--r-- | mod/network.php | 18 | ||||
-rw-r--r-- | mod/profile.php | 4 | ||||
-rw-r--r-- | mod/settings.php | 64 |
4 files changed, 63 insertions, 42 deletions
diff --git a/mod/editpost.php b/mod/editpost.php index 7a102119b..16acc76e1 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -52,17 +52,20 @@ function editpost_content(&$a) { $jotplugins = ''; $jotnets = ''; + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + $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_disabled) { + $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) { diff --git a/mod/network.php b/mod/network.php index 746206031..9061dff0f 100644 --- a/mod/network.php +++ b/mod/network.php @@ -95,18 +95,20 @@ function network_content(&$a, $update = 0) { $jotplugins = ''; $jotnets = ''; + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); $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_disabled) { + $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) { diff --git a/mod/profile.php b/mod/profile.php index fa2c261df..77df6cbdb 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -148,10 +148,12 @@ function profile_content(&$a, $update = 0) { $jotplugins = ''; $jotnets = ''; + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + $mail_enabled = false; $pubmail_enabled = false; - if($is_owner) { + if(($is_owner) && (! $mail_disabled)) { $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval(local_user()) ); diff --git a/mod/settings.php b/mod/settings.php index 7a9469068..95b622c4e 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -81,32 +81,37 @@ function settings_post(&$a) { $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)", + + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + + if(! $mail_disabled) { + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", 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)), + 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()) ); } - $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; @@ -285,9 +290,17 @@ function settings_content(&$a) { $timezone = date_default_timezone_get(); - $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", - local_user() - ); + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + + if(! $mail_disabled) { + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", + local_user() + ); + } + else { + $r = null; + $imap_disabled = (($mail_disabled) ? ' disabled="disabled" ' : ''); + } $mail_server = ((count($r)) ? $r[0]['server'] : ''); $mail_port = ((count($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : ''); @@ -472,7 +485,8 @@ function settings_content(&$a) { '$imap_replyto' => $mail_replyto, '$lbl_imap7' => t('Send public posts to all email contacts:'), '$pubmail_checked' => (($mail_pubmail) ? ' checked="checked" ' : ''), - + '$mail_disabled' => (($mail_disabled) ? '<div class="error-message">' . t('Email access is disabled on this site.') . '</div>' : ''), + '$imap_disabled' => $imap_disabled )); call_hooks('settings_form',$o); |