networkpublicnoticestream.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. if (!defined('GNUSOCIAL')) { exit(1); }
  3. class NetworkPublicNoticeStream extends ScopingNoticeStream
  4. {
  5. function __construct(Profile $scoped=null)
  6. {
  7. parent::__construct(new CachingNoticeStream(new RawNetworkPublicNoticeStream(),
  8. 'networkpublic'),
  9. $scoped);
  10. }
  11. }
  12. /**
  13. * Raw public stream
  14. *
  15. * @category Stream
  16. * @package StatusNet
  17. * @author Evan Prodromou <evan@status.net>
  18. * @copyright 2011 StatusNet, Inc.
  19. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  20. * @link http://status.net/
  21. */
  22. class RawNetworkPublicNoticeStream extends NoticeStream
  23. {
  24. function getNoticeIds($offset, $limit, $since_id, $max_id)
  25. {
  26. $notice = new Notice();
  27. $notice->selectAdd(); // clears it
  28. $notice->selectAdd('id');
  29. $notice->orderBy('created DESC, id DESC');
  30. if (!is_null($offset)) {
  31. $notice->limit($offset, $limit);
  32. }
  33. $notice->whereAdd('is_local ='. Notice::REMOTE);
  34. // -1 == blacklisted, -2 == gateway (i.e. Twitter)
  35. $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC);
  36. $notice->whereAdd('is_local !='. Notice::GATEWAY);
  37. Notice::addWhereSinceId($notice, $since_id);
  38. Notice::addWhereMaxId($notice, $max_id);
  39. if (!empty($this->selectVerbs)) {
  40. $notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
  41. }
  42. $ids = array();
  43. if ($notice->find()) {
  44. while ($notice->fetch()) {
  45. $ids[] = $notice->id;
  46. }
  47. }
  48. $notice->free();
  49. $notice = NULL;
  50. return $ids;
  51. }
  52. }