summaryrefslogtreecommitdiff
path: root/classes/Notice.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-05-06 00:20:10 -0700
committerZach Copley <zach@status.net>2010-05-18 15:15:27 -0700
commitc78f67aa7367acab5f9156ecf8963e2d5243e400 (patch)
treeab525d91b96ca159e6e5b41b8137731257f032d1 /classes/Notice.php
parentd9fddff5395e77287c4de0796fd072b3073f1eb9 (diff)
Refactor and centralize notice source link calculation
Diffstat (limited to 'classes/Notice.php')
-rw-r--r--classes/Notice.php39
1 files changed, 38 insertions, 1 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 9a9172cba..2c2c87d56 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -703,7 +703,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
*/
@@ -1809,4 +1809,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;
+ }
+
}