array($this, 'show_header'), $user,
array($this, 'show_top'));
- $this->show_notices($profile);
+ $this->show_notices($user);
common_show_footer();
}
$this->views_menu();
}
- function show_notices($profile) {
-
- $notice = DB_DataObject::factory('notice');
-
- # XXX: chokety and bad
-
- $notice->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$profile->id.' and subscribed = notice.profile_id)', 'OR');
- $notice->whereAdd('profile_id = ' . $profile->id, 'OR');
-
- $notice->orderBy('created DESC, notice.id DESC');
-
- $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
+ function show_notices($user) {
+ $page = $this->trimmed('page');
+ if (!$page) {
+ $page = 1;
+ }
+
+ $notice = $user->noticesWithFriends($page);
+ # 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'));
for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
function get_notices($limit=0) {
$user = $this->user;
- $notices = array();
-
- $notice = DB_DataObject::factory('notice');
-
- $notice->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$user->id.' and subscribed = notice.profile_id)', 'OR');
- $notice->whereAdd('profile_id = ' . $user->id, 'OR');
-
- $notice->orderBy('created DESC, notice.id DESC');
+
+ $notice = $user->noticesWithFriends();
+
if ($limit != 0) {
$notice->limit(0, $limit);
}
+
$notice->find();
while ($notice->fetch()) {
$link = common_local_url('all', array('nickname' => $user->nickname));
$subtitle = sprintf(_("Updates from %s and friends on %s!"), $user->nickname, $sitename);
- $notice = new Notice();
-
- # XXX: chokety and bad
-
- $notice->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$profile->id.' and subscribed = notice.profile_id)', 'OR');
- $notice->whereAdd('profile_id = ' . $profile->id, 'OR');
-
- # XXX: since
- # XXX: since_id
+ $notice->$user->noticesWithFriends();
- $notice->orderBy('created DESC, notice.id DESC');
-
$notice->limit((($page-1)*20), $count);
$cnt = $notice->find();
return true;
}
+
+ function noticesWithFriends() {
+
+ $notice = new Notice();
+
+ $notice->selectAs();
+
+ $subscription = new Subscription();
+
+ $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;
+ }
}
[queue_item]
notice_id = notice:id
+[subscription]
+subscriber = profile:id
+subscribed = profile:id
define('AVATAR_MINI_SIZE', 24);
define('MAX_AVATAR_SIZE', 256 * 1024);
+define('NOTICES_PER_PAGE', 20);
+
define_syslog_variables();
# global configuration object
if (!defined('LACONICA')) { exit(1); }
-define('NOTICES_PER_PAGE', 20);
-
class StreamAction extends Action {
function handle($args) {