From: Friendika Date: Wed, 12 Oct 2011 01:46:33 +0000 (-0700) Subject: background deliver plugins X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=754941e42b3d10e99bba337fd1c07cd5beda2e92;p=friendica-addons.git background deliver plugins --- diff --git a/facebook.tgz b/facebook.tgz index a1617de5..6acb8c5c 100644 Binary files a/facebook.tgz and b/facebook.tgz differ diff --git a/facebook/facebook.php b/facebook/facebook.php index 0205204a..22cefc03 100644 --- a/facebook/facebook.php +++ b/facebook/facebook.php @@ -48,20 +48,26 @@ define('FACEBOOK_MAXPOSTLEN', 420); function facebook_install() { - register_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook'); + register_hook('post_local', 'addon/facebook/facebook.php', 'facebook_post_local'); + register_hook('notifier_normal', 'addon/facebook/facebook.php', 'facebook_post_hook'); register_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets'); - register_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings'); + register_hook('connector_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings'); register_hook('cron', 'addon/facebook/facebook.php', 'facebook_cron'); register_hook('queue_predeliver', 'addon/facebook/facebook.php', 'fb_queue_hook'); } function facebook_uninstall() { - unregister_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook'); + unregister_hook('post_local', 'addon/facebook/facebook.php', 'facebook_post_local'); + unregister_hook('notifier_normal', 'addon/facebook/facebook.php', 'facebook_post_hook'); unregister_hook('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets'); - unregister_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings'); + unregister_hook('connector_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings'); unregister_hook('cron', 'addon/facebook/facebook.php', 'facebook_cron'); unregister_hook('queue_predeliver', 'addon/facebook/facebook.php', 'fb_queue_hook'); + + // hook moved + unregister_hook('post_local_end', 'addon/facebook/facebook.php', 'facebook_post_hook'); + unregister_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings'); } @@ -481,6 +487,10 @@ function facebook_jot_nets(&$a,&$b) { function facebook_post_hook(&$a,&$b) { + + if($b['deleted'] || ($b['created'] !== $b['edited'])) + return; + /** * Post to Facebook stream */ @@ -492,18 +502,16 @@ function facebook_post_hook(&$a,&$b) { $reply = false; $likes = false; - if((local_user()) && (local_user() == $b['uid'])) { + $toplevel = (($b['id'] == $b['parent']) ? true : false); - // Facebook is not considered a private network - if($b['prvnets'] && $b['private']) - return; + if(strstr($b['postopts'],'facebook')) { - $linking = ((get_pconfig(local_user(),'facebook','no_linking')) ? 0 : 1); + $linking = ((get_pconfig($b['uid'],'facebook','no_linking')) ? 0 : 1); - if(($b['parent']) && ($linking)) { + if((! $toplevel) && ($linking)) { $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($b['parent']), - intval(local_user()) + intval($b['uid']) ); if(count($r) && substr($r[0]['uri'],0,4) === 'fb::') $reply = substr($r[0]['uri'],4); @@ -571,24 +579,14 @@ function facebook_post_hook(&$a,&$b) { logger('facebook: have appid+secret'); - $fb_post = intval(get_pconfig(local_user(),'facebook','post')); - $fb_enable = (($fb_post && x($_POST,'facebook_enable')) ? intval($_POST['facebook_enable']) : 0); - $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; - + $fb_token = get_pconfig($b['uid'],'facebook','access_token'); - - 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, // or it's a private message with facebook participants // or it's a reply or likes action to an existing facebook post - if($fb_post && $fb_token && ($fb_enable || $b['private'] || $reply)) { + if($fb_token && ($toplevel || $b['private'] || $reply)) { logger('facebook: able to post'); require_once('library/facebook.php'); require_once('include/bbcode.php'); @@ -741,6 +739,32 @@ function facebook_post_hook(&$a,&$b) { } +function facebook_post_local(&$a,&$b) { + + // Figure out if Facebook posting is enabled for this post and file it in 'postopts' + // where we will discover it during background delivery. + + // This can only be triggered by a local user posting to their own wall. + + if((local_user()) && (local_user() == $b['uid'])) { + + $fb_post = intval(get_pconfig(local_user(),'facebook','post')); + $fb_enable = (($fb_post && x($_POST,'facebook_enable')) ? intval($_POST['facebook_enable']) : 0); + + // 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; + + if(! $fb_enable) + return; + + if(strlen($b['postopts'])) + $b['postopts'] .= ','; + $b['postopts'] .= 'facebook'; + } +} + + function fb_queue_hook(&$a,&$b) { $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'", diff --git a/statusnet.tgz b/statusnet.tgz index d6bd821f..21c3fec5 100644 Binary files a/statusnet.tgz and b/statusnet.tgz differ diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 25b52108..51caba10 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -106,19 +106,27 @@ class StatusNetOAuth extends TwitterOAuth { function statusnet_install() { // we need some hooks, for the configuration and for sending tweets - register_hook('plugin_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings'); - register_hook('plugin_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post'); - register_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook'); + register_hook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings'); + register_hook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post'); + register_hook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook'); + register_hook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local'); register_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets'); logger("installed statusnet"); } function statusnet_uninstall() { + unregister_hook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings'); + unregister_hook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post'); + unregister_hook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook'); + unregister_hook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local'); + unregister_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets'); + + // old setting - remove only + unregister_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook'); unregister_hook('plugin_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings'); unregister_hook('plugin_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post'); - unregister_hook('post_local_end', 'addon/statusnet/statusnet.php', 'statusnet_post_hook'); - unregister_hook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets'); + } function statusnet_jot_nets(&$a,&$b) { @@ -347,72 +355,77 @@ function statusnet_settings(&$a,&$s) { } +function statusnet_post_local(&$a,&$b) { + if($b['edit']) + return; + + if((local_user()) && (local_user() == $b['uid']) && (! $b['private'])) { + + $statusnet_post = get_pconfig(local_user(),'statusnet','post'); + $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) + return; + + if(strlen($b['postopts'])) + $b['postopts'] .= ','; + $b['postopts'] .= 'statusnet'; + } +} + function statusnet_post_hook(&$a,&$b) { /** * Post to statusnet */ - logger('StatusNet post invoked'); + if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + return; - if((local_user()) && (local_user() == $b['uid']) && (! $b['private'])) { + if(! strstr($b['postopts'],'statusnet')) + return; - // mike 2-9-11 there was a restriction to only allow this for top level posts - // now relaxed so should allow one's own comments to be forwarded through the connector as well. + logger('StatusNet post invoked'); - // Status.Net is not considered a private network - if($b['prvnets']) - return; - load_pconfig(local_user(), 'statusnet'); + load_pconfig($b['uid'], 'statusnet'); - $api = get_pconfig(local_user(), 'statusnet', 'baseapi'); - $ckey = get_pconfig(local_user(), 'statusnet', 'consumerkey' ); - $csecret = get_pconfig(local_user(), 'statusnet', 'consumersecret' ); - $otoken = get_pconfig(local_user(), 'statusnet', 'oauthtoken' ); - $osecret = get_pconfig(local_user(), 'statusnet', 'oauthsecret' ); - - if($ckey && $csecret && $otoken && $osecret) { - - $statusnet_post = get_pconfig(local_user(),'statusnet','post'); - $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) { - require_once('include/bbcode.php'); - $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret); - $max_char = $dent->get_maxlength(); // max. length for a dent - $msg = strip_tags(bbcode($b['body'])); - // quotes not working - let's try this - $msg = html_entity_decode($msg); - if ( strlen($msg) > $max_char) { - $shortlink = ""; - require_once('library/slinky.php'); - // post url = base url + /display/ + owner + post id - // we construct this from the Owner link and replace - // profile by display - this will cause an error when - // /profile/ is in the owner url twice but I don't - // think this will be very common... - $posturl = str_replace('/profile/','/display/',$b['owner-link']).'/'.$b['id']; - $slinky = new Slinky( $posturl ); - // setup a cascade of shortening services - // try to get a short link from these services - // in the order ur1.ca, trim, id.gd, tinyurl - $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); - $shortlink = $slinky->short(); - // the new message will be shortened such that "... $shortlink" - // will fit into the character limit - $msg = substr($msg, 0, $max_char-strlen($shortlink)-4); - $msg .= '... ' . $shortlink; - } - // and now tweet it :-) - if(strlen($msg)) - $dent->post('statuses/update', array('status' => $msg)); - } + $api = get_pconfig($b['uid'], 'statusnet', 'baseapi'); + $ckey = get_pconfig($b['uid'], 'statusnet', 'consumerkey' ); + $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret' ); + $otoken = get_pconfig($b['uid'], 'statusnet', 'oauthtoken' ); + $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret' ); + + if($ckey && $csecret && $otoken && $osecret) { + + require_once('include/bbcode.php'); + $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret); + $max_char = $dent->get_maxlength(); // max. length for a dent + $msg = strip_tags(bbcode($b['body'])); + // quotes not working - let's try this + $msg = html_entity_decode($msg); + if ( strlen($msg) > $max_char) { + $shortlink = ""; + require_once('library/slinky.php'); + $slinky = new Slinky( $b['plink'] ); + // setup a cascade of shortening services + // try to get a short link from these services + // in the order ur1.ca, trim, id.gd, tinyurl + $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + $shortlink = $slinky->short(); + // the new message will be shortened such that "... $shortlink" + // will fit into the character limit + $msg = substr($msg, 0, $max_char-strlen($shortlink)-4); + $msg .= '... ' . $shortlink; } - } + // and now tweet it :-) + if(strlen($msg)) + $dent->post('statuses/update', array('status' => $msg)); + } } function statusnet_plugin_admin_post(&$a){ diff --git a/twitter.tgz b/twitter.tgz index 5f33a2c9..26527383 100644 Binary files a/twitter.tgz and b/twitter.tgz differ diff --git a/twitter/twitter.php b/twitter/twitter.php index dd229dc5..74d88168 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -43,19 +43,27 @@ function twitter_install() { // we need some hooks, for the configuration and for sending tweets - register_hook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings'); - register_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); - register_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook'); + register_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings'); + register_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); + register_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local'); + register_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook'); register_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets'); logger("installed twitter"); } function twitter_uninstall() { + unregister_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings'); + unregister_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); + unregister_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local'); + unregister_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook'); + unregister_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets'); + + // old setting - remove only + unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook'); unregister_hook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings'); unregister_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post'); - unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook'); - unregister_hook('jot_networks', 'addon/twitter/twitter.php', 'twitter_jot_nets'); + } function twitter_jot_nets(&$a,&$b) { @@ -198,73 +206,82 @@ function twitter_settings(&$a,&$s) { } +function twitter_post_local(&$a,&$b) { + + if($b['edit']) + return; + + if((local_user()) && (local_user() == $b['uid']) && (! $b['private']) && (! $b['parent']) ) { + + $twitter_post = intval(get_pconfig(local_user(),'twitter','post')); + $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_enable) + return; + + if(strlen($b['postopts'])) + $b['postopts'] .= ','; + $b['postopts'] .= 'twitter'; + } +} + + function twitter_post_hook(&$a,&$b) { /** * Post to Twitter */ - logger('twitter post invoked'); + if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + return; - if((local_user()) && (local_user() == $b['uid']) && (! $b['private']) && (! $b['parent']) ) { + if(! strstr($b['postopts'],'twitter')) + return; - // Twitter is not considered a private network - if($b['prvnets']) - return; + if($b['parent'] != $b['id']) + return; + logger('twitter post invoked'); - load_pconfig(local_user(), 'twitter'); - $ckey = get_config('twitter', 'consumerkey' ); - $csecret = get_config('twitter', 'consumersecret' ); - $otoken = get_pconfig(local_user(), 'twitter', 'oauthtoken' ); - $osecret = get_pconfig(local_user(), 'twitter', 'oauthsecret' ); - - if($ckey && $csecret && $otoken && $osecret) { - logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); - - $twitter_post = intval(get_pconfig(local_user(),'twitter','post')); - $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) { - logger('Posting to Twitter', LOGGER_DEBUG); - require_once('library/twitteroauth.php'); - require_once('include/bbcode.php'); - $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret); - $max_char = 140; // max. length for a tweet - $msg = strip_tags(bbcode($b['body'])); - if ( strlen($msg) > $max_char) { - logger('Twitter: have to shorten the message to fit 140 chars', LOGGER_DEBUG); - $shortlink = ""; - require_once('library/slinky.php'); - // post url = base url + /display/ + owner + post id - // we construct this from the Owner link and replace - // profile by display - this will cause an error when - // /profile/ is in the owner url twice but I don't - // think this will be very common... - $posturl = str_replace('/profile/','/display/',$b['owner-link']).'/'.$b['id']; - $slinky = new Slinky( $posturl ); - // setup a cascade of shortening services - // try to get a short link from these services - // in the order ur1.ca, trim, id.gd, tinyurl - $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); - $shortlink = $slinky->short(); - // the new message will be shortened such that "... $shortlink" - // will fit into the character limit - $msg = substr($msg, 0, $max_char-strlen($shortlink)-4); - $msg .= '... ' . $shortlink; - } - // and now tweet it :-) - if(strlen($msg)) { - $result = $tweet->post('statuses/update', array('status' => $msg)); - logger('twitter_post send', LOGGER_DEBUG); - } - - } + load_pconfig($b['uid'], 'twitter'); + + $ckey = get_config('twitter', 'consumerkey' ); + $csecret = get_config('twitter', 'consumersecret' ); + $otoken = get_pconfig($b['uid'], 'twitter', 'oauthtoken' ); + $osecret = get_pconfig($b['uid'], 'twitter', 'oauthsecret' ); + + if($ckey && $csecret && $otoken && $osecret) { + logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); + + require_once('library/twitteroauth.php'); + require_once('include/bbcode.php'); + $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret); + $max_char = 140; // max. length for a tweet + $msg = strip_tags(bbcode($b['body'])); + if ( strlen($msg) > $max_char) { + logger('Twitter: have to shorten the message to fit 140 chars', LOGGER_DEBUG); + $shortlink = ""; + require_once('library/slinky.php'); + $slinky = new Slinky( $b['plink'] ); + // setup a cascade of shortening services + // try to get a short link from these services + // in the order ur1.ca, trim, id.gd, tinyurl + $slinky->set_cascade( array( new Slinky_UR1ca(), new Slinky_Trim(), new Slinky_IsGd(), new Slinky_TinyURL() ) ); + $shortlink = $slinky->short(); + // the new message will be shortened such that "... $shortlink" + // will fit into the character limit + $msg = substr($msg, 0, $max_char-strlen($shortlink)-4); + $msg .= '... ' . $shortlink; + } + // and now tweet it :-) + if(strlen($msg)) { + $result = $tweet->post('statuses/update', array('status' => $msg)); + logger('twitter_post send', LOGGER_DEBUG); } } } diff --git a/wppost.tgz b/wppost.tgz index 091f1a59..fd0d262b 100644 Binary files a/wppost.tgz and b/wppost.tgz differ diff --git a/wppost/wppost.php b/wppost/wppost.php index 9aac6c38..b987778a 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -7,17 +7,25 @@ */ function wppost_install() { - register_hook('post_local_end', 'addon/wppost/wppost.php', 'wppost_send'); - register_hook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets'); - register_hook('plugin_settings', 'addon/wppost/wppost.php', 'wppost_settings'); - register_hook('plugin_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); + register_hook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local'); + register_hook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send'); + register_hook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets'); + register_hook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings'); + register_hook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); } function wppost_uninstall() { - unregister_hook('post_local_end', 'addon/wppost/wppost.php', 'wppost_send'); + unregister_hook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local'); + unregister_hook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send'); unregister_hook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets'); + unregister_hook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings'); + unregister_hook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); + + // obsolete - remove + unregister_hook('post_local_end', 'addon/wppost/wppost.php', 'wppost_send'); unregister_hook('plugin_settings', 'addon/wppost/wppost.php', 'wppost_settings'); unregister_hook('plugin_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); + } @@ -109,23 +117,19 @@ function wppost_settings_post(&$a,&$b) { } +function wppost_post_local(&$a,&$b) { + // This can probably be changed to allow editing by pointing to a different API endpoint - -function wppost_send(&$a,&$b) { - - if((! local_user()) || (local_user() != $b['uid'])) + if($b['edit']) return; - if($b['prvnets'] && $b['private']) + if((! local_user()) || (local_user() != $b['uid'])) return; - if($b['parent']) + if($b['private'] || $b['parent']) return; - $wp_username = get_pconfig(local_user(),'wppost','wp_username'); - $wp_password = get_pconfig(local_user(),'wppost','wp_password'); - $wp_blog = get_pconfig(local_user(),'wppost','wp_blog'); $wp_post = intval(get_pconfig(local_user(),'wppost','post')); $wp_enable = (($wp_post && x($_POST,'wppost_enable')) ? intval($_POST['wppost_enable']) : 0); @@ -133,7 +137,34 @@ function wppost_send(&$a,&$b) { if($_POST['api_source'] && intval(get_pconfig(local_user(),'wppost','post_by_default'))) $wp_enable = 1; - if($wp_username && $wp_password && $wp_blog && $wp_post && $wp_enable) { + if(! $wp_enable) + return; + + if(strlen($b['postopts'])) + $b['postopts'] .= ','; + $b['postopts'] .= 'wppost'; +} + + + + +function wppost_send(&$a,&$b) { + + if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) + return; + + if(! strstr($b['postopts'],'wppost')) + return; + + if($b['parent'] != $b['id']) + return; + + + $wp_username = get_pconfig($b['uid'],'wppost','wp_username'); + $wp_password = get_pconfig($b['uid'],'wppost','wp_password'); + $wp_blog = get_pconfig($b['uid'],'wppost','wp_blog'); + + if($wp_username && $wp_password && $wp_blog) { require_once('include/bbcode.php');