X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FNoticeTitle%2FNotice_title.php;h=4030b5c965579578e783461f694d8a0eba70ee29;hb=73afcad34c244f17706d686669a02abc1b709708;hp=ed71f135675862edd0f7cf32811060035201e99a;hpb=ac6486f12e3a51fc0b7b1433de881934d8029299;p=quix0rs-gnu-social.git diff --git a/plugins/NoticeTitle/Notice_title.php b/plugins/NoticeTitle/Notice_title.php index ed71f13567..4030b5c965 100644 --- a/plugins/NoticeTitle/Notice_title.php +++ b/plugins/NoticeTitle/Notice_title.php @@ -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; + } + } }