- parent::prepare($args);
-
- $nickname = common_canonical_nickname($this->arg('nickname'));
-
- $this->user = User::getKV('nickname', $nickname);
-
- if (!$this->user) {
- // TRANS: Client error displayed when trying to display favourite notices for a non-existing user.
- $this->clientError(_('No such user.'));
- }
-
- $this->page = $this->trimmed('page');
-
- if (!$this->page) {
- $this->page = 1;
- }
-
- common_set_returnto($this->selfUrl());
-
- $cur = common_current_user();
-
- if (!empty($cur) && $cur->id == $this->user->id) {
-
- // Show imported/gateway notices as well as local if
- // the user is looking at their own favorites
-
- $this->notice = $this->user->favoriteNotices(true, ($this->page-1)*NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1);
- } else {
- $this->notice = $this->user->favoriteNotices(false, ($this->page-1)*NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1);
- }
-
- if (empty($this->notice)) {
- // TRANS: Server error displayed when favourite notices could not be retrieved from the database.
- $this->serverError(_('Could not retrieve favorite notices.'));
- }
-
- if($this->page > 1 && $this->notice->N == 0){
- // TRANS: Server error when page not found (404)
- $this->serverError(_('No such page.'),$code=404);
- }
-
- return true;