]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/all.php
save notice to inbox on saveNew
[quix0rs-gnu-social.git] / actions / all.php
index 038572ba80f12132013a6e44fadab25bbefed310..bd5b9f01e5f5dce8f642ea28300ee47d6d6734a1 100644 (file)
@@ -21,35 +21,81 @@ if (!defined('LACONICA')) { exit(1); }
 
 require_once(INSTALLDIR.'/actions/showstream.php');
 
-class AllAction extends ShowstreamAction {
+class AllAction extends StreamAction {
 
-       // XXX: push this up to a common function.
+       function handle($args) {
 
-       function show_notices($profile) {
+               parent::handle($args);
 
-               $notice = DB_DataObject::factory('notice');
+               $nickname = common_canonical_nickname($this->arg('nickname'));
+               $user = User::staticGet('nickname', $nickname);
 
-               # XXX: chokety and bad
+               if (!$user) {
+                       $this->client_error(_('No such user.'));
+                       return;
+               }
+
+               $profile = $user->getProfile();
+
+               if (!$profile) {
+                       common_server_error(_('User has no profile.'));
+                       return;
+               }
+
+               # Looks like we're good; show the header
+
+               common_show_header(sprintf(_("%s and friends"), $profile->nickname),
+                                                  array($this, 'show_header'), $user,
+                                                  array($this, 'show_top'));
 
-               $notice->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$profile->id.' and subscribed = notice.profile_id)', 'OR');
-               $notice->whereAdd('profile_id = ' . $profile->id, 'OR');
+               $this->show_notices($user);
 
-               $notice->orderBy('created DESC');
+               common_show_footer();
+       }
+
+       function show_header($user) {
+               common_element('link', array('rel' => 'alternate',
+                                                                        'href' => common_local_url('allrss', array('nickname' =>
+                                                                                                                                                          $user->nickname)),
+                                                                        'type' => 'application/rss+xml',
+                                                                        'title' => sprintf(_('Feed for friends of %s'), $user->nickname)));
+       }
 
-               $page = $this->arg('page') || 1;
+       function show_top($user) {
+               $cur = common_current_user();
 
-               $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE);
+               if ($cur && $cur->id == $user->id) {
+                       common_notice_form('all');
+               }
 
-               $notice->find();
+               $this->views_menu();
+       }
 
-               common_element_start('div', 'notices');
-               common_element('h2', 'notices', _t('Notices'));
+       function show_notices($user) {
 
-               while ($notice->fetch()) {
+               $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;
+                       }
+                       
                        $this->show_notice($notice);
                }
+               common_element_end('ul');
 
-               # XXX: show a link for the next page
-               common_element_end('div');
+               common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
+                                                 $page, 'all', array('nickname' => $user->nickname));
        }
 }