X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Freplies.php;h=f5bc2ce1a43801f0ebc5a35d87a9cf8cae61dcee;hb=74291968c4b4f1fca29cb79caad695a1e2360734;hp=14f19cd765c72138a8d830449865680bdfa4b785;hpb=0b21ac3dd79d2bf39341a4f0ff3566def8282eae;p=quix0rs-gnu-social.git diff --git a/actions/replies.php b/actions/replies.php index 14f19cd765..f5bc2ce1a4 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -38,66 +38,64 @@ class RepliesAction extends StreamAction { $profile = $user->getProfile(); if (!$profile) { - common_server_error(_t('User record exists without profile.')); + common_server_error(_('User has no profile.')); return; } # Looks like we're good; show the header - common_show_header($profile->nickname . _t(" and friends"), + common_show_header(sprintf(_("Replies to %s"), $profile->nickname), array($this, 'show_header'), $user, array($this, 'show_top')); - - $this->show_replies($profile); - + + $this->show_replies($user); + common_show_footer(); } - + + function no_such_user() { + common_user_error(_('No such user.')); + } + function show_header($user) { common_element('link', array('rel' => 'alternate', - 'href' => common_local_url('allrss', array('nickname' => - $user->nickname)), + 'href' => common_local_url('repliesrss', array('nickname' => + $user->nickname)), 'type' => 'application/rss+xml', - 'title' => _t('Feed for friends of ') . $user->nickname)); + 'title' => sprintf(_('Feed for replies to %s'), $user->nickname))); } function show_top($user) { $cur = common_current_user(); - - $this->views_menu(); - } - - function show_replies($profile) { - $reply = DB_DataObject::factory('reply'); + if ($cur && $cur->id == $user->id) { + common_notice_form('replies'); + } - $reply->user_id = $profile->id; + $this->views_menu(); + } - $reply->orderBy('created DESC'); + function show_replies($user) { $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - $reply->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1); - - $cnt = $reply->find(); - - if ($cnt > 0) { - common_element_start('ul', array('id' => 'replies')); - for ($i = 0; $i < min($cnt, REPLIES_PER_PAGE); $i++) { - if ($reply->fetch()) { - $notice = DB_DataObject::factory('notice'); - $notice->id = $reply->notice_id; - $notice->find(1); - $this->show_reply($notice, $reply->replied_id); - } else { - // shouldn't happen! + $notice = $user->getReplies(($page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + + $cnt = 0; + + if ($notice) { + common_element_start('ul', array('id' => 'notices')); + while ($notice->fetch()) { + $cnt++; + if ($cnt > NOTICES_PER_PAGE) { break; } + $this->show_notice($notice); } common_element_end('ul'); } - - common_pagination($page > 1, $cnt > REPLIES_PER_PAGE, - $page, 'all', array('nickname' => $profile->nickname)); + + common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, + $page, 'replies', array('nickname' => $user->nickname)); } }