Reply.php 2.4 KB

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