]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/all.php
Twitter-compatible API: support for new in_reply_to_status_id in statuses/update
[quix0rs-gnu-social.git] / actions / all.php
index 20aea766868552348f4b275a84bd29642a85dccb..bd5b9f01e5f5dce8f642ea28300ee47d6d6734a1 100644 (file)
@@ -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, 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();
-
-               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));
        }
 }