$page = 1;
}
- $notice = $user->noticesWithFriends($page);
+ $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+
# XXX: revisit constant scope
- $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
-
+ $cnt = $notice->find();
if ($cnt > 0) {
common_element_start('ul', array('id' => 'notices'));
$user = $this->user;
- $notice = $user->noticesWithFriends();
+ $notice = $user->noticesWithFriends(0, $limit);
+
+ # XXX: revisit constant scope
- if ($limit != 0) {
- $notice->limit(0, $limit);
- }
-
- $notice->find();
+ $cnt = $notice->find();
while ($notice->fetch()) {
$notices[] = clone($notice);
$link = common_local_url('all', array('nickname' => $user->nickname));
$subtitle = sprintf(_("Updates from %s and friends on %s!"), $user->nickname, $sitename);
- $notice->$user->noticesWithFriends();
-
- $notice->limit((($page-1)*20), $count);
+ $notice->$user->noticesWithFriends(($page-1)*20, $count);
$cnt = $notice->find();
return true;
}
-
- function noticesWithFriends() {
+
+ function noticesWithFriends($offset=0, $limit=20) {
$notice = new Notice();
- $notice->selectAs();
-
- $subscription = new Subscription();
+ $notice->query('SELECT notice.* ' .
+ 'FROM notice JOIN subscription on notice.profile_id = subscription.subscribed' .
+ 'WHERE subscription.subscriber = ' . $this->id .
+ 'ORDER BY created DESC, notice.id DESC ' .
+ 'LIMIT ' . $offset . ', ' . $limit);
- $subscription->subscriber = $this->id;
-
- $notice->joinAdd($subscription);
- $notice->whereAdd('notice.profile_id = subscription.subscribed');
- $notice->selectAs($subscription, 'sub_%');
-
- $notice->orderBy('created DESC, notice.id DESC');
-
return $notice;
}
}