summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Facebook/facebookaction.php5
-rw-r--r--plugins/Gravatar/locale/Gravatar.po61
-rw-r--r--plugins/OpenID/openidserver.php2
-rw-r--r--plugins/Realtime/RealtimePlugin.php21
-rw-r--r--plugins/Realtime/realtimeupdate.js58
-rw-r--r--plugins/TemplatePlugin.php2
-rw-r--r--plugins/TwitterBridge/twitter.php98
-rw-r--r--plugins/TwitterBridge/twitterbasicauthclient.php23
8 files changed, 214 insertions, 56 deletions
diff --git a/plugins/Facebook/facebookaction.php b/plugins/Facebook/facebookaction.php
index 705bb2780..24bf215fd 100644
--- a/plugins/Facebook/facebookaction.php
+++ b/plugins/Facebook/facebookaction.php
@@ -445,8 +445,9 @@ class FacebookAction extends Action
$replyto = $this->trimmed('inreplyto');
try {
- $notice = Notice::saveNew($user->id, $content,
- 'web', 1, ($replyto == 'false') ? null : $replyto);
+ $notice = Notice::saveNew($user->id, $content, 'web',
+ array('reply_to' => ($replyto == 'false') ? null : $replyto));
+
} catch (Exception $e) {
$this->showPage($e->getMessage());
return;
diff --git a/plugins/Gravatar/locale/Gravatar.po b/plugins/Gravatar/locale/Gravatar.po
new file mode 100644
index 000000000..1df62b666
--- /dev/null
+++ b/plugins/Gravatar/locale/Gravatar.po
@@ -0,0 +1,61 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-12-11 16:27-0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: GravatarPlugin.php:57
+msgid "Set Gravatar"
+msgstr ""
+
+#: GravatarPlugin.php:60
+msgid "If you want to use your Gravatar image, click \"Add\"."
+msgstr ""
+
+#: GravatarPlugin.php:65
+msgid "Add"
+msgstr ""
+
+#: GravatarPlugin.php:75
+msgid "Remove Gravatar"
+msgstr ""
+
+#: GravatarPlugin.php:78
+msgid "If you want to remove your Gravatar image, click \"Remove\"."
+msgstr ""
+
+#: GravatarPlugin.php:83
+msgid "Remove"
+msgstr ""
+
+#: GravatarPlugin.php:88
+msgid "To use a Gravatar first enter in an email address."
+msgstr ""
+
+#: GravatarPlugin.php:137
+msgid "You do not have a email set in your profile."
+msgstr ""
+
+#: GravatarPlugin.php:155
+msgid "Failed to save Gravatar to the DB."
+msgstr ""
+
+#: GravatarPlugin.php:159
+msgid "Gravatar added."
+msgstr ""
+
+#: GravatarPlugin.php:177
+msgid "Gravatar removed."
+msgstr ""
diff --git a/plugins/OpenID/openidserver.php b/plugins/OpenID/openidserver.php
index 181cbdf45..afbca553f 100644
--- a/plugins/OpenID/openidserver.php
+++ b/plugins/OpenID/openidserver.php
@@ -103,7 +103,7 @@ class OpenidserverAction extends Action
$response = $this->generateDenyResponse($request);
} else {
//invalid
- $this->clientError(sprintf(_m('You are not authorized to use the identity %s'),$request->identity),$code=403);
+ $this->clientError(sprintf(_m('You are not authorized to use the identity %s.'),$request->identity),$code=403);
}
} else {
$response = $this->oserver->handleRequest($request);
diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php
index 3e33fdaf1..a810b7165 100644
--- a/plugins/Realtime/RealtimePlugin.php
+++ b/plugins/Realtime/RealtimePlugin.php
@@ -59,6 +59,7 @@ class RealtimePlugin extends Plugin
{
$this->replyurl = common_local_url('newnotice');
$this->favorurl = common_local_url('favor');
+ $this->repeaturl = common_local_url('repeat');
// FIXME: need to find a better way to pass this pattern in
$this->deleteurl = common_local_url('deletenotice',
array('notice' => '0000000000'));
@@ -266,6 +267,24 @@ class RealtimePlugin extends Plugin
$profile = $notice->getProfile();
$arr['user']['profile_url'] = $profile->profileurl;
+ // Add needed repeat data
+
+ if (!empty($notice->repeat_of)) {
+ $original = Notice::staticGet('id', $notice->repeat_of);
+ if (!empty($original)) {
+ $arr['retweeted_status']['url'] = $original->bestUrl();
+ $arr['retweeted_status']['html'] = htmlspecialchars($original->rendered);
+ $arr['retweeted_status']['source'] = htmlspecialchars($original->source);
+ $originalProfile = $original->getProfile();
+ $arr['retweeted_status']['user']['profile_url'] = $originalProfile->profileurl;
+ if (!empty($original->reply_to)) {
+ $originalReply = Notice::staticGet('id', $original->reply_to);
+ $arr['retweeted_status']['in_reply_to_status_url'] = $originalReply->bestUrl();
+ }
+ }
+ $original = null;
+ }
+
return $arr;
}
@@ -297,7 +316,7 @@ class RealtimePlugin extends Plugin
function _updateInitialize($timeline, $user_id)
{
- return "RealtimeUpdate.init($user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->deleteurl\"); ";
+ return "RealtimeUpdate.init($user_id, \"$this->replyurl\", \"$this->favorurl\", \"$this->repeaturl\", \"$this->deleteurl\"); ";
}
function _connect()
diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js
index 56a52433f..281d3d82d 100644
--- a/plugins/Realtime/realtimeupdate.js
+++ b/plugins/Realtime/realtimeupdate.js
@@ -32,6 +32,7 @@ RealtimeUpdate = {
_userid: 0,
_replyurl: '',
_favorurl: '',
+ _repeaturl: '',
_deleteurl: '',
_updatecounter: 0,
_maxnotices: 50,
@@ -40,11 +41,12 @@ RealtimeUpdate = {
_paused:false,
_queuedNotices:[],
- init: function(userid, replyurl, favorurl, deleteurl)
+ init: function(userid, replyurl, favorurl, repeaturl, deleteurl)
{
RealtimeUpdate._userid = userid;
RealtimeUpdate._replyurl = replyurl;
RealtimeUpdate._favorurl = favorurl;
+ RealtimeUpdate._repeaturl = repeaturl;
RealtimeUpdate._deleteurl = deleteurl;
RealtimeUpdate._documenttitle = document.title;
@@ -95,6 +97,7 @@ RealtimeUpdate = {
SN.U.FormXHR($('#'+noticeItemID+' .form_favor'));
SN.U.NoticeReplyTo($('#'+noticeItemID));
+ SN.U.FormXHR($('#'+noticeItemID+' .form_repeat'));
SN.U.NoticeWithAttachment($('#'+noticeItemID));
},
@@ -113,11 +116,24 @@ RealtimeUpdate = {
makeNoticeItem: function(data)
{
+ if (data.hasOwnProperty('retweeted_status')) {
+ original = data['retweeted_status'];
+ repeat = data;
+ data = original;
+ unique = repeat['id'];
+ responsible = repeat['user'];
+ } else {
+ original = null;
+ repeat = null;
+ unique = data['id'];
+ responsible = data['user'];
+ }
+
user = data['user'];
html = data['html'].replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'"');
source = data['source'].replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'"');
- ni = "<li class=\"hentry notice\" id=\"notice-"+data['id']+"\">"+
+ ni = "<li class=\"hentry notice\" id=\"notice-"+unique+"\">"+
"<div class=\"entry-title\">"+
"<span class=\"vcard author\">"+
"<a href=\""+user['profile_url']+"\" class=\"url\">"+
@@ -139,20 +155,31 @@ RealtimeUpdate = {
ni = ni+" <a class=\"response\" href=\""+data['in_reply_to_status_url']+"\">in context</a>";
}
- ni = ni+"</div>"+
- "<div class=\"notice-options\">";
+ if (repeat) {
+ ru = repeat['user'];
+ ni = ni + "<span class=\"repeat vcard\">Repeated by " +
+ "<a href=\"" + ru['profile_url'] + "\" class=\"url\">" +
+ "<span class=\"nickname\">"+ ru['screen_name'] + "</span></a></span>";
+ }
+
+ ni = ni+"</div>";
+
+ ni = ni + "<div class=\"notice-options\">";
if (RealtimeUpdate._userid != 0) {
var input = $("form#form_notice fieldset input#token");
var session_key = input.val();
ni = ni+RealtimeUpdate.makeFavoriteForm(data['id'], session_key);
ni = ni+RealtimeUpdate.makeReplyLink(data['id'], data['user']['screen_name']);
- if (RealtimeUpdate._userid == data['user']['id']) {
+ if (RealtimeUpdate._userid == responsible['id']) {
ni = ni+RealtimeUpdate.makeDeleteLink(data['id']);
+ } else if (RealtimeUpdate._userid != user['id']) {
+ ni = ni+RealtimeUpdate.makeRepeatForm(data['id'], session_key);
}
}
- ni = ni+"</div>"+
+ ni = ni+"</div>";
+
"</li>";
return ni;
},
@@ -177,7 +204,22 @@ RealtimeUpdate = {
var rl;
rl = "<a class=\"notice_reply\" href=\""+RealtimeUpdate._replyurl+"?replyto="+nickname+"\" title=\"Reply to this notice\">Reply <span class=\"notice_id\">"+id+"</span></a>";
return rl;
- },
+ },
+
+ makeRepeatForm: function(id, session_key)
+ {
+ var rf;
+ rf = "<form id=\"repeat-"+id+"\" class=\"form_repeat\" method=\"post\" action=\""+RealtimeUpdate._repeaturl+"\">"+
+ "<fieldset>"+
+ "<legend>Favor this notice</legend>"+
+ "<input name=\"token-"+id+"\" type=\"hidden\" id=\"token-"+id+"\" value=\""+session_key+"\"/>"+
+ "<input name=\"notice\" type=\"hidden\" id=\"notice-n"+id+"\" value=\""+id+"\"/>"+
+ "<input type=\"submit\" id=\"repeat-submit-"+id+"\" name=\"repeat-submit-"+id+"\" class=\"submit\" value=\"Favor\" title=\"Repeat this notice\"/>"+
+ "</fieldset>"+
+ "</form>";
+
+ return rf;
+ },
makeDeleteLink: function(id)
{
@@ -309,7 +351,7 @@ RealtimeUpdate = {
{
$('.notices .entry-title a, .notices .entry-content a').bind('click', function() {
window.open(this.href, '');
-
+
return false;
});
diff --git a/plugins/TemplatePlugin.php b/plugins/TemplatePlugin.php
index 5f3ad81f5..18aa8034c 100644
--- a/plugins/TemplatePlugin.php
+++ b/plugins/TemplatePlugin.php
@@ -300,7 +300,7 @@ class TemplateAction extends Action
// verify that user is admin
if (!($user->id == 1))
- $this->clientError(_('only User #1 can update the template'), $code = 401);
+ $this->clientError(_('Only User #1 can update the template.'), $code = 401);
// open the old template
$tpl_file = $this->templateFolder() . '/index.html';
diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php
index b338a200d..003b52682 100644
--- a/plugins/TwitterBridge/twitter.php
+++ b/plugins/TwitterBridge/twitter.php
@@ -179,7 +179,7 @@ function broadcast_oauth($notice, $flink) {
try {
$status = $client->statusesUpdate($statustxt);
} catch (OAuthClientException $e) {
- return process_error($e, $flink);
+ return process_error($e, $flink, $notice);
}
if (empty($status)) {
@@ -188,8 +188,11 @@ function broadcast_oauth($notice, $flink) {
// or the Twitter API might just be behaving flakey.
$errmsg = sprintf('Twitter bridge - No data returned by Twitter API when ' .
- 'trying to send update for %1$s (user id %2$s).',
- $user->nickname, $user->id);
+ 'trying to post notice %d for User %s (user id %d).',
+ $notice->id,
+ $user->nickname,
+ $user->id);
+
common_log(LOG_WARNING, $errmsg);
return false;
@@ -197,8 +200,12 @@ function broadcast_oauth($notice, $flink) {
// Notice crossed the great divide
- $msg = sprintf('Twitter bridge - posted notice %s to Twitter using OAuth.',
- $notice->id);
+ $msg = sprintf('Twitter bridge - posted notice %d to Twitter using ' .
+ 'OAuth for User %s (user id %d).',
+ $notice->id,
+ $user->nickname,
+ $user->id);
+
common_log(LOG_INFO, $msg);
return true;
@@ -215,62 +222,69 @@ function broadcast_basicauth($notice, $flink)
try {
$status = $client->statusesUpdate($statustxt);
- } catch (HTTP_Request2_Exception $e) {
- return process_error($e, $flink);
+ } catch (BasicAuthException $e) {
+ return process_error($e, $flink, $notice);
}
if (empty($status)) {
$errmsg = sprintf('Twitter bridge - No data returned by Twitter API when ' .
- 'trying to send update for %1$s (user id %2$s).',
- $user->nickname, $user->id);
+ 'trying to post notice %d for %s (user id %d).',
+ $notice->id,
+ $user->nickname,
+ $user->id);
+
common_log(LOG_WARNING, $errmsg);
- $errmsg = sprintf('No data returned by Twitter API when ' .
- 'trying to send update for %1$s (user id %2$s).',
- $user->nickname, $user->id);
- common_log(LOG_WARNING, $errmsg);
+ $errmsg = sprintf('No data returned by Twitter API when ' .
+ 'trying to post notice %d for %s (user id %d).',
+ $notice->id,
+ $user->nickname,
+ $user->id);
+ common_log(LOG_WARNING, $errmsg);
return false;
}
- $msg = sprintf('Twitter bridge - posted notice %s to Twitter using basic auth.',
- $notice->id);
+ $msg = sprintf('Twitter bridge - posted notice %d to Twitter using ' .
+ 'HTTP basic auth for User %s (user id %d).',
+ $notice->id,
+ $user->nickname,
+ $user->id);
+
common_log(LOG_INFO, $msg);
return true;
}
-function process_error($e, $flink)
+function process_error($e, $flink, $notice)
{
- $user = $flink->getUser();
- $errmsg = $e->getMessage();
- $delivered = false;
-
- switch($errmsg) {
- case 'The requested URL returned error: 401':
- $logmsg = sprintf('Twiter bridge - User %1$s (user id: %2$s) has an invalid ' .
- 'Twitter screen_name/password combo or an invalid acesss token.',
- $user->nickname, $user->id);
- $delivered = true;
- remove_twitter_link($flink);
- break;
- case 'The requested URL returned error: 403':
- $logmsg = sprintf('Twitter bridge - User %1$s (user id: %2$s) has exceeded ' .
- 'his/her Twitter request limit.',
- $user->nickname, $user->id);
- break;
- default:
- $logmsg = sprintf('Twitter bridge - cURL error trying to send notice to Twitter ' .
- 'for user %1$s (user id: %2$s) - ' .
- 'code: %3$s message: %4$s.',
- $user->nickname, $user->id,
- $e->getCode(), $e->getMessage());
- break;
- }
+ $user = $flink->getUser();
+ $code = $e->getCode();
+
+ $logmsg = sprintf('Twitter bridge - %d posting notice %d for ' .
+ 'User %s (user id: %d): %s.',
+ $code,
+ $notice->id,
+ $user->nickname,
+ $user->id,
+ $e->getMessage());
common_log(LOG_WARNING, $logmsg);
- return $delivered;
+ if ($code == 401) {
+
+ // Probably a revoked or otherwise bad access token - nuke!
+
+ remove_twitter_link($flink);
+ return true;
+
+ } else {
+
+ // For every other case, it's probably some flakiness so try
+ // sending the notice again later (requeue).
+
+ return false;
+ }
}
function format_status($notice)
diff --git a/plugins/TwitterBridge/twitterbasicauthclient.php b/plugins/TwitterBridge/twitterbasicauthclient.php
index 7ee8d7d4c..fd26293f9 100644
--- a/plugins/TwitterBridge/twitterbasicauthclient.php
+++ b/plugins/TwitterBridge/twitterbasicauthclient.php
@@ -32,6 +32,20 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
}
/**
+ * General Exception wrapper for HTTP basic auth errors
+ *
+ * @category Integration
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ *
+ */
+class BasicAuthException extends Exception
+{
+}
+
+/**
* Class for talking to the Twitter API with HTTP Basic Auth.
*
* @category Integration
@@ -169,12 +183,13 @@ class TwitterBasicAuthClient
}
/**
- * Make a HTTP request using cURL.
+ * Make an HTTP request
*
* @param string $url Where to make the request
* @param array $params post parameters
*
* @return mixed the request
+ * @throws BasicAuthException
*/
function httpRequest($url, $params = null, $auth = true)
{
@@ -199,6 +214,12 @@ class TwitterBasicAuthClient
$response = $request->get($url);
}
+ $code = $response->getStatus();
+
+ if ($code < 200 || $code >= 400) {
+ throw new BasicAuthException($response->getBody(), $code);
+ }
+
return $response->getBody();
}