コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: Profile.php プロジェクト: phpsource/gnu-social
 function getTagSubscriptions($offset = 0, $limit = null, $since_id = 0, $max_id = 0)
 {
     $lists = new Profile_list();
     $subs = new Profile_tag_subscription();
     $lists->joinAdd(array('id', 'profile_tag_subscription:profile_tag_id'));
     #@fixme: postgres (round(date_part('epoch', my_date)))
     $lists->selectAdd('unix_timestamp(profile_tag_subscription.created) as "cursor"');
     $lists->whereAdd('profile_tag_subscription.profile_id = ' . $this->id);
     if ($since_id > 0) {
         $lists->whereAdd('cursor > ' . $since_id);
     }
     if ($max_id > 0) {
         $lists->whereAdd('cursor <= ' . $max_id);
     }
     if ($offset >= 0 && !is_null($limit)) {
         $lists->limit($offset, $limit);
     }
     $lists->orderBy('"cursor" DESC');
     $lists->find();
     return $lists;
 }