]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/showstream.php
better deletion of old avatars
[quix0rs-gnu-social.git] / actions / showstream.php
index 03e8de29c884ae9a4f49033f2468a70741897a53..82a55518da60fdfafca3b770d25847d853a45757 100644 (file)
@@ -35,12 +35,14 @@ class ShowstreamAction extends StreamAction {
 
                if (!$user) {
                        $this->no_such_user();
+                       return;
                }
 
                $profile = $user->getProfile();
 
                if (!$profile) {
                        common_server_error(_t('User record exists without profile.'));
+                       return;                 
                }
 
                # Looks like we're good; show the header
@@ -57,7 +59,7 @@ class ShowstreamAction extends StreamAction {
 
                $this->show_last_notice($profile);
 
-               if ($cur) {
+               if ($cur && $cur->id != $profile->id) {
                        if ($cur->isSubscribed($profile)) {
                                $this->show_unsubscribe_form($profile);
                        } else {
@@ -81,8 +83,10 @@ class ShowstreamAction extends StreamAction {
        function notice_form() {
                common_element_start('form', array('id' => 'newnotice', 'method' => 'POST',
                                                                                   'action' => common_local_url('newnotice')));
-               common_element('textarea', array('rows' => 4, 'cols' => 80, 'id' => 'content'));
-               common_element('input', array('type' => 'submit'), 'Send');
+               common_element('textarea', array('rows' => 4, 'cols' => 80,
+                                                                                'name' => 'content', 
+                                                                                'id' => 'content'));
+               common_element('input', array('type' => 'submit', 'value' => 'Send'));
                common_element_end('form');
        }
 
@@ -121,7 +125,7 @@ class ShowstreamAction extends StreamAction {
                                                                          'name' => 'subscribeto',
                                                                          'type' => 'hidden',
                                                                          'value' => $profile->nickname));
-               common_element('input', array('type' => 'submit'), _t('subscribe'));
+               common_element('input', array('type' => 'submit', 'value' => _t('Subscribe')));
                common_element_end('form');
        }
 
@@ -188,13 +192,25 @@ class ShowstreamAction extends StreamAction {
                $subs->subscriber = $profile->id;
                $subs_count = $subs->count();
 
+               if (!$subs_count) {
+                       $subs_count = 0;
+               }
+               
                $subbed = DB_DataObject::factory('subscription');
                $subbed->subscribed = $profile->id;
                $subbed_count = $subbed->count();
 
+               if (!$subbed_count) {
+                       $subbed_count = 0;
+               }
+               
                $notices = DB_DataObject::factory('notice');
                $notices->profile_id = $profile->id;
                $notice_count = $notices->count();
+               
+               if (!$notice_count) {
+                       $notice_count = 0;
+               }
 
                # Other stats...?
                common_element_start('dl', 'statistics');
@@ -216,7 +232,7 @@ class ShowstreamAction extends StreamAction {
 
                $page = $this->arg('page') || 1;
 
-               $notice->limit((($page-1)*NOTICES_PER_PAGE) + 1, NOTICES_PER_PAGE);
+               $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE);
 
                $notice->find();
 
@@ -225,7 +241,7 @@ class ShowstreamAction extends StreamAction {
                while ($notice->fetch()) {
                        $this->show_notice($notice);
                }
-
+               # XXX: show a link for the next page
                common_element_end('div');
        }
 
@@ -233,7 +249,7 @@ class ShowstreamAction extends StreamAction {
                $notice = DB_DataObject::factory('notice');
                $notice->profile_id = $profile->id;
                $notice->orderBy('created DESC');
-               $notice->limit(1, 1);
+               $notice->limit(0, 1);
                $notice->find();
 
                while ($notice->fetch()) {