]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/NoticeTitle/Notice_title.php
Merge remote-tracking branch 'origin/1.0.x' into 1.0.x
[quix0rs-gnu-social.git] / plugins / NoticeTitle / Notice_title.php
index 44d56b49687606a2541fb6fc35e1372ce943161e..4030b5c965579578e783461f694d8a0eba70ee29 100644 (file)
@@ -44,7 +44,6 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
  *
  * @see      DB_DataObject
  */
-
 class Notice_title extends Memcached_DataObject
 {
     const MAXCHARS = 255;
@@ -64,7 +63,6 @@ class Notice_title extends Memcached_DataObject
      * @return Notice_title object found, or null for no hits
      *
      */
-
     function staticGet($k, $v=null)
     {
         return Memcached_DataObject::staticGet('Notice_title', $k, $v);
@@ -78,7 +76,6 @@ class Notice_title extends Memcached_DataObject
      *
      * @return array array of column definitions
      */
-
     function table()
     {
         return array('notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
@@ -90,7 +87,6 @@ class Notice_title extends Memcached_DataObject
      *
      * @return array list of key field names
      */
-
     function keys()
     {
         return array_keys($this->keyTypes());
@@ -98,8 +94,9 @@ class Notice_title extends Memcached_DataObject
 
     /**
      * return key definitions for Memcached_DataObject
+     *
+     * @return array list mapping field names to key types
      */
-
     function keyTypes()
     {
         return array('notice_id' => 'K');
@@ -110,9 +107,25 @@ class Notice_title extends Memcached_DataObject
      *
      * @return array magic three-false array that stops auto-incrementing.
      */
-
     function sequenceKey()
     {
         return array(false, false, false);
     }
+
+    /**
+     * Get a notice title based on the notice
+     *
+     * @param Notice $notice Notice to fetch a title for
+     *
+     * @return string title of the notice, or null if none
+     */
+    static function fromNotice($notice)
+    {
+        $nt = Notice_title::staticGet('notice_id', $notice->id);
+        if (empty($nt)) {
+            return null;
+        } else {
+            return $nt->title;
+        }
+    }
 }