3 * Data class for notice titles
9 * @author Evan Prodromou <evan@status.net>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2010, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
37 * Data class for notice titles
41 * @author Evan Prodromou <evan@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
43 * @link http://status.net/
47 class Notice_title extends Managed_DataObject
49 const MAXCHARS = 191; // not 255 because utf8mb4 takes more space
51 public $__table = 'notice_title'; // table name
52 public $notice_id; // int(11) primary_key not_null
53 public $title; // varchar(191) not 255 because utf8mb4 takes more space
54 public $created; // datetime() not_null
55 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
57 public static function schemaDef()
61 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id this title relates to'),
62 'title' => array('type' => 'varchar', 'length' => Notice_title::MAXCHARS, 'description' => 'title to notice'),
63 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
64 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
66 'primary key' => array('notice_id'),
67 'foreign keys' => array(
68 'notice_title_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
74 * Get a notice title based on the notice
76 * @param Notice $notice Notice to fetch a title for
78 * @return string title of the notice, or null if none
80 static function fromNotice($notice)
82 $nt = Notice_title::getKV('notice_id', $notice->id);