]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/NoticeTitle/Notice_title.php
add hooks for upgrades
[quix0rs-gnu-social.git] / plugins / NoticeTitle / Notice_title.php
index ed71f135675862edd0f7cf32811060035201e99a..4030b5c965579578e783461f694d8a0eba70ee29 100644 (file)
@@ -44,9 +44,10 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
  *
  * @see      DB_DataObject
  */
-
 class Notice_title extends Memcached_DataObject
 {
+    const MAXCHARS = 255;
+
     public $__table = 'notice_title'; // table name
     public $notice_id;                         // int(4)  primary_key not_null
     public $title;                             // varchar(255)
@@ -62,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);
@@ -76,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,
@@ -88,7 +87,6 @@ class Notice_title extends Memcached_DataObject
      *
      * @return array list of key field names
      */
-
     function keys()
     {
         return array_keys($this->keyTypes());
@@ -96,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');
@@ -108,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;
+        }
+    }
 }