Exemple #1
0
 function execute($channel)
 {
     $subs = new Subscription();
     $subs->subscriber = $this->user->id;
     $subs_count = (int) $subs->count() - 1;
     $subbed = new Subscription();
     $subbed->subscribed = $this->user->id;
     $subbed_count = (int) $subbed->count() - 1;
     $notices = new Notice();
     $notices->profile_id = $this->user->id;
     $notice_count = (int) $notices->count();
     $channel->output($this->user, sprintf(_("Subscriptions: %1\$s\n" . "Subscribers: %2\$s\n" . "Notices: %3\$s"), $subs_count, $subbed_count, $notice_count));
 }
Exemple #2
0
 function showStatistics()
 {
     // XXX: WORM cache this
     $subs = new Subscription();
     $subs->subscriber = $this->profile->id;
     $subs_count = (int) $subs->count() - 1;
     $subbed = new Subscription();
     $subbed->subscribed = $this->profile->id;
     $subbed_count = (int) $subbed->count() - 1;
     $notices = new Notice();
     $notices->profile_id = $this->profile->id;
     $notice_count = (int) $notices->count();
     $this->elementStart('div', array('id' => 'entity_statistics', 'class' => 'section'));
     $this->element('h2', null, _('Statistics'));
     // Other stats...?
     $this->elementStart('dl', 'entity_member-since');
     $this->element('dt', null, _('Member since'));
     $this->element('dd', null, date('j M Y', strtotime($this->profile->created)));
     $this->elementEnd('dl');
     $this->elementStart('dl', 'entity_subscriptions');
     $this->elementStart('dt');
     $this->element('a', array('href' => common_local_url('subscriptions', array('nickname' => $this->profile->nickname))), _('Subscriptions'));
     $this->elementEnd('dt');
     $this->element('dd', null, is_int($subs_count) ? $subs_count : '0');
     $this->elementEnd('dl');
     $this->elementStart('dl', 'entity_subscribers');
     $this->elementStart('dt');
     $this->element('a', array('href' => common_local_url('subscribers', array('nickname' => $this->profile->nickname))), _('Subscribers'));
     $this->elementEnd('dt');
     $this->element('dd', 'subscribers', is_int($subbed_count) ? $subbed_count : '0');
     $this->elementEnd('dl');
     $this->elementStart('dl', 'entity_notices');
     $this->element('dt', null, _('Notices'));
     $this->element('dd', null, is_int($notice_count) ? $notice_count : '0');
     $this->elementEnd('dl');
     $this->elementEnd('div');
 }
Exemple #3
0
 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;
 }