static function getTags($tagger, $tagged, $auth_user = null) { $profile_list = new Profile_list(); $include_priv = 1; if (!($auth_user instanceof User || $auth_user instanceof Profile) || $auth_user->id !== $tagger) { $profile_list->private = false; $include_priv = 0; } $key = sprintf('profile_tag:tagger_tagged_privacy:%d-%d-%d', $tagger, $tagged, $include_priv); $tags = Profile_list::getCached($key); if ($tags !== false) { return $tags; } $profile_tag = new Profile_tag(); $profile_list->tagger = $tagger; $profile_tag->tagged = $tagged; $profile_list->selectAdd(); // only fetch id, tag, mainpage and // private hoping this will be faster $profile_list->selectAdd('profile_list.id, ' . 'profile_list.tag, ' . 'profile_list.mainpage, ' . 'profile_list.private'); $profile_list->joinAdd($profile_tag); $profile_list->find(); Profile_list::setCache($key, $profile_list); return $profile_list; }
static function getTags($tagger, $tagged, $auth_user = null) { $profile_list = new Profile_list(); $include_priv = 1; if (!($auth_user instanceof User || $auth_user instanceof Profile) || $auth_user->id !== $tagger) { $profile_list->private = false; $include_priv = 0; } $key = sprintf('profile_tag:tagger_tagged_privacy:%d-%d-%d', $tagger, $tagged, $include_priv); $tags = Profile_list::getCached($key); if ($tags !== false) { return $tags; } $qry = 'select profile_list.* from profile_list left join ' . 'profile_tag on (profile_list.tag = profile_tag.tag and ' . 'profile_list.tagger = profile_tag.tagger) where ' . 'profile_tag.tagger = %d and profile_tag.tagged = %d '; $qry = sprintf($qry, $tagger, $tagged); if (!$include_priv) { $qry .= ' and profile_list.private = 0'; } $profile_list->query($qry); Profile_list::setCache($key, $profile_list); return $profile_list; }
function showContent() { $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) )'); $ptags->orderBy('profile_list.modified DESC'); $ptags->find(); } $pl = new PeopletagList($ptags, $this); $cnt = $pl->show(); $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE, $this->page, 'peopletag', array('tag' => $this->tag)); }