Merge branch '0.9.x' into location

This commit is contained in:
Evan Prodromou 2009-10-24 19:59:46 -04:00
commit 3c724ccd0d
37 changed files with 504 additions and 334 deletions

49
README
View File

@ -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
--------

View File

@ -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)) {

View File

@ -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';

View File

@ -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);
}

View File

@ -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);

View File

@ -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',

View File

@ -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");
}
}
}

View File

@ -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');

View File

@ -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

View File

@ -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
{

View File

@ -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
{

View File

@ -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'));
return true;
}
// Add in xmlns:fb
/**
* 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,14 +161,23 @@ class FBConnectPlugin extends Plugin
}
}
// Note: this script needs to appear in the <body>
/**
* Add in the Facebook Connect JavaScript stuff
*
* Note: this script needs to appear in the <body>
*
* @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');
$plugin_path = common_path('plugins/Facebook');
$login_url = common_local_url('FBConnectAuth');
$logout_url = common_local_url('logout');
@ -154,6 +224,7 @@ class FBConnectPlugin extends Plugin
$js = sprintf($js, $apikey, $login_url, $logout_url);
// Compress the bugger down a bit
$js = str_replace(' ', '', $js);
$action->raw(" $js"); // leading two spaces to make it line up
@ -161,19 +232,37 @@ class FBConnectPlugin extends Plugin
}
// Note: this script needs to appear as close as possible to </body>
/**
* Add in an additional Facebook Connect script that's supposed to
* appear as close as possible to </body>
*
* @param Action $action the current action
*
* @return void
*
*/
function onEndShowFooter($action)
{
if ($this->reqFbScripts($action)) {
$action->script('http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php');
$action->script('http://static.ak.connect.facebook.com' .
'/js/api_lib/v0.4/FeatureLoader.js.php');
}
}
/**
* Output Facebook Connect specific CSS link
*
* @param Action $action the current action
*
* @return void
*
*/
function onEndShowStatusNetStyles($action)
{
if ($this->reqFbScripts($action)) {
$action->cssLink('plugins/FBConnect/FBConnectPlugin.css');
$action->cssLink('plugins/Facebook/FBConnect.css');
}
}
@ -182,12 +271,13 @@ class FBConnectPlugin extends Plugin
* want to output FB namespace, scripts, CSS, etc. on the pages that
* really need them.
*
* @param Action the action in question
* @param Action $action the current action
*
* @return boolean true
*/
function reqFbScripts($action) {
function reqFbScripts($action)
{
// If you're logged in w/FB Connect, you always need the FB stuff
@ -249,10 +339,19 @@ class FBConnectPlugin extends Plugin
return null;
}
/**
* Add in a Facebook Connect avatar to the primary nav menu
*
* @param Action $action the current action
*
* @return void
*
*/
function onStartPrimaryNav($action)
{
$user = common_current_user();
$connect = 'FBConnectSettings';
if (common_config('xmpp', 'enabled')) {
$connect = 'imsettings';
@ -283,7 +382,7 @@ class FBConnectPlugin extends Plugin
'alt' => 'Facebook Connect User',
'width' => '16'), '');
$iconurl = common_path('plugins/FBConnect/fbfavicon.ico');
$iconurl = common_path('plugins/Facebook/fbfavicon.ico');
$action->element('img', array('id' => 'fb_favicon',
'src' => $iconurl));
@ -295,6 +394,16 @@ class FBConnectPlugin extends Plugin
return true;
}
/**
* Alter the local nav menu to have a Facebook Connect login and
* settings pages
*
* @param Action $action the current action
*
* @return void
*
*/
function onStartShowLocalNavBlock($action)
{
$action_name = get_class($action);
@ -320,6 +429,14 @@ class FBConnectPlugin extends Plugin
return true;
}
/**
* Have the logout process do some Facebook Connect cookie cleanup
*
* @param Action $action the current action
*
* @return void
*/
function onStartLogout($action)
{
$action->logout();
@ -339,9 +456,16 @@ class FBConnectPlugin extends Plugin
return true;
}
/**
* Get the URL of the user's Facebook avatar
*
* @param int $fbuid the Facebook user ID
*
* @return string $url the url for the user's Facebook avatar
*/
function getProfilePicURL($fbuid)
{
$facebook = getFacebook();
$url = null;
@ -361,7 +485,69 @@ class FBConnectPlugin extends Plugin
}
return $url;
}
/**
* Add a Facebook queue item for each notice
*
* @param Notice $notice the notice
* @param array &$transports the list of transports (queues)
*
* @return boolean hook return
*/
function onStartEnqueueNotice($notice, &$transports)
{
array_push($transports, 'facebook');
return true;
}
/**
* broadcast the message when not using queuehandler
*
* @param Notice &$notice the notice
* @param array $queue destination queue
*
* @return boolean hook return
*/
function onUnqueueHandleNotice(&$notice, $queue)
{
if (($queue == 'facebook') && ($this->_isLocal($notice))) {
facebookBroadcastNotice($notice);
return false;
}
return true;
}
/**
* Determine whether the notice was locally created
*
* @param Notice $notice the notice
*
* @return boolean locality
*/
function _isLocal($notice)
{
return ($notice->is_local == Notice::LOCAL_PUBLIC ||
$notice->is_local == Notice::LOCAL_NONPUBLIC);
}
/**
* Add Facebook queuehandler to the list of daemons to start
*
* @param array $daemons the list fo daemons to run
*
* @return boolean hook return
*
*/
function onGetValidDaemons($daemons)
{
array_push($daemons, INSTALLDIR .
'/plugins/Facebook/facebookqueuehandler.php');
return true;
}
}

129
plugins/Facebook/README Normal file
View File

@ -0,0 +1,129 @@
This plugin allows you to use Facebook Connect with StatusNet, provides a
Facebook application for your users, and allows them to update their
Facebook statuses from StatusNet.
Facebook Connect
----------------
Facebook connect allows users to register and login using nothing but their
Facebook credentials. With Facebook Connect, your users can:
- 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
Built-in Facebook Application
-----------------------------
The plugin also installs a StatusNet Facebook application that 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 the StatusNet Facebook plugin and runs on your
host.
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. Add a
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/app/
- Post-Remove Callback URL: http://example.net/mublog/facebook/app/remove
- Post-Add Redirect URL : http://apps.facebook.com/yourapp/
- Canvas Page URL : http://apps.facebook.com/yourapp/
- Connect URL : http://example.net/mublog/
*** ATTENTION ***
These URLs have changed slightly since StatusNet version 0.8.1,
so if you have been using the Facebook app previously, you will
need to update your configuration!
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. (If you don't have "Fancy URLs" on, you'll need to
change http://example.net/mublog/ to http://example.net/mublog/index.php/).
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.
* NOTE: For more under-the-hood detailed instructions about setting up a
Facebook application and getting an API key, check out the
following pages on the Facebook wiki:
http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site
http://wiki.developers.facebook.com/index.php/Creating_your_first_application
Finally you must activate the plugin by adding the following line to your
config.php:
addPlugin('Facebook');
Testing It Out
--------------
If the Facebook plugin is enabled and working, 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.
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"
and you should be able to login or register.
From within Facebook, you should also be able to get to the Facebook
application, and run it by hitting the link you specified above when
configuring it:
http://apps.facebook.com/yourapp/
That link should be present you with a login screen. After logging in to
the app, you are given the option to update their Facebook status via
StatusNet.
* 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.
Offline Queue Handling
----------------------
For larger sites needing better performance it's possible to enable queuing
and have users' notices posted to Facebook via a separate "offline"
FacebookQueueHandler (facebookqueuhandler.php in the Facebook plugin
directory), which will be started by the plugin along with their other
daemons when you run scripts/startdaemons.sh. See the StatusNet README for
more about queuing and daemons.
TODO
----
- Invite Facebook friends to use your StatusNet installation via Facebook
Connect
- Auto-subscribe Facebook friends already using StatusNet
- Share StatusNet favorite notices to your Facebook stream
- Allow users to update their Facebook statuses once they have authenticated
with Facebook Connect (no need for them to use the Facebook app if they
don't want to).
- Re-design the whole thing to support multiple instances of StatusNet

View File

@ -2,7 +2,7 @@
/**
* StatusNet, the distributed open-source microblogging tool
*
* Low-level generator for HTML
* Base Facebook Action
*
* PHP version 5
*
@ -22,17 +22,16 @@
* @category Faceboook
* @package StatusNet
* @author Zach Copley <zach@status.net>
* @copyright 2008 StatusNet, Inc.
* @copyright 2008-2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA'))
{
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/facebookutil.php';
require_once INSTALLDIR . '/plugins/Facebook/facebookutil.php';
require_once INSTALLDIR . '/lib/noticeform.php';
class FacebookAction extends Action
@ -45,17 +44,6 @@ class FacebookAction extends Action
var $app_uri = null;
var $app_name = null;
/**
* Constructor
*
* Just wraps the HTMLOutputter constructor.
*
* @param string $output URI to output to, default = stdout
* @param boolean $indent Whether to indent output, default true
*
* @see XMLOutputter::__construct
* @see HTMLOutputter::__construct
*/
function __construct($output='php://output', $indent=true, $facebook=null, $flink=null)
{
parent::__construct($output, $indent);
@ -110,8 +98,6 @@ class FacebookAction extends Action
* For Facebook we don't want to actually output any headers,
* DTD info, etc. Just Stylesheet and JavaScript links.
*
* If $type isn't specified, will attempt to do content negotiation.
*
* @param string $type MIME type to use; default is to do negotation.
*
* @return void
@ -139,8 +125,6 @@ class FacebookAction extends Action
/**
* Show notice form.
*
* MAY overload if no notice form needed... or direct message box????
*
* @return nothing
*/
function showNoticeForm()
@ -157,10 +141,6 @@ class FacebookAction extends Action
$this->elementEnd('div');
}
function showAside()
{
}
function showHead($error, $success)
{
@ -214,8 +194,6 @@ class FacebookAction extends Action
/**
* Show header of the page.
*
* Calls template methods
*
* @return nothing
*/
function showHeader()

View File

@ -17,9 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/facebookaction.php';
require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebookhomeAction extends FacebookAction
{

View File

@ -21,7 +21,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once(INSTALLDIR.'/lib/facebookaction.php');
require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebookinviteAction extends FacebookAction
{

View File

@ -17,9 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once(INSTALLDIR.'/lib/facebookaction.php');
require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebookinviteAction extends FacebookAction
{
@ -42,7 +44,6 @@ class FacebookinviteAction extends FacebookAction
}
}
function showContent()
{
@ -78,14 +79,11 @@ class FacebookinviteAction extends FacebookAction
function showSuccessContent()
{
}
function showFormContent()
{
}
function title()

View File

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..'));
$shortoptions = 'i::';
$longoptions = array('id::');
@ -31,8 +31,7 @@ Daemon script for pushing new notices to Facebook.
END_OF_FACEBOOK_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
require_once INSTALLDIR . '/lib/facebookutil.php';
require_once INSTALLDIR . '/plugins/Facebook/facebookutil.php';
require_once INSTALLDIR . '/lib/queuehandler.php';
class FacebookQueueHandler extends QueueHandler

View File

@ -17,9 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/facebookaction.php';
require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebookremoveAction extends FacebookAction
{

View File

@ -17,9 +17,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/facebookaction.php';
require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
class FacebooksettingsAction extends FacebookAction
{

View File

@ -17,8 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once INSTALLDIR.'/extlib/facebook/facebook.php';
require_once INSTALLDIR.'/lib/facebookaction.php';
require_once INSTALLDIR . '/plugins/Facebook/facebook/facebook.php';
require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
require_once INSTALLDIR . '/lib/noticelist.php';
define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2
@ -258,3 +258,38 @@ function remove_facebook_app($flink)
}
}
/**
* 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);
}

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -312,3 +312,40 @@ function remove_twitter_link($flink)
}
}
/**
* 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);
}

View File

@ -39,7 +39,6 @@ $daemons = array();
$daemons[] = INSTALLDIR.'/scripts/pluginqueuehandler.php';
$daemons[] = INSTALLDIR.'/scripts/ombqueuehandler.php';
$daemons[] = INSTALLDIR.'/scripts/facebookqueuehandler.php';
$daemons[] = INSTALLDIR.'/scripts/pingqueuehandler.php';
if(common_config('xmpp','enabled')) {

View File

@ -47,7 +47,9 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
array('127.0.0.1/\'test',
'<a href="http://127.0.0.1/\'test" title="http://127.0.0.1/\'test" rel="external">127.0.0.1/\'test</a>'),
array('127.0.0.1/"test',
'<a href="http://127.0.0.1/&quot;test" title="http://127.0.0.1/&quot;test" rel="external">127.0.0.1/&quot;test</a>'),
'<a href="http://127.0.0.1/" title="http://127.0.0.1/" rel="external">127.0.0.1/</a>&quot;test'),
array('127.0.0.1/test"test',
'<a href="http://127.0.0.1/test" title="http://127.0.0.1/test" rel="external">127.0.0.1/test</a>&quot;test'),
array('127.0.0.1/-test',
'<a href="http://127.0.0.1/-test" title="http://127.0.0.1/-test" rel="external">127.0.0.1/-test</a>'),
array('127.0.0.1/_test',
@ -170,6 +172,8 @@ class URLDetectionTest extends PHPUnit_Framework_TestCase
'\'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>\''),
array('"http://example.com"',
'&quot;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>&quot;'),
array('"http://example.com/"',
'&quot;<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com/</a>&quot;'),
array('http://example.com',
'<a href="http://example.com/" title="http://example.com/" rel="external">http://example.com</a>'),
array('(http://example.com)',