X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fshowstream.php;h=5650038b340f403137f70c1ce4e474e489966dbb;hb=f2e3021b59f3661b3c900b06600a580b8970df2f;hp=563a743bc52e58daf6c5d34090bfce38e7060639;hpb=124762160a15a5b2407ac2d1814dc195fd8c64f2;p=quix0rs-gnu-social.git diff --git a/actions/showstream.php b/actions/showstream.php index 563a743bc5..5650038b34 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -58,7 +58,7 @@ class ShowstreamAction extends StreamAction { $this->show_profile($profile); - $this->show_notices($profile); + $this->show_notices($user); common_show_footer(); } @@ -149,8 +149,8 @@ class ShowstreamAction extends StreamAction { $user = User::staticGet('id', $profile->id); - if ($cur->mutuallySubscribed($user)) { - common_element('a', array('href' => common_local_url('newmessage', array('nickname' => $user->nickname))), + if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) { + common_element('a', array('href' => common_local_url('newmessage', array('to' => $user->id))), _('Send a message')); } @@ -252,6 +252,11 @@ class ShowstreamAction extends StreamAction { $other = Profile::staticGet($subs->subscribed); + if (!$other) { + common_log_db_error($subs, 'SELECT', __FILE__); + continue; + } + common_element_start('li'); common_element_start('a', array('title' => ($other->fullname) ? $other->fullname : @@ -330,35 +335,31 @@ class ShowstreamAction extends StreamAction { common_element_end('div'); } - function show_notices($profile) { - - $notice = DB_DataObject::factory('notice'); - $notice->profile_id = $profile->id; - - $notice->orderBy('created DESC, notice.id DESC'); + function show_notices($user) { $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1); - - $cnt = $notice->find(); + $notice = $user->getNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + + $cnt = 0; - if ($cnt > 0) { + if ($notice) { + 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! + + while ($notice->fetch()) { + $cnt++; + if ($cnt > NOTICES_PER_PAGE) { break; } + $this->show_notice($notice); } common_element_end('ul'); } + common_pagination($page>1, $cnt>NOTICES_PER_PAGE, $page, - 'showstream', array('nickname' => $profile->nickname)); + 'showstream', array('nickname' => $user->nickname)); } function show_last_notice($profile) { @@ -389,6 +390,13 @@ class ShowstreamAction extends StreamAction { # XXX: RDFa common_element_start('li', array('class' => 'notice_single', 'id' => 'notice-' . $notice->id)); + if ($user) { + if ($user->hasFave($notice)) { + common_disfavor_form($notice); + } else { + common_favor_form($notice); + } + } $noticeurl = common_local_url('shownotice', array('notice' => $notice->id)); # FIXME: URL, image, video, audio common_element_start('p');