function getTags()
 {
     $notice_tag = new Notice_tag();
     $query = 'select tag,count(tag) as weight from notice_tag join file_to_post on (notice_tag.notice_id=post_id) join notice on notice_id = notice.id where file_id=' . $notice_tag->escape($this->out->attachment->id) . ' group by tag order by weight desc';
     $notice_tag->query($query);
     return $notice_tag;
 }
 function getTags()
 {
     $profile = Profile::current();
     $keypart = sprintf('Inbox:notice_tag:%d:%d', $this->user->id, $profile->id);
     $tag = Memcached_DataObject::cacheGet($keypart);
     if ($tag === false) {
         $stream = new InboxNoticeStream($this->user, $profile);
         $ids = $stream->getNoticeIds(0, Inbox::MAX_NOTICES, null, null);
         if (empty($ids)) {
             $tag = array();
         } else {
             $weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
             // @fixme should we use the cutoff too? Doesn't help with indexing per-user.
             $qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' as weight ' . 'FROM notice_tag JOIN notice ' . 'ON notice_tag.notice_id = notice.id ' . 'WHERE notice.id in (' . implode(',', $ids) . ')' . 'GROUP BY notice_tag.tag ' . 'ORDER BY weight DESC ';
             $limit = TAGS_PER_SECTION;
             $offset = 0;
             if (common_config('db', 'type') == 'pgsql') {
                 $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
             } else {
                 $qry .= ' LIMIT ' . $offset . ', ' . $limit;
             }
             $t = new Notice_tag();
             $t->query($qry);
             $tag = array();
             while ($t->fetch()) {
                 $tag[] = clone $t;
             }
         }
         Memcached_DataObject::cacheSet($keypart, $tag, 3600);
     }
     return new ArrayWrapper($tag);
 }
 function getTags($lst, $usr)
 {
     $profile_tag = new Notice_tag();
     $profile_tag->query('SELECT DISTINCT(tag) ' . 'FROM profile_tag, subscription ' . 'WHERE tagger = ' . $this->target->id . ' ' . 'AND ' . $usr . ' = ' . $this->target->id . ' ' . 'AND ' . $lst . ' = tagged ' . 'AND tagger != tagged');
     $tags = array();
     while ($profile_tag->fetch()) {
         $tags[] = $profile_tag->tag;
     }
     $profile_tag->free();
     return $tags;
 }