X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fconversationnoticestream.php;h=21b2d7f0be59a0561e6ecf1994cfcc7e89a451dd;hb=0b9a2fdf3ad19942e85a66b94d08501ce9c927dd;hp=c43b5deb24a3bd12d5d26da534a21036bcc17ac3;hpb=12588b1cf73fad7d0a76a29a46ec355150eaa54e;p=quix0rs-gnu-social.git diff --git a/lib/conversationnoticestream.php b/lib/conversationnoticestream.php index c43b5deb24..21b2d7f0be 100644 --- a/lib/conversationnoticestream.php +++ b/lib/conversationnoticestream.php @@ -28,11 +28,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET')) { - // This check helps protect against security problems; - // your code file can't be executed directly from the web. - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * Notice stream for a conversation @@ -73,38 +69,35 @@ class RawConversationNoticeStream extends NoticeStream function __construct($id) { + parent::__construct(); $this->id = $id; } - function getNotices($offset, $limit, $sinceId = null, $maxId = null) + function getNoticeIds($offset, $limit, $since_id=null, $max_id=null) { - $all = Memcached_DataObject::listGet('Notice', 'conversation', array($this->id)); - $notices = $all[$this->id]; - // Re-order in reverse-chron - usort($notices, array('RawConversationNoticeStream', '_reverseChron')); - // FIXME: handle since and max - $wanted = array_slice($notices, $offset, $limit); - return new ArrayWrapper($wanted); - } - - function getNoticeIds($offset, $limit, $since_id, $max_id) - { - $notice = $this->getNotices($offset, $limit, $since_id, $max_id); - $ids = $notice->fetchAll('id'); - return $ids; - } + $notice = new Notice(); + // SELECT + $notice->selectAdd(); + $notice->selectAdd('id'); - function _reverseChron($a, $b) - { - $at = strtotime($a->created); - $bt = strtotime($b->created); - - if ($at == $bt) { - return 0; - } else if ($at > $bt) { - return -1; - } else { - return 1; + // WHERE + $notice->conversation = $this->id; + if (!empty($since_id)) { + $notice->whereAdd(sprintf('notice.id > %d', $since_id)); + } + if (!empty($max_id)) { + $notice->whereAdd(sprintf('notice.id <= %d', $max_id)); + } + if (!is_null($offset)) { + $notice->limit($offset, $limit); } + + self::filterVerbs($notice, $this->selectVerbs); + + // ORDER BY + // currently imitates the previously used "_reverseChron" sorting + $notice->orderBy('notice.created DESC'); + $notice->find(); + return $notice->fetchAll('id'); } }