]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Reply.php
staticGet for sub-Managed_DataObject classes now calls parent
[quix0rs-gnu-social.git] / classes / Reply.php
1 <?php
2 /**
3  * Table Definition for reply
4  */
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
6
7 class Reply extends Managed_DataObject
8 {
9     ###START_AUTOCODE
10     /* the code below is auto generated do not remove the above tag */
11
12     public $__table = 'reply';                           // table name
13     public $notice_id;                       // int(4)  primary_key not_null
14     public $profile_id;                      // int(4)  primary_key not_null
15     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
16     public $replied_id;                      // int(4)
17
18     /* the code above is auto generated do not remove the tag below */
19     ###END_AUTOCODE
20
21     public static function schemaDef()
22     {
23         return array(
24             'fields' => array(
25                 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the reply'),
26                 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile replied to'),
27                 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
28                 'replied_id' => array('type' => 'int', 'description' => 'notice replied to (not used, see notice.reply_to)'),
29             ),
30             'primary key' => array('notice_id', 'profile_id'),
31             'foreign keys' => array(
32                 'reply_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
33                 'reply_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
34             ),
35             'indexes' => array(
36                 'reply_notice_id_idx' => array('notice_id'),
37                 'reply_profile_id_idx' => array('profile_id'),
38                 'reply_replied_id_idx' => array('replied_id'),
39                 'reply_profile_id_modified_notice_id_idx' => array('profile_id', 'modified', 'notice_id')
40             ),
41         );
42     }    
43
44         function pkeyGet($kv)
45         {
46                 return Memcached_DataObject::pkeyGet('Reply',$kv);   
47         }
48         
49     /**
50      * Wrapper for record insertion to update related caches
51      */
52     function insert()
53     {
54         $result = parent::insert();
55
56         if ($result) {
57             self::blow('reply:stream:%d', $this->profile_id);
58         }
59
60         return $result;
61     }
62
63     function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
64     {
65         $stream = new ReplyNoticeStream($user_id);
66
67         return $stream->getNotices($offset, $limit, $since_id, $max_id);
68     }
69 }