summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/disfavor.php2
-rw-r--r--actions/favor.php3
-rw-r--r--actions/public.php34
-rw-r--r--actions/publicrss.php24
-rw-r--r--actions/replies.php35
-rw-r--r--actions/repliesrss.php24
-rw-r--r--actions/showstream.php26
-rw-r--r--actions/twitapistatuses.php51
-rw-r--r--actions/userrss.php13
9 files changed, 58 insertions, 154 deletions
diff --git a/actions/disfavor.php b/actions/disfavor.php
index ef01e891f..35cfd6070 100644
--- a/actions/disfavor.php
+++ b/actions/disfavor.php
@@ -63,6 +63,8 @@ class DisfavorAction extends Action {
$this->server_error(_('Could not delete favorite.'));
return;
}
+
+ $user->blowFavesCache();
if ($this->boolean('ajax')) {
common_start_html('text/xml');
diff --git a/actions/favor.php b/actions/favor.php
index a4baa817a..7718f84d2 100644
--- a/actions/favor.php
+++ b/actions/favor.php
@@ -62,7 +62,8 @@ class FavorAction extends Action {
}
$this->notify($fave, $notice, $user);
-
+ $user->blowFavesCache();
+
if ($this->boolean('ajax')) {
common_start_html('text/xml');
common_element_start('head');
diff --git a/actions/public.php b/actions/public.php
index f99215dad..e0b2b1635 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -59,32 +59,17 @@ class PublicAction extends StreamAction {
function show_notices($page) {
- $notice = new Notice();
-
- # XXX: sub-optimal
-
- if (common_config('public', 'localonly')) {
- $notice->is_local = 1;
- }
-
- $notice->orderBy('created DESC, notice.id DESC');
-
- # We fetch one extra, to see if we need an "older" link
-
- $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
-
- $cnt = $notice->find();
-
- if ($cnt > 0) {
+ $cnt = 0;
+ $notice = Notice::publicStream($page);
+
+ if ($notice) {
common_element_start('ul', array('id' => 'notices'));
- $iMax = min($cnt, NOTICES_PER_PAGE);
- for ($i = 0; $i < $iMax; $i++) {
- if ($notice->fetch()) {
- $this->show_notice($notice);
- } else {
- // shouldn't happen!
+ while ($notice->fetch()) {
+ $cnt++;
+ if ($cnt > NOTICES_PER_PAGE) {
break;
}
+ $this->show_notice($notice);
}
common_element_end('ul');
}
@@ -92,5 +77,4 @@ class PublicAction extends StreamAction {
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
$page, 'public');
}
-}
-
+} \ No newline at end of file
diff --git a/actions/publicrss.php b/actions/publicrss.php
index 98a1908ab..1ab6a8be0 100644
--- a/actions/publicrss.php
+++ b/actions/publicrss.php
@@ -30,29 +30,15 @@ class PublicrssAction extends Rss10Action {
}
function get_notices($limit=0) {
-
- $user = $this->user;
+
$notices = array();
-
- $notice = new Notice();
-
- # XXX: bad performance
-
- if (common_config('public', 'localonly')) {
- $notice->is_local = 1;
- }
-
- $notice->orderBy('created DESC, notice.id DESC');
-
- if ($limit != 0) {
- $notice->limit(0, $limit);
- }
- $notice->find();
-
+
+ $notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit);
+
while ($notice->fetch()) {
$notices[] = clone($notice);
}
-
+
return $notices;
}
diff --git a/actions/replies.php b/actions/replies.php
index ecf737eb1..c49960370 100644
--- a/actions/replies.php
+++ b/actions/replies.php
@@ -48,7 +48,7 @@ class RepliesAction extends StreamAction {
array($this, 'show_header'), $user,
array($this, 'show_top'));
- $this->show_replies($profile);
+ $this->show_replies($user);
common_show_footer();
}
@@ -75,35 +75,22 @@ class RepliesAction extends StreamAction {
$this->views_menu();
}
- function show_replies($profile) {
-
- $reply = new Reply();
-
- $reply->profile_id = $profile->id;
-
- $reply->orderBy('modified DESC');
+ function show_replies($user) {
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
- $reply->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
-
- $cnt = $reply->find();
-
- if ($cnt > 0) {
+ $notice = $user->getReplies(($page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+
+ $cnt = 0;
+
+ if ($notice) {
common_element_start('ul', array('id' => 'notices'));
- for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
- if ($reply->fetch()) {
- $notice = new Notice();
- $notice->id = $reply->notice_id;
- $result = $notice->find(true);
- if (!$result) {
- continue;
- }
- $this->show_notice($notice);
- } else {
- // shouldn't happen!
+ while ($notice->fetch()) {
+ $cnt++;
+ if ($cnt > NOTICES_PER_PAGE) {
break;
}
+ $this->show_notice($notice);
}
common_element_end('ul');
}
diff --git a/actions/repliesrss.php b/actions/repliesrss.php
index b811db7eb..7369db5e0 100644
--- a/actions/repliesrss.php
+++ b/actions/repliesrss.php
@@ -42,27 +42,13 @@ class RepliesrssAction extends Rss10Action {
function get_notices($limit=0) {
$user = $this->user;
- $notices = array();
-
- $reply = new Reply();
- $reply->profile_id = $user->id;
- $reply->orderBy('modified DESC');
- if ($limit) {
- $reply->limit(0, $limit);
- }
- $cnt = $reply->find();
+ $notice = $user->getReplies(0, ($limit == 0) ? 48 : $limit);
- if ($cnt) {
- while ($reply->fetch()) {
- $notice = new Notice();
- $notice->id = $reply->notice_id;
- $result = $notice->find(true);
- if (!$result) {
- continue;
- }
- $notices[] = clone($notice);
- }
+ $notices = array();
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
}
return $notices;
diff --git a/actions/showstream.php b/actions/showstream.php
index 43556a0ed..d0f72280b 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -337,31 +337,27 @@ class ShowstreamAction extends StreamAction {
function show_notices($profile) {
- $notice = DB_DataObject::factory('notice');
- $notice->profile_id = $profile->id;
-
- $notice->orderBy('created DESC, notice.id DESC');
-
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
- $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
-
- $cnt = $notice->find();
+ $notice = $user->getNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+
+ $cnt = 0;
- if ($cnt > 0) {
+ if ($notice) {
+
common_element_start('ul', array('id' => 'notices'));
-
- for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
- if ($notice->fetch()) {
- $this->show_notice($notice);
- } else {
- // shouldn't happen!
+
+ while ($notice->fetch()) {
+ $cnt++;
+ if ($cnt > NOTICES_PER_PAGE) {
break;
}
+ $this->show_notice($notice);
}
common_element_end('ul');
}
+
common_pagination($page>1, $cnt>NOTICES_PER_PAGE, $page,
'showstream', array('nickname' => $profile->nickname));
}
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 87e805e87..723c19499 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -54,22 +54,12 @@ class TwitapistatusesAction extends TwitterapiAction {
// Number of public statuses to return by default -- Twitter sends 20
$MAX_PUBSTATUSES = 20;
- $notice = new Notice();
-
// FIXME: To really live up to the spec we need to build a list
// of notices by users who have custom avatars, so fix this SQL -- Zach
- # XXX: sub-optimal performance
-
- if (common_config('public', 'localonly')) {
- $notice->is_local = 1;
- }
-
- $notice->orderBy('created DESC, notice.id DESC');
- $notice->limit($MAX_PUBSTATUSES);
- $cnt = $notice->find();
-
- if ($cnt > 0) {
+ $notice = Notice::publicStream(0, $MAX_PUBSTATUSES);
+
+ if ($notice) {
switch($apidata['content-type']) {
case 'xml':
@@ -341,18 +331,10 @@ class TwitapistatusesAction extends TwitterapiAction {
$link = common_local_url('showstream', array('nickname' => $user->nickname));
$subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
- $notice = new Notice();
-
- $notice->profile_id = $user->id;
-
# XXX: since
# XXX: since_id
- $notice->orderBy('created DESC, notice.id DESC');
-
- $notice->limit((($page-1)*20), $count);
-
- $cnt = $notice->find();
+ $notice = $user->getNotices((($page-1)*20), $count);
switch($apidata['content-type']) {
case 'xml':
@@ -490,30 +472,11 @@ class TwitapistatusesAction extends TwitterapiAction {
$count = 20;
}
- $reply = new Reply();
-
- $reply->profile_id = $user->id;
-
- $reply->orderBy('modified DESC');
-
- $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-
- $reply->limit((($page-1)*20), $count);
-
- $cnt = $reply->find();
-
+ $notice = $user->getReplies((($page-1)*20), $count);
$notices = array();
- if ($cnt) {
- while ($reply->fetch()) {
- $notice = new Notice();
- $notice->id = $reply->notice_id;
- $result = $notice->find(true);
- if (!$result) {
- continue;
- }
- $notices[] = clone($notice);
- }
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
}
switch($apidata['content-type']) {
diff --git a/actions/userrss.php b/actions/userrss.php
index e60851915..da305f675 100644
--- a/actions/userrss.php
+++ b/actions/userrss.php
@@ -42,14 +42,13 @@ class UserrssAction extends Rss10Action {
function get_notices($limit=0) {
$user = $this->user;
- $notices = array();
-
- $notice = DB_DataObject::factory('notice');
- $notice->profile_id = $user->id; # user id === profile id
- $notice->orderBy('created DESC, notice.id DESC');
- if ($limit != 0) {
- $notice->limit(0, $limit);
+
+ if (is_null($user)) {
+ return NULL;
}
+
+ $notice = $user->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
+
$notice->find();
while ($notice->fetch()) {