function onEndAvatarFormData($action) { $user = common_current_user(); $hasGravatar = $this->hasGravatar($user->id); if (!empty($user->email) && !$hasGravatar) { //and not gravatar already set $action->elementStart('form', array('method' => 'post', 'id' => 'form_settings_gravatar_add', 'class' => 'form_settings', 'action' => common_local_url('avatarsettings'))); $action->elementStart('fieldset', array('id' => 'settings_gravatar_add')); $action->element('legend', null, _m('Set Gravatar')); $action->hidden('token', common_session_token()); $action->element('p', 'form_guide', _m('If you want to use your Gravatar image, click "Add".')); $action->element('input', array('type' => 'submit', 'id' => 'settings_gravatar_add_action-submit', 'name' => 'add', 'class' => 'submit', 'value' => _m('Add'))); $action->elementEnd('fieldset'); $action->elementEnd('form'); } elseif ($hasGravatar) { $action->elementStart('form', array('method' => 'post', 'id' => 'form_settings_gravatar_remove', 'class' => 'form_settings', 'action' => common_local_url('avatarsettings'))); $action->elementStart('fieldset', array('id' => 'settings_gravatar_remove')); $action->element('legend', null, _m('Remove Gravatar')); $action->hidden('token', common_session_token()); $action->element('p', 'form_guide', _m('If you want to remove your Gravatar image, click "Remove".')); $action->element('input', array('type' => 'submit', 'id' => 'settings_gravatar_remove_action-submit', 'name' => 'remove', 'class' => 'submit', 'value' => _m('Remove'))); $action->elementEnd('fieldset'); $action->elementEnd('form'); } else { $action->element('p', 'form_guide', _m('To use a Gravatar first enter in an email address.')); } }
function prepare($args) { parent::prepare($args); $this->user = common_current_user(); if (empty($this->user)) { // TRANS: Client error displayed when trying to repeat a notice while not logged in. $this->clientError(_('Only logged-in users can repeat notices.')); return false; } $id = $this->trimmed('notice'); if (empty($id)) { // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID. $this->clientError(_('No notice specified.')); return false; } $this->notice = Notice::staticGet('id', $id); if (empty($this->notice)) { // TRANS: Client error displayed when trying to repeat a non-existing notice. $this->clientError(_('No notice specified.')); return false; } $token = $this->trimmed('token-' . $id); if (empty($token) || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. Try again, please.')); return false; } return true; }
/** * Check pre-requisites and instantiate attributes * * @param Array $args array of arguments (URL, GET, POST) * * @return boolean success flag */ function prepare($args) { parent::prepare($args); // @fixme these are pretty common, should a parent class factor these out? // Only allow POST requests if ($_SERVER['REQUEST_METHOD'] != 'POST') { // TRANS: Client error displayed when trying to use another method than POST. // TRANS: Do not translate POST. $this->clientError(_('This action only accepts POST requests.')); } // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token.' . ' Try again, please.')); } // Only for logged-in users $this->user = common_current_user(); if (empty($this->user)) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); } if (!AdminPanelAction::canAdmin('plugins')) { // TRANS: Client error displayed when trying to enable or disable a plugin without access rights. $this->clientError(_('You cannot administer plugins.')); } $this->plugin = $this->arg('plugin'); $defaultPlugins = common_config('plugins', 'default'); if (!array_key_exists($this->plugin, $defaultPlugins)) { // TRANS: Client error displayed when trying to enable or disable a non-existing plugin. $this->clientError(_('No such plugin.')); } return true; }
/** * Check pre-requisites and instantiate attributes * * @param Array $args array of arguments (URL, GET, POST) * * @return boolean success flag */ function prepare($args) { parent::prepare($args); // Only for logged-in users $this->user = common_current_user(); if (empty($this->user)) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); } // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token.' . ' Try again, please.')); } $profile = $this->user->getProfile(); $tags = $profile->getLists($this->scoped); $this->tags = array(); while ($tags->fetch()) { if (empty($this->last_mod)) { $this->last_mod = $tags->modified; } $arr = array(); $arr['tag'] = $tags->tag; $arr['mode'] = $tags->private ? 'private' : 'public'; // $arr['url'] = $tags->homeUrl(); $arr['freq'] = $tags->taggedCount(); $this->tags[] = $arr; } $tags = NULL; return true; }
/** * Check pre-requisites and instantiate attributes * * @param Array $args array of arguments (URL, GET, POST) * * @return boolean success flag */ function prepare($args) { parent::prepare($args); // Only allow POST requests if ($_SERVER['REQUEST_METHOD'] != 'POST') { // TRANS: Client error displayed trying to perform any request method other than POST. // TRANS: Do not translate POST. $this->clientError(_('This action only accepts POST requests.')); return false; } // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token is not okay. $this->clientError(_('There was a problem with your session token.' . ' Try again, please.')); return false; } // Only for logged-in users $this->user = common_current_user(); if (empty($this->user)) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); return false; } // Profile to subscribe to $other_id = $this->arg('subscribeto'); $this->other = Profile::staticGet('id', $other_id); if (empty($this->other)) { // TRANS: Client error displayed trying to subscribe to a non-existing profile. $this->clientError(_('No such profile.')); return false; } return true; }
function prepare($args) { parent::prepare($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return false; } $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->clientError(_('网页错误,请返回重试 ')); return false; } $id = $this->trimmed('profile'); if (!$id) { $this->clientError(_('No profile specified.')); return false; } $this->profile = Profile::staticGet('id', $id); if (!$this->profile) { $this->clientError(_('No profile with that ID.')); return false; } return true; }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('all', array('nickname' => $user->nickname))); return; } $idGroup = $this->trimmed('idGroup'); $token = $this->trimmed('token-' . $idGroup); if (!$token || $token != common_session_token()) { $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } if ($this->trimmed('submit-auto') != null) { $groupids = NotesPDF::getNoticeIDsInAGroupModeAuto($idGroup); $notices = Notice::multiGet('id', $groupids)->fetchAll(); GenerarPDF::content($idGroup, $notices, 'Automáticos'); } else { if ($this->trimmed('submit-custom') != null) { $tag = $this->trimmed('combo-tag') == 'Todos' ? '%' : $this->trimmed('combo-tag'); $nick = $this->trimmed('combo-user') == 'Todos' ? '%' : $this->trimmed('combo-user'); $grade = $this->trimmed('combo-grade') == 'Todos' ? '%' : $this->trimmed('combo-grade'); $noticeIds = NotesPDF::getNoticesInModeCustom(array('idGroup' => $idGroup, 'tag' => $tag, 'nick' => $nick, 'grade' => $grade)); $notices = Notice::multiGet('id', $noticeIds)->fetchAll(); GenerarPDF::content($idGroup, $notices, 'Personalizados'); } else { $this->showForm('Error al generar los apuntes. Inténtelo de nuevo en unos minutos.'); } } }
function handle($args) { // Trigger short error responses; not a human-readable web page. StatusNet::setApi(true); // We're not a general oEmbed proxy service; limit to valid sessions. $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_m('There was a problem with your session token. ' . 'Try again, please.')); } $format = $this->arg('format'); if ($format && $format != 'json') { // TRANS: Client exception thrown when requesting a different format than JSON. throw new ClientException(_m('Invalid format; only JSON supported.')); } $url = $this->arg('url'); if (!common_valid_http_url($url)) { // TRANS: Client exception thrown when not providing a valid URL. throw new ClientException(_m('Invalid URL.')); } $params = array(); if ($this->arg('maxwidth')) { $params['maxwidth'] = $this->arg('maxwidth'); } if ($this->arg('maxheight')) { $params['maxheight'] = $this->arg('maxheight'); } $data = oEmbedHelper::getObject($url, $params); $this->init_document('json'); print json_encode($data); }
/** * Prepare to run */ function prepare($args) { parent::prepare($args); if (!common_logged_in()) { // TRANS: Client error displayed when trying to perform an action while not logged in. $this->clientError(_('You must be logged in to unsubscribe from a list.')); } // Only allow POST requests if ($_SERVER['REQUEST_METHOD'] != 'POST') { // TRANS: Client error displayed when trying to use another method than POST. $this->clientError(_('This action only accepts POST requests.')); } // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token.' . ' Try again, please.')); } $tagger_arg = $this->trimmed('tagger'); $tag_arg = $this->trimmed('tag'); $id = intval($this->arg('id')); if ($id) { $this->peopletag = Profile_list::getKV('id', $id); } else { // TRANS: Client error displayed when trying to perform an action without providing an ID. $this->clientError(_('No ID given.'), 404); } if (!$this->peopletag || $this->peopletag->private) { // TRANS: Client error displayed trying to reference a non-existing list. $this->clientError(_('No such list.'), 404); } $this->tagger = Profile::getKV('id', $this->peopletag->tagger); return true; }
function showContent() { if (!empty($this->message_text)) { $this->element('p', null, $this->message); return; } $this->elementStart('form', array('method' => 'post', 'id' => 'account_connect', 'action' => common_local_url('finishopenidlogin'))); $this->hidden('token', common_session_token()); $this->element('h2', null, _('Create new account')); $this->element('p', null, _('Create a new user with this nickname.')); $this->input('newname', _('New nickname'), $this->username ? $this->username : '', _('1-64 lowercase letters or numbers, no punctuation or spaces')); $this->elementStart('p'); $this->element('input', array('type' => 'checkbox', 'id' => 'license', 'name' => 'license', 'value' => 'true')); $this->text(_('My text and files are available under ')); $this->element('a', array('href' => common_config('license', 'url')), common_config('license', 'title')); $this->text(_(' except this private data: password, email address, IM address, phone number.')); $this->elementEnd('p'); $this->submit('create', _('Create')); $this->element('h2', null, _('Connect existing account')); $this->element('p', null, _('If you already have an account, login with your username and password to connect it to your OpenID.')); $this->input('nickname', _('Existing nickname')); $this->password('password', _('Password')); $this->submit('connect', _('Connect')); $this->elementEnd('form'); }
/** * Check pre-requisites and instantiate attributes * * @param Array $args array of arguments (URL, GET, POST) * * @return boolean success flag */ function prepare($args) { parent::prepare($args); // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token.' . ' Try again, please.')); return false; } // Only for logged-in users $this->user = common_current_user(); if (empty($this->user)) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); return false; } $id = $this->arg('peopletag_id'); $this->peopletag = Profile_list::staticGet('id', $id); if (empty($this->peopletag)) { // TRANS: Client error displayed trying to reference a non-existing list. $this->clientError(_('No such list.')); return false; } $field = $this->arg('field'); if (!in_array($field, array('fulltext', 'nickname', 'fullname', 'description', 'location', 'uri'))) { // TRANS: Client error displayed when trying to add an unindentified field to profile. // TRANS: %s is a field name. $this->clientError(sprintf(_('Unidentified field %s.'), htmlspecialchars($field)), 404); return false; } $this->field = $field; return true; }
function prepare($args) { parent::prepare($args); if (!common_logged_in()) { // TRANS: Client error displayed trying a change a subscription while not logged in. $this->clientError(_('Not logged in.')); return false; } $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->clientError(_('There was a problem with your session token. ' . 'Try again, please.')); return false; } $id = $this->trimmed('profile'); if (!$id) { // TRANS: Client error displayed trying a change a subscription without providing a profile. $this->clientError(_('No profile specified.')); return false; } $this->profile = Profile::staticGet('id', $id); if (!$this->profile) { // TRANS: Client error displayed trying a change a subscription for a non-existant profile ID. $this->clientError(_('No profile with that ID.')); return false; } return true; }
function prepare($args) { parent::prepare($args); $this->user = common_current_user(); if (empty($this->user)) { $this->clientError(_('Only logged-in users can repeat notices.')); return false; } $id = $this->trimmed('notice'); if (empty($id)) { $this->clientError(_('No notice specified.')); return false; } $this->notice = Notice::staticGet('id', $id); if (empty($this->notice)) { $this->clientError(_('No notice specified.')); return false; } if ($this->user->id == $this->notice->profile_id) { $this->clientError(_("You can't repeat your own notice.")); return false; } $token = $this->trimmed('token-' . $id); if (empty($token) || $token != common_session_token()) { $this->clientError(_('There was a problem with your session token. Try again, please.')); return false; } $profile = $this->user->getProfile(); if ($profile->hasRepeated($id)) { $this->clientError(_('You already repeated that notice.')); return false; } return true; }
/** * Check pre-requisites and instantiate attributes * * @param Array $args array of arguments (URL, GET, POST) * * @return boolean success flag */ function prepare($args) { parent::prepare($args); // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token.' . ' Try again, please.')); } // Only for logged-in users $this->user = common_current_user(); if (empty($this->user)) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); } // Profile to subscribe to $tagged_id = $this->arg('tagged'); $this->tagged = Profile::getKV('id', $tagged_id); if (empty($this->tagged)) { // TRANS: Client error displayed trying to perform an action related to a non-existing profile. $this->clientError(_('No such profile.')); } $id = $this->arg('peopletag_id'); $this->peopletag = Profile_list::getKV('id', $id); if (empty($this->peopletag)) { // TRANS: Client error displayed trying to reference a non-existing list. $this->clientError(_('No such list.')); } return true; }
function showContent() { $this->elementStart('form', array('method' => 'POST', 'id' => 'form_password', 'class' => 'form_settings', 'action' => common_local_url('passwordsettings'))); $this->elementStart('fieldset'); // TRANS: Fieldset legend on page where to change password. $this->element('legend', null, _('Password change')); $this->hidden('token', common_session_token()); $this->elementStart('ul', 'form_data'); // Users who logged in with OpenID won't have a pwd if ($this->scoped->hasPassword()) { $this->elementStart('li'); // TRANS: Field label on page where to change password. $this->password('oldpassword', _('Old password')); $this->elementEnd('li'); } $this->elementStart('li'); // TRANS: Field label on page where to change password. $this->password('newpassword', _('New password'), _('6 or more characters.')); $this->elementEnd('li'); $this->elementStart('li'); // TRANS: Field label on page where to change password. In this field the new password should be typed a second time. $this->password('confirm', _m('LABEL', 'Confirm'), _('Same as password above.')); $this->elementEnd('li'); $this->elementEnd('ul'); // TRANS: Button text on page where to change password. $this->submit('changepass', _m('BUTTON', 'Change')); $this->elementEnd('fieldset'); $this->elementEnd('form'); }
function handle($args) { parent::handle($args); if ($this->boolean('ajax')) { StatusNet::setApi(true); } if (!common_logged_in()) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname))); return; } /* Use a session token for CSRF protection. */ $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. ' . 'Try again, please.')); return; } $other_id = $this->arg('unsubscribeto'); if (!$other_id) { // TRANS: Client error displayed when trying to leave a group without specifying an ID. $this->clientError(_('No profile ID in request.')); return; } $other = Profile::staticGet('id', $other_id); if (!$other) { // TRANS: Client error displayed when trying to leave a non-existing group. $this->clientError(_('No profile with that ID.')); return; } $this->request = Subscription_queue::pkeyGet(array('subscriber' => $user->id, 'subscribed' => $other->id)); if (empty($this->request)) { // TRANS: Client error displayed when trying to approve a non-existing group join request. // TRANS: %s is a user nickname. $this->clientError(sprintf(_('%s is not in the moderation queue for this group.'), $this->profile->nickname), 403); } $this->request->abort(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title after unsubscribing from a group. $this->element('title', null, _m('TITLE', 'Unsubscribed')); $this->elementEnd('head'); $this->elementStart('body'); $subscribe = new SubscribeForm($this, $other); $subscribe->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)), 303); } }
function showContent() { $this->elementStart('form', array('method' => 'post', 'class' => 'form_settings', 'action' => common_local_url('linkbacksettings'))); $this->hidden('token', common_session_token()); $this->elementStart('fieldset'); $this->element('legend', null, _m('LEGEND', 'Preferences')); $this->checkbox('disable_linkbacks', "Opt out of sending linkbacks for URLs you post", $this->scoped->getPref("linkbackplugin", "disable_linkbacks")); // TRANS: Button text to save OpenID prefs $this->submit('settings_linkback_prefs_save', _m('BUTTON', 'Save'), 'submit', 'save_prefs'); $this->elementEnd('fieldset'); $this->elementEnd('form'); }
function prepare($args) { parent::prepare($args); $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->clientError(_('There was a problem with your session token. ' . 'Try again, please.')); } $this->lat = $this->trimmed('lat'); $this->lon = $this->trimmed('lon'); $this->location = Location::fromLatLon($this->lat, $this->lon); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); if (!common_logged_in()) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); return false; } $token = $this->trimmed('token'); if (empty($token) || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } $id = $this->trimmed('profileid'); if (empty($id)) { // TRANS: Client error displayed when not providing a profile ID on the Make Admin page. $this->clientError(_('No profile specified.')); return false; } $this->profile = Profile::staticGet('id', $id); if (empty($this->profile)) { // TRANS: Client error displayed when specifying an invalid profile ID on the Make Admin page. $this->clientError(_('No profile with that ID.')); return false; } $group_id = $this->trimmed('groupid'); if (empty($group_id)) { // TRANS: Client error displayed when not providing a group ID on the Make Admin page. $this->clientError(_('No group specified.')); return false; } $this->group = User_group::staticGet('id', $group_id); if (empty($this->group)) { // TRANS: Client error displayed when providing an invalid group ID on the Make Admin page. $this->clientError(_('No such group.')); return false; } $user = common_current_user(); if (!$user->isAdmin($this->group) && !$user->hasRight(Right::MAKEGROUPADMIN)) { // TRANS: Client error displayed when trying to make another user admin on the Make Admin page while not an admin. $this->clientError(_('Only an admin can make another user an admin.'), 401); return false; } if ($this->profile->isAdmin($this->group)) { // TRANS: Client error displayed when trying to make another user admin on the Make Admin page who already is admin. // TRANS: %1$s is the user that is already admin, %2$s is the group user is already admin for. $this->clientError(sprintf(_('%1$s is already an admin for group "%2$s".'), $this->profile->getBestName(), $this->group->getBestName()), 401); return false; } return true; }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { // TRANS: Client error displayed when trying to remove a favorite while not logged in. $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); return; } $id = $this->trimmed('notice'); $notice = Notice::staticGet($id); $token = $this->trimmed('token-' . $notice->id); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } $fave = new Fave(); $fave->user_id = $user->id; $fave->notice_id = $notice->id; if (!$fave->find(true)) { // TRANS: Client error displayed when trying to remove favorite status for a notice that is not a favorite. $this->clientError(_('This notice is not a favorite!')); return; } $result = $fave->delete(); if (!$result) { common_log_db_error($fave, 'DELETE', __FILE__); // TRANS: Server error displayed when removing a favorite from the database fails. $this->serverError(_('Could not delete favorite.')); return; } $user->blowFavesCache(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title for page on which favorites can be added. $this->element('title', null, _('Add to favorites')); $this->elementEnd('head'); $this->elementStart('body'); $favor = new FavorForm($this, $notice); $favor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)), 303); } }
function handle($args) { parent::handle($args); if (!common_logged_in()) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname))); return; } /* Use a session token for CSRF protection. */ $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. ' . 'Try again, please.')); return; } $other_id = $this->arg('unsubscribeto'); if (!$other_id) { // TRANS: Client error displayed when trying to unsubscribe without providing a profile ID. $this->clientError(_('No profile ID in request.')); return; } $other = Profile::staticGet('id', $other_id); if (!$other) { // TRANS: Client error displayed when trying to unsubscribe while providing a non-existing profile ID. $this->clientError(_('No profile with that ID.')); return; } $result = subs_unsubscribe_to($user, $other); if (is_string($result)) { $this->clientError($result); return; } if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Page title for page to unsubscribe. $this->element('title', null, _('Unsubscribed')); $this->elementEnd('head'); $this->elementStart('body'); $subscribe = new SubscribeForm($this, $other); $subscribe->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)), 303); } }
function prepare($args) { parent::prepare($args); $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->clientError(_('网页错误,请返回重试 ')); } $this->lat = $this->trimmed('lat'); $this->lon = $this->trimmed('lon'); $this->location = Location::fromLatLon($this->lat, $this->lon); return true; }
function prepare($args) { parent::prepare($args); $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. ' . 'Try again, please.')); } $this->lat = $this->trimmed('lat'); $this->lon = $this->trimmed('lon'); $this->location = Location::fromLatLon($this->lat, $this->lon); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); if (!common_logged_in()) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); return false; } $token = $this->trimmed('token'); if (empty($token) || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } $id = $this->trimmed('unblockto'); if (empty($id)) { // TRANS: Client error displayed when trying to unblock a user from a group without providing a profile. $this->clientError(_('No profile specified.')); return false; } $this->profile = Profile::staticGet('id', $id); if (empty($this->profile)) { // TRANS: Client error displayed when trying to unblock a user from a group without providing an existing profile. $this->clientError(_('No profile with that ID.')); return false; } $group_id = $this->trimmed('unblockgroup'); if (empty($group_id)) { // TRANS: Client error displayed when trying to unblock a user from a group without providing a group. $this->clientError(_('No group specified.')); return false; } $this->group = User_group::staticGet('id', $group_id); if (empty($this->group)) { // TRANS: Client error displayed when trying to unblock a user from a non-existing group. $this->clientError(_('No such group.')); return false; } $user = common_current_user(); if (!$user->isAdmin($this->group)) { // TRANS: Client error displayed when trying to unblock a user from a group without being an administrator for the group. $this->clientError(_('Only an admin can unblock group members.'), 401); return false; } if (!Group_block::isBlocked($this->group, $this->profile)) { // TRANS: Client error displayed when trying to unblock a non-blocked user from a group. $this->clientError(_('User is not blocked from group.')); return false; } return true; }
function handlePost() { // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->showForm(_m('There was a problem with your session token. ' . 'Try again, please.')); return; } if ($this->arg('save')) { $this->savePreferences(); } else { $this->showForm(_m('Unexpected form submission.')); } }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); return; } $id = $this->trimmed('notice'); $notice = Notice::staticGet($id); $token = $this->trimmed('token-' . $notice->id); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } if ($user->hasFave($notice)) { // TRANS: Client error displayed when trying to mark a notice as favorite that already is a favorite. $this->clientError(_('This notice is already a favorite!')); return; } $fave = Fave::addNew($user->getProfile(), $notice); if (!$fave) { // TRANS: Server error displayed when trying to mark a notice as favorite fails in the database. $this->serverError(_('Could not create favorite.')); return; } $this->notify($notice, $user); $user->blowFavesCache(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Page title for page on which favorite notices can be unfavourited. $this->element('title', null, _('Disfavor favorite.')); $this->elementEnd('head'); $this->elementStart('body'); $disfavor = new DisFavorForm($this, $notice); $disfavor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)), 303); } }
/** * Show the initial form, when we haven't yet been given a valid * remote profile. */ function showInputForm() { $this->elementStart('form', array('method' => 'post', 'id' => 'form_ostatus_sub', 'class' => 'form_settings', 'action' => $this->selfLink())); $this->hidden('token', common_session_token()); $this->elementStart('fieldset', array('id' => 'settings_feeds')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('profile', _m('Join group'), $this->profile_uri, _m("OStatus group's address, like http://example.net/group/nickname.")); $this->elementEnd('li'); $this->elementEnd('ul'); // TRANS: Button text. $this->submit('validate', _m('BUTTON', 'Continue')); $this->elementEnd('fieldset'); $this->elementEnd('form'); }
/** * Show the initial form, when we haven't yet been given a valid * remote profile. */ function showInputForm() { $this->elementStart('form', array('method' => 'post', 'id' => 'form_ostatus_sub', 'class' => 'form_settings', 'action' => $this->selfLink())); $this->hidden('token', common_session_token()); $this->elementStart('fieldset', array('id' => 'settings_feeds')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('profile', _m('Subscribe to list'), $this->profile_uri, _m("Address of the OStatus list, like http://example.net/user/all/tag.")); $this->elementEnd('li'); $this->elementEnd('ul'); // TRANS: Button text to continue joining a remote list. $this->submit('validate', _m('BUTTON', 'Continue')); $this->elementEnd('fieldset'); $this->elementEnd('form'); }
function handlePost() { // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->showForm(_m('There was a problem with your session token. ' . 'Try again, please.')); return; } if ($this->arg('save')) { $this->saveDetails(); } else { // TRANS: Message given submitting a form with an unknown action. $this->showForm(_m('Unexpected form submission.')); } }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); return; } $id = $this->trimmed('notice'); $notice = Notice::staticGet($id); $token = $this->trimmed('token-' . $notice->id); if (!$token || $token != common_session_token()) { $this->clientError(_("There was a problem with your session token. Try again, please.")); return; } $fave = new Fave(); $fave->user_id = $this->id; $fave->notice_id = $notice->id; if (!$fave->find(true)) { $this->clientError(_('This notice is not a favorite!')); return; } $result = $fave->delete(); if (!$result) { common_log_db_error($fave, 'DELETE', __FILE__); $this->serverError(_('Could not delete favorite.')); return; } $user->blowFavesCache(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); $this->element('title', null, _('Add to favorites')); $this->elementEnd('head'); $this->elementStart('body'); $favor = new FavorForm($this, $notice); $favor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); } }