summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrenda Wallace <shiny@cpan.org>2009-12-12 22:47:12 +0000
committerBrenda Wallace <shiny@cpan.org>2009-12-12 22:47:12 +0000
commit9d3829df9d29581c1d0281e57fda8ba4452ce2c2 (patch)
treea196e99a9de45a982b76f5c4cef24b7dfc57d21b /lib
parenta5c11cc92a277c3af6f9b18b1ffaf6dc5f90f5cc (diff)
parent438a0d7f1c23d176f380d6f5dba181ec54722b83 (diff)
Merge commit 'origin/0.9.x' into 0.9.x
Diffstat (limited to 'lib')
-rw-r--r--lib/action.php30
-rw-r--r--lib/api.php50
-rw-r--r--lib/command.php8
-rw-r--r--lib/language.php3
-rw-r--r--lib/messageform.php2
-rw-r--r--lib/noticeform.php2
-rw-r--r--lib/noticelist.php107
-rw-r--r--lib/oauthstore.php5
-rw-r--r--lib/repeatform.php (renamed from lib/forwardform.php)26
-rw-r--r--lib/router.php25
10 files changed, 200 insertions, 58 deletions
diff --git a/lib/action.php b/lib/action.php
index 87d8a4399..dac0e2583 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -952,6 +952,36 @@ class Action extends HTMLOutputter // lawsuit
}
/**
+ * Integer value of an argument
+ *
+ * @param string $key query key we're interested in
+ * @param string $defValue optional default value (default null)
+ * @param string $maxValue optional max value (default null)
+ * @param string $minValue optional min value (default null)
+ *
+ * @return integer integer value
+ */
+
+ function int($key, $defValue=null, $maxValue=null, $minValue=null)
+ {
+ $arg = strtolower($this->trimmed($key));
+
+ if (is_null($arg) || !is_integer($arg)) {
+ return $defValue;
+ }
+
+ if (!is_null($maxValue)) {
+ $arg = min($arg, $maxValue);
+ }
+
+ if (!is_null($minValue)) {
+ $arg = max($arg, $minValue);
+ }
+
+ return $arg;
+ }
+
+ /**
* Server error
*
* @param string $msg error message to display
diff --git a/lib/api.php b/lib/api.php
index eacb80dbe..b7ab407a1 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -134,17 +134,19 @@ class ApiAction extends Action
$twitter_user['protected'] = false; # not supported by StatusNet yet
$twitter_user['followers_count'] = $profile->subscriberCount();
- $user = $profile->getUser();
$design = null;
+ $user = $profile->getUser();
// Note: some profiles don't have an associated user
- $defaultDesign = Design::siteDesign();
-
if (!empty($user)) {
$design = $user->getDesign();
}
+ if (empty($design)) {
+ $design = Design::siteDesign();
+ }
+
$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);
@@ -163,7 +165,7 @@ class ApiAction extends Action
$timezone = 'UTC';
- if (!empty($user) && !empty($user->timezone)) {
+ if ($user->timezone) {
$timezone = $user->timezone;
}
@@ -214,6 +216,20 @@ class ApiAction extends Action
function twitterStatusArray($notice, $include_user=true)
{
+ $base = $this->twitterSimpleStatusArray($notice, $include_user);
+
+ if (empty($notice->repeat_of)) {
+ return $base;
+ } else {
+ $original = Notice::staticGet('id', $notice->repeat_of);
+ $original_array = $this->twitterSimpleStatusArray($original, $include_user);
+ $original_array['retweeted_status'] = $base;
+ return $original_array;
+ }
+ }
+
+ function twitterSimpleStatusArray($notice, $include_user=true)
+ {
$profile = $notice->getProfile();
$twitter_status = array();
@@ -446,9 +462,9 @@ class ApiAction extends Action
}
}
- function showTwitterXmlStatus($twitter_status)
+ function showTwitterXmlStatus($twitter_status, $tag='status')
{
- $this->elementStart('status');
+ $this->elementStart($tag);
foreach($twitter_status as $element => $value) {
switch ($element) {
case 'user':
@@ -463,11 +479,14 @@ class ApiAction extends Action
case 'geo':
$this->showGeoRSS($value);
break;
+ case 'retweeted_status':
+ $this->showTwitterXmlStatus($value, 'retweeted_status');
+ break;
default:
$this->element($element, null, $value);
}
}
- $this->elementEnd('status');
+ $this->elementEnd($tag);
}
function showTwitterXmlGroup($twitter_group)
@@ -586,7 +605,7 @@ class ApiAction extends Action
$this->endDocument('xml');
}
- function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null)
+ function showRssTimeline($notice, $title, $link, $subtitle, $suplink=null, $logo=null)
{
$this->initDocument('rss');
@@ -600,6 +619,15 @@ class ApiAction extends Action
'href' => $suplink,
'type' => 'application/json'));
}
+
+ if (!is_null($logo)) {
+ $this->elementStart('image');
+ $this->element('link', null, $link);
+ $this->element('title', null, $title);
+ $this->element('url', null, $logo);
+ $this->elementEnd('image');
+ }
+
$this->element('description', null, $subtitle);
$this->element('language', null, 'en-us');
$this->element('ttl', null, '40');
@@ -619,7 +647,7 @@ class ApiAction extends Action
$this->endTwitterRss();
}
- function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null)
+ function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null, $logo=null)
{
$this->initDocument('atom');
@@ -628,6 +656,10 @@ class ApiAction extends Action
$this->element('id', null, $id);
$this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null);
+ if (!is_null($logo)) {
+ $this->element('logo',null,$logo);
+ }
+
if (!is_null($suplink)) {
# For FriendFeed's SUP protocol
$this->element('link', array('rel' => 'http://api.friendfeed.com/2008/03#sup',
diff --git a/lib/command.php b/lib/command.php
index e2a665511..085331f82 100644
--- a/lib/command.php
+++ b/lib/command.php
@@ -433,8 +433,9 @@ class ReplyCommand extends Command
return;
}
- $notice = Notice::saveNew($this->user->id, $this->text, $channel->source(), 1,
- $notice->id);
+ $notice = Notice::saveNew($this->user->id, $this->text, $channel->source(),
+ array('reply_to' => $notice->id));
+
if ($notice) {
$channel->output($this->user, sprintf(_('Reply to %s sent'), $recipient->nickname));
} else {
@@ -584,7 +585,8 @@ class LoginCommand extends Command
function execute($channel)
{
$disabled = common_config('logincommand','disabled');
- if(isset($disabled)) {
+ $disabled = isset($disabled) && $disabled;
+ if($disabled) {
$channel->error($this->user, _('Login command is disabled'));
return;
}
diff --git a/lib/language.php b/lib/language.php
index ab46f1a65..c037d30c3 100644
--- a/lib/language.php
+++ b/lib/language.php
@@ -153,7 +153,7 @@ if (!function_exists('npgettext')) {
*/
function _m($msg/*, ...*/)
{
- $domain = _mdomain(debug_backtrace(false));
+ $domain = _mdomain(debug_backtrace());
$args = func_get_args();
switch(count($args)) {
case 1: return dgettext($domain, $msg);
@@ -272,6 +272,7 @@ function get_nice_language_list()
function get_all_languages() {
return array(
'ar' => array('q' => 0.8, 'lang' => 'ar', 'name' => 'Arabic', 'direction' => 'rtl'),
+ 'arz' => array('q' => 0.8, 'lang' => 'arz', 'name' => 'Egyptian Spoken Arabic', 'direction' => 'rtl'),
'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'),
diff --git a/lib/messageform.php b/lib/messageform.php
index 4df193c6d..0c568e1bd 100644
--- a/lib/messageform.php
+++ b/lib/messageform.php
@@ -154,8 +154,6 @@ class MessageForm extends Form
$contentLimit = Message::maxContent();
- $this->out->inlineScript('maxLength = ' . $contentLimit . ';');
-
if ($contentLimit > 0) {
$this->out->elementStart('dl', 'form_note');
$this->out->element('dt', null, _('Available characters'));
diff --git a/lib/noticeform.php b/lib/noticeform.php
index 0dd3f2d77..593a1e932 100644
--- a/lib/noticeform.php
+++ b/lib/noticeform.php
@@ -178,8 +178,6 @@ class NoticeForm extends Form
$contentLimit = Notice::maxContent();
- $this->out->inlineScript('maxLength = ' . $contentLimit . ';');
-
if ($contentLimit > 0) {
$this->out->elementStart('dl', 'form_note');
$this->out->element('dt', null, _('Available characters'));
diff --git a/lib/noticelist.php b/lib/noticelist.php
index d6ffc9ca9..aa6ea278c 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -147,6 +147,10 @@ class NoticeListItem extends Widget
var $notice = null;
+ /** The notice that was repeated. */
+
+ var $repeat = null;
+
/** The profile of the author of the notice, extracted once for convenience. */
var $profile = null;
@@ -162,8 +166,18 @@ class NoticeListItem extends Widget
function __construct($notice, $out=null)
{
parent::__construct($out);
- $this->notice = $notice;
- $this->profile = $notice->getProfile();
+ if (!empty($notice->repeat_of)) {
+ $original = Notice::staticGet('id', $notice->repeat_of);
+ if (empty($original)) { // could have been deleted
+ $this->notice = $notice;
+ } else {
+ $this->notice = $original;
+ $this->repeat = $notice;
+ }
+ } else {
+ $this->notice = $notice;
+ }
+ $this->profile = $this->notice->getProfile();
}
/**
@@ -202,6 +216,7 @@ class NoticeListItem extends Widget
$this->showNoticeSource();
$this->showNoticeLocation();
$this->showContext();
+ $this->showRepeat();
$this->out->elementEnd('div');
}
@@ -212,7 +227,7 @@ class NoticeListItem extends Widget
$this->out->elementStart('div', 'notice-options');
$this->showFaveForm();
$this->showReplyLink();
- $this->showForwardForm();
+ $this->showRepeatForm();
$this->showDeleteLink();
$this->out->elementEnd('div');
}
@@ -509,6 +524,52 @@ class NoticeListItem extends Widget
}
/**
+ * show a link to the author of repeat
+ *
+ * @return void
+ */
+
+ function showRepeat()
+ {
+ if (!empty($this->repeat)) {
+
+ $repeater = Profile::staticGet('id', $this->repeat->profile_id);
+
+ $attrs = array('href' => $repeater->profileurl,
+ 'class' => 'url');
+
+ if (!empty($repeater->fullname)) {
+ $attrs['title'] = $repeater->fullname . ' (' . $repeater->nickname . ')';
+ }
+
+ $this->out->elementStart('span', 'repeat');
+
+ $this->out->elementStart('a', $attrs);
+
+ $avatar = $repeater->getAvatar(AVATAR_MINI_SIZE);
+
+ $this->out->element('img', array('src' => ($avatar) ?
+ $avatar->displayUrl() :
+ Avatar::defaultImage(AVATAR_MINI_SIZE),
+ 'class' => 'avatar photo',
+ 'width' => AVATAR_MINI_SIZE,
+ 'height' => AVATAR_MINI_SIZE,
+ 'alt' =>
+ ($repeater->fullname) ?
+ $repeater->fullname :
+ $repeater->nickname));
+
+ $this->out->elementEnd('a');
+
+ $text_link = XMLStringer::estring('a', $attrs, $repeater->nickname);
+
+ $this->out->raw(sprintf(_('Repeated by %s'), $text_link));
+
+ $this->out->elementEnd('span');
+ }
+ }
+
+ /**
* show a link to reply to the current notice
*
* Should either do the reply in the current notice form (if available), or
@@ -532,26 +593,6 @@ class NoticeListItem extends Widget
}
/**
- * show the form to forward a notice
- *
- * @return void
- */
-
- function showForwardForm()
- {
- $user = common_current_user();
- if ($user && $user->id != $this->notice->profile_id) {
- $profile = $user->getProfile();
- if ($profile->hasForwarded($this->notice->id)) {
- $this->out->text(_('Forwarded'));
- } else {
- $ff = new ForwardForm($this->out, $this->notice);
- $ff->show();
- }
- }
- }
-
- /**
* if the user is the author, let them delete the notice
*
* @return void
@@ -573,6 +614,26 @@ class NoticeListItem extends Widget
}
/**
+ * show the form to repeat a notice
+ *
+ * @return void
+ */
+
+ function showRepeatForm()
+ {
+ $user = common_current_user();
+ if ($user && $user->id != $this->notice->profile_id) {
+ $profile = $user->getProfile();
+ if ($profile->hasRepeated($this->notice->id)) {
+ $this->out->text(_('Repeated'));
+ } else {
+ $rf = new RepeatForm($this->out, $this->notice);
+ $rf->show();
+ }
+ }
+ }
+
+ /**
* finish the notice
*
* Close the last elements in the notice list item
diff --git a/lib/oauthstore.php b/lib/oauthstore.php
index e34bf8a5e..df63cc151 100644
--- a/lib/oauthstore.php
+++ b/lib/oauthstore.php
@@ -359,9 +359,8 @@ class StatusNetOAuthDataStore extends OAuthDataStore
$notice = Notice::saveNew($author->id,
$omb_notice->getContent(),
'omb',
- false,
- null,
- $omb_notice->getIdentifierURI());
+ array('is_local' => Notice::REMOTE_OMB,
+ 'uri' => $omb_notice->getIdentifierURI()));
common_broadcast_notice($notice, true);
}
diff --git a/lib/forwardform.php b/lib/repeatform.php
index 2052856ae..50e5d6dbe 100644
--- a/lib/forwardform.php
+++ b/lib/repeatform.php
@@ -2,7 +2,7 @@
/**
* StatusNet, the distributed open-source microblogging tool
*
- * Form for forwarding a notice
+ * Form for repeating a notice
*
* PHP version 5
*
@@ -27,14 +27,12 @@
* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
+if (!defined('STATUSNET')) {
exit(1);
}
-require_once INSTALLDIR.'/lib/form.php';
-
/**
- * Form for forwarding a notice
+ * Form for repeating a notice
*
* @category Form
* @package StatusNet
@@ -43,10 +41,10 @@ require_once INSTALLDIR.'/lib/form.php';
* @link http://status.net/
*/
-class ForwardForm extends Form
+class RepeatForm extends Form
{
/**
- * Notice to forward
+ * Notice to repeat
*/
var $notice = null;
@@ -55,7 +53,7 @@ class ForwardForm extends Form
* Constructor
*
* @param HTMLOutputter $out output channel
- * @param Notice $notice notice to forward
+ * @param Notice $notice notice to repeat
*/
function __construct($out=null, $notice=null)
@@ -73,7 +71,7 @@ class ForwardForm extends Form
function id()
{
- return 'forward-' . $this->notice->id;
+ return 'repeat-' . $this->notice->id;
}
/**
@@ -84,7 +82,7 @@ class ForwardForm extends Form
function action()
{
- return common_local_url('forward');
+ return common_local_url('repeat');
}
/**
@@ -106,7 +104,7 @@ class ForwardForm extends Form
*/
function formLegend()
{
- $this->out->element('legend', null, _('Forward this notice'));
+ $this->out->element('legend', null, _('Repeat this notice'));
}
/**
@@ -130,8 +128,8 @@ class ForwardForm extends Form
function formActions()
{
- $this->out->submit('forward-submit-' . $this->notice->id,
- _('Forward'), 'submit', null, _('Forward this notice'));
+ $this->out->submit('repeat-submit-' . $this->notice->id,
+ _('Repeat'), 'submit', null, _('Repeat this notice'));
}
/**
@@ -142,6 +140,6 @@ class ForwardForm extends Form
function formClass()
{
- return 'form_forward';
+ return 'form_repeat';
}
}
diff --git a/lib/router.php b/lib/router.php
index 398135a3e..8f68f86ac 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -99,7 +99,8 @@ class Router
'groupblock', 'groupunblock',
'sandbox', 'unsandbox',
'silence', 'unsilence',
- 'deleteuser', 'forward');
+ 'repeat',
+ 'deleteuser');
foreach ($main as $a) {
$m->connect('main/'.$a, array('action' => $a));
@@ -318,6 +319,18 @@ class Router
'id' => '[a-zA-Z0-9]+',
'format' => '(xml|json|rss|atom)'));
+ $m->connect('api/statuses/retweeted_by_me.:format',
+ array('action' => 'ApiTimelineRetweetedByMe',
+ 'format' => '(xml|json|atom)'));
+
+ $m->connect('api/statuses/retweeted_to_me.:format',
+ array('action' => 'ApiTimelineRetweetedToMe',
+ 'format' => '(xml|json|atom)'));
+
+ $m->connect('api/statuses/retweets_of_me.:format',
+ array('action' => 'ApiTimelineRetweetsOfMe',
+ 'format' => '(xml|json|atom)'));
+
$m->connect('api/statuses/friends.:format',
array('action' => 'ApiUserFriends',
'format' => '(xml|json)'));
@@ -358,6 +371,16 @@ class Router
'id' => '[0-9]+',
'format' => '(xml|json)'));
+ $m->connect('api/statuses/retweet/:id.:format',
+ array('action' => 'ApiStatusesRetweet',
+ 'id' => '[0-9]+',
+ 'format' => '(xml|json)'));
+
+ $m->connect('api/statuses/retweets/:id.:format',
+ array('action' => 'ApiStatusesRetweets',
+ 'id' => '[0-9]+',
+ 'format' => '(xml|json)'));
+
// users
$m->connect('api/users/show.:format',