From 519edd184b17d905c1c6b89dd5cc565b9c22d715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B6=C3=9Fl?= Date: Sun, 18 Mar 2012 10:59:01 +0000 Subject: [PATCH 1/3] Delete the app_access_token once the addon is uninstalled. And some more error handling --- facebook/facebook.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/facebook/facebook.php b/facebook/facebook.php index 4524a486..a0fa3936 100755 --- a/facebook/facebook.php +++ b/facebook/facebook.php @@ -75,6 +75,7 @@ function facebook_uninstall() { unregister_hook('plugin_settings', 'addon/facebook/facebook.php', 'facebook_plugin_settings'); if (get_config('facebook', 'realtime_active') == 1) facebook_subscription_del_users(); + del_config('facebook', 'app_access_token'); } @@ -150,8 +151,12 @@ function facebook_init(&$a) { $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token); if($s) { $j = json_decode($s); - logger('facebook_init: wall: ' . print_r($j,true), LOGGER_DATA); - fb_consume_stream($uid,$j,($private_wall) ? false : true); + if (isset($j->data)) { + logger('facebook_init: wall: ' . print_r($j,true), LOGGER_DATA); + fb_consume_stream($uid,$j,($private_wall) ? false : true); + } else { + logger('facebook_init: wall: got no data from Facebook: ' . print_r($j,true), LOGGER_NORMAL); + } } } @@ -1018,15 +1023,23 @@ function fb_consume_all($uid) { $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token); if($s) { $j = json_decode($s); - logger('fb_consume_stream: wall: ' . print_r($j,true), LOGGER_DATA); - fb_consume_stream($uid,$j,($private_wall) ? false : true); + if (isset($j->data)) { + logger('fb_consume_stream: wall: ' . print_r($j,true), LOGGER_DATA); + fb_consume_stream($uid,$j,($private_wall) ? false : true); + } else { + logger('fb_consume_stream: wall: got no data from Facebook: ' . print_r($j,true), LOGGER_NORMAL); + } } } $s = fetch_url('https://graph.facebook.com/me/home?access_token=' . $access_token); if($s) { $j = json_decode($s); - logger('fb_consume_stream: feed: ' . print_r($j,true), LOGGER_DATA); - fb_consume_stream($uid,$j,false); + if (isset($j->data)) { + logger('fb_consume_stream: feed: ' . print_r($j,true), LOGGER_DATA); + fb_consume_stream($uid,$j,false); + } else { + logger('fb_consume_stream: feed: got no data from Facebook: ' . print_r($j,true), LOGGER_NORMAL); + } } } From be363e0ad4dda8ccd41ec83bbfbc20a5990980ad Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 19 Mar 2012 05:46:09 -0700 Subject: [PATCH 2/3] add frown plugin --- frown.tgz | Bin 0 -> 1183 bytes frown/frown.css | 14 ++++++++ frown/frown.php | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 frown.tgz create mode 100755 frown/frown.css create mode 100755 frown/frown.php diff --git a/frown.tgz b/frown.tgz new file mode 100644 index 0000000000000000000000000000000000000000..6a2343f00b57938b22efee862f698db86bf9e125 GIT binary patch literal 1183 zcmV;Q1Yr9giwFRMDrZjs1MOFBZ`(Ey_E-B?+%%(-1IO}9YzJ=aqFDFxp;-&0*gmv{ zK}(cGSP})2auTfh?>mZ;U*ZKphb09%J+On2JRa|!=XjC>!LL)d@ucV@rqgj_I6j*W zhi8rccru)v4T|{^jlp0#8cc@c{%F$Z4~B!`umR(z4a*>xiU@#4LcEZP4ND)e%fj(w zaDION95Fp3fu=lWl~Le*RD$w>=N z;CGVH8T_J)K@ZkB6c_mn=oG;@IiH zU#(VC(2z+*#WLc2?bunIhb&!6suW8@X?MXUzR%0z-j%psFz&XdotKY!TV`CUuW)JX z(Qm66^Dv~svC817Z<4Wa@$NXqJUvV@PygFAAM^L`6WwJhXu>!5^DJvj>-!U?w<6wJ z8zi723Y9m|-k_qSr;Xdil*dy=keR}|y?p=f>H`oV$ZcWsCxvSk$B+;#H<=3@QhS57 z$`ugUkeK<9ODceP9?w&y_mI>F7J%gXaNxPnX9O(F1u5hxLxO+{Jd|N*SmP!pQ=IpN zJ0QeqlWq~X7O}|!=Ld*6-kGJ20+s#p1#s%dF`0A?r>8PsB@D^zbXrZUN0o~d6+_3% z%*5vGJL%f;7IjSQuATB_c^U04OBE(udj4oU+n+l{DY7)+4k*ViuK14iJoAa7e$Vbe z4}O04wv_BpF(ata>wQr)aJAzo=|OSveZS!Hz`Z^e6fbsWB&0hIA7s&afegNAOLGa1 z2;3*A)pU2~N_87k8BvsU??A2cH3g5PrbG(MD!Lf20i?{MMMTXuIbG;IAMHpbaYTu4 ze}>*1?2DMCYY;S^Tf0*%0Ck(uxuxihay=<6hy)GhmW@nmS0SpmB9i7p-{>CL?(xOK zZQ9(nAfY}Za|_wFz+LD`>y!ADT4k2M>a;K?FBgKQ3bRGofCqc!i`6bz(Wp%}G}Qwi z<`8~W9qC@t_9E)7i_MNxdFsF`u%TR;Tjf6%&dtC!9k0|w@`S=~A1>ckQqUW0JXO7v z@kzt2&oj(jS5n>6@0aAZJNIeSFgW3^vWBYX=Uj? zmg8ukxyItE#L+c%;NHcw7yFEQF(sI + * + * + */ + + +function frown_install() { + + register_hook('plugin_settings', 'addon/frown/frown.php', 'frown_settings'); + register_hook('plugin_settings_post', 'addon/frown/frown.php', 'frown_settings_post'); + + logger("installed frown"); +} + + +function frown_uninstall() { + + unregister_hook('plugin_settings', 'addon/frown/frown.php', 'frown_settings'); + unregister_hook('plugin_settings_post', 'addon/frown/frown.php', 'frown_settings_post'); + + + logger("removed frown"); +} + + + +/** + * + * Callback from the settings post function. + * $post contains the $_POST array. + * We will make sure we've got a valid user account + * and if so set our configuration setting for this person. + * + */ + +function frown_settings_post($a,$post) { + if(! local_user() || (! x($_POST,'frown-submit'))) + return; + set_pconfig(local_user(),'system','no_smilies',intval($_POST['frown'])); + + info( t('Frown settings updated.') . EOL); +} + + +/** + * + * Called from the Plugin Setting form. + * Add our own settings info to the page. + * + */ + + + +function frown_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variable */ + + $enabled = get_pconfig(local_user(),'system','no_smilies'); + $checked = (($enabled) ? ' checked="checked" ' : ''); + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

' . t('Frown Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + /* provide a submit button */ + + $s .= '
'; + +} From 437325c5c8d0e4ed040a46f606646d5e3f1aa483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B6=C3=9Fl?= Date: Mon, 19 Mar 2012 21:20:51 +0000 Subject: [PATCH 3/3] This deactivated the plugin not only when uninstalling it, but also when updating it --- facebook/facebook.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/facebook/facebook.php b/facebook/facebook.php index 1749a058..3ed40c91 100755 --- a/facebook/facebook.php +++ b/facebook/facebook.php @@ -46,6 +46,12 @@ * authenticate to your site to establish identity. We will address this * in a future release. */ + + /** TODO + * - Implement a method for the administrator to delete all configuration data the plugin has created, + * e.g. the app_access_token + * - Implement a configuration option to set the polling interval system-wide + */ define('FACEBOOK_MAXPOSTLEN', 420); @@ -57,8 +63,6 @@ function facebook_install() { 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'); - - if (get_config('facebook', 'realtime_active') == 1) facebook_subscription_add_users(); // Restore settings, if the plugin was installed before } @@ -73,9 +77,6 @@ function facebook_uninstall() { // 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'); - - if (get_config('facebook', 'realtime_active') == 1) facebook_subscription_del_users(); - del_config('facebook', 'app_access_token'); }