当前位置: 首页>>代码示例>>PHP>>正文


PHP Subscription::whereAdd方法代码示例

本文整理汇总了PHP中Subscription::whereAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::whereAdd方法的具体用法?PHP Subscription::whereAdd怎么用?PHP Subscription::whereAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


在下文中一共展示了Subscription::whereAdd方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getSubscribers

 function getSubscribers()
 {
     $subs = array();
     $sub = new Subscription();
     $sub->subscribed = $this->user->id;
     if (!empty($this->after)) {
         $sub->whereAdd("created > '" . common_sql_date($this->after) . "'");
     }
     if ($sub->find()) {
         while ($sub->fetch()) {
             if ($sub->subscriber != $this->user->id) {
                 $subs[] = clone $sub;
             }
         }
     }
     return $subs;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:17,代码来源:useractivitystream.php

示例2: realBySubscribed

 private static function realBySubscribed($subscribedId, $offset, $limit)
 {
     $sub = new Subscription();
     $sub->subscribed = $subscribedId;
     $sub->whereAdd('subscriber != ' . $subscribedId);
     $sub->orderBy('created DESC');
     $sub->limit($offset, $limit);
     $sub->find();
     $subs = array();
     while ($sub->fetch()) {
         $subs[] = clone $sub;
     }
     return $subs;
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:14,代码来源:Subscription.php

示例3: showMicrobloggingAccount

 /**
  * Output FOAF <account> bit for the given profile.
  *
  * @param Profile $profile
  * @param mixed $service Root URL of this StatusNet instance for a local
  *                       user, otherwise null.
  * @param mixed $useruri URI string for the referenced profile..
  * @param boolean $fetchSubscriptions Should we load and list all their subscriptions?
  * @param boolean $isSubscriber if not fetching subs, we can still mark the user as following the current page.
  *
  * @return array if $fetchSubscribers is set, return a list of info on those
  *               subscriptions.
  */
 function showMicrobloggingAccount($profile, $service = null, $useruri = null, $fetchSubscriptions = false, $isSubscriber = false)
 {
     $attr = array();
     if ($useruri) {
         $attr['rdf:about'] = $useruri . '#acct';
     }
     // Their account
     $this->elementStart('account');
     $this->elementStart('OnlineAccount', $attr);
     if ($service) {
         $this->element('accountServiceHomepage', array('rdf:resource' => $service));
     }
     $this->element('accountName', null, $profile->nickname);
     $this->element('accountProfilePage', array('rdf:resource' => $profile->profileurl));
     if ($useruri) {
         $this->element('sioc:account_of', array('rdf:resource' => $useruri));
     }
     $person = array();
     if ($fetchSubscriptions) {
         // Get people user is subscribed to
         $sub = new Subscription();
         $sub->subscriber = $profile->id;
         $sub->whereAdd('subscriber != subscribed');
         if ($sub->find()) {
             while ($sub->fetch()) {
                 $profile = Profile::staticGet('id', $sub->subscribed);
                 if (empty($profile)) {
                     common_debug('Got a bad subscription: ' . print_r($sub, true));
                     continue;
                 }
                 $user = $profile->getUser();
                 $other_uri = $profile->getUri();
                 $this->element('sioc:follows', array('rdf:resource' => $other_uri . '#acct'));
                 $person[$other_uri] = array(LISTENEE, $profile->id, $profile->nickname, $user ? 'local' : 'remote');
                 unset($profile);
             }
         }
         unset($sub);
     } else {
         if ($isSubscriber) {
             // Just declare that they follow the user whose FOAF we're showing.
             $this->element('sioc:follows', array('rdf:resource' => $this->user->uri . '#acct'));
         }
     }
     $this->elementEnd('OnlineAccount');
     $this->elementEnd('account');
     return $person;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:61,代码来源:foaf.php

示例4: subscriberCount

 function subscriberCount()
 {
     $c = common_memcache();
     if (!empty($c)) {
         $cnt = $c->get(common_cache_key('profile:subscriber_count:' . $this->id));
         if (is_integer($cnt)) {
             return (int) $cnt;
         }
     }
     $sub = new Subscription();
     $sub->subscribed = $this->id;
     $sub->whereAdd('subscriber != subscribed');
     $cnt = (int) $sub->count('distinct subscriber');
     if (!empty($c)) {
         $c->set(common_cache_key('profile:subscriber_count:' . $this->id), $cnt);
     }
     return $cnt;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:18,代码来源:Profile.php

示例5: initSubscriptionURI

function initSubscriptionURI()
{
    printfnq("Ensuring all subscriptions have a URI...");
    $sub = new Subscription();
    $sub->whereAdd('uri IS NULL');
    if ($sub->find()) {
        while ($sub->fetch()) {
            try {
                $sub->decache();
                $sub->query(sprintf('update subscription ' . 'set uri = "%s" ' . 'where subscriber = %d ' . 'and subscribed = %d', Subscription::newURI($sub->subscriber, $sub->subscribed, $sub->created), $sub->subscriber, $sub->subscribed));
            } catch (Exception $e) {
                common_log(LOG_ERR, "Error updated subscription URI: " . $e->getMessage());
            }
        }
    }
    printfnq("DONE.\n");
}
开发者ID:Grasia,项目名称:bolotweet,代码行数:17,代码来源:upgrade.php

示例6: getSubscriptionIDs

 private static function getSubscriptionIDs($get_type, $profile_id, $offset, $limit)
 {
     switch ($get_type) {
         case 'subscribed':
             $by_type = 'subscriber';
             break;
         case 'subscriber':
             $by_type = 'subscribed';
             break;
         default:
             throw new Exception('Bad type argument to getSubscriptionIDs');
     }
     $cacheKey = 'subscription:by-' . $by_type . ':' . $profile_id;
     $queryoffset = $offset;
     $querylimit = $limit;
     if ($offset + $limit <= self::CACHE_WINDOW) {
         // Oh, it seems it should be cached
         $ids = self::cacheGet($cacheKey);
         if (is_array($ids)) {
             return array_slice($ids, $offset, $limit);
         }
         // Being here indicates we didn't find anything cached
         // so we'll have to fill it up simultaneously
         $queryoffset = 0;
         $querylimit = self::CACHE_WINDOW;
     }
     $sub = new Subscription();
     $sub->{$by_type} = $profile_id;
     $sub->selectAdd($get_type);
     $sub->whereAdd("{$get_type} != {$profile_id}");
     $sub->orderBy('created DESC');
     $sub->limit($queryoffset, $querylimit);
     if (!$sub->find()) {
         return array();
     }
     $ids = $sub->fetchAll($get_type);
     // If we're simultaneously filling up cache, remember to slice
     if ($queryoffset === 0 && $querylimit === self::CACHE_WINDOW) {
         self::cacheSet($cacheKey, $ids);
         return array_slice($ids, $offset, $limit);
     }
     return $ids;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:43,代码来源:Subscription.php

示例7: subscriptions

 function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs = false)
 {
     $this->auth_user = $apidata['user'];
     $user = $this->get_user($apidata['api_arg'], $apidata);
     if (!$user) {
         $this->clientError('Not Found', 404, $apidata['content-type']);
         return;
     }
     $page = $this->trimmed('page');
     if (!$page || !is_numeric($page)) {
         $page = 1;
     }
     $profile = $user->getProfile();
     if (!$profile) {
         $this->serverError(_('User has no profile.'));
         return;
     }
     $sub = new Subscription();
     $sub->{$user_attr} = $profile->id;
     $since = strtotime($this->trimmed('since'));
     if ($since) {
         $d = date('Y-m-d H:i:s', $since);
         $sub->whereAdd("created > '{$d}'");
     }
     $sub->orderBy('created DESC');
     if (!$onlyIDs) {
         $sub->limit(($page - 1) * 100, 100);
     }
     $others = array();
     if ($sub->find()) {
         while ($sub->fetch()) {
             $others[] = Profile::staticGet($sub->{$other_attr});
         }
     } else {
         // user has no followers
     }
     $type = $apidata['content-type'];
     $this->init_document($type);
     if ($onlyIDs) {
         $this->showIDs($others, $type);
     } else {
         $this->show_profiles($others, $type);
     }
     $this->end_document($type);
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:45,代码来源:twitapistatuses.php

示例8: handle

 function handle($args)
 {
     parent::handle($args);
     header('Content-Type: application/rdf+xml');
     $this->startXML();
     $this->elementStart('rdf:RDF', array('xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'xmlns:rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'xmlns:geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#', 'xmlns' => 'http://xmlns.com/foaf/0.1/'));
     // This is the document about the user
     $this->showPpd('', $this->user->uri);
     // XXX: might not be a person
     $this->elementStart('Person', array('rdf:about' => $this->user->uri));
     $this->element('mbox_sha1sum', null, sha1('mailto:' . $this->user->email));
     if ($this->profile->fullname) {
         $this->element('name', null, $this->profile->fullname);
     }
     if ($this->profile->homepage) {
         $this->element('homepage', array('rdf:resource' => $this->profile->homepage));
     }
     if ($this->profile->bio) {
         $this->element('rdfs:comment', null, $this->profile->bio);
     }
     // XXX: more structured location data
     if ($this->profile->location) {
         $this->elementStart('based_near');
         $this->elementStart('geo:SpatialThing');
         $this->element('name', null, $this->profile->location);
         $this->elementEnd('geo:SpatialThing');
         $this->elementEnd('based_near');
     }
     $this->showMicrobloggingAccount($this->profile, common_root_url());
     $avatar = $this->profile->getOriginalAvatar();
     if ($avatar) {
         $this->elementStart('img');
         $this->elementStart('Image', array('rdf:about' => $avatar->url));
         foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
             $scaled = $this->profile->getAvatar($size);
             if (!$scaled->original) {
                 // sometimes the original has one of our scaled sizes
                 $this->elementStart('thumbnail');
                 $this->element('Image', array('rdf:about' => $scaled->url));
                 $this->elementEnd('thumbnail');
             }
         }
         $this->elementEnd('Image');
         $this->elementEnd('img');
     }
     // Get people user is subscribed to
     $person = array();
     $sub = new Subscription();
     $sub->subscriber = $this->profile->id;
     $sub->whereAdd('subscriber != subscribed');
     if ($sub->find()) {
         while ($sub->fetch()) {
             if ($sub->token) {
                 $other = Remote_profile::staticGet('id', $sub->subscribed);
             } else {
                 $other = User::staticGet('id', $sub->subscribed);
             }
             if (!$other) {
                 common_debug('Got a bad subscription: ' . print_r($sub, true));
                 continue;
             }
             $this->element('knows', array('rdf:resource' => $other->uri));
             $person[$other->uri] = array(LISTENEE, $other);
         }
     }
     // Get people who subscribe to user
     $sub = new Subscription();
     $sub->subscribed = $this->profile->id;
     $sub->whereAdd('subscriber != subscribed');
     if ($sub->find()) {
         while ($sub->fetch()) {
             if ($sub->token) {
                 $other = Remote_profile::staticGet('id', $sub->subscriber);
             } else {
                 $other = User::staticGet('id', $sub->subscriber);
             }
             if (!$other) {
                 common_debug('Got a bad subscription: ' . print_r($sub, true));
                 continue;
             }
             if (array_key_exists($other->uri, $person)) {
                 $person[$other->uri][0] = BOTH;
             } else {
                 $person[$other->uri] = array(LISTENER, $other);
             }
         }
     }
     $this->elementEnd('Person');
     foreach ($person as $uri => $p) {
         $foaf_url = null;
         if ($p[1] instanceof User) {
             $foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname));
         }
         $this->profile = Profile::staticGet($p[1]->id);
         $this->elementStart('Person', array('rdf:about' => $uri));
         if ($p[0] == LISTENER || $p[0] == BOTH) {
             $this->element('knows', array('rdf:resource' => $this->user->uri));
         }
         $this->showMicrobloggingAccount($this->profile, $p[1] instanceof User ? common_root_url() : null);
         if ($foaf_url) {
//.........这里部分代码省略.........
开发者ID:Br3nda,项目名称:laconica,代码行数:101,代码来源:foaf.php


注:本文中的Subscription::whereAdd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。