summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/File.php4
-rw-r--r--classes/Notice.php67
-rw-r--r--classes/Safe_DataObject.php24
-rw-r--r--classes/Subscription.php8
4 files changed, 94 insertions, 9 deletions
diff --git a/classes/File.php b/classes/File.php
index 33273bbdc..c9477f5f1 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -286,7 +286,9 @@ class File extends Memcached_DataObject
if(! isset($this->filename)){
$notEnclosureMimeTypes = array(null,'text/html','application/xhtml+xml');
- $mimetype = strtolower($this->mimetype);
+ if($mimetype != null){
+ $mimetype = strtolower($this->mimetype);
+ }
$semicolon = strpos($mimetype,';');
if($semicolon){
$mimetype = substr($mimetype,0,$semicolon);
diff --git a/classes/Notice.php b/classes/Notice.php
index 0b1b2e402..875bcaa02 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -172,7 +172,8 @@ class Notice extends Memcached_DataObject
$id = $tag->insert();
if (!$id) {
- throw new ServerException(sprintf(_('DB error inserting hashtag: %s'),
+ // TRANS: Server exception. %s are the error details.
+ throw new ServerException(sprintf(_('Database error inserting hashtag: %s'),
$last_error->message));
return;
}
@@ -703,7 +704,7 @@ class Notice extends Memcached_DataObject
/**
* Is this notice part of an active conversation?
- *
+ *
* @return boolean true if other messages exist in the same
* conversation, false if this is the only one
*/
@@ -1171,7 +1172,7 @@ class Notice extends Memcached_DataObject
return $groups;
}
- function asAtomEntry($namespace=false, $source=false, $author=true)
+ function asAtomEntry($namespace=false, $source=false, $author=true, $cur=null)
{
$profile = $this->getProfile();
@@ -1184,7 +1185,8 @@ class Notice extends Memcached_DataObject
'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
'xmlns:media' => 'http://purl.org/syndication/atommedia',
'xmlns:poco' => 'http://portablecontacts.net/spec/1.0',
- 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0');
+ 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
+ 'xmlns:statusnet' => 'http://status.net/ont/');
} else {
$attrs = array();
}
@@ -1210,6 +1212,24 @@ class Notice extends Memcached_DataObject
$xs->element('icon', null, $profile->avatarUrl(AVATAR_PROFILE_SIZE));
$xs->element('updated', null, common_date_w3dtf($this->created));
+
+ $noticeInfoAttr = array(
+ 'local_id' => $this->id, // local notice ID (useful to clients for ordering)
+ 'source' => $this->source // the client name (source attribution)
+ );
+
+ $ns = $this->getSource();
+ if ($ns) {
+ if (!empty($ns->url)) {
+ $noticeInfoAttr['source_link'] = $ns->url;
+ }
+ }
+
+ if (!empty($cur)) {
+ $noticeInfoAttr['favorited'] = ($cur->hasFave($this)) ? 'true' : 'false';
+ }
+
+ $xs->element('statusnet:notice_info', $noticeInfoAttr, null);
}
if ($source) {
@@ -1527,6 +1547,8 @@ class Notice extends Memcached_DataObject
{
$author = Profile::staticGet('id', $this->profile_id);
+ // TRANS: Message used to repeat a notice. RT is the abbreviation of 'retweet'.
+ // TRANS: %1$s is the repeated user's name, %2$s is the repeated notice.
$content = sprintf(_('RT @%1$s %2$s'),
$author->nickname,
$this->content);
@@ -1796,4 +1818,41 @@ class Notice extends Memcached_DataObject
return $result;
}
+
+ /**
+ * Get the source of the notice
+ *
+ * @return Notice_source $ns A notice source object. 'code' is the only attribute
+ * guaranteed to be populated.
+ */
+ function getSource()
+ {
+ $ns = new Notice_source();
+ if (!empty($this->source)) {
+ switch ($this->source) {
+ case 'web':
+ case 'xmpp':
+ case 'mail':
+ case 'omb':
+ case 'system':
+ case 'api':
+ $ns->code = $this->source;
+ break;
+ default:
+ $ns = Notice_source::staticGet($this->source);
+ if (!$ns) {
+ $ns = new Notice_source();
+ $ns->code = $this->source;
+ $app = Oauth_application::staticGet('name', $this->source);
+ if ($app) {
+ $ns->name = $app->name;
+ $ns->url = $app->source_url;
+ }
+ }
+ break;
+ }
+ }
+ return $ns;
+ }
+
}
diff --git a/classes/Safe_DataObject.php b/classes/Safe_DataObject.php
index 08bc6846f..e926cb0d5 100644
--- a/classes/Safe_DataObject.php
+++ b/classes/Safe_DataObject.php
@@ -96,6 +96,30 @@ class Safe_DataObject extends DB_DataObject
$this->_link_loaded = false;
}
+ /**
+ * Magic function called when someone attempts to call a method
+ * that doesn't exist. DB_DataObject uses this to implement
+ * setters and getters for fields, but neglects to throw an error
+ * when you just misspell an actual method name. This leads to
+ * silent failures which can cause all kinds of havoc.
+ *
+ * @param string $method
+ * @param array $params
+ * @return mixed
+ * @throws Exception
+ */
+ function __call($method, $params)
+ {
+ $return = null;
+ // Yes, that's _call with one underscore, which does the
+ // actual implementation.
+ if ($this->_call($method, $params, $return)) {
+ return $return;
+ } else {
+ throw new Exception('Call to undefined method ' .
+ get_class($this) . '::' . $method);
+ }
+ }
/**
* Work around memory-leak bugs...
diff --git a/classes/Subscription.php b/classes/Subscription.php
index 60c12cccc..0679c0925 100644
--- a/classes/Subscription.php
+++ b/classes/Subscription.php
@@ -88,8 +88,8 @@ class Subscription extends Memcached_DataObject
self::blow('user:notices_with_friends:%d', $subscriber->id);
- $subscriber->blowSubscriptionsCount();
- $other->blowSubscribersCount();
+ $subscriber->blowSubscriptionCount();
+ $other->blowSubscriberCount();
$otherUser = User::staticGet('id', $other->id);
@@ -213,8 +213,8 @@ class Subscription extends Memcached_DataObject
self::blow('user:notices_with_friends:%d', $subscriber->id);
- $subscriber->blowSubscriptionsCount();
- $other->blowSubscribersCount();
+ $subscriber->blowSubscriptionCount();
+ $other->blowSubscriberCount();
Event::handle('EndUnsubscribe', array($subscriber, $other));
}