]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Notice::getAsTimestamp() static function to look up the timestamp for a given notice...
authorBrion Vibber <brion@pobox.com>
Fri, 17 Dec 2010 20:09:02 +0000 (12:09 -0800)
committerBrion Vibber <brion@pobox.com>
Fri, 17 Dec 2010 20:09:02 +0000 (12:09 -0800)
classes/Notice.php

index a067cd3741fa4fb4b8e6fafff99b0f407cc44ad1..079f56dcf9f2ee229f2f955c469b3afadf8663b0 100644 (file)
@@ -1978,4 +1978,26 @@ class Notice extends Memcached_DataObject
         $d = new DateTime($dateStr, new DateTimeZone('UTC'));
         return $d->format(DATE_W3C);
     }
+
+    /**
+     * Look up the creation timestamp for a given notice ID, even
+     * if it's been deleted.
+     *
+     * @param int $id
+     * @return mixed string recorded creation timestamp, or false if can't be found
+     */
+    public static function getAsTimestamp($id)
+    {
+        $notice = Notice::staticGet('id', $id);
+        if ($notice) {
+            return $notice->created;
+        } else {
+            $deleted = Deleted_notice::staticGet('id', $id);
+            if ($deleted) {
+                return $deleted->created;
+            } else {
+                return false;
+            }
+        }
+    }
 }