]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Reply.php
Dropped deprecated timestamp-based 'since' parameter for all API methods. When it...
[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 Memcached_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     function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
26     {
27         $ids = Notice::stream(array('Reply', '_streamDirect'),
28                               array($user_id),
29                               'reply:stream:' . $user_id,
30                               $offset, $limit, $since_id, $max_id);
31         return $ids;
32     }
33
34     function _streamDirect($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
35     {
36         $reply = new Reply();
37         $reply->profile_id = $user_id;
38
39         if ($since_id != 0) {
40             $reply->whereAdd('notice_id > ' . $since_id);
41         }
42
43         if ($max_id != 0) {
44             $reply->whereAdd('notice_id < ' . $max_id);
45         }
46
47         $reply->orderBy('notice_id DESC');
48
49         if (!is_null($offset)) {
50             $reply->limit($offset, $limit);
51         }
52
53         $ids = array();
54
55         if ($reply->find()) {
56             while ($reply->fetch()) {
57                 $ids[] = $reply->notice_id;
58             }
59         }
60
61         return $ids;
62     }
63 }