]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/all.php
generate an etag for shownotice
[quix0rs-gnu-social.git] / actions / all.php
index ae21b81ee68ddc4aab5136cc91be9be1a3f4f641..729b8dd16aec644e619fa6040967e5baa0e64216 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();
        }
@@ -69,39 +69,38 @@ class AllAction extends StreamAction {
                }
 
                $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');
-
-               $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-
-               $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
+               $this->show_feeds_list(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $user->nickname)),
+                                                                                         'type' => 'rss',
+                                                                                         'version' => 'RSS 1.0',
+                                                                                         'item' => 'allrss')));
+       }
 
-               $cnt = $notice->find();
+       function show_notices($user) {
 
-               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));
        }
 }