Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 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;
 }