Exemplo n.º 1
0
 static function noticeCount($id)
 {
     $keypart = sprintf('conversation:notice_count:%d', $id);
     $cnt = self::cacheGet($keypart);
     if ($cnt !== false) {
         return $cnt;
     }
     $notice = new Notice();
     $notice->conversation = $id;
     $cnt = $notice->count();
     self::cacheSet($keypart, $cnt);
     return $cnt;
 }
Exemplo n.º 2
0
 static function noticeCount($id)
 {
     $keypart = sprintf('conversation:notice_count:%d', $id);
     $cnt = self::cacheGet($keypart);
     if ($cnt !== false) {
         return $cnt;
     }
     $notice = new Notice();
     $notice->conversation = $id;
     $notice->whereAddIn('verb', array(ActivityVerb::POST, ActivityUtils::resolveUri(ActivityVerb::POST, true)), $notice->columnType('verb'));
     $cnt = $notice->count();
     self::cacheSet($keypart, $cnt);
     return $cnt;
 }
Exemplo n.º 3
0
 public function run()
 {
     $this->controller->_seoTitle = '系统公告 - ' . $this->controller->_setting['site_name'];
     $model = new Notice();
     $criteria = new CDbCriteria();
     //查询条件
     $criteria->addColumnCondition(array('status' => 'Y'));
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     $lists = $model->findAll($criteria);
     $this->controller->render('index', array('lists' => $lists, 'pages' => $pages));
 }
Exemplo n.º 4
0
 /**
  * 公告列表
  *
  */
 public function actionIndex()
 {
     $model = new Notice();
     $criteria = new CDbCriteria();
     $title = trim($this->_request->getParam('title'));
     $title && ($condition .= ' AND title LIKE \'%' . $title . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     //根据title查询
     $pageParams = $this->buildCondition($_GET, array('title'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
Exemplo n.º 5
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');
 }
Exemplo n.º 6
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));
 }
Exemplo n.º 7
0
 static function checkDupes($profile_id, $content)
 {
     $profile = Profile::getKV($profile_id);
     if (!$profile instanceof Profile) {
         return false;
     }
     $notice = $profile->getNotices(0, CachingNoticeStream::CACHE_WINDOW);
     if (!empty($notice)) {
         $last = 0;
         while ($notice->fetch()) {
             if (time() - strtotime($notice->created) >= common_config('site', 'dupelimit')) {
                 return true;
             } else {
                 if ($notice->content == $content) {
                     return false;
                 }
             }
         }
     }
     // If we get here, oldest item in cache window is not
     // old enough for dupe limit; do direct check against DB
     $notice = new Notice();
     $notice->profile_id = $profile_id;
     $notice->content = $content;
     $threshold = common_sql_date(time() - common_config('site', 'dupelimit'));
     $notice->whereAdd(sprintf("created > '%s'", $notice->escape($threshold)));
     $cnt = $notice->count();
     return $cnt == 0;
 }
Exemplo n.º 8
0
 function noticeCount()
 {
     $c = common_memcache();
     if (!empty($c)) {
         $cnt = $c->get(common_cache_key('profile:notice_count:' . $this->id));
         if (is_integer($cnt)) {
             return (int) $cnt;
         }
     }
     $notices = new Notice();
     $notices->profile_id = $this->id;
     $cnt = (int) $notices->count('distinct id');
     if (!empty($c)) {
         $c->set(common_cache_key('profile:notice_count:' . $this->id), $cnt);
     }
     return $cnt;
 }
Exemplo n.º 9
0
 static function checkDupes($profile_id, $content)
 {
     $profile = Profile::staticGet($profile_id);
     if (empty($profile)) {
         return false;
     }
     $notice = $profile->getNotices(0, NOTICE_CACHE_WINDOW);
     if (!empty($notice)) {
         $last = 0;
         while ($notice->fetch()) {
             if (time() - strtotime($notice->created) >= common_config('site', 'dupelimit')) {
                 return true;
             } else {
                 if ($notice->content == $content) {
                     return false;
                 }
             }
         }
     }
     # If we get here, oldest item in cache window is not
     # old enough for dupe limit; do direct check against DB
     $notice = new Notice();
     $notice->profile_id = $profile_id;
     $notice->content = $content;
     if (common_config('db', 'type') == 'pgsql') {
         $notice->whereAdd('extract(epoch from now() - created) < ' . common_config('site', 'dupelimit'));
     } else {
         $notice->whereAdd('now() - created < ' . common_config('site', 'dupelimit'));
     }
     $cnt = $notice->count();
     return $cnt == 0;
 }
Exemplo n.º 10
0
 function noticeCount()
 {
     $c = Cache::instance();
     if (!empty($c)) {
         $cnt = $c->get(Cache::key('profile:notice_count:' . $this->id));
         if (is_integer($cnt)) {
             return (int) $cnt;
         }
     }
     $notices = new Notice();
     $notices->profile_id = $this->id;
     $notices->verb = ActivityVerb::POST;
     $cnt = (int) $notices->count('distinct id');
     if (!empty($c)) {
         $c->set(Cache::key('profile:notice_count:' . $this->id), $cnt);
     }
     return $cnt;
 }
 static function getCount($d)
 {
     $notice = new Notice();
     $notice->whereAdd('created BETWEEN "' . $d . ' 00:00:00" AND "' . self::incrementDay($d) . ' 00:00:00"');
     $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
     $n = $notice->count();
     return $n;
 }