]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Reply.php
Merge branch 'master' into testing
[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     /* Static get */
19     function staticGet($k,$v=null)
20     { return Memcached_DataObject::staticGet('Reply',$k,$v); }
21
22     /* the code above is auto generated do not remove the tag below */
23     ###END_AUTOCODE
24
25     public static function schemaDef()
26     {
27         return array(
28             'fields' => array(
29                 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice that is the reply'),
30                 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile replied to'),
31                 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
32                 'replied_id' => array('type' => 'int', 'description' => 'notice replied to (not used, see notice.reply_to)'),
33             ),
34             'primary key' => array('notice_id', 'profile_id'),
35             'foreign keys' => array(
36                 'reply_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
37                 'reply_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
38             ),
39             'indexes' => array(
40                 'reply_notice_id_idx' => array('notice_id'),
41                 'reply_profile_id_idx' => array('profile_id'),
42                 'reply_replied_id_idx' => array('replied_id'),
43             ),
44         );
45     }    
46
47         function pkeyGet($kv)
48         {
49                 return Memcached_DataObject::pkeyGet('Reply',$kv);   
50         }
51         
52     /**
53      * Wrapper for record insertion to update related caches
54      */
55     function insert()
56     {
57         $result = parent::insert();
58
59         if ($result) {
60             self::blow('reply:stream:%d', $this->profile_id);
61         }
62
63         return $result;
64     }
65
66     function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
67     {
68         $stream = new ReplyNoticeStream($user_id);
69
70         return $stream->getNotices($offset, $limit, $since_id, $max_id);
71     }
72 }