networkpublicnoticestream.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. if (!defined('GNUSOCIAL')) { exit(1); }
  3. class NetworkPublicNoticeStream extends ModeratedNoticeStream
  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->whereAdd('scope != ' . Notice::MESSAGE_SCOPE);
  38. Notice::addWhereSinceId($notice, $since_id);
  39. Notice::addWhereMaxId($notice, $max_id);
  40. self::filterVerbs($notice, $this->selectVerbs);
  41. $ids = array();
  42. if ($notice->find()) {
  43. while ($notice->fetch()) {
  44. $ids[] = $notice->id;
  45. }
  46. }
  47. $notice->free();
  48. $notice = NULL;
  49. return $ids;
  50. }
  51. }