/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { parent::prepare($argarray); $cur = common_current_user(); if (empty($cur)) { throw new ClientException(_('Only for logged-in users'), 403); } $nicknameArg = $this->trimmed('nickname'); $nickname = common_canonical_nickname($nicknameArg); if ($nickname != $nicknameArg) { $url = common_local_url('groupinbox', array('nickname' => $nickname)); common_redirect($url); return false; } $localGroup = Local_group::staticGet('nickname', $nickname); if (empty($localGroup)) { throw new ClientException(_('No such group'), 404); } $this->group = User_group::staticGet('id', $localGroup->group_id); if (empty($this->group)) { throw new ClientException(_('No such group'), 404); } if (!$cur->isMember($this->group)) { throw new ClientException(_('Only for members'), 403); } $this->page = $this->trimmed('page'); if (!$this->page) { $this->page = 1; } $this->gm = Group_message::forGroup($this->group, ($this->page - 1) * MESSAGES_PER_PAGE, MESSAGES_PER_PAGE + 1); return true; }
function showScripts() { parent::showScripts(); $this->autofocus('nickname'); }
function handle($args) { parent::handle($args); $this->showPage(); }
/** * Add the jCrop scripts * * @return void */ function showScripts() { parent::showScripts(); if ($this->mode == 'crop') { $this->script('jcrop/jquery.Jcrop.min.js'); $this->script('jcrop/jquery.Jcrop.go.js'); } $this->autofocus('avatarfile'); }
/** * 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; } common_set_returnto($this->selfUrl()); return true; }