networkpublicnoticestream.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 FullNoticeStream
  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. self::filterVerbs($notice, $this->selectVerbs);
  40. $ids = array();
  41. if ($notice->find()) {
  42. while ($notice->fetch()) {
  43. $ids[] = $notice->id;
  44. }
  45. }
  46. $notice->free();
  47. $notice = NULL;
  48. return $ids;
  49. }
  50. }