summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@status.net>2009-10-27 15:00:35 +0100
committerSarven Capadisli <csarven@status.net>2009-10-27 15:00:35 +0100
commitac47015e2b9b4a82ef497d203fb971b7f128ad41 (patch)
treec9bb929b2062f4437bafea1830a8af08d877015f /lib
parent0e029d728429009e7791ae052df4e9998e309fab (diff)
parent0b4390e7f2322a15f16919425de039d555b3e516 (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'lib')
-rw-r--r--lib/api.php20
-rw-r--r--lib/default.php29
-rw-r--r--lib/facebookaction.php672
-rw-r--r--lib/facebookutil.php260
-rw-r--r--lib/httpclient.php2
-rw-r--r--lib/language.php47
-rw-r--r--lib/mail.php72
-rw-r--r--lib/omb.php2
-rw-r--r--lib/profilelist.php62
-rw-r--r--lib/queuehandler.php77
-rw-r--r--lib/router.php8
-rw-r--r--lib/unqueuemanager.php13
-rw-r--r--lib/util.php20
13 files changed, 195 insertions, 1089 deletions
diff --git a/lib/api.php b/lib/api.php
index 7a63a4a78..9bd2083de 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/default.php b/lib/default.php
index 329b041e9..9f64cc9e4 100644
--- a/lib/default.php
+++ b/lib/default.php
@@ -84,7 +84,8 @@ $default =
'image' => 'http://i.creativecommons.org/l/by/3.0/80x15.png'),
'mail' =>
array('backend' => 'mail',
- 'params' => null),
+ 'params' => null,
+ 'domain_check' => true),
'nickname' =>
array('blacklist' => array(),
'featured' => array()),
@@ -140,24 +141,24 @@ $default =
array('enabled' => true),
'sms' =>
array('enabled' => true),
- 'twitterbridge' =>
+ 'twitterimport' =>
array('enabled' => false),
'integration' =>
array('source' => 'StatusNet', # source attribute for Twitter
'taguri' => $_server.',2009'), # base for tag URIs
- 'twitter' =>
- array('enabled' => true,
- 'consumer_key' => null,
- 'consumer_secret' => null),
+ 'twitter' =>
+ array('enabled' => true,
+ 'consumer_key' => null,
+ 'consumer_secret' => null),
'memcached' =>
array('enabled' => false,
'server' => 'localhost',
'base' => null,
'port' => 11211),
- 'ping' =>
+ 'ping' =>
array('notify' => array()),
'inboxes' =>
- array('enabled' => true), # on by default for new sites
+ array('enabled' => true), # ignored after 0.9.x
'newuser' =>
array('default' => null,
'welcome' => null),
@@ -200,12 +201,12 @@ $default =
'video/mp4',
'video/quicktime',
'video/mpeg'),
- 'file_quota' => 5000000,
- 'user_quota' => 50000000,
- 'monthly_quota' => 15000000,
- 'uploads' => true,
- 'filecommand' => '/usr/bin/file',
- ),
+ 'file_quota' => 5000000,
+ 'user_quota' => 50000000,
+ 'monthly_quota' => 15000000,
+ 'uploads' => true,
+ 'filecommand' => '/usr/bin/file',
+ ),
'group' =>
array('maxaliases' => 3,
'desclimit' => null),
diff --git a/lib/facebookaction.php b/lib/facebookaction.php
deleted file mode 100644
index 3f3a8d3b0..000000000
--- a/lib/facebookaction.php
+++ /dev/null
@@ -1,672 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Low-level generator for HTML
- *
- * PHP version 5
- *
- * LICENCE: This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category Faceboook
- * @package StatusNet
- * @author Zach Copley <zach@status.net>
- * @copyright 2008 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'))
-{
- exit(1);
-}
-
-require_once INSTALLDIR.'/lib/facebookutil.php';
-require_once INSTALLDIR.'/lib/noticeform.php';
-
-class FacebookAction extends Action
-{
-
- var $facebook = null;
- var $fbuid = null;
- var $flink = null;
- var $action = null;
- 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);
-
- $this->facebook = $facebook;
- $this->flink = $flink;
-
- if ($this->flink) {
- $this->fbuid = $flink->foreign_id;
- $this->user = $flink->getUser();
- }
-
- $this->args = array();
- }
-
- function prepare($argarray)
- {
- parent::prepare($argarray);
-
- $this->facebook = getFacebook();
- $this->fbuid = $this->facebook->require_login();
-
- $this->action = $this->trimmed('action');
-
- $app_props = $this->facebook->api_client->Admin_getAppProperties(
- array('canvas_name', 'application_name'));
-
- $this->app_uri = 'http://apps.facebook.com/' . $app_props['canvas_name'];
- $this->app_name = $app_props['application_name'];
-
- $this->flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_SERVICE);
-
- return true;
-
- }
-
- function showStylesheets()
- {
- $this->cssLink('css/display.css', 'base');
- $this->cssLink('css/display.css',null,'screen, projection, tv');
- $this->cssLink('css/facebookapp.css', 'base');
- }
-
- function showScripts()
- {
- $this->script('js/facebookapp.js');
- }
-
- /**
- * Start an Facebook ready HTML document
- *
- * 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
- */
-
- function startHTML($type=null)
- {
- $this->showStylesheets();
- $this->showScripts();
-
- $this->elementStart('div', array('class' => 'facebook-page'));
- }
-
- /**
- * Ends a Facebook ready HTML document
- *
- * @return void
- */
- function endHTML()
- {
- $this->elementEnd('div');
- $this->endXML();
- }
-
- /**
- * Show notice form.
- *
- * MAY overload if no notice form needed... or direct message box????
- *
- * @return nothing
- */
- function showNoticeForm()
- {
- // don't do it for most of the Facebook pages
- }
-
- function showBody()
- {
- $this->elementStart('div', array('id' => 'wrap'));
- $this->showHeader();
- $this->showCore();
- $this->showFooter();
- $this->elementEnd('div');
- }
-
- function showAside()
- {
- }
-
- function showHead($error, $success)
- {
-
- if ($error) {
- $this->element("h1", null, $error);
- }
-
- if ($success) {
- $this->element("h1", null, $success);
- }
-
- $this->elementStart('fb:if-section-not-added', array('section' => 'profile'));
- $this->elementStart('span', array('id' => 'add_to_profile'));
- $this->element('fb:add-section-button', array('section' => 'profile'));
- $this->elementEnd('span');
- $this->elementEnd('fb:if-section-not-added');
-
- }
-
- // Make this into a widget later
- function showLocalNav()
- {
- $this->elementStart('ul', array('class' => 'nav'));
-
- $this->elementStart('li', array('class' =>
- ($this->action == 'facebookhome') ? 'current' : 'facebook_home'));
- $this->element('a',
- array('href' => 'index.php', 'title' => _('Home')), _('Home'));
- $this->elementEnd('li');
-
- if (common_config('invite', 'enabled')) {
- $this->elementStart('li',
- array('class' =>
- ($this->action == 'facebookinvite') ? 'current' : 'facebook_invite'));
- $this->element('a',
- array('href' => 'invite.php', 'title' => _('Invite')), _('Invite'));
- $this->elementEnd('li');
- }
-
- $this->elementStart('li',
- array('class' =>
- ($this->action == 'facebooksettings') ? 'current' : 'facebook_settings'));
- $this->element('a',
- array('href' => 'settings.php',
- 'title' => _('Settings')), _('Settings'));
- $this->elementEnd('li');
-
- $this->elementEnd('ul');
- }
-
- /**
- * Show header of the page.
- *
- * Calls template methods
- *
- * @return nothing
- */
- function showHeader()
- {
- $this->elementStart('div', array('id' => 'header'));
- $this->showLogo();
- $this->showNoticeForm();
- $this->elementEnd('div');
- }
-
- /**
- * Show page, a template method.
- *
- * @return nothing
- */
- function showPage($error = null, $success = null)
- {
- $this->startHTML();
- $this->showHead($error, $success);
- $this->showBody();
- $this->endHTML();
- }
-
- function showInstructions()
- {
-
- $this->elementStart('div', array('class' => 'facebook_guide'));
-
- $this->elementStart('dl', array('class' => 'system_notice'));
- $this->element('dt', null, 'Page Notice');
-
- $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' .
- 'with your username and password. Don\'t have a username yet? ');
- $loginmsg_part2 = _(' a new account.');
-
- $this->elementStart('dd');
- $this->elementStart('p');
- $this->text(sprintf($loginmsg_part1, common_config('site', 'name')));
- $this->element('a',
- array('href' => common_local_url('register')), _('Register'));
- $this->text($loginmsg_part2);
- $this->elementEnd('p');
- $this->elementEnd('dd');
-
- $this->elementEnd('dl');
- $this->elementEnd('div');
- }
-
- function showLoginForm($msg = null)
- {
-
- $this->elementStart('div', array('id' => 'content'));
- $this->element('h1', null, _('Login'));
-
- if ($msg) {
- $this->element('fb:error', array('message' => $msg));
- }
-
- $this->showInstructions();
-
- $this->elementStart('div', array('id' => 'content_inner'));
-
- $this->elementStart('form', array('method' => 'post',
- 'class' => 'form_settings',
- 'id' => 'login',
- 'action' => 'index.php'));
-
- $this->elementStart('fieldset');
-
- $this->elementStart('ul', array('class' => 'form_datas'));
- $this->elementStart('li');
- $this->input('nickname', _('Nickname'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->password('password', _('Password'));
- $this->elementEnd('li');
- $this->elementEnd('ul');
-
- $this->submit('submit', _('Login'));
- $this->elementEnd('fieldset');
- $this->elementEnd('form');
-
- $this->elementStart('p');
- $this->element('a', array('href' => common_local_url('recoverpassword')),
- _('Lost or forgotten password?'));
- $this->elementEnd('p');
-
- $this->elementEnd('div');
- $this->elementEnd('div');
-
- }
-
- function updateProfileBox($notice)
- {
-
- // Need to include inline CSS for styling the Profile box
-
- $app_props = $this->facebook->api_client->Admin_getAppProperties(array('icon_url'));
- $icon_url = $app_props['icon_url'];
-
- $style = '<style>
- .entry-title *,
- .entry-content * {
- font-size:14px;
- font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
- }
- .entry-title a,
- .entry-content a {
- color:#002E6E;
- }
-
- .entry-title .vcard .photo {
- float:left;
- display:inline;
- margin-right:11px;
- margin-bottom:11px
- }
- .entry-title {
- margin-bottom:11px;
- }
- .entry-title p.entry-content {
- display:inline;
- margin-left:5px;
- }
-
- div.entry-content {
- clear:both;
- }
- div.entry-content dl,
- div.entry-content dt,
- div.entry-content dd {
- display:inline;
- text-transform:lowercase;
- }
-
- div.entry-content dd,
- div.entry-content .device dt {
- margin-left:0;
- margin-right:5px;
- }
- div.entry-content dl.timestamp dt,
- div.entry-content dl.response dt {
- display:none;
- }
- div.entry-content dd a {
- display:inline-block;
- }
-
- #facebook_statusnet_app {
- text-indent:-9999px;
- height:16px;
- width:16px;
- display:block;
- background:url('.$icon_url.') no-repeat 0 0;
- float:right;
- }
- </style>';
-
- $this->xw->openMemory();
-
- $item = new FacebookProfileBoxNotice($notice, $this);
- $item->show();
-
- $fbml = "<fb:wide>$style " . $this->xw->outputMemory(false) . "</fb:wide>";
- $fbml .= "<fb:narrow>$style " . $this->xw->outputMemory(false) . "</fb:narrow>";
-
- $fbml_main = "<fb:narrow>$style " . $this->xw->outputMemory(false) . "</fb:narrow>";
-
- $this->facebook->api_client->profile_setFBML(null, $this->fbuid, $fbml, null, null, $fbml_main);
-
- $this->xw->openURI('php://output');
- }
-
- /**
- * Generate pagination links
- *
- * @param boolean $have_before is there something before?
- * @param boolean $have_after is there something after?
- * @param integer $page current page
- * @param string $action current action
- * @param array $args rest of query arguments
- *
- * @return nothing
- */
- function pagination($have_before, $have_after, $page, $action, $args=null)
- {
- // Does a little before-after block for next/prev page
- if ($have_before || $have_after) {
- $this->elementStart('div', array('class' => 'pagination'));
- $this->elementStart('dl', null);
- $this->element('dt', null, _('Pagination'));
- $this->elementStart('dd', null);
- $this->elementStart('ul', array('class' => 'nav'));
- }
- if ($have_before) {
- $pargs = array('page' => $page-1);
- $newargs = $args ? array_merge($args, $pargs) : $pargs;
- $this->elementStart('li', array('class' => 'nav_prev'));
- $this->element('a', array('href' => "$this->app_uri/$action?page=$newargs[page]", 'rel' => 'prev'),
- _('After'));
- $this->elementEnd('li');
- }
- if ($have_after) {
- $pargs = array('page' => $page+1);
- $newargs = $args ? array_merge($args, $pargs) : $pargs;
- $this->elementStart('li', array('class' => 'nav_next'));
- $this->element('a', array('href' => "$this->app_uri/$action?page=$newargs[page]", 'rel' => 'next'),
- _('Before'));
- $this->elementEnd('li');
- }
- if ($have_before || $have_after) {
- $this->elementEnd('ul');
- $this->elementEnd('dd');
- $this->elementEnd('dl');
- $this->elementEnd('div');
- }
- }
-
- function saveNewNotice()
- {
-
- $user = $this->flink->getUser();
-
- $content = $this->trimmed('status_textarea');
-
- if (!$content) {
- $this->showPage(_('No notice content!'));
- return;
- } else {
- $content_shortened = common_shorten_links($content);
-
- if (Notice::contentTooLong($content_shortened)) {
- $this->showPage(sprintf(_('That\'s too long. Max notice size is %d chars.'),
- Notice::maxContent()));
- return;
- }
- }
-
- $inter = new CommandInterpreter();
-
- $cmd = $inter->handle_command($user, $content_shortened);
-
- if ($cmd) {
-
- // XXX fix this
-
- $cmd->execute(new WebChannel());
- return;
- }
-
- $replyto = $this->trimmed('inreplyto');
-
- try {
- $notice = Notice::saveNew($user->id, $content,
- 'web', 1, ($replyto == 'false') ? null : $replyto);
- } catch (Exception $e) {
- $this->showPage($e->getMessage());
- return;
- }
-
- common_broadcast_notice($notice);
-
- // Also update the user's Facebook status
- facebookBroadcastNotice($notice);
-
- }
-
-}
-
-class FacebookNoticeForm extends NoticeForm
-{
-
- var $post_action = null;
-
- /**
- * Constructor
- *
- * @param HTMLOutputter $out output channel
- * @param string $action action to return to, if any
- * @param string $content content to pre-fill
- */
-
- function __construct($out=null, $action=null, $content=null,
- $post_action=null, $user=null)
- {
- parent::__construct($out, $action, $content, $user);
- $this->post_action = $post_action;
- }
-
- /**
- * Action of the form
- *
- * @return string URL of the action
- */
-
- function action()
- {
- return $this->post_action;
- }
-
-}
-
-class FacebookNoticeList extends NoticeList
-{
-
- /**
- * constructor
- *
- * @param Notice $notice stream of notices from DB_DataObject
- */
-
- function __construct($notice, $out=null)
- {
- parent::__construct($notice, $out);
- }
-
- /**
- * show the list of notices
- *
- * "Uses up" the stream by looping through it. So, probably can't
- * be called twice on the same list.
- *
- * @return int count of notices listed.
- */
-
- function show()
- {
- $this->out->elementStart('div', array('id' =>'notices_primary'));
- $this->out->element('h2', null, _('Notices'));
- $this->out->elementStart('ul', array('class' => 'notices'));
-
- $cnt = 0;
-
- while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
- $cnt++;
-
- if ($cnt > NOTICES_PER_PAGE) {
- break;
- }
-
- $item = $this->newListItem($this->notice);
- $item->show();
- }
-
- $this->out->elementEnd('ul');
- $this->out->elementEnd('div');
-
- return $cnt;
- }
-
- /**
- * returns a new list item for the current notice
- *
- * Overridden to return a Facebook specific list item.
- *
- * @param Notice $notice the current notice
- *
- * @return FacebookNoticeListItem a list item for displaying the notice
- * formatted for display in the Facebook App.
- */
-
- function newListItem($notice)
- {
- return new FacebookNoticeListItem($notice, $this);
- }
-
-}
-
-class FacebookNoticeListItem extends NoticeListItem
-{
-
- /**
- * constructor
- *
- * Also initializes the profile attribute.
- *
- * @param Notice $notice The notice we'll display
- */
-
- function __construct($notice, $out=null)
- {
- parent::__construct($notice, $out);
- }
-
- /**
- * recipe function for displaying a single notice in the Facebook App.
- *
- * Overridden to strip out some of the controls that we don't
- * want to be available.
- *
- * @return void
- */
-
- function show()
- {
- $this->showStart();
- $this->showNotice();
- $this->showNoticeInfo();
-
- // XXX: Need to update to show attachements and controls
-
- $this->showEnd();
- }
-
-}
-
-class FacebookProfileBoxNotice extends FacebookNoticeListItem
-{
-
- /**
- * constructor
- *
- * Also initializes the profile attribute.
- *
- * @param Notice $notice The notice we'll display
- */
-
- function __construct($notice, $out=null)
- {
- parent::__construct($notice, $out);
- }
-
- /**
- * Recipe function for displaying a single notice in the
- * Facebook App profile notice box
- *
- * @return void
- */
-
- function show()
- {
- $this->showNotice();
- $this->showNoticeInfo();
- $this->showAppLink();
- }
-
- function showAppLink()
- {
-
- $this->facebook = getFacebook();
-
- $app_props = $this->facebook->api_client->Admin_getAppProperties(
- array('canvas_name', 'application_name'));
-
- $this->app_uri = 'http://apps.facebook.com/' . $app_props['canvas_name'];
- $this->app_name = $app_props['application_name'];
-
- $this->out->elementStart('a', array('id' => 'facebook_statusnet_app',
- 'href' => $this->app_uri));
- $this->out->text($this->app_name);
- $this->out->elementEnd('a');
- }
-
-}
diff --git a/lib/facebookutil.php b/lib/facebookutil.php
deleted file mode 100644
index f5121609d..000000000
--- a/lib/facebookutil.php
+++ /dev/null
@@ -1,260 +0,0 @@
-<?php
-/*
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, StatusNet, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * 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.'/lib/noticelist.php';
-
-define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2
-define("FACEBOOK_NOTICE_PREFIX", 1);
-define("FACEBOOK_PROMPTED_UPDATE_PREF", 2);
-
-function getFacebook()
-{
- static $facebook = null;
-
- $apikey = common_config('facebook', 'apikey');
- $secret = common_config('facebook', 'secret');
-
- if ($facebook === null) {
- $facebook = new Facebook($apikey, $secret);
- }
-
- if (empty($facebook)) {
- common_log(LOG_ERR, 'Could not make new Facebook client obj!',
- __FILE__);
- }
-
- return $facebook;
-}
-
-function isFacebookBound($notice, $flink) {
-
- if (empty($flink)) {
- return false;
- }
-
- // Avoid a loop
-
- if ($notice->source == 'Facebook') {
- common_log(LOG_INFO, "Skipping notice $notice->id because its " .
- 'source is Facebook.');
- return false;
- }
-
- // If the user does not want to broadcast to Facebook, move along
-
- if (!($flink->noticesync & FOREIGN_NOTICE_SEND == FOREIGN_NOTICE_SEND)) {
- common_log(LOG_INFO, "Skipping notice $notice->id " .
- 'because user has FOREIGN_NOTICE_SEND bit off.');
- return false;
- }
-
- // If it's not a reply, or if the user WANTS to send @-replies,
- // then, yeah, it can go to Facebook.
-
- if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $notice->content) ||
- ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY)) {
- return true;
- }
-
- return false;
-
-}
-
-function facebookBroadcastNotice($notice)
-{
- $facebook = getFacebook();
- $flink = Foreign_link::getByUserID($notice->profile_id, FACEBOOK_SERVICE);
-
- if (isFacebookBound($notice, $flink)) {
-
- // Okay, we're good to go, update the FB status
-
- $status = null;
- $fbuid = $flink->foreign_id;
- $user = $flink->getUser();
- $attachments = $notice->attachments();
-
- try {
-
- // Get the status 'verb' (prefix) the user has set
-
- // XXX: Does this call count against our per user FB request limit?
- // If so we should consider storing verb elsewhere or not storing
-
- $prefix = $facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX,
- $fbuid);
-
- $status = "$prefix $notice->content";
-
- $can_publish = $facebook->api_client->users_hasAppPermission('publish_stream',
- $fbuid);
-
- $can_update = $facebook->api_client->users_hasAppPermission('status_update',
- $fbuid);
- if (!empty($attachments) && $can_publish == 1) {
- $fbattachment = format_attachments($attachments);
- $facebook->api_client->stream_publish($status, $fbattachment,
- null, null, $fbuid);
- common_log(LOG_INFO,
- "Posted notice $notice->id w/attachment " .
- "to Facebook user's stream (fbuid = $fbuid).");
- } elseif ($can_update == 1 || $can_publish == 1) {
- $facebook->api_client->users_setStatus($status, $fbuid, false, true);
- common_log(LOG_INFO,
- "Posted notice $notice->id to Facebook " .
- "as a status update (fbuid = $fbuid).");
- } else {
- $msg = "Not sending notice $notice->id to Facebook " .
- "because user $user->nickname hasn't given the " .
- 'Facebook app \'status_update\' or \'publish_stream\' permission.';
- common_log(LOG_WARNING, $msg);
- }
-
- // Finally, attempt to update the user's profile box
-
- if ($can_publish == 1 || $can_update == 1) {
- updateProfileBox($facebook, $flink, $notice);
- }
-
- } catch (FacebookRestClientException $e) {
-
- $code = $e->getCode();
-
- common_log(LOG_WARNING, 'Facebook returned error code ' .
- $code . ': ' . $e->getMessage());
- common_log(LOG_WARNING,
- 'Unable to update Facebook status for ' .
- "$user->nickname (user id: $user->id)!");
-
- if ($code == 200 || $code == 250) {
-
- // 200 The application does not have permission to operate on the passed in uid parameter.
- // 250 Updating status requires the extended permission status_update or publish_stream.
- // see: http://wiki.developers.facebook.com/index.php/Users.setStatus#Example_Return_XML
-
- remove_facebook_app($flink);
-
- } else {
-
- // Try sending again later.
-
- return false;
- }
-
- }
- }
-
- return true;
-
-}
-
-function updateProfileBox($facebook, $flink, $notice) {
- $fbaction = new FacebookAction($output = 'php://output',
- $indent = true, $facebook, $flink);
- $fbaction->updateProfileBox($notice);
-}
-
-function format_attachments($attachments)
-{
- $fbattachment = array();
- $fbattachment['media'] = array();
-
- foreach($attachments as $attachment)
- {
- if($enclosure = $attachment->getEnclosure()){
- $fbmedia = get_fbmedia_for_attachment($enclosure);
- }else{
- $fbmedia = get_fbmedia_for_attachment($attachment);
- }
- if($fbmedia){
- $fbattachment['media'][]=$fbmedia;
- }else{
- $fbattachment['name'] = ($attachment->title ?
- $attachment->title : $attachment->url);
- $fbattachment['href'] = $attachment->url;
- }
- }
- if(count($fbattachment['media'])>0){
- unset($fbattachment['name']);
- unset($fbattachment['href']);
- }
- return $fbattachment;
-}
-
-/**
-* given an File objects, returns an associative array suitable for Facebook media
-*/
-function get_fbmedia_for_attachment($attachment)
-{
- $fbmedia = array();
-
- if (strncmp($attachment->mimetype, 'image/', strlen('image/')) == 0) {
- $fbmedia['type'] = 'image';
- $fbmedia['src'] = $attachment->url;
- $fbmedia['href'] = $attachment->url;
- } else if ($attachment->mimetype == 'audio/mpeg') {
- $fbmedia['type'] = 'mp3';
- $fbmedia['src'] = $attachment->url;
- }else if ($attachment->mimetype == 'application/x-shockwave-flash') {
- $fbmedia['type'] = 'flash';
-
- // http://wiki.developers.facebook.com/index.php/Attachment_%28Streams%29
- // says that imgsrc is required... but we have no value to put in it
- // $fbmedia['imgsrc']='';
-
- $fbmedia['swfsrc'] = $attachment->url;
- }else{
- return false;
- }
- return $fbmedia;
-}
-
-function remove_facebook_app($flink)
-{
-
- $user = $flink->getUser();
-
- common_log(LOG_INFO, 'Removing Facebook App Foreign link for ' .
- "user $user->nickname (user id: $user->id).");
-
- $result = $flink->delete();
-
- if (empty($result)) {
- common_log(LOG_ERR, 'Could not remove Facebook App ' .
- "Foreign_link for $user->nickname (user id: $user->id)!");
- common_log_db_error($flink, 'DELETE', __FILE__);
- }
-
- // Notify the user that we are removing their FB app access
-
- $result = mail_facebook_app_removed($user);
-
- if (!$result) {
-
- $msg = 'Unable to send email to notify ' .
- "$user->nickname (user id: $user->id) " .
- 'that their Facebook app link was ' .
- 'removed!';
-
- common_log(LOG_WARNING, $msg);
- }
-
-}
diff --git a/lib/httpclient.php b/lib/httpclient.php
index c8c8ae5b2..f16e31e10 100644
--- a/lib/httpclient.php
+++ b/lib/httpclient.php
@@ -48,7 +48,7 @@ if (!defined('STATUSNET')) {
class HTTPResponse
{
public $code = null;
- public $headers = null;
+ public $headers = array();
public $body = null;
}
diff --git a/lib/language.php b/lib/language.php
index 561a4ddb8..7dcb808c9 100644
--- a/lib/language.php
+++ b/lib/language.php
@@ -101,35 +101,36 @@ function get_nice_language_list()
*/
function get_all_languages() {
return array(
- 'bg' => array('q' => 0.8, 'lang' => 'bg_BG', 'name' => 'Bulgarian', 'direction' => 'ltr'),
- 'ca' => array('q' => 0.5, 'lang' => 'ca_ES', 'name' => 'Catalan', 'direction' => 'ltr'),
- 'cs' => array('q' => 0.5, 'lang' => 'cs_CZ', 'name' => 'Czech', 'direction' => 'ltr'),
- 'de' => array('q' => 0.8, 'lang' => 'de_DE', 'name' => 'German', 'direction' => 'ltr'),
+ 'bg' => array('q' => 0.8, 'lang' => 'bg', 'name' => 'Bulgarian', 'direction' => 'ltr'),
+ 'ca' => array('q' => 0.5, 'lang' => 'ca', 'name' => 'Catalan', 'direction' => 'ltr'),
+ 'cs' => array('q' => 0.5, 'lang' => 'cs', 'name' => 'Czech', 'direction' => 'ltr'),
+ 'de' => array('q' => 0.8, 'lang' => 'de', 'name' => 'German', 'direction' => 'ltr'),
'el' => array('q' => 0.1, 'lang' => 'el', 'name' => 'Greek', 'direction' => 'ltr'),
- 'en-us' => array('q' => 1, 'lang' => 'en_US', 'name' => 'English (US)', 'direction' => 'ltr'),
+ 'en-us' => array('q' => 1, 'lang' => 'en', 'name' => 'English (US)', 'direction' => 'ltr'),
'en-gb' => array('q' => 1, 'lang' => 'en_GB', 'name' => 'English (British)', 'direction' => 'ltr'),
- 'en' => array('q' => 1, 'lang' => 'en_US', 'name' => 'English (US)', 'direction' => 'ltr'),
+ 'en' => array('q' => 1, 'lang' => 'en', 'name' => 'English (US)', 'direction' => 'ltr'),
'es' => array('q' => 1, 'lang' => 'es', 'name' => 'Spanish', 'direction' => 'ltr'),
'fi' => array('q' => 1, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'),
- 'fr-fr' => array('q' => 1, 'lang' => 'fr_FR', 'name' => 'French', 'direction' => 'ltr'),
- 'he' => array('q' => 0.5, 'lang' => 'he_IL', 'name' => 'Hebrew', 'direction' => 'rtl'),
- 'it' => array('q' => 1, 'lang' => 'it_IT', 'name' => 'Italian', 'direction' => 'ltr'),
- 'jp' => array('q' => 0.5, 'lang' => 'ja_JP', 'name' => 'Japanese', 'direction' => 'ltr'),
- 'ko' => array('q' => 0.9, 'lang' => 'ko_KR', 'name' => 'Korean', 'direction' => 'ltr'),
- 'mk' => array('q' => 0.5, 'lang' => 'mk_MK', 'name' => 'Macedonian', 'direction' => 'ltr'),
- 'nb' => array('q' => 0.1, 'lang' => 'nb_NO', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
- 'no' => array('q' => 0.1, 'lang' => 'nb_NO', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
- 'nn' => array('q' => 1, 'lang' => 'nn_NO', 'name' => 'Norwegian (Nynorsk)', 'direction' => 'ltr'),
- 'nl' => array('q' => 0.5, 'lang' => 'nl_NL', 'name' => 'Dutch', 'direction' => 'ltr'),
- 'pl' => array('q' => 0.5, 'lang' => 'pl_PL', 'name' => 'Polish', 'direction' => 'ltr'),
+ 'fr-fr' => array('q' => 1, 'lang' => 'fr', 'name' => 'French', 'direction' => 'ltr'),
+ 'ga' => array('q' => 0.5, 'lang' => 'ga', 'name' => 'Galician', 'direction' => 'ltr'),
+ 'he' => array('q' => 0.5, 'lang' => 'he', 'name' => 'Hebrew', 'direction' => 'rtl'),
+ 'it' => array('q' => 1, 'lang' => 'it', 'name' => 'Italian', 'direction' => 'ltr'),
+ 'jp' => array('q' => 0.5, 'lang' => 'ja', 'name' => 'Japanese', 'direction' => 'ltr'),
+ 'ko' => array('q' => 0.9, 'lang' => 'ko', 'name' => 'Korean', 'direction' => 'ltr'),
+ 'mk' => array('q' => 0.5, 'lang' => 'mk', 'name' => 'Macedonian', 'direction' => 'ltr'),
+ 'nb' => array('q' => 0.1, 'lang' => 'nb', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
+ 'no' => array('q' => 0.1, 'lang' => 'nb', 'name' => 'Norwegian (Bokmål)', 'direction' => 'ltr'),
+ 'nn' => array('q' => 1, 'lang' => 'nn', 'name' => 'Norwegian (Nynorsk)', 'direction' => 'ltr'),
+ 'nl' => array('q' => 0.5, 'lang' => 'nl', 'name' => 'Dutch', 'direction' => 'ltr'),
+ 'pl' => array('q' => 0.5, 'lang' => 'pl', 'name' => 'Polish', 'direction' => 'ltr'),
'pt' => array('q' => 0.1, 'lang' => 'pt', 'name' => 'Portuguese', 'direction' => 'ltr'),
'pt-br' => array('q' => 0.9, 'lang' => 'pt_BR', 'name' => 'Portuguese Brazil', 'direction' => 'ltr'),
- 'ru' => array('q' => 0.9, 'lang' => 'ru_RU', 'name' => 'Russian', 'direction' => 'ltr'),
- 'sv' => array('q' => 0.8, 'lang' => 'sv_SE', 'name' => 'Swedish', 'direction' => 'ltr'),
- 'te' => array('q' => 0.3, 'lang' => 'te_IN', 'name' => 'Telugu', 'direction' => 'ltr'),
- 'tr' => array('q' => 0.5, 'lang' => 'tr_TR', 'name' => 'Turkish', 'direction' => 'ltr'),
- 'uk' => array('q' => 1, 'lang' => 'uk_UA', 'name' => 'Ukrainian', 'direction' => 'ltr'),
- 'vi' => array('q' => 0.8, 'lang' => 'vi_VN', 'name' => 'Vietnamese', 'direction' => 'ltr'),
+ 'ru' => array('q' => 0.9, 'lang' => 'ru', 'name' => 'Russian', 'direction' => 'ltr'),
+ 'sv' => array('q' => 0.8, 'lang' => 'sv', 'name' => 'Swedish', 'direction' => 'ltr'),
+ 'te' => array('q' => 0.3, 'lang' => 'te', 'name' => 'Telugu', 'direction' => 'ltr'),
+ 'tr' => array('q' => 0.5, 'lang' => 'tr', 'name' => 'Turkish', 'direction' => 'ltr'),
+ 'uk' => array('q' => 1, 'lang' => 'uk', 'name' => 'Ukrainian', 'direction' => 'ltr'),
+ 'vi' => array('q' => 0.8, 'lang' => 'vi', 'name' => 'Vietnamese', 'direction' => 'ltr'),
'zh-cn' => array('q' => 0.9, 'lang' => 'zh_CN', 'name' => 'Chinese (Simplified)', 'direction' => 'ltr'),
'zh-hant' => array('q' => 0.2, 'lang' => 'zh_TW', 'name' => 'Chinese (Taiwanese)', 'direction' => 'ltr'),
);
diff --git a/lib/mail.php b/lib/mail.php
index 5bf4d7425..5218059e9 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 0566701ff..cd6d6e1b2 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/profilelist.php b/lib/profilelist.php
index 331430b3e..5cc211e36 100644
--- a/lib/profilelist.php
+++ b/lib/profilelist.php
@@ -62,9 +62,15 @@ class ProfileList extends Widget
function show()
{
- $this->startList();
- $cnt = $this->showProfiles();
- $this->endList();
+ $cnt = 0;
+
+ if (Event::handle('StartProfileList', array($this))) {
+ $this->startList();
+ $cnt = $this->showProfiles();
+ $this->endList();
+ Event::handle('EndProfileList', array($this));
+ }
+
return $cnt;
}
@@ -117,10 +123,19 @@ class ProfileListItem extends Widget
function show()
{
- $this->startItem();
- $this->showProfile();
- $this->showActions();
- $this->endItem();
+ if (Event::handle('StartProfileListItem', array($this))) {
+ $this->startItem();
+ if (Event::handle('StartProfileListItemProfile', array($this))) {
+ $this->showProfile();
+ Event::handle('EndProfileListItemProfile', array($this));
+ }
+ if (Event::handle('StartProfileListItemActions', array($this))) {
+ $this->showActions();
+ Event::handle('EndProfileListItemActions', array($this));
+ }
+ $this->endItem();
+ Event::handle('EndProfileListItem', array($this));
+ }
}
function startItem()
@@ -132,11 +147,29 @@ class ProfileListItem extends Widget
function showProfile()
{
$this->startProfile();
- $this->showAvatar();
- $this->showFullName();
- $this->showLocation();
- $this->showHomepage();
- $this->showBio();
+ if (Event::handle('StartProfileListItemProfileElements', array($this))) {
+ if (Event::handle('StartProfileListItemAvatar', array($this))) {
+ $this->showAvatar();
+ Event::handle('EndProfileListItemAvatar', array($this));
+ }
+ if (Event::handle('StartProfileListItemFullName', array($this))) {
+ $this->showFullName();
+ Event::handle('EndProfileListItemFullName', array($this));
+ }
+ if (Event::handle('StartProfileListItemLocation', array($this))) {
+ $this->showLocation();
+ Event::handle('EndProfileListItemLocation', array($this));
+ }
+ if (Event::handle('StartProfileListItemHomepage', array($this))) {
+ $this->showHomepage();
+ Event::handle('EndProfileListItemHomepage', array($this));
+ }
+ if (Event::handle('StartProfileListItemBio', array($this))) {
+ $this->showBio();
+ Event::handle('EndProfileListItemBio', array($this));
+ }
+ Event::handle('EndProfileListItemProfileElements', array($this));
+ }
$this->endProfile();
}
@@ -225,7 +258,10 @@ class ProfileListItem extends Widget
function showActions()
{
$this->startActions();
- $this->showSubscribeButton();
+ if (Event::handle('StartProfileListItemActionElements', array($this))) {
+ $this->showSubscribeButton();
+ Event::handle('EndProfileListItemActionElements', array($this));
+ }
$this->endActions();
}
diff --git a/lib/queuehandler.php b/lib/queuehandler.php
index 8c65a97c6..cd43b1e09 100644
--- a/lib/queuehandler.php
+++ b/lib/queuehandler.php
@@ -27,6 +27,22 @@ define('CLAIM_TIMEOUT', 1200);
define('QUEUE_HANDLER_MISS_IDLE', 10);
define('QUEUE_HANDLER_HIT_IDLE', 0);
+/**
+ * Base class for queue handlers.
+ *
+ * As extensions of the Daemon class, each queue handler has the ability
+ * to launch itself in the background, at which point it'll pass control
+ * to the configured QueueManager class to poll for updates.
+ *
+ * Subclasses must override at least the following methods:
+ * - transport
+ * - start
+ * - finish
+ * - handle_notice
+ *
+ * Some subclasses will also want to override the idle handler:
+ * - idle
+ */
class QueueHandler extends Daemon
{
@@ -39,6 +55,14 @@ class QueueHandler extends Daemon
}
}
+ /**
+ * How many seconds a polling-based queue manager should wait between
+ * checks for new items to handle.
+ *
+ * Defaults to 60 seconds; override to speed up or slow down.
+ *
+ * @return int timeout in seconds
+ */
function timeout()
{
return 60;
@@ -54,24 +78,69 @@ class QueueHandler extends Daemon
return strtolower($this->class_name().'.'.$this->get_id());
}
+ /**
+ * Return transport keyword which identifies items this queue handler
+ * services; must be defined for all subclasses.
+ *
+ * Must be 8 characters or less to fit in the queue_item database.
+ * ex "email", "jabber", "sms", "irc", ...
+ *
+ * @return string
+ */
function transport()
{
return null;
}
+ /**
+ * Initialization, run when the queue handler starts.
+ * If this function indicates failure, the handler run will be aborted.
+ *
+ * @fixme run() will abort if this doesn't return true,
+ * but some subclasses don't bother.
+ * @return boolean true on success, false on failure
+ */
function start()
{
}
+ /**
+ * Cleanup, run when the queue handler ends.
+ * If this function indicates failure, a warning will be logged.
+ *
+ * @fixme run() will throw warnings if this doesn't return true,
+ * but many subclasses don't bother.
+ * @return boolean true on success, false on failure
+ */
function finish()
{
}
+ /**
+ * Here's the meat of your queue handler -- you're handed a Notice
+ * object, which you may do as you will with.
+ *
+ * If this function indicates failure, a warning will be logged
+ * and the item is placed back in the queue to be re-run.
+ *
+ * @param Notice $notice
+ * @return boolean true on success, false on failure
+ */
function handle_notice($notice)
{
return true;
}
+ /**
+ * Setup and start of run loop for this queue handler as a daemon.
+ * Most of the heavy lifting is passed on to the QueueManager's service()
+ * method, which passes control back to our handle_notice() method for
+ * each notice that comes in on the queue.
+ *
+ * Most of the time this won't need to be overridden in a subclass.
+ *
+ * @return boolean true on success, false on failure
+ */
function run()
{
if (!$this->start()) {
@@ -100,6 +169,14 @@ class QueueHandler extends Daemon
return true;
}
+ /**
+ * Called by QueueHandler after each handled item or empty polling cycle.
+ * This is a good time to e.g. service your XMPP connection.
+ *
+ * Doesn't need to be overridden if there's no maintenance to do.
+ *
+ * @param int $timeout seconds to sleep if there's nothing to do
+ */
function idle($timeout=0)
{
if ($timeout > 0) {
diff --git a/lib/router.php b/lib/router.php
index a5b6a9a30..4fb0834fd 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 6cfe5bcbd..72dbc4eed 100644
--- a/lib/unqueuemanager.php
+++ b/lib/unqueuemanager.php
@@ -48,17 +48,6 @@ class UnQueueManager
jabber_public_notice($notice);
}
break;
- case 'twitter':
- if ($this->_isLocal($notice)) {
- broadcast_twitter($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';
@@ -77,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 be10647fc..b6e89f0bd 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -51,13 +51,23 @@ function common_init_locale($language=null)
function common_init_language()
{
mb_internal_encoding('UTF-8');
+
+ // gettext seems very picky... We first need to setlocale()
+ // to a locale which _does_ exist on the system, and _then_
+ // we can set in another locale that may not be set up
+ // (say, ga_ES for Galego/Galician) it seems to take it.
+ common_init_locale("en_US");
+
$language = common_language();
- // So we don't have to make people install the gettext locales
$locale_set = common_init_locale($language);
- bindtextdomain("statusnet", common_config('site','locale_path'));
+ setlocale(LC_CTYPE, 'C');
+
+ // So we don't have to make people install the gettext locales
+ $path = common_config('site','locale_path');
+ bindtextdomain("statusnet", $path);
bind_textdomain_codeset("statusnet", "UTF-8");
textdomain("statusnet");
- setlocale(LC_CTYPE, 'C');
+
if(!$locale_set) {
common_log(LOG_INFO, 'Language requested:' . $language . ' - locale could not be set. Perhaps that system locale is not installed.', __FILE__);
}
@@ -391,7 +401,7 @@ function common_render_content($text, $notice)
{
$r = common_render_text($text);
$id = $notice->profile_id;
- $r = preg_replace('/(^|[\s\.\,\:\;]+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
+ $r = preg_replace('/(^|\s+)@(['.NICKNAME_FMT.']{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
$r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
$r = preg_replace('/(^|[\s\.\,\:\;]+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r);
$r = preg_replace('/(^|[\s\.\,\:\;]+)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r);
@@ -896,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');