From bbd545b9caa278d61ad423725dc591b3eb0e61f7 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 14 Aug 2011 04:26:41 -0700 Subject: honour "post to xxx network by default" when using API --- mod/item.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index 62c1d4a87..cc4e1e1a8 100644 --- a/mod/item.php +++ b/mod/item.php @@ -178,6 +178,20 @@ function item_post(&$a) { $pubmail_enable = ((x($_POST,'pubmail_enable') && intval($_POST['pubmail_enable']) && (! $private)) ? 1 : 0); + // if using the API, we won't see pubmail_enable - figure out if it should be set + + if($api_source && $profile_uid && $profile_uid == 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 AND `server` != '' LIMIT 1", + intval(local_user()) + ); + if(count($r) && intval($r[0]['pubmail'])) + $pubmail_enabled = true; + } + } + + if(! strlen($body)) { info( t('Empty post discarded.') . EOL ); if(x($_POST,'return')) -- cgit v1.2.3