+ $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
+ $limit = PEOPLETAGS_PER_PAGE + 1;
+
+ $ptags = new Profile_list();
+ $ptags->tag = $this->tag;
+
+ $user = common_current_user();
+
+ if (empty($user)) {
+ $ckey = sprintf('profile_list:tag:%s', $this->tag);
+ $ptags->private = false;
+ $ptags->orderBy('profile_list.modified DESC');
+
+ $c = Cache::instance();
+ if ($offset+$limit <= PEOPLETAG_CACHE_WINDOW && !empty($c)) {
+ $cached_ptags = Profile_list::getCached($ckey, $offset, $limit);
+ if ($cached_ptags === false) {
+ $ptags->limit(0, PEOPLETAG_CACHE_WINDOW);
+ $ptags->find();
+
+ Profile_list::setCache($ckey, $ptags, $offset, $limit);
+ } else {
+ $ptags = clone($cached_ptags);
+ }
+ } else {
+ $ptags->limit($offset, $limit);
+ $ptags->find();
+ }
+ } else {
+ $ptags->whereAdd('(profile_list.private = false OR (' .
+ ' profile_list.tagger =' . $user->id .
+ ' AND profile_list.private = true) )');