function showContent() { if (Event::handle('StartShowTagSubscriptionsContent', array($this))) { parent::showContent(); $offset = ($this->page - 1) * PROFILES_PER_PAGE; $limit = PROFILES_PER_PAGE + 1; $cnt = 0; $tagsub = new TagSub(); $tagsub->profile_id = $this->getTarget()->getID(); $tagsub->limit($limit, $offset); $tagsub->find(); if ($tagsub->N) { $list = new TagSubscriptionsList($tagsub, $this->getTarget(), $this); $cnt = $list->show(); if (0 == $cnt) { $this->showEmptyListMessage(); } } else { $this->showEmptyListMessage(); } $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, $this->page, 'tagsubs', array('nickname' => $this->getTarget()->getNickname())); Event::handle('EndShowTagSubscriptionsContent', array($this)); } }
static function forProfile(Profile $profile) { $tags = array(); $keypart = sprintf('tagsub:by_profile:%d', $profile->id); $tagstring = self::cacheGet($keypart); if ($tagstring !== false) { // cache hit if (!empty($tagstring)) { $tags = explode(',', $tagstring); } } else { $tagsub = new TagSub(); $tagsub->profile_id = $profile->id; $tagsub->selectAdd(); $tagsub->selectAdd('tag'); if ($tagsub->find()) { $tags = $tagsub->fetchAll('tag'); } self::cacheSet($keypart, implode(',', $tags)); } return $tags; }
/** * Hook inbox delivery setup so tag subscribers receive all * notices with that tag in their inbox. * * Currently makes no distinction between local messages and * remote ones which happen to come in to the system. Remote * notices that don't come in at all won't ever reach this. * * @param Notice $notice * @param array $ni in/out map of profile IDs to inbox constants * @return boolean hook result */ function onStartNoticeWhoGets(Notice $notice, array &$ni) { foreach ($notice->getTags() as $tag) { $tagsub = new TagSub(); $tagsub->tag = $tag; $tagsub->find(); while ($tagsub->fetch()) { // These constants are currently not actually used, iirc $ni[$tagsub->profile_id] = NOTICE_INBOX_SOURCE_SUB; } } return true; }
static function forProfile(Profile $profile) { $tags = array(); $keypart = sprintf('tagsub:by_profile:%d', $profile->id); $tagstring = self::cacheGet($keypart); if ($tagstring !== false && !empty($tagstring)) { $tags = explode(',', $tagstring); } else { $tagsub = new TagSub(); $tagsub->profile_id = $profile->id; if ($tagsub->find()) { while ($tagsub->fetch()) { if (!empty($tagsub->tag)) { $tags[] = $tagsub->tag; } } } self::cacheSet($keypart, implode(',', $tags)); } return $tags; }