diff options
author | Brion Vibber <brion@pobox.com> | 2010-06-10 15:37:06 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-06-10 15:37:06 -0700 |
commit | b1a68e15b760aa2e588680c9e8c7526a7a6d1d13 (patch) | |
tree | 6100f1aa00f9930433f178173099c0ce67fdc502 /lib | |
parent | 7cc58b97feb822ab999b7fefa3a50ce53a7838d5 (diff) | |
parent | e121d472e7dbb914a85b10bde0a9e2add4d19d11 (diff) |
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 1.0.x
Conflicts:
lib/default.php
lib/util.php
plugins/UrlShortener/UrlShortenerPlugin.php (has been removed?)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/apiaction.php | 1 | ||||
-rw-r--r-- | lib/apiauth.php | 1 | ||||
-rw-r--r-- | lib/apibareauth.php | 3 | ||||
-rw-r--r-- | lib/apiprivateauth.php | 1 | ||||
-rw-r--r-- | lib/atomgroupnoticefeed.php | 5 | ||||
-rw-r--r-- | lib/atomnoticefeed.php | 17 | ||||
-rw-r--r-- | lib/atomusernoticefeed.php | 5 | ||||
-rw-r--r-- | lib/authenticationplugin.php | 1 | ||||
-rw-r--r-- | lib/authorizationplugin.php | 1 | ||||
-rw-r--r-- | lib/default.php | 5 | ||||
-rw-r--r-- | lib/httpclient.php | 14 | ||||
-rw-r--r-- | lib/installer.php | 1 | ||||
-rw-r--r-- | lib/language.php | 27 | ||||
-rw-r--r-- | lib/liberalstomp.php | 27 | ||||
-rw-r--r-- | lib/mail.php | 10 | ||||
-rw-r--r-- | lib/popularnoticesection.php | 2 | ||||
-rw-r--r-- | lib/profileformaction.php | 13 | ||||
-rw-r--r-- | lib/redirectingaction.php | 9 | ||||
-rw-r--r-- | lib/router.php | 5 | ||||
-rw-r--r-- | lib/stompqueuemanager.php | 21 | ||||
-rw-r--r-- | lib/util.php | 14 | ||||
-rw-r--r-- | lib/xrdsoutputter.php | 1 |
22 files changed, 150 insertions, 34 deletions
diff --git a/lib/apiaction.php b/lib/apiaction.php index e481a1ef2..04028aef0 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -28,6 +28,7 @@ * @author Toby Inkster <mail@tobyinkster.co.uk> * @author Zach Copley <zach@status.net> * @copyright 2009 StatusNet, Inc. + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ diff --git a/lib/apiauth.php b/lib/apiauth.php index 9c68e2771..91cb64262 100644 --- a/lib/apiauth.php +++ b/lib/apiauth.php @@ -30,6 +30,7 @@ * @author Sarven Capadisli <csarven@status.net> * @author Zach Copley <zach@status.net> * @copyright 2009-2010 StatusNet, Inc. + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ diff --git a/lib/apibareauth.php b/lib/apibareauth.php index 2d29c1ddd..da7af1261 100644 --- a/lib/apibareauth.php +++ b/lib/apibareauth.php @@ -32,6 +32,7 @@ * @author Sarven Capadisli <csarven@status.net> * @author Zach Copley <zach@status.net> * @copyright 2009 StatusNet, Inc. + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -106,4 +107,4 @@ class ApiBareAuthAction extends ApiAuthAction return false; } -}
\ No newline at end of file +} diff --git a/lib/apiprivateauth.php b/lib/apiprivateauth.php index 5d0033005..5e78c65a1 100644 --- a/lib/apiprivateauth.php +++ b/lib/apiprivateauth.php @@ -31,6 +31,7 @@ * @author Sarven Capadisli <csarven@status.net> * @author Zach Copley <zach@status.net> * @copyright 2009 StatusNet, Inc. + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ diff --git a/lib/atomgroupnoticefeed.php b/lib/atomgroupnoticefeed.php index b4810d04a..c7c36af82 100644 --- a/lib/atomgroupnoticefeed.php +++ b/lib/atomgroupnoticefeed.php @@ -50,12 +50,13 @@ class AtomGroupNoticeFeed extends AtomNoticeFeed * Constructor * * @param Group $group the group for the feed + * @param User $cur the current authenticated user, if any * @param boolean $indent flag to turn indenting on or off * * @return void */ - function __construct($group, $indent = true) { - parent::__construct($indent); + function __construct($group, $cur = null, $indent = true) { + parent::__construct($cur, $indent); $this->group = $group; // TRANS: Title in atom group notice feed. %s is a group name. diff --git a/lib/atomnoticefeed.php b/lib/atomnoticefeed.php index 35a45118c..ef44de4b6 100644 --- a/lib/atomnoticefeed.php +++ b/lib/atomnoticefeed.php @@ -44,9 +44,22 @@ if (!defined('STATUSNET')) */ class AtomNoticeFeed extends Atom10Feed { - function __construct($indent = true) { + var $cur; + + /** + * Constructor - adds a bunch of XML namespaces we need in our + * notice-specific Atom feeds, and allows setting the current + * authenticated user (useful for API methods). + * + * @param User $cur the current authenticated user (optional) + * @param boolean $indent Whether to indent XML output + * + */ + function __construct($cur = null, $indent = true) { parent::__construct($indent); + $this->cur = $cur; + // Feeds containing notice info use these namespaces $this->addNamespace( @@ -115,7 +128,7 @@ class AtomNoticeFeed extends Atom10Feed $source = $this->showSource(); $author = $this->showAuthor(); - $cur = common_current_user(); + $cur = empty($this->cur) ? common_current_user() : $this->cur; $this->addEntryRaw($notice->asAtomEntry(false, $source, $author, $cur)); } diff --git a/lib/atomusernoticefeed.php b/lib/atomusernoticefeed.php index acfcbd75f..785db4915 100644 --- a/lib/atomusernoticefeed.php +++ b/lib/atomusernoticefeed.php @@ -50,13 +50,14 @@ class AtomUserNoticeFeed extends AtomNoticeFeed * Constructor * * @param User $user the user for the feed + * @param User $cur the current authenticated user, if any * @param boolean $indent flag to turn indenting on or off * * @return void */ - function __construct($user, $indent = true) { - parent::__construct($indent); + function __construct($user, $cur = null, $indent = true) { + parent::__construct($cur, $indent); $this->user = $user; if (!empty($user)) { $profile = $user->getProfile(); diff --git a/lib/authenticationplugin.php b/lib/authenticationplugin.php index 0a3763e2e..dbdf20629 100644 --- a/lib/authenticationplugin.php +++ b/lib/authenticationplugin.php @@ -22,6 +22,7 @@ * @category Plugin * @package StatusNet * @author Craig Andrews <candrews@integralblue.com> + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ diff --git a/lib/authorizationplugin.php b/lib/authorizationplugin.php index 3790bccf4..d71f77243 100644 --- a/lib/authorizationplugin.php +++ b/lib/authorizationplugin.php @@ -22,6 +22,7 @@ * @category Plugin * @package StatusNet * @author Craig Andrews <candrews@integralblue.com> + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ diff --git a/lib/default.php b/lib/default.php index 52a4ec783..754cf5728 100644 --- a/lib/default.php +++ b/lib/default.php @@ -309,5 +309,8 @@ $default = 'url' => array('shortener' => 'ur1.ca', 'maxlength' => 25, - 'maxnoticelength' => -1) + 'maxnoticelength' => -1), + 'http' => // HTTP client settings when contacting other sites + array('ssl_cafile' => false // To enable SSL cert validation, point to a CA bundle (eg '/usr/lib/ssl/certs/ca-certificates.crt') + ), ); diff --git a/lib/httpclient.php b/lib/httpclient.php index 384626ae0..b69f718e5 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -132,7 +132,19 @@ class HTTPClient extends HTTP_Request2 // ought to be investigated to see if we can handle // it gracefully in that case as well. $this->config['protocol_version'] = '1.0'; - + + // Default state of OpenSSL seems to have no trusted + // SSL certificate authorities, which breaks hostname + // verification and means we have a hard time communicating + // with other sites' HTTPS interfaces. + // + // Turn off verification unless we've configured a CA bundle. + if (common_config('http', 'ssl_cafile')) { + $this->config['ssl_cafile'] = common_config('http', 'ssl_cafile'); + } else { + $this->config['ssl_verify_peer'] = false; + } + parent::__construct($url, $method, $config); $this->setHeader('User-Agent', $this->userAgent()); } diff --git a/lib/installer.php b/lib/installer.php index 58ffbfef7..1cad2fd20 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -32,6 +32,7 @@ * @author Sarven Capadisli <csarven@status.net> * @author Tom Adams <tom@holizz.com> * @author Zach Copley <zach@status.net> + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license GNU Affero General Public License http://www.gnu.org/licenses/ * @version 0.9.x * @link http://status.net diff --git a/lib/language.php b/lib/language.php index 8009adc9b..1805707ad 100644 --- a/lib/language.php +++ b/lib/language.php @@ -61,7 +61,7 @@ if (!function_exists('dpgettext')) { * Not currently exposed in PHP's gettext module; implemented to be compat * with gettext.h's macros. * - * @param string $domain domain identifier, or null for default domain + * @param string $domain domain identifier * @param string $context context identifier, should be some key like "menu|file" * @param string $msgid English source text * @return string original or translated message @@ -106,7 +106,7 @@ if (!function_exists('dnpgettext')) { * Not currently exposed in PHP's gettext module; implemented to be compat * with gettext.h's macros. * - * @param string $domain domain identifier, or null for default domain + * @param string $domain domain identifier * @param string $context context identifier, should be some key like "menu|file" * @param string $msg singular English source text * @param string $plural plural English source text @@ -180,7 +180,11 @@ function _m($msg/*, ...*/) } /** - * Looks for which plugin we've been called from to set the gettext domain. + * Looks for which plugin we've been called from to set the gettext domain; + * if not in a plugin subdirectory, we'll use the default 'statusnet'. + * + * Note: we can't return null for default domain since most of the PHP gettext + * wrapper functions turn null into "" before passing to the backend library. * * @param array $backtrace debug_backtrace() output * @return string @@ -206,12 +210,19 @@ function _mdomain($backtrace) if (DIRECTORY_SEPARATOR !== '/') { $path = strtr($path, DIRECTORY_SEPARATOR, '/'); } - $cut = strpos($path, '/plugins/'); - if ($cut) { - $cut += strlen('/plugins/'); + $plug = strpos($path, '/plugins/'); + if ($plug === false) { + // We're not in a plugin; return default domain. + return 'statusnet'; + } else { + $cut = $plug + 9; $cut2 = strpos($path, '/', $cut); - if ($cut && $cut2) { - $final = substr($path, $cut, $cut2 - $cut); + if ($cut2) { + $cached[$path] = substr($path, $cut, $cut2 - $cut); + } else { + // We might be running directly from the plugins dir? + // If so, there's no place to store locale info. + return 'statusnet'; } } $cached[$path] = $final; diff --git a/lib/liberalstomp.php b/lib/liberalstomp.php index 3d38953fd..70c22c17e 100644 --- a/lib/liberalstomp.php +++ b/lib/liberalstomp.php @@ -147,5 +147,30 @@ class LiberalStomp extends Stomp } return $frame; } -} + + /** + * Write frame to server + * + * @param StompFrame $stompFrame + */ + protected function _writeFrame (StompFrame $stompFrame) + { + if (!is_resource($this->_socket)) { + require_once 'Stomp/Exception.php'; + throw new StompException('Socket connection hasn\'t been established'); + } + + $data = $stompFrame->__toString(); + + // Make sure the socket's in a writable state; if not, wait a bit. + stream_set_blocking($this->_socket, 1); + + $r = fwrite($this->_socket, $data, strlen($data)); + stream_set_blocking($this->_socket, 0); + if ($r === false || $r == 0) { + $this->_reconnect(); + $this->_writeFrame($stompFrame); + } + } + } diff --git a/lib/mail.php b/lib/mail.php index a4065e8d5..ab5742e33 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -245,6 +245,11 @@ function mail_subscribe_notify_profile($listenee, $other) $other->getBestName(), common_config('site', 'name')); + $blocklink = sprintf(_("If you believe this account is being used abusively, " . + "you can block them from your subscribers list and " . + "report as spam to site administrators at %s"), + common_local_url('block', array('profileid' => $other->id))); + // TRANS: Main body of new-subscriber notification e-mail $body = sprintf(_('%1$s is now listening to your notices on %2$s.'."\n\n". "\t".'%3$s'."\n\n". @@ -264,9 +269,10 @@ function mail_subscribe_notify_profile($listenee, $other) ($other->homepage) ? // TRANS: Profile info line in new-subscriber notification e-mail sprintf(_("Homepage: %s"), $other->homepage) . "\n" : '', - ($other->bio) ? + (($other->bio) ? // TRANS: Profile info line in new-subscriber notification e-mail - sprintf(_("Bio: %s"), $other->bio) . "\n\n" : '', + sprintf(_("Bio: %s"), $other->bio) . "\n" : '') . + "\n\n" . $blocklink . "\n", common_config('site', 'name'), common_local_url('emailsettings')); diff --git a/lib/popularnoticesection.php b/lib/popularnoticesection.php index 3f0241790..f70a972ef 100644 --- a/lib/popularnoticesection.php +++ b/lib/popularnoticesection.php @@ -72,7 +72,7 @@ class PopularNoticeSection extends NoticeSection $qry .= ' GROUP BY notice.id,notice.profile_id,notice.content,notice.uri,' . 'notice.rendered,notice.url,notice.created,notice.modified,' . 'notice.reply_to,notice.is_local,notice.source,notice.conversation, ' . - 'notice.lat,notice.lon,location_id,location_ns,notice.repeat_of,notice.location' . + 'notice.lat,notice.lon,location_id,location_ns,notice.repeat_of' . ' ORDER BY weight DESC'; $offset = 0; diff --git a/lib/profileformaction.php b/lib/profileformaction.php index 0ffafe5fb..51c89a922 100644 --- a/lib/profileformaction.php +++ b/lib/profileformaction.php @@ -60,7 +60,16 @@ class ProfileFormAction extends RedirectingAction $this->checkSessionToken(); if (!common_logged_in()) { - $this->clientError(_('Not logged in.')); + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $this->clientError(_('Not logged in.')); + } else { + // Redirect to login. + common_set_returnto($this->selfUrl()); + $user = common_current_user(); + if (Event::handle('RedirectToLogin', array($this, $user))) { + common_redirect(common_local_url('login'), 303); + } + } return false; } @@ -97,7 +106,7 @@ class ProfileFormAction extends RedirectingAction if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->handlePost(); - $this->returnToArgs(); + $this->returnToPrevious(); } } diff --git a/lib/redirectingaction.php b/lib/redirectingaction.php index f11585274..3a358f891 100644 --- a/lib/redirectingaction.php +++ b/lib/redirectingaction.php @@ -53,12 +53,13 @@ class RedirectingAction extends Action * * To be called only after successful processing. * - * @fixme rename this -- it obscures Action::returnToArgs() which - * returns a list of arguments, and is a bit confusing. + * Note: this was named returnToArgs() up through 0.9.2, which + * caused problems because there's an Action::returnToArgs() + * already which does something different. * * @return void */ - function returnToArgs() + function returnToPrevious() { // Now, gotta figure where we go back to $action = false; @@ -77,7 +78,7 @@ class RedirectingAction extends Action if ($action) { common_redirect(common_local_url($action, $args, $params), 303); } else { - $url = $this->defaultReturnToUrl(); + $url = $this->defaultReturnTo(); } common_redirect($url, 303); } diff --git a/lib/router.php b/lib/router.php index faa26c861..ef5fece13 100644 --- a/lib/router.php +++ b/lib/router.php @@ -136,6 +136,11 @@ class Router $m->connect('main/'.$a, array('action' => $a)); } + // Also need a block variant accepting ID on URL for mail links + $m->connect('main/block/:profileid', + array('action' => 'block'), + array('profileid' => '[0-9]+')); + $m->connect('main/sup/:seconds', array('action' => 'sup'), array('seconds' => '[0-9]+')); diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php index 5d5c7ccfb..91faa8c36 100644 --- a/lib/stompqueuemanager.php +++ b/lib/stompqueuemanager.php @@ -115,14 +115,27 @@ class StompQueueManager extends QueueManager * * @param mixed $object * @param string $queue + * @param string $siteNickname optional override to drop into another site's queue * * @return boolean true on success * @throws StompException on connection or send error */ - public function enqueue($object, $queue) + public function enqueue($object, $queue, $siteNickname=null) { $this->_connect(); - return $this->_doEnqueue($object, $queue, $this->defaultIdx); + if (common_config('queue', 'stomp_enqueue_on')) { + // We're trying to force all writes to a single server. + // WARNING: this might do odd things if that server connection dies. + $idx = array_search(common_config('queue', 'stomp_enqueue_on'), + $this->servers); + if ($idx === false) { + common_log(LOG_ERR, 'queue stomp_enqueue_on setting does not match our server list.'); + $idx = $this->defaultIdx; + } + } else { + $idx = $this->defaultIdx; + } + return $this->_doEnqueue($object, $queue, $idx, $siteNickname); } /** @@ -132,10 +145,10 @@ class StompQueueManager extends QueueManager * @return boolean true on success * @throws StompException on connection or send error */ - protected function _doEnqueue($object, $queue, $idx) + protected function _doEnqueue($object, $queue, $idx, $siteNickname=null) { $rep = $this->logrep($object); - $envelope = array('site' => common_config('site', 'nickname'), + $envelope = array('site' => $siteNickname ? $siteNickname : common_config('site', 'nickname'), 'handler' => $queue, 'payload' => $this->encode($object)); $msg = serialize($envelope); diff --git a/lib/util.php b/lib/util.php index c6d8f814d..d8fb3b65e 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1270,9 +1270,8 @@ function common_enqueue_notice($notice) $transports[] = 'plugin'; } - // @fixme move these checks into QueueManager and/or individual handlers - if ($notice->is_local == Notice::LOCAL_PUBLIC || - $notice->is_local == Notice::LOCAL_NONPUBLIC) { + // We can skip these for gatewayed notices. + if ($notice->isLocal()) { $transports = array_merge($transports, $localTransports); } @@ -1969,6 +1968,15 @@ function common_url_to_nickname($url) $path = preg_replace('@/$@', '', $parts['path']); $path = preg_replace('@^/@', '', $path); $path = basename($path); + + // Hack for MediaWiki user pages, in the form: + // http://example.com/wiki/User:Myname + // ('User' may be localized.) + if (strpos($path, ':')) { + $parts = array_filter(explode(':', $path)); + $path = $parts[count($parts) - 1]; + } + if ($path) { return common_nicknamize($path); } diff --git a/lib/xrdsoutputter.php b/lib/xrdsoutputter.php index 4b77ed5a3..95dc73300 100644 --- a/lib/xrdsoutputter.php +++ b/lib/xrdsoutputter.php @@ -23,6 +23,7 @@ * @package StatusNet * @author Craig Andrews <candrews@integralblue.com> * @copyright 2008 StatusNet, Inc. + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ |