summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-06-26 10:16:27 -0400
committerBrion Vibber <brion@pobox.com>2010-06-26 10:16:27 -0400
commitd9e56e15cc3174093fc994e524d1d9cf402ae8a3 (patch)
treeba673d3417cca00b2db1e7d2c1bd7697f9712215
parentb66709215309126969104ad114874360785f3d57 (diff)
parent9eb5a976b03fae6bd1e1fce6abfe4a6c7964d1ae (diff)
Merge branch 'master' into testing
-rw-r--r--actions/apiaccountverifycredentials.php2
-rw-r--r--actions/apisearchatom.php (renamed from actions/twitapisearchatom.php)12
-rw-r--r--actions/apisearchjson.php (renamed from actions/twitapisearchjson.php)7
-rw-r--r--actions/apisubscriptions.php3
-rw-r--r--actions/apitrends.php (renamed from actions/twitapitrends.php)8
-rw-r--r--actions/showgroup.php10
-rw-r--r--classes/Notice.php28
-rw-r--r--classes/Profile.php10
-rw-r--r--classes/User_group.php15
-rw-r--r--lib/apiaction.php42
-rw-r--r--lib/atomgroupnoticefeed.php19
-rw-r--r--lib/atomnoticefeed.php2
-rw-r--r--lib/avatarlink.php2
-rw-r--r--lib/router.php6
-rw-r--r--locale/de/LC_MESSAGES/statusnet.po2
-rw-r--r--plugins/Recaptcha/RecaptchaPlugin.php30
16 files changed, 147 insertions, 51 deletions
diff --git a/actions/apiaccountverifycredentials.php b/actions/apiaccountverifycredentials.php
index ea61a3205..79416e9b2 100644
--- a/actions/apiaccountverifycredentials.php
+++ b/actions/apiaccountverifycredentials.php
@@ -75,7 +75,7 @@ class ApiAccountVerifyCredentialsAction extends ApiAuthAction
if ($this->format == 'xml') {
$this->initDocument('xml');
- $this->showTwitterXmlUser($twitter_user);
+ $this->showTwitterXmlUser($twitter_user, 'user', true);
$this->endDocument('xml');
} elseif ($this->format == 'json') {
$this->initDocument('json');
diff --git a/actions/twitapisearchatom.php b/actions/apisearchatom.php
index 51e8a8881..60bb8b040 100644
--- a/actions/twitapisearchatom.php
+++ b/actions/apisearchatom.php
@@ -22,7 +22,7 @@
* @category Search
* @package StatusNet
* @author Zach Copley <zach@status.net>
- * @copyright 2008-2009 StatusNet, Inc.
+ * @copyright 2008-2010 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/
*/
@@ -31,6 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
+require_once INSTALLDIR.'/lib/apiprivateauth.php';
+
/**
* Action for outputting search results in Twitter compatible Atom
* format.
@@ -44,10 +46,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*
- * @see ApiAction
+ * @see ApiPrivateAuthAction
*/
-class TwitapisearchatomAction extends ApiAction
+class ApiSearchAtomAction extends ApiPrivateAuthAction
{
var $cnt;
@@ -96,8 +98,11 @@ class TwitapisearchatomAction extends ApiAction
function prepare($args)
{
+ common_debug("in apisearchatom prepare()");
+
parent::prepare($args);
+
$this->query = $this->trimmed('q');
$this->lang = $this->trimmed('lang');
$this->rpp = $this->trimmed('rpp');
@@ -138,6 +143,7 @@ class TwitapisearchatomAction extends ApiAction
function handle($args)
{
parent::handle($args);
+ common_debug("In apisearchatom handle()");
$this->showAtom();
}
diff --git a/actions/twitapisearchjson.php b/actions/apisearchjson.php
index b5c006aa7..e44634684 100644
--- a/actions/twitapisearchjson.php
+++ b/actions/apisearchjson.php
@@ -22,7 +22,7 @@
* @category Search
* @package StatusNet
* @author Zach Copley <zach@status.net>
- * @copyright 2008-2009 StatusNet, Inc.
+ * @copyright 2008-2010 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/
*/
@@ -31,6 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
+require_once INSTALLDIR.'/lib/apiprivateauth.php';
require_once INSTALLDIR.'/lib/jsonsearchresultslist.php';
/**
@@ -44,7 +45,7 @@ require_once INSTALLDIR.'/lib/jsonsearchresultslist.php';
* @see ApiAction
*/
-class TwitapisearchjsonAction extends ApiAction
+class ApiSearchJSONAction extends ApiPrivateAuthAction
{
var $query;
var $lang;
@@ -64,6 +65,8 @@ class TwitapisearchjsonAction extends ApiAction
function prepare($args)
{
+ common_debug("apisearchjson prepare()");
+
parent::prepare($args);
$this->query = $this->trimmed('q');
diff --git a/actions/apisubscriptions.php b/actions/apisubscriptions.php
index 0ba324057..63d65f289 100644
--- a/actions/apisubscriptions.php
+++ b/actions/apisubscriptions.php
@@ -206,7 +206,8 @@ class ApiSubscriptionsAction extends ApiBareAuthAction
{
switch ($this->format) {
case 'xml':
- $this->elementStart('users', array('type' => 'array'));
+ $this->elementStart('users', array('type' => 'array',
+ 'xmlns:statusnet' => 'http://status.net/schema/api/1/'));
foreach ($this->profiles as $profile) {
$this->showProfile(
$profile,
diff --git a/actions/twitapitrends.php b/actions/apitrends.php
index 5a04569a2..5b74636c6 100644
--- a/actions/twitapitrends.php
+++ b/actions/apitrends.php
@@ -22,7 +22,7 @@
* @category Search
* @package StatusNet
* @author Zach Copley <zach@status.net>
- * @copyright 2008-2009 StatusNet, Inc.
+ * @copyright 2008-2010 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/
*/
@@ -31,6 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
+require_once INSTALLDIR.'/lib/apiprivateauth.php';
+
/**
* Returns the top ten queries that are currently trending
*
@@ -43,7 +45,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @see ApiAction
*/
-class TwitapitrendsAction extends ApiAction
+class ApiTrendsAction extends ApiPrivateAuthAction
{
var $callback;
@@ -82,7 +84,7 @@ class TwitapitrendsAction extends ApiAction
*/
function showTrends()
{
- $this->serverError(_('API method under construction.'), $code = 501);
+ $this->serverError(_('API method under construction.'), 501);
}
} \ No newline at end of file
diff --git a/actions/showgroup.php b/actions/showgroup.php
index 3d369e9eb..17c37e4d7 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -430,14 +430,6 @@ class ShowgroupAction extends GroupDesignAction
function showStatistics()
{
- // XXX: WORM cache this
- $members = $this->group->getMembers();
- $members_count = 0;
- /** $member->count() doesn't work. */
- while ($members->fetch()) {
- $members_count++;
- }
-
$this->elementStart('div', array('id' => 'entity_statistics',
'class' => 'section'));
@@ -451,7 +443,7 @@ class ShowgroupAction extends GroupDesignAction
$this->elementStart('dl', 'entity_members');
$this->element('dt', null, _('Members'));
- $this->element('dd', null, (is_int($members_count)) ? $members_count : '0');
+ $this->element('dd', null, $this->group->getMemberCount());
$this->elementEnd('dl');
$this->elementEnd('div');
diff --git a/classes/Notice.php b/classes/Notice.php
index 9ac9e10c1..e6f527439 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -1190,7 +1190,7 @@ class Notice extends Memcached_DataObject
'xmlns:media' => 'http://purl.org/syndication/atommedia',
'xmlns:poco' => 'http://portablecontacts.net/spec/1.0',
'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
- 'xmlns:statusnet' => 'http://status.net/ont/');
+ 'xmlns:statusnet' => 'http://status.net/schema/api/1/');
} else {
$attrs = array();
}
@@ -1225,7 +1225,7 @@ class Notice extends Memcached_DataObject
$xs->element('title', null, common_xml_safe_str($this->content));
if ($author) {
- $xs->raw($profile->asAtomAuthor());
+ $xs->raw($profile->asAtomAuthor($cur));
$xs->raw($profile->asActivityActor());
}
@@ -1238,9 +1238,25 @@ class Notice extends Memcached_DataObject
$xs->element('published', null, common_date_w3dtf($this->created));
$xs->element('updated', null, common_date_w3dtf($this->created));
+ $source = null;
+
+ $ns = $this->getSource();
+
+ if ($ns) {
+ if (!empty($ns->name) && !empty($ns->url)) {
+ $source = '<a href="'
+ . htmlspecialchars($ns->url)
+ . '" rel="nofollow">'
+ . htmlspecialchars($ns->name)
+ . '</a>';
+ } else {
+ $source = $ns->code;
+ }
+ }
+
$noticeInfoAttr = array(
- 'local_id' => $this->id, // local notice ID (useful to clients for ordering)
- 'source' => $this->source, // the client name (source attribution)
+ 'local_id' => $this->id, // local notice ID (useful to clients for ordering)
+ 'source' => $source, // the client name (source attribution)
);
$ns = $this->getSource();
@@ -1252,8 +1268,8 @@ class Notice extends Memcached_DataObject
if (!empty($cur)) {
$noticeInfoAttr['favorite'] = ($cur->hasFave($this)) ? "true" : "false";
- $profile = $cur->getProfile();
- $noticeInfoAttr['repeated'] = ($profile->hasRepeated($this->id)) ? "true" : "false";
+ $profile = $cur->getProfile();
+ $noticeInfoAttr['repeated'] = ($profile->hasRepeated($this->id)) ? "true" : "false";
}
if (!empty($this->repeat_of)) {
diff --git a/classes/Profile.php b/classes/Profile.php
index 54f557ea7..a303469e9 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -849,15 +849,23 @@ class Profile extends Memcached_DataObject
*
* Assumes that Atom has been previously set up as the base namespace.
*
+ * @param Profile $cur the current authenticated user
+ *
* @return string
*/
- function asAtomAuthor()
+ function asAtomAuthor($cur = null)
{
$xs = new XMLStringer(true);
$xs->elementStart('author');
$xs->element('name', null, $this->nickname);
$xs->element('uri', null, $this->getUri());
+ if ($cur != null) {
+ $attrs = Array();
+ $attrs['following'] = $cur->isSubscribed($this) ? 'true' : 'false';
+ $attrs['blocking'] = $cur->hasBlocked($this) ? 'true' : 'false';
+ $xs->element('statusnet:profile_info', $attrs, null);
+ }
$xs->elementEnd('author');
return $xs->getString();
diff --git a/classes/User_group.php b/classes/User_group.php
index 110f08301..e04c46626 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -154,6 +154,21 @@ class User_group extends Memcached_DataObject
return $members;
}
+ function getMemberCount()
+ {
+ // XXX: WORM cache this
+
+ $members = $this->getMembers();
+ $member_count = 0;
+
+ /** $member->count() doesn't work. */
+ while ($members->fetch()) {
+ $member_count++;
+ }
+
+ return $member_count;
+ }
+
function getAdmins($offset=0, $limit=null)
{
$qry =
diff --git a/lib/apiaction.php b/lib/apiaction.php
index 320aa0316..226481778 100644
--- a/lib/apiaction.php
+++ b/lib/apiaction.php
@@ -208,11 +208,13 @@ class ApiAction extends Action
// Is the requesting user following this user?
$twitter_user['following'] = false;
+ $twitter_user['statusnet:blocking'] = false;
$twitter_user['notifications'] = false;
if (isset($this->auth_user)) {
$twitter_user['following'] = $this->auth_user->isSubscribed($profile);
+ $twitter_user['statusnet:blocking'] = $this->auth_user->hasBlocked($profile);
// Notifications on?
$sub = Subscription::pkeyGet(array('subscriber' =>
@@ -346,20 +348,32 @@ class ApiAction extends Action
function twitterGroupArray($group)
{
- $twitter_group=array();
- $twitter_group['id']=$group->id;
- $twitter_group['url']=$group->permalink();
- $twitter_group['nickname']=$group->nickname;
- $twitter_group['fullname']=$group->fullname;
- $twitter_group['original_logo']=$group->original_logo;
- $twitter_group['homepage_logo']=$group->homepage_logo;
- $twitter_group['stream_logo']=$group->stream_logo;
- $twitter_group['mini_logo']=$group->mini_logo;
- $twitter_group['homepage']=$group->homepage;
- $twitter_group['description']=$group->description;
- $twitter_group['location']=$group->location;
- $twitter_group['created']=$this->dateTwitter($group->created);
- $twitter_group['modified']=$this->dateTwitter($group->modified);
+ $twitter_group = array();
+
+ $twitter_group['id'] = $group->id;
+ $twitter_group['url'] = $group->permalink();
+ $twitter_group['nickname'] = $group->nickname;
+ $twitter_group['fullname'] = $group->fullname;
+
+ if (isset($this->auth_user)) {
+ $twitter_group['member'] = $this->auth_user->isMember($group);
+ $twitter_group['blocked'] = Group_block::isBlocked(
+ $group,
+ $this->auth_user->getProfile()
+ );
+ }
+
+ $twitter_group['member_count'] = $group->getMemberCount();
+ $twitter_group['original_logo'] = $group->original_logo;
+ $twitter_group['homepage_logo'] = $group->homepage_logo;
+ $twitter_group['stream_logo'] = $group->stream_logo;
+ $twitter_group['mini_logo'] = $group->mini_logo;
+ $twitter_group['homepage'] = $group->homepage;
+ $twitter_group['description'] = $group->description;
+ $twitter_group['location'] = $group->location;
+ $twitter_group['created'] = $this->dateTwitter($group->created);
+ $twitter_group['modified'] = $this->dateTwitter($group->modified);
+
return $twitter_group;
}
diff --git a/lib/atomgroupnoticefeed.php b/lib/atomgroupnoticefeed.php
index 7934a4f9e..761df587c 100644
--- a/lib/atomgroupnoticefeed.php
+++ b/lib/atomgroupnoticefeed.php
@@ -93,4 +93,23 @@ class AtomGroupNoticeFeed extends AtomNoticeFeed
return $this->group;
}
+ function initFeed()
+ {
+ parent::initFeed();
+
+ $attrs = array();
+
+ if (!empty($this->cur)) {
+ $attrs['member'] = $this->cur->isMember($this->group)
+ ? 'true' : 'false';
+ $attrs['blocked'] = Group_block::isBlocked(
+ $this->group,
+ $this->cur->getProfile()
+ ) ? 'true' : 'false';
+ }
+
+ $attrs['member_count'] = $this->group->getMemberCount();
+
+ $this->element('statusnet:group_info', $attrs, null);
+ }
}
diff --git a/lib/atomnoticefeed.php b/lib/atomnoticefeed.php
index ef44de4b6..6ed803ce4 100644
--- a/lib/atomnoticefeed.php
+++ b/lib/atomnoticefeed.php
@@ -95,7 +95,7 @@ class AtomNoticeFeed extends Atom10Feed
$this->addNamespace(
'statusnet',
- 'http://status.net/ont/'
+ 'http://status.net/schema/api/1/'
);
}
diff --git a/lib/avatarlink.php b/lib/avatarlink.php
index e67799e2e..7d4256d6e 100644
--- a/lib/avatarlink.php
+++ b/lib/avatarlink.php
@@ -76,8 +76,8 @@ class AvatarLink
$alink = new AvatarLink();
$alink->url = $filename;
$alink->height = $size;
+ $alink->width = $size;
if (!empty($filename)) {
- $alink->width = $size;
$alink->type = self::mediatype($filename);
} else {
$alink->url = User_group::defaultLogo($size);
diff --git a/lib/router.php b/lib/router.php
index fec229c9b..7e1e6a2a4 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -667,9 +667,9 @@ class Router
);
// search
- $m->connect('api/search.atom', array('action' => 'twitapisearchatom'));
- $m->connect('api/search.json', array('action' => 'twitapisearchjson'));
- $m->connect('api/trends.json', array('action' => 'twitapitrends'));
+ $m->connect('api/search.atom', array('action' => 'ApiSearchAtom'));
+ $m->connect('api/search.json', array('action' => 'ApiSearchJSON'));
+ $m->connect('api/trends.json', array('action' => 'ApiTrends'));
$m->connect('api/oauth/request_token',
array('action' => 'apioauthrequesttoken'));
diff --git a/locale/de/LC_MESSAGES/statusnet.po b/locale/de/LC_MESSAGES/statusnet.po
index eda01937a..e453e8025 100644
--- a/locale/de/LC_MESSAGES/statusnet.po
+++ b/locale/de/LC_MESSAGES/statusnet.po
@@ -2620,7 +2620,7 @@ msgstr "Profil-Einstellungen ansehen"
#: actions/othersettings.php:123
msgid "Show or hide profile designs."
-msgstr "Prifil-Designs anzeigen oder verstecken."
+msgstr "Profil-Designs anzeigen oder verstecken."
#: actions/othersettings.php:153
msgid "URL shortening service is too long (max 50 chars)."
diff --git a/plugins/Recaptcha/RecaptchaPlugin.php b/plugins/Recaptcha/RecaptchaPlugin.php
index c585da43c..7cc34c568 100644
--- a/plugins/Recaptcha/RecaptchaPlugin.php
+++ b/plugins/Recaptcha/RecaptchaPlugin.php
@@ -62,12 +62,32 @@ class RecaptchaPlugin extends Plugin
{
$action->elementStart('li');
$action->raw('<label for="recaptcha">Captcha</label>');
- if($this->checkssl() === true) {
- $action->raw(recaptcha_get_html($this->public_key), null, true);
- } else {
- $action->raw(recaptcha_get_html($this->public_key));
- }
+
+ // AJAX API will fill this div out.
+ // We're calling that instead of the regular one so we stay compatible
+ // with application/xml+xhtml output as for mobile.
+ $action->element('div', array('id' => 'recaptcha'));
$action->elementEnd('li');
+
+ $action->recaptchaPluginNeedsOutput = true;
+ return true;
+ }
+
+ function onEndShowScripts($action)
+ {
+ if (isset($action->recaptchaPluginNeedsOutput) && $action->recaptchaPluginNeedsOutput) {
+ // Load the AJAX API
+ if ($this->checkssl()) {
+ $url = "https://api-secure.recaptcha.net/js/recaptcha_ajax.js";
+ } else {
+ $url = "http://api.recaptcha.net/js/recaptcha_ajax.js";
+ }
+ $action->script($url);
+
+ // And when we're ready, fill out the captcha!
+ $key = json_encode($this->public_key);
+ $action->inlinescript("\$(function(){Recaptcha.create($key, 'recaptcha');});");
+ }
return true;
}