summaryrefslogtreecommitdiff
path: root/lib/apiaction.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-05-21 16:47:57 -0400
committerEvan Prodromou <evan@status.net>2010-05-21 16:47:57 -0400
commit6d8e01ad13dd9bc9e149f43a1eb88671d4737f4d (patch)
tree12f8b318971d1a1eebbb318e3c19142a56dce444 /lib/apiaction.php
parent8a2144aeed2e338ef1b21425b9387086790aa820 (diff)
parentbbfd6eff0c69f038d151d3bf6c8bf9b45a64716f (diff)
Merge branch 'master' of gitorious.org:statusnet/mainline
Diffstat (limited to 'lib/apiaction.php')
-rw-r--r--lib/apiaction.php64
1 files changed, 26 insertions, 38 deletions
diff --git a/lib/apiaction.php b/lib/apiaction.php
index 6ee0a94d9..320aa0316 100644
--- a/lib/apiaction.php
+++ b/lib/apiaction.php
@@ -63,9 +63,12 @@ class ApiAction extends Action
var $count = null;
var $max_id = null;
var $since_id = null;
+ var $source = null;
var $access = self::READ_ONLY; // read (default) or read-write
+ static $reserved_sources = array('web', 'omb', 'ostatus', 'mail', 'xmpp', 'api');
+
/**
* Initialization.
*
@@ -89,6 +92,12 @@ class ApiAction extends Action
header('X-StatusNet-Warning: since parameter is disabled; use since_id');
}
+ $this->source = $this->trimmed('source');
+
+ if (empty($this->source) || in_array($this->source, self::$reserved_sources)) {
+ $this->source = 'api';
+ }
+
return true;
}
@@ -255,7 +264,23 @@ class ApiAction extends Action
$twitter_status['created_at'] = $this->dateTwitter($notice->created);
$twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ?
intval($notice->reply_to) : null;
- $twitter_status['source'] = $this->sourceLink($notice->source);
+
+ $source = null;
+
+ $ns = $notice->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;
+ }
+ }
+
+ $twitter_status['source'] = $source;
$twitter_status['id'] = intval($notice->id);
$replier_profile = null;
@@ -1311,43 +1336,6 @@ class ApiAction extends Action
}
}
- function sourceLink($source)
- {
- $source_name = _($source);
- switch ($source) {
- case 'web':
- case 'xmpp':
- case 'mail':
- case 'omb':
- case 'api':
- break;
- default:
-
- $name = null;
- $url = null;
-
- $ns = Notice_source::staticGet($source);
-
- if ($ns) {
- $name = $ns->name;
- $url = $ns->url;
- } else {
- $app = Oauth_application::staticGet('name', $source);
- if ($app) {
- $name = $app->name;
- $url = $app->source_url;
- }
- }
-
- if (!empty($name) && !empty($url)) {
- $source_name = '<a href="' . $url . '">' . $name . '</a>';
- }
-
- break;
- }
- return $source_name;
- }
-
/**
* Returns query argument or default value if not found. Certain
* parameters used throughout the API are lightly scrubbed and