X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fall.php;h=bd5b9f01e5f5dce8f642ea28300ee47d6d6734a1;hb=a034e13bf03fe06cf5d2500bd29506c71c67b6bb;hp=ae21b81ee68ddc4aab5136cc91be9be1a3f4f641;hpb=b104da04fbcdc39faae42b4a714b730e3e1b05f5;p=quix0rs-gnu-social.git diff --git a/actions/all.php b/actions/all.php index ae21b81ee6..bd5b9f01e5 100644 --- a/actions/all.php +++ b/actions/all.php @@ -48,7 +48,7 @@ class AllAction extends StreamAction { array($this, 'show_header'), $user, array($this, 'show_top')); - $this->show_notices($profile); + $this->show_notices($user); common_show_footer(); } @@ -71,37 +71,31 @@ class AllAction extends StreamAction { $this->views_menu(); } - function show_notices($profile) { + function show_notices($user) { - $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'); - - $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - - $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++) { - if ($notice->fetch()) { - $this->show_notice($notice); - } else { - // shouldn't happen! - break; - } + $page = $this->trimmed('page'); + if (!$page) { + $page = 1; + } + + $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + + common_element_start('ul', array('id' => 'notices')); + + $cnt = 0; + + while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) { + $cnt++; + + if ($cnt > NOTICES_PER_PAGE) { + break; } - common_element_end('ul'); + + $this->show_notice($notice); } + common_element_end('ul'); common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'all', array('nickname' => $profile->nickname)); + $page, 'all', array('nickname' => $user->nickname)); } }