]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Reply.php
Merge ActivitySpam plugin
[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                 'reply_profile_id_modified_notice_id_idx' => array('profile_id', 'modified', 'notice_id')
44             ),
45         );
46     }    
47
48         function pkeyGet($kv)
49         {
50                 return Memcached_DataObject::pkeyGet('Reply',$kv);   
51         }
52         
53     /**
54      * Wrapper for record insertion to update related caches
55      */
56     function insert()
57     {
58         $result = parent::insert();
59
60         if ($result) {
61             self::blow('reply:stream:%d', $this->profile_id);
62         }
63
64         return $result;
65     }
66
67     function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
68     {
69         $stream = new ReplyNoticeStream($user_id);
70
71         return $stream->getNotices($offset, $limit, $since_id, $max_id);
72     }
73 }