/** * Prepare the action * * Reads and validates arguments and instantiates the attributes. * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $this->userProfile = Profile::current(); $user = common_current_user(); if (!empty($user) && $user->streamModeOnly()) { $stream = new GroupNoticeStream($this->group, $this->userProfile); } else { $stream = new ThreadingGroupNoticeStream($this->group, $this->userProfile); } $this->notice = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); common_set_returnto($this->selfUrl()); return true; }
/** * Prepare the action * * Reads and validates arguments and instantiates the attributes. * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $this->page = $this->arg('page') ? $this->arg('page') + 0 : 1; $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); if ($this->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('showgroup', $args), 301); return false; } if (!$nickname) { // TRANS: Client error displayed if no nickname argument was given requesting a group page. $this->clientError(_('No nickname.'), 404); return false; } $local = Local_group::staticGet('nickname', $nickname); if (!$local) { $alias = Group_alias::staticGet('alias', $nickname); if ($alias) { $args = array('id' => $alias->group_id); if ($this->page != 1) { $args['page'] = $this->page; } common_redirect(common_local_url('groupbyid', $args), 301); return false; } else { common_log(LOG_NOTICE, "Couldn't find local group for nickname '{$nickname}'"); // TRANS: Client error displayed if no remote group with a given name was found requesting group page. $this->clientError(_('No such group.'), 404); return false; } } $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { // TRANS: Client error displayed if no local group with a given name was found requesting group page. $this->clientError(_('No such group.'), 404); return false; } $this->userProfile = Profile::current(); $stream = new ThreadingGroupNoticeStream($this->group, $this->userProfile); $this->notice = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); common_set_returnto($this->selfUrl()); return true; }