honour "post to xxx network by default" when using API
This commit is contained in:
parent
025485ea69
commit
bbd545b9ca
4 changed files with 28 additions and 0 deletions
|
@ -530,6 +530,13 @@ function facebook_post_hook(&$a,&$b) {
|
||||||
$fb_enable = (($fb_post && x($_POST,'facebook_enable')) ? intval($_POST['facebook_enable']) : 0);
|
$fb_enable = (($fb_post && x($_POST,'facebook_enable')) ? intval($_POST['facebook_enable']) : 0);
|
||||||
$fb_token = get_pconfig(local_user(),'facebook','access_token');
|
$fb_token = get_pconfig(local_user(),'facebook','access_token');
|
||||||
|
|
||||||
|
// if API is used, default to the chosen settings
|
||||||
|
if($_POST['api_source'] && intval(get_pconfig(local_user(),'facebook','post_by_default')))
|
||||||
|
$fb_enable = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger('facebook: $fb_post: ' . $fb_post . ' $fb_enable: ' . $fb_enable . ' $fb_token: ' . $fb_token,LOGGER_DEBUG);
|
logger('facebook: $fb_post: ' . $fb_post . ' $fb_enable: ' . $fb_enable . ' $fb_token: ' . $fb_token,LOGGER_DEBUG);
|
||||||
|
|
||||||
// post to facebook if it's a public post and we've ticked the 'post to Facebook' box,
|
// post to facebook if it's a public post and we've ticked the 'post to Facebook' box,
|
||||||
|
|
|
@ -374,6 +374,9 @@ function statusnet_post_hook(&$a,&$b) {
|
||||||
|
|
||||||
$statusnet_post = get_pconfig(local_user(),'statusnet','post');
|
$statusnet_post = get_pconfig(local_user(),'statusnet','post');
|
||||||
$statusnet_enable = (($statusnet_post && x($_POST,'statusnet_enable')) ? intval($_POST['statusnet_enable']) : 0);
|
$statusnet_enable = (($statusnet_post && x($_POST,'statusnet_enable')) ? intval($_POST['statusnet_enable']) : 0);
|
||||||
|
// if API is used, default to the chosen settings
|
||||||
|
if($_POST['api_source'] && intval(get_pconfig(local_user(),'statusnet','post_by_default')))
|
||||||
|
$statusnet_enable = 1;
|
||||||
|
|
||||||
if($statusnet_enable && $statusnet_post) {
|
if($statusnet_enable && $statusnet_post) {
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
|
|
|
@ -225,6 +225,10 @@ function twitter_post_hook(&$a,&$b) {
|
||||||
$twitter_post = intval(get_pconfig(local_user(),'twitter','post'));
|
$twitter_post = intval(get_pconfig(local_user(),'twitter','post'));
|
||||||
$twitter_enable = (($twitter_post && x($_POST,'twitter_enable')) ? intval($_POST['twitter_enable']) : 0);
|
$twitter_enable = (($twitter_post && x($_POST,'twitter_enable')) ? intval($_POST['twitter_enable']) : 0);
|
||||||
|
|
||||||
|
// if API is used, default to the chosen settings
|
||||||
|
if($_POST['api_source'] && intval(get_pconfig(local_user(),'twitter','post_by_default')))
|
||||||
|
$twitter_enable = 1;
|
||||||
|
|
||||||
if($twitter_post && $twitter_enable) {
|
if($twitter_post && $twitter_enable) {
|
||||||
logger('Posting to Twitter', LOGGER_DEBUG);
|
logger('Posting to Twitter', LOGGER_DEBUG);
|
||||||
require_once('library/twitteroauth.php');
|
require_once('library/twitteroauth.php');
|
||||||
|
|
14
mod/item.php
14
mod/item.php
|
@ -178,6 +178,20 @@ function item_post(&$a) {
|
||||||
|
|
||||||
$pubmail_enable = ((x($_POST,'pubmail_enable') && intval($_POST['pubmail_enable']) && (! $private)) ? 1 : 0);
|
$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)) {
|
if(! strlen($body)) {
|
||||||
info( t('Empty post discarded.') . EOL );
|
info( t('Empty post discarded.') . EOL );
|
||||||
if(x($_POST,'return'))
|
if(x($_POST,'return'))
|
||||||
|
|
Loading…
Reference in a new issue