diff --git a/README b/README index ee75b802ea..03064ba184 100644 --- a/README +++ b/README @@ -526,8 +526,6 @@ This will run eight (for now) queue handlers: of registered users. * xmppconfirmhandler.php - sends confirmation messages to registered users. -* facebookqueuehandler.php - sends queued notices to Facebook for users - of the built-in Facebook application. Note that these queue daemons are pretty raw, and need your care. In particular, they leak memory, and you may want to restart them on a @@ -545,53 +543,6 @@ our kind of hacky home-grown DB-based queue solution. See the "queues" config section below for how to configure to use STOMP. As of this writing, the software has been tested with ActiveMQ ( -Built-in Facebook Application ------------------------------ - -StatusNet's Facebook application allows your users to automatically -update their Facebook statuses with their latest notices, invite -their friends to use the app (and thus your site), view their notice -timelines, and post notices -- all from within Facebook. The application -is built into StatusNet and runs on your host. For automatic Facebook -status updating to work you will need to enable queuing and run the -facebookqueuehandler.php daemon (see the "Queues and daemons" section -above). - -Quick setup instructions*: - -Install the Facebook Developer application on Facebook: - - http://www.facebook.com/developers/ - -Use it to create a new application and generate an API key and secret. -Uncomment the Facebook app section of your config.php and copy in the -key and secret, e.g.: - - # Config section for the built-in Facebook application - $config['facebook']['apikey'] = 'APIKEY'; - $config['facebook']['secret'] = 'SECRET'; - -In Facebook's application editor, specify the following URLs for your app: - -- Canvas Callback URL: http://example.net/mublog/facebook/ -- Post-Remove Callback URL: http://example.net/mublog/facebook/remove -- Post-Add Redirect URL: http://apps.facebook.com/yourapp/ -- Canvas Page URL: http://apps.facebook.com/yourapp/ - -(Replace 'example.net' with your host's URL, 'mublog' with the path -to your StatusNet installation, and 'yourapp' with the name of the -Facebook application you created.) - -Additionally, Choose "Web" for Application type in the Advanced tab. -In the "Canvas setting" section, choose the "FBML" for Render Method, -"Smart Size" for IFrame size, and "Full width (760px)" for Canvas Width. -Everything else can be left with default values. - -*For more detailed instructions please see the installation guide on the -StatusNet wiki: - - http://status.net/trac/wiki/FacebookApplication - Sitemaps -------- diff --git a/classes/Profile.php b/classes/Profile.php index 5fb7bb6782..53d07fb2ff 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -52,6 +52,11 @@ class Profile extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE + function getUser() + { + return User::staticGet('id', $this->id); + } + function getAvatar($width, $height=null) { if (is_null($height)) { diff --git a/lib/api.php b/lib/api.php index 7a63a4a785..9bd2083deb 100644 --- a/lib/api.php +++ b/lib/api.php @@ -134,11 +134,19 @@ class ApiAction extends Action $twitter_user['protected'] = false; # not supported by StatusNet yet $twitter_user['followers_count'] = $profile->subscriberCount(); - // To be supported soon... - $twitter_user['profile_background_color'] = ''; - $twitter_user['profile_text_color'] = ''; - $twitter_user['profile_link_color'] = ''; - $twitter_user['profile_sidebar_fill_color'] = ''; + // Need to pull up the user for some of this + $user = $profile->getUser(); + $design = $user->getDesign(); + $defaultDesign = Design::siteDesign(); + if (!$design) $design = $defaultDesign; + $color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor); + $twitter_user['profile_background_color'] = ($color == null) ? '' : '#'.$color->hexValue(); + $color = Design::toWebColor(empty($design->textcolor) ? $defaultDesign->textcolor : $design->textcolor); + $twitter_user['profile_text_color'] = ($color == null) ? '' : '#'.$color->hexValue(); + $color = Design::toWebColor(empty($design->linkcolor) ? $defaultDesign->linkcolor : $design->linkcolor); + $twitter_user['profile_link_color'] = ($color == null) ? '' : '#'.$color->hexValue(); + $color = Design::toWebColor(empty($design->sidebarcolor) ? $defaultDesign->sidebarcolor : $design->sidebarcolor); + $twitter_user['profile_sidebar_fill_color'] = ($color == null) ? '' : '#'.$color->hexValue(); $twitter_user['profile_sidebar_border_color'] = ''; $twitter_user['friends_count'] = $profile->subscriptionCount(); @@ -147,8 +155,6 @@ class ApiAction extends Action $twitter_user['favourites_count'] = $profile->faveCount(); // British spelling! - // Need to pull up the user for some of this - $user = User::staticGet($profile->id); $timezone = 'UTC'; diff --git a/lib/mail.php b/lib/mail.php index 5bf4d74256..5218059e9d 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -640,75 +640,3 @@ function mail_notify_attn($user, $notice) mail_to_user($user, $subject, $body); } -/** - * Send a mail message to notify a user that her Twitter bridge link - * has stopped working, and therefore has been removed. This can - * happen when the user changes her Twitter password, or otherwise - * revokes access. - * - * @param User $user user whose Twitter bridge link has been removed - * - * @return boolean success flag - */ - -function mail_twitter_bridge_removed($user) -{ - common_init_locale($user->language); - - $profile = $user->getProfile(); - - $subject = sprintf(_('Your Twitter bridge has been disabled.')); - - $site_name = common_config('site', 'name'); - - $body = sprintf(_('Hi, %1$s. We\'re sorry to inform you that your ' . - 'link to Twitter has been disabled. We no longer seem to have ' . - 'permission to update your Twitter status. (Did you revoke ' . - '%3$s\'s access?)' . "\n\n" . - 'You can re-enable your Twitter bridge by visiting your ' . - "Twitter settings page:\n\n\t%2\$s\n\n" . - "Regards,\n%3\$s\n"), - $profile->getBestName(), - common_local_url('twittersettings'), - common_config('site', 'name')); - - common_init_locale(); - return mail_to_user($user, $subject, $body); -} - -/** - * Send a mail message to notify a user that her Facebook Application - * access has been removed. - * - * @param User $user user whose Facebook app link has been removed - * - * @return boolean success flag - */ - -function mail_facebook_app_removed($user) -{ - common_init_locale($user->language); - - $profile = $user->getProfile(); - - $site_name = common_config('site', 'name'); - - $subject = sprintf( - _('Your %1$s Facebook application access has been disabled.', - $site_name)); - - $body = sprintf(_("Hi, %1\$s. We're sorry to inform you that we are " . - 'unable to update your Facebook status from %2$s, and have disabled ' . - 'the Facebook application for your account. This may be because ' . - 'you have removed the Facebook application\'s authorization, or ' . - 'have deleted your Facebook account. You can re-enable the ' . - 'Facebook application and automatic status updating by ' . - "re-installing the %2\$s Facebook application.\n\nRegards,\n\n%2\$s"), - $user->nickname, $site_name); - - common_init_locale(); - return mail_to_user($user, $subject, $body); - -} - - diff --git a/lib/omb.php b/lib/omb.php index 0566701ff1..cd6d6e1b25 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -87,7 +87,7 @@ function omb_broadcast_notice($notice) common_debug('Posting to ' . $rp->postnoticeurl, __FILE__); /* Post notice. */ - $service = new Laconica_OMB_Service_Consumer( + $service = new StatusNet_OMB_Service_Consumer( array(OMB_ENDPOINT_POSTNOTICE => $rp->postnoticeurl)); try { $service->setToken($rp->token, $rp->secret); diff --git a/lib/router.php b/lib/router.php index a5b6a9a304..4fb0834fd0 100644 --- a/lib/router.php +++ b/lib/router.php @@ -86,14 +86,6 @@ class Router $m->connect('doc/:title', array('action' => 'doc')); - // facebook - - $m->connect('facebook', array('action' => 'facebookhome')); - $m->connect('facebook/index.php', array('action' => 'facebookhome')); - $m->connect('facebook/settings.php', array('action' => 'facebooksettings')); - $m->connect('facebook/invite.php', array('action' => 'facebookinvite')); - $m->connect('facebook/remove', array('action' => 'facebookremove')); - // main stuff is repetitive $main = array('login', 'logout', 'register', 'subscribe', diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php index 51261bcd71..72dbc4eede 100644 --- a/lib/unqueuemanager.php +++ b/lib/unqueuemanager.php @@ -48,12 +48,6 @@ class UnQueueManager jabber_public_notice($notice); } break; - case 'facebook': - if ($this->_isLocal($notice)) { - require_once INSTALLDIR . '/lib/facebookutil.php'; - return facebookBroadcastNotice($notice); - } - break; case 'ping': if ($this->_isLocal($notice)) { require_once INSTALLDIR . '/lib/ping.php'; @@ -72,7 +66,7 @@ class UnQueueManager break; default: if (Event::handle('UnqueueHandleNotice', array(&$notice, $queue))) { - throw ServerException("UnQueueManager: Unknown queue: $queue"); + throw new ServerException("UnQueueManager: Unknown queue: $queue"); } } } diff --git a/lib/util.php b/lib/util.php index e641afd4db..b6e89f0bd9 100644 --- a/lib/util.php +++ b/lib/util.php @@ -906,8 +906,6 @@ function common_broadcast_notice($notice, $remote=false) function common_enqueue_notice($notice) { static $localTransports = array('omb', - 'twitter', - 'facebook', 'ping'); static $allTransports = array('sms', 'plugin'); diff --git a/plugins/FBConnect/README b/plugins/FBConnect/README deleted file mode 100644 index 77d57eff92..0000000000 --- a/plugins/FBConnect/README +++ /dev/null @@ -1,76 +0,0 @@ -This plugin allows you to utilize Facebook Connect with StatusNet. -Supported Facebook Connect features: - -- Authenticate (register/login/logout -- works similar to OpenID) -- Associate an existing StatusNet account with a Facebook account -- Disconnect a Facebook account from a StatusNet account - -Future planned functionality: - -- Invite Facebook friends to use your StatusNet installation -- Auto-subscribe Facebook friends already using StatusNet -- Share StatusNet favorite notices to your Facebook stream - -To use the plugin you will need to configure a Facebook application -to point to your StatusNet installation (see the Installation section -below). - -Installation -============ - -If you don't already have the built-in Facebook application configured, -you'll need to log into Facebook and create/configure a new application. -Please follow the instructions in the section titled, "Setting Up Your -Application and Getting an API Key," on the following page of the -Facebook developer wiki: - - http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site - -If you already are using the build-in StatusNet Facebook application, -you can modify your existing application's configuration using the -Facebook Developer Application on Facebook. Use it to edit your -application settings, and under the 'Connect' tab, change the 'Connect -URL' to be the main URL for your StatusNet site. E.g.: - - http://SITE/PATH_TO_STATUSNET/ - -After you application is created and configured, you'll need to add its -API key and secret to your StatusNet config.php file: - - $config['facebook']['apikey'] = 'APIKEY'; - $config['facebook']['secret'] = 'SECRET'; - -Finally, to enable the plugin, add the following stanza to your -config.php: - - addPlugin('FBConnect'); - -To try out the plugin, fire up your browser and connect to: - - http://SITE/PATH_TO_STATUSNET/main/facebooklogin - -or, if you do not have fancy URLs turned on: - - http://SITE/PATH_TO_STATUSNET/index.php/main/facebooklogin - -You should see a page with a blue button that says: "Connect with -Facebook". - -Connect/Disconnect existing account -=================================== - -If the Facebook Connect plugin is enabled, there will be a new Facebook -Connect Settings tab under each user's Connect menu. Users can connect -and disconnect to their Facebook accounts from it. Note: Before a user -can disconnect from Facebook, she must set a normal StatusNet password. -Otherwise, she might not be able to login in to her account in the -future. This is usually only required for users who have used Facebook -Connect to register their StatusNet account, and therefore haven't -already set a local password. - -Helpful links -============= - -Facebook Connect Homepage: -http://developers.facebook.com/connect.php - diff --git a/plugins/FBConnect/FBCLoginGroupNav.php b/plugins/Facebook/FBCLoginGroupNav.php similarity index 100% rename from plugins/FBConnect/FBCLoginGroupNav.php rename to plugins/Facebook/FBCLoginGroupNav.php diff --git a/plugins/FBConnect/FBCSettingsNav.php b/plugins/Facebook/FBCSettingsNav.php similarity index 100% rename from plugins/FBConnect/FBCSettingsNav.php rename to plugins/Facebook/FBCSettingsNav.php diff --git a/plugins/FBConnect/FBC_XDReceiver.php b/plugins/Facebook/FBC_XDReceiver.php similarity index 100% rename from plugins/FBConnect/FBC_XDReceiver.php rename to plugins/Facebook/FBC_XDReceiver.php diff --git a/plugins/FBConnect/FBConnectPlugin.css b/plugins/Facebook/FBConnect.css similarity index 100% rename from plugins/FBConnect/FBConnectPlugin.css rename to plugins/Facebook/FBConnect.css diff --git a/plugins/FBConnect/FBConnectAuth.php b/plugins/Facebook/FBConnectAuth.php similarity index 99% rename from plugins/FBConnect/FBConnectAuth.php rename to plugins/Facebook/FBConnectAuth.php index 647d5def89..b909a49771 100644 --- a/plugins/FBConnect/FBConnectAuth.php +++ b/plugins/Facebook/FBConnectAuth.php @@ -27,7 +27,7 @@ * @link http://status.net/ */ -require_once INSTALLDIR . '/plugins/FBConnect/FBConnectPlugin.php'; +require_once INSTALLDIR . '/plugins/Facebook/FacebookPlugin.php'; class FBConnectauthAction extends Action { diff --git a/plugins/FBConnect/FBConnectLogin.php b/plugins/Facebook/FBConnectLogin.php similarity index 96% rename from plugins/FBConnect/FBConnectLogin.php rename to plugins/Facebook/FBConnectLogin.php index 5696d88489..f146bef7d1 100644 --- a/plugins/FBConnect/FBConnectLogin.php +++ b/plugins/Facebook/FBConnectLogin.php @@ -21,7 +21,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR . '/plugins/FBConnect/FBConnectPlugin.php'; + +require_once INSTALLDIR . '/plugins/Facebook/FacebookPlugin.php'; class FBConnectLoginAction extends Action { diff --git a/plugins/FBConnect/FBConnectSettings.php b/plugins/Facebook/FBConnectSettings.php similarity index 100% rename from plugins/FBConnect/FBConnectSettings.php rename to plugins/Facebook/FBConnectSettings.php diff --git a/plugins/FBConnect/FBConnectPlugin.php b/plugins/Facebook/FacebookPlugin.php similarity index 63% rename from plugins/FBConnect/FBConnectPlugin.php rename to plugins/Facebook/FacebookPlugin.php index 0dacf90122..fc3adcfadf 100644 --- a/plugins/FBConnect/FBConnectPlugin.php +++ b/plugins/Facebook/FacebookPlugin.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * Plugin to enable Facebook Connect + * Plugin to add a StatusNet Facebook application * * PHP version 5 * @@ -27,22 +27,16 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { +if (!defined('STATUSNET')) { exit(1); } define("FACEBOOK_CONNECT_SERVICE", 3); -require_once INSTALLDIR . '/lib/facebookutil.php'; -require_once INSTALLDIR . '/plugins/FBConnect/FBConnectAuth.php'; -require_once INSTALLDIR . '/plugins/FBConnect/FBConnectLogin.php'; -require_once INSTALLDIR . '/plugins/FBConnect/FBConnectSettings.php'; -require_once INSTALLDIR . '/plugins/FBConnect/FBCLoginGroupNav.php'; -require_once INSTALLDIR . '/plugins/FBConnect/FBCSettingsNav.php'; -require_once INSTALLDIR . '/plugins/FBConnect/FBC_XDReceiver.php'; +require_once INSTALLDIR . '/plugins/Facebook/facebookutil.php'; /** - * Plugin to enable Facebook Connect + * Facebook plugin to add a StatusNet Facebook application * * @category Plugin * @package StatusNet @@ -51,22 +45,88 @@ require_once INSTALLDIR . '/plugins/FBConnect/FBC_XDReceiver.php'; * @link http://status.net/ */ -class FBConnectPlugin extends Plugin +class FacebookPlugin extends Plugin { - function __construct() - { - parent::__construct(); - } - // Hook in new actions - function onRouterInitialized(&$m) { + /** + * Add Facebook app actions to the router table + * + * Hook for RouterInitialized event. + * + * @param Net_URL_Mapper &$m path-to-action mapper + * + * @return boolean hook return + */ + + function onRouterInitialized(&$m) + { + + // Facebook App stuff + + $m->connect('facebook/app', array('action' => 'facebookhome')); + $m->connect('facebook/app/index.php', array('action' => 'facebookhome')); + $m->connect('facebook/app/settings.php', + array('action' => 'facebooksettings')); + $m->connect('facebook/app/invite.php', array('action' => 'facebookinvite')); + $m->connect('facebook/app/remove', array('action' => 'facebookremove')); + + // Facebook Connect stuff + $m->connect('main/facebookconnect', array('action' => 'FBConnectAuth')); $m->connect('main/facebooklogin', array('action' => 'FBConnectLogin')); $m->connect('settings/facebook', array('action' => 'FBConnectSettings')); $m->connect('xd_receiver.html', array('action' => 'FBC_XDReceiver')); - } - // Add in xmlns:fb + return true; + } + + /** + * Automatically load the actions and libraries used by the Facebook app + * + * @param Class $cls the class + * + * @return boolean hook return + * + */ + + function onAutoload($cls) + { + switch ($cls) { + case 'FacebookAction': + case 'FacebookhomeAction': + case 'FacebookinviteAction': + case 'FacebookremoveAction': + case 'FacebooksettingsAction': + include_once INSTALLDIR . '/plugins/Facebook/' . + strtolower(mb_substr($cls, 0, -6)) . '.php'; + return false; + case 'FBConnectAuthAction': + case 'FBConnectLoginAction': + case 'FBConnectSettingsAction': + case 'FBC_XDReceiverAction': + include_once INSTALLDIR . '/plugins/Facebook/' . + mb_substr($cls, 0, -6) . '.php'; + return false; + case 'FBCLoginGroupNav': + include_once INSTALLDIR . '/plugins/Facebook/FBCLoginGroupNav.php'; + return false; + case 'FBCSettingsNav': + include_once INSTALLDIR . '/plugins/Facebook/FBCSettingsNav.php'; + return false; + default: + return true; + } + } + + /** + * Override normal HTML output to force the content type to + * text/html and add in xmlns:fb + * + * @param Action $action the current action + * + * @return void + */ + function onStartShowHTML($action) { @@ -78,6 +138,7 @@ class FBConnectPlugin extends Plugin // text/html even though Facebook Connect uses XHTML. This is // A bug in Facebook Connect, and this is a temporary solution // until they fix their JavaScript libs. + header('Content-Type: text/html'); $action->extraHeaders(); @@ -100,22 +161,31 @@ class FBConnectPlugin extends Plugin } } - // Note: this script needs to appear in the + /** + * Add in the Facebook Connect JavaScript stuff + * + * Note: this script needs to appear in the + * + * @param Action $action the current action + * + * @return void + * + */ function onEndShowScripts($action) { if ($this->reqFbScripts($action)) { - $apikey = common_config('facebook', 'apikey'); - $plugin_path = common_path('plugins/FBConnect'); + $apikey = common_config('facebook', 'apikey'); + $plugin_path = common_path('plugins/Facebook'); - $login_url = common_local_url('FBConnectAuth'); + $login_url = common_local_url('FBConnectAuth'); $logout_url = common_local_url('logout'); // XXX: Facebook says we don't need this FB_RequireFeatures(), // but we actually do, for IE and Safari. Gar. - $js = '