From 96857389ac6a9ab11f0543da5b0af3895dfccfaf Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 23 Jun 2011 01:57:14 -0700 Subject: friendika-z initial implementation --- addon/facebook/facebook.php | 4 ++++ addon/statusnet/statusnet.php | 10 +++++++--- addon/twitter/twitter.php | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'addon') diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php index 15dffa594..4265ce801 100644 --- a/addon/facebook/facebook.php +++ b/addon/facebook/facebook.php @@ -431,6 +431,10 @@ function facebook_post_hook(&$a,&$b) { if((local_user()) && (local_user() == $b['uid'])) { + // Facebook is not considered a private network + if($b['prvnets']) + return; + if($b['parent']) { $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($b['parent']), diff --git a/addon/statusnet/statusnet.php b/addon/statusnet/statusnet.php index 85024631c..22f7dc8f9 100644 --- a/addon/statusnet/statusnet.php +++ b/addon/statusnet/statusnet.php @@ -303,10 +303,14 @@ function statusnet_post_hook(&$a,&$b) { if((local_user()) && (local_user() == $b['uid']) && (! $b['private']) && (!$b['parent']) ) { - load_pconfig(local_user(), 'statusnet'); + // Status.Net is not considered a private network + if($b['prvnets']) + return; + + load_pconfig(local_user(), 'statusnet'); - $api = get_pconfig(local_user(), 'statusnet', 'baseapi'); - $ckey = get_pconfig(local_user(), 'statusnet', 'consumerkey' ); + $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' ); diff --git a/addon/twitter/twitter.php b/addon/twitter/twitter.php index aeb9cc937..7829799bc 100644 --- a/addon/twitter/twitter.php +++ b/addon/twitter/twitter.php @@ -195,6 +195,11 @@ function twitter_post_hook(&$a,&$b) { if((local_user()) && (local_user() == $b['uid']) && (! $b['private']) && (! $b['parent']) ) { + // Twitter is not considered a private network + if($b['prvnets']) + return; + + load_pconfig(local_user(), 'twitter'); $ckey = get_config('twitter', 'consumerkey' ); -- cgit v1.2.3 From 6a491db3e0fa0471725bcc875e8c393bc0f6ffdb Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Thu, 23 Jun 2011 20:47:24 +0200 Subject: admin interface stuff for the piwik addon --- addon/piwik/admin.tpl | 4 ++++ addon/piwik/piwik.php | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 addon/piwik/admin.tpl (limited to 'addon') diff --git a/addon/piwik/admin.tpl b/addon/piwik/admin.tpl new file mode 100644 index 000000000..e7a281e3a --- /dev/null +++ b/addon/piwik/admin.tpl @@ -0,0 +1,4 @@ +{{ inc field_input.tpl with $field=$baseurl }}{{ endinc }} +{{ inc field_input.tpl with $field=$sideid }}{{ endinc }} +{{ inc field_checkbox.tpl with $field=$optout }}{{ endinc }} +
diff --git a/addon/piwik/piwik.php b/addon/piwik/piwik.php index 032f84f4b..94aa9b55c 100644 --- a/addon/piwik/piwik.php +++ b/addon/piwik/piwik.php @@ -70,4 +70,21 @@ function piwik_analytics($a,&$b) { } } - +function piwik_plugin_admin (&$a, &$o) { + $t = file_get_contents( dirname(__file__)."/admin.tpl"); + $o = replace_macros( $t, array( + '$submit' => t('Submit'), + '$baseurl' => array('baseurl', t('Piwik Base URL'), get_config('piwik','baseurl' ), ''), + '$sideid' => array('sideid', t('Side ID'), get_config('piwik','sideid' ), ''), + '$optout' => array('optout', t('Show opt-out cookie link?'), get_config('piwik','optout' ), ''), + )); +} +function piwik_plugin_admin_post (&$a) { + $url = ((x($_POST, 'baseurl')) ? notags(trim($_POST['baseurl'])) : ''); + $id = ((x($_POST, 'sideid')) ? trim($_POST['sideid']) : ''); + $optout = ((x($_POST, 'optout')) ? trim($_POST['optout']) : ''); + set_config('piwik', 'baseurl', $url); + set_config('piwik', 'sideid', $id); + set_config('piwik', 'optout', $optout); + info( t('Settings updated.'). EOL); +} -- cgit v1.2.3 From cb319c68249bc02da6e41d9e907d08439f57895d Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Thu, 23 Jun 2011 21:44:25 +0200 Subject: fixed a typo --- addon/piwik/admin.tpl | 2 +- addon/piwik/piwik.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'addon') diff --git a/addon/piwik/admin.tpl b/addon/piwik/admin.tpl index e7a281e3a..0edd06210 100644 --- a/addon/piwik/admin.tpl +++ b/addon/piwik/admin.tpl @@ -1,4 +1,4 @@ {{ inc field_input.tpl with $field=$baseurl }}{{ endinc }} -{{ inc field_input.tpl with $field=$sideid }}{{ endinc }} +{{ inc field_input.tpl with $field=$siteid }}{{ endinc }} {{ inc field_checkbox.tpl with $field=$optout }}{{ endinc }}
diff --git a/addon/piwik/piwik.php b/addon/piwik/piwik.php index 94aa9b55c..3cc136d29 100644 --- a/addon/piwik/piwik.php +++ b/addon/piwik/piwik.php @@ -18,10 +18,10 @@ * Add the following two lines to your .htconfig.php file: * * $a->config['piwik']['baseurl'] = 'www.example.com/piwik/'; - * $a->config['piwik']['sideid'] = '1'; + * $a->config['piwik']['siteid'] = '1'; * $a->config['piwik']['optout'] = true; // set to false to disable * - * Change the sideid to the ID that the Piwik tracker for your Friendika + * Change the siteid to the ID that the Piwik tracker for your Friendika * installation has. Alter the baseurl to fit your needs, don't care * about http/https but beware to put the trailing / at the end of your * setting. @@ -54,13 +54,13 @@ function piwik_analytics($a,&$b) { * Get the configuration variables from the .htconfig file. */ $baseurl = get_config('piwik','baseurl'); - $sideod = get_config('piwik','sideid'); + $siteid = get_config('piwik','siteid'); $optout = get_config('piwik','optout'); /* - * Add the Piwik code for the side. + * Add the Piwik code for the site. */ - $b .= "
\r\n \r\n\r\n\r\n
"; + $b .= "
\r\n \r\n\r\n\r\n
"; /* * If the optout variable is set to true then display the notice * otherwise just include the above code into the page. @@ -75,16 +75,16 @@ function piwik_plugin_admin (&$a, &$o) { $o = replace_macros( $t, array( '$submit' => t('Submit'), '$baseurl' => array('baseurl', t('Piwik Base URL'), get_config('piwik','baseurl' ), ''), - '$sideid' => array('sideid', t('Side ID'), get_config('piwik','sideid' ), ''), + '$siteid' => array('siteid', t('Site ID'), get_config('piwik','siteid' ), ''), '$optout' => array('optout', t('Show opt-out cookie link?'), get_config('piwik','optout' ), ''), )); } function piwik_plugin_admin_post (&$a) { $url = ((x($_POST, 'baseurl')) ? notags(trim($_POST['baseurl'])) : ''); - $id = ((x($_POST, 'sideid')) ? trim($_POST['sideid']) : ''); + $id = ((x($_POST, 'siteid')) ? trim($_POST['siteid']) : ''); $optout = ((x($_POST, 'optout')) ? trim($_POST['optout']) : ''); set_config('piwik', 'baseurl', $url); - set_config('piwik', 'sideid', $id); + set_config('piwik', 'siteid', $id); set_config('piwik', 'optout', $optout); info( t('Settings updated.'). EOL); } -- cgit v1.2.3 From 5633430a19624423ddd98655518d8a765f081230 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 23 Jun 2011 15:58:43 -0700 Subject: don't allow tags in app source --- addon/facebook/facebook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addon') diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php index 4265ce801..e9290b10e 100644 --- a/addon/facebook/facebook.php +++ b/addon/facebook/facebook.php @@ -821,7 +821,7 @@ function fb_consume_stream($uid,$j,$wall = false) { $datarray['owner-avatar'] = $self[0]['thumb']; } if(isset($entry->application) && isset($entry->application->name) && strlen($entry->application->name)) - $datarray['app'] = $entry->application->name; + $datarray['app'] = strip_tags($entry->application->name); else $datarray['app'] = 'facebook'; $datarray['author-name'] = $from->name; -- cgit v1.2.3 From 694c1c1af4ec1e19486fcb97da697cba70a9546a Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 23 Jun 2011 21:55:27 -0700 Subject: new contact_selector function to provide more fine-tuned selection options. --- addon/facebook/facebook.php | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'addon') diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php index e9290b10e..49f193804 100644 --- a/addon/facebook/facebook.php +++ b/addon/facebook/facebook.php @@ -43,6 +43,25 @@ define('FACEBOOK_MAXPOSTLEN', 420); + +function facebook_install() { + register_hook('post_local_end', '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('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('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets'); + unregister_hook('plugin_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'); +} + + /* declare the facebook_module function so that /facebook url requests will land here */ function facebook_module() {} @@ -339,22 +358,6 @@ function facebook_content(&$a) { return $o; } -function facebook_install() { - register_hook('post_local_end', '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('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('jot_networks', 'addon/facebook/facebook.php', 'facebook_jot_nets'); - unregister_hook('plugin_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'); -} function facebook_cron($a,$b) { @@ -432,7 +435,7 @@ function facebook_post_hook(&$a,&$b) { if((local_user()) && (local_user() == $b['uid'])) { // Facebook is not considered a private network - if($b['prvnets']) + if($b['prvnets'] && $b['private']) return; if($b['parent']) { -- cgit v1.2.3 From 762bb8de795f8bb455da969d287397b2fa6a2f82 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 30 Jun 2011 17:00:26 +0200 Subject: update oembed and widgets plugins settings form --- addon/oembed/oembed.php | 28 ++++++++++------------------ addon/oembed/settings.tpl | 7 +++++++ addon/widgets/settings.tpl | 19 +++++++++++++++++++ addon/widgets/widgets.php | 36 +++++++++++++++++------------------- 4 files changed, 53 insertions(+), 37 deletions(-) create mode 100644 addon/oembed/settings.tpl create mode 100644 addon/widgets/settings.tpl (limited to 'addon') diff --git a/addon/oembed/oembed.php b/addon/oembed/oembed.php index 7e677fd6f..880e4992f 100644 --- a/addon/oembed/oembed.php +++ b/addon/oembed/oembed.php @@ -25,9 +25,9 @@ function oembed_uninstall() { function oembed_settings_post($a,$b){ if(! local_user()) return; - if (isset($_POST['oembed-submit'])){ - set_pconfig(local_user(), 'oembed', 'use_for_youtube', (isset($_POST['oembed_use_for_youtube'])? intval($_POST['oembed_use_for_youtube']):0)); - notice( t('OEmbed settings updated') . EOL); + if (x($_POST,'oembed-submit')){ + set_pconfig(local_user(), 'oembed', 'use_for_youtube', (x($_POST,'oembed_use_for_youtube')? intval($_POST['oembed_use_for_youtube']):0)); + info( t('OEmbed settings updated') . EOL); } } @@ -36,21 +36,13 @@ function oembed_settings(&$a,&$o) { return; $uofy = intval(get_pconfig(local_user(), 'oembed', 'use_for_youtube' )); - $o.=' -
-

OEmbed

-
- -
-
-
- -
-
'; + $t = file_get_contents( dirname(__file__). "/settings.tpl" ); + $o .= replace_macros($t, array( + '$submit' => t('Submit'), + '$title' => "OEmbed", + '$useoembed' => array('oembed_use_for_youtube', t('Use OEmbed for YouTube videos'), $uofy, ""), + )); + } diff --git a/addon/oembed/settings.tpl b/addon/oembed/settings.tpl new file mode 100644 index 000000000..5a65ef8e5 --- /dev/null +++ b/addon/oembed/settings.tpl @@ -0,0 +1,7 @@ +
+

$title

+ {{ inc field_checkbox.tpl with $field=$useoembed }}{{ endinc }} +
+ +
+
diff --git a/addon/widgets/settings.tpl b/addon/widgets/settings.tpl new file mode 100644 index 000000000..9d0f21d29 --- /dev/null +++ b/addon/widgets/settings.tpl @@ -0,0 +1,19 @@ +
+

$title

+
+ + $key +
+ +
+ +
+ +

$widgets_h

+
    + {{ for $widgets as $w }} +
  • $w.1
  • + {{ endfor }} +
+ +
diff --git a/addon/widgets/widgets.php b/addon/widgets/widgets.php index f5f868222..13c4f93bb 100644 --- a/addon/widgets/widgets.php +++ b/addon/widgets/widgets.php @@ -33,34 +33,32 @@ function widgets_settings(&$a,&$o) { $key = get_pconfig(local_user(), 'widgets', 'key' ); if ($key=='') { $key = mt_rand(); set_pconfig(local_user(), 'widgets', 'key', $key); } - - $o .='

Widgets

'; - - - $o.=' -
- '. t('Widgets key: ') .''.$key.' -
-
-
- -
'; - - - $o.='

Widgets:

'; - $o .= '
    '; + + $widgets = array(); $d = dir(dirname(__file__)); while(false !== ($f = $d->read())) { if(substr($f,0,7)=="widget_") { preg_match("|widget_([^.]+).php|", $f, $m); $w=$m[1]; require_once($f); - $o.='
  • '. call_user_func($w."_widget_name") .'
  • '; + $widgets[] = array($w, call_user_func($w."_widget_name")); + } } - $o .= '
'; - + + + $t = file_get_contents( dirname(__file__). "/settings.tpl" ); + $o .= replace_macros($t, array( + '$submit' => t('Generate new key'), + '$baseurl' => $a->get_baseurl(), + '$title' => "Widgets", + '$label' => t('Widgets key'), + '$key' => $key, + '$widgets_h' => t('Widgets available'), + '$widgets' => $widgets, + )); + } function widgets_module() { -- cgit v1.2.3 From 7778dbb67b2c033473b0da9b34df01d28162b5ee Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 30 Jun 2011 17:01:26 +0200 Subject: twitter and statusnet plugin settings are not parsed on post if their respective submit buttons was not clicked by user --- addon/statusnet/statusnet.php | 63 ++++++++++++++++++++++--------------------- addon/twitter/twitter.php | 7 +++-- 2 files changed, 38 insertions(+), 32 deletions(-) (limited to 'addon') diff --git a/addon/statusnet/statusnet.php b/addon/statusnet/statusnet.php index 22f7dc8f9..9357b0ebd 100644 --- a/addon/statusnet/statusnet.php +++ b/addon/statusnet/statusnet.php @@ -89,6 +89,9 @@ function statusnet_jot_nets(&$a,&$b) { function statusnet_settings_post ($a,$post) { if(! local_user()) return; + // don't check statusnet settings if statusnet submit button is not clicked + if (!x($_POST,'statusnet-submit')) return; + if (isset($_POST['statusnet-disconnect'])) { /*** * if the statusnet-disconnect checkbox is set, clear the statusnet configuration @@ -152,28 +155,28 @@ function statusnet_settings_post ($a,$post) { goaway($a->get_baseurl().'/settings/addon'); } else { if (isset($_POST['statusnet-pin'])) { - // if the user supplied us with a PIN from Twitter, let the magic of OAuth happen - logger('got a StatusNet security code'); + // if the user supplied us with a PIN from Twitter, let the magic of OAuth happen + logger('got a StatusNet security code'); $api = get_pconfig(local_user(), 'statusnet', 'baseapi'); - $ckey = get_pconfig(local_user(), 'statusnet', 'consumerkey' ); - $csecret = get_pconfig(local_user(), 'statusnet', 'consumersecret' ); - // the token and secret for which the PIN was generated were hidden in the settings - // form as token and token2, we need a new connection to Twitter using these token - // and secret to request a Access Token with the PIN - $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']); - $token = $connection->getAccessToken( $_POST['statusnet-pin'] ); - // ok, now that we have the Access Token, save them in the user config - set_pconfig(local_user(),'statusnet', 'oauthtoken', $token['oauth_token']); - set_pconfig(local_user(),'statusnet', 'oauthsecret', $token['oauth_token_secret']); + $ckey = get_pconfig(local_user(), 'statusnet', 'consumerkey' ); + $csecret = get_pconfig(local_user(), 'statusnet', 'consumersecret' ); + // the token and secret for which the PIN was generated were hidden in the settings + // form as token and token2, we need a new connection to Twitter using these token + // and secret to request a Access Token with the PIN + $connection = new StatusNetOAuth($api, $ckey, $csecret, $_POST['statusnet-token'], $_POST['statusnet-token2']); + $token = $connection->getAccessToken( $_POST['statusnet-pin'] ); + // ok, now that we have the Access Token, save them in the user config + set_pconfig(local_user(),'statusnet', 'oauthtoken', $token['oauth_token']); + set_pconfig(local_user(),'statusnet', 'oauthsecret', $token['oauth_token_secret']); set_pconfig(local_user(),'statusnet', 'post', 1); // reload the Addon Settings page, if we don't do it see Bug #42 goaway($a->get_baseurl().'/settings/addon'); - } else { - // if no PIN is supplied in the POST variables, the user has changed the setting - // to post a tweet for every new __public__ posting to the wall - set_pconfig(local_user(),'statusnet','post',intval($_POST['statusnet-enable'])); - set_pconfig(local_user(),'statusnet','post_by_default',intval($_POST['statusnet-default'])); - info( t('StatusNet settings updated.') . EOL); + } else { + // if no PIN is supplied in the POST variables, the user has changed the setting + // to post a tweet for every new __public__ posting to the wall + set_pconfig(local_user(),'statusnet','post',intval($_POST['statusnet-enable'])); + set_pconfig(local_user(),'statusnet','post_by_default',intval($_POST['statusnet-default'])); + info( t('StatusNet settings updated.') . EOL); }}}} } function statusnet_settings(&$a,&$s) { @@ -217,7 +220,7 @@ function statusnet_settings(&$a,&$s) { $s .= ''. $asn['sitename'] .'
'; } $s .= '

'; - $s .= '
'; + $s .= '
'; } $s .= '

' . t('Provide your own OAuth Credentials') . '

'; $s .= '

'. t('No consumer key pair for StatusNet found. Register your Friendika Account as an desktop client on your StatusNet account, copy the consumer key pair here and enter the API base root.
Before you register your own OAuth key pair ask the administrator if there is already a key pair for this Friendika installation at your favorited StatusNet installation.') .'

'; @@ -231,7 +234,7 @@ function statusnet_settings(&$a,&$s) { $s .= ''; $s .= '
'; $s .= '

'; - $s .= '
'; + $s .= '
'; } else { /*** * ok we have a consumer key pair now look into the OAuth stuff @@ -256,15 +259,15 @@ function statusnet_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= ''; - $s .= '
'; - $s .= '
'; - $s .= '

'.t('Cancel Connection Process').'

'; - $s .= '
'; - $s .= '

'.t('Current StatusNet API is').': '.$api.'

'; - $s .= ''; - $s .= ''; - $s .= '
'; - $s .= '
'; + $s .= '
'; + $s .= '
'; + $s .= '

'.t('Cancel Connection Process').'

'; + $s .= '
'; + $s .= '

'.t('Current StatusNet API is').': '.$api.'

'; + $s .= ''; + $s .= ''; + $s .= '
'; + $s .= '
'; } else { /*** * we have an OAuth key / secret pair for the user @@ -286,7 +289,7 @@ function statusnet_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= '
'; - $s .= '
'; + $s .= '
'; } } $s .= '
'; diff --git a/addon/twitter/twitter.php b/addon/twitter/twitter.php index 7829799bc..183c71126 100644 --- a/addon/twitter/twitter.php +++ b/addon/twitter/twitter.php @@ -76,6 +76,9 @@ function twitter_jot_nets(&$a,&$b) { function twitter_settings_post ($a,$post) { if(! local_user()) return; + // don't check twitter settings if twitter submit button is not clicked + if (!x($_POST,'twitter-submit')) return; + if (isset($_POST['twitter-disconnect'])) { /*** * if the twitter-disconnect checkbox is set, clear the OAuth key/secret pair @@ -159,7 +162,7 @@ function twitter_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= '
'; - $s .= '
'; + $s .= '
'; } else { /*** * we have an OAuth key / secret pair for the user @@ -178,7 +181,7 @@ function twitter_settings(&$a,&$s) { $s .= ''; $s .= ''; $s .= '
'; - $s .= '
'; + $s .= '
'; } } $s .= '
'; -- cgit v1.2.3 From 481cd708acfd3291eed7eba6af596c541651963c Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 30 Jun 2011 21:56:07 -0700 Subject: allow polling to mostly survive minor memory shortages. --- addon/facebook/facebook.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'addon') diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php index 49f193804..c54d5b5f0 100644 --- a/addon/facebook/facebook.php +++ b/addon/facebook/facebook.php @@ -376,9 +376,12 @@ function facebook_cron($a,$b) { logger('facebook_cron'); - set_config('facebook','last_poll', time()); - $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'facebook' AND `k` = 'post' AND `v` = '1' "); + // Find the FB users on this site and randomize in case one of them + // uses an obscene amount of memory. It may kill this queue run + // but hopefully we'll get a few others through on each run. + + $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'facebook' AND `k` = 'post' AND `v` = '1' ORDER BY RAND() "); if(count($r)) { foreach($r as $rr) { // check for new friends once a day @@ -392,6 +395,9 @@ function facebook_cron($a,$b) { fb_consume_all($rr['uid']); } } + + set_config('facebook','last_poll', time()); + } -- cgit v1.2.3