/** * Handle request * * This is the main method for handling a request. Note that * most preparation should be done in the prepare() method; * by the time handle() is called the action should be * more or less ready to go. * * @param array $args $_REQUEST args; handled in prepare() * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } if (!$this->user->hasRole('grader')) { $this->clientError(_('Usted no tiene privilegios para visitar esta página.')); return; } $groupid = $this->trimmed('groupid'); $delimiter = $this->trimmed('grade-export-delimiter'); $separator = $this->trimmed('grade-export-separator'); $arrayReport = Grades::getGradedNoticesAndUsersWithinGroup($groupid); $nicksMembers = Grades::getMembersNicksExcludeGradersAndAdmin($groupid); foreach ($nicksMembers as $nick) { if (!array_key_exists($nick, $arrayReport)) { $arrayReport[$nick] = 0; } } $arrayFinal = array(); foreach ($arrayReport as $alumno => $puntuacion) { $arrayFinal[] = array($alumno, number_format($puntuacion, 2)); } $this->generarInformeCSV($arrayFinal, 'report_group_' . $groupid . '.csv', $separator, $delimiter); }
function handle($args) { parent::handle($args); if (common_is_real_login()) { $this->clientError(_('Already logged in.')); } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $openid_url = $this->trimmed('openid_url'); # CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->showForm(_('There was a problem with your session token. Try again, please.'), $openid_url); return; } $rememberme = $this->boolean('rememberme'); common_ensure_session(); $_SESSION['openid_rememberme'] = $rememberme; $result = oid_authenticate($openid_url, 'finishopenidlogin'); if (is_string($result)) { # error message unset($_SESSION['openid_rememberme']); $this->showForm($result, $openid_url); } } else { $openid_url = oid_get_last(); $this->showForm(null, $openid_url); } } }
function handle($args) { parent::handle($args); if (common_is_real_login()) { // TRANS: Client error message trying to log on with OpenID while already logged on. $this->clientError(_m('Already logged in.')); } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $provider = common_config('openid', 'trusted_provider'); if ($provider) { $openid_url = $provider; if (common_config('openid', 'append_username')) { $openid_url .= $this->trimmed('openid_username'); } } else { $openid_url = $this->trimmed('openid_url'); } oid_assert_allowed($openid_url); $rememberme = $this->boolean('rememberme'); common_ensure_session(); $_SESSION['openid_rememberme'] = $rememberme; $result = oid_authenticate($openid_url, 'finishopenidlogin'); if (is_string($result)) { # error message unset($_SESSION['openid_rememberme']); $this->showForm($result, $openid_url); } } else { $openid_url = oid_get_last(); $this->showForm(null, $openid_url); } } }
/** * Handle the request * * @param array $args $_REQUEST data (unused) * * @return void */ function handle($args) { parent::handle($args); if (empty($this->url)) { // TRANS: Form validation error displayed when a URL parameter is missing. $this->showError(_m('A URL parameter is required.')); return; } if (!empty($this->challenge)) { // must be a GET if ($_SERVER['REQUEST_METHOD'] != 'GET') { // TRANS: Form validation error displayed when HTTP GET is not used. $this->showError(_m('This resource requires an HTTP GET.')); return; } header('Content-Type: text/xml'); echo $this->challenge; } else { // must be a POST if ($_SERVER['REQUEST_METHOD'] != 'POST') { // TRANS: Form validation error displayed when HTTP POST is not used. $this->showError(_m('This resource requires an HTTP POST.')); return; } header('Content-Type: text/xml'); echo "<notifyResult success='true' msg='Thanks for the update.' />\n"; } $this->ip = $_SERVER['REMOTE_ADDR']; common_log(LOG_INFO, 'RSSCloud Logging Aggregator - ' . $this->ip . ' claims the feed at ' . $this->url . ' has been updated.'); }
/** * Class handler. * * @param array $args query arguments * * @return boolean false if user doesn't exist */ function handle($args) { parent::handle($args); $type = $this->trimmed('type'); $short_name = ''; if ($type == 'people') { $type = 'peoplesearch'; // TRANS: ShortName in the OpenSearch interface when trying to find users. $short_name = _('People Search'); } else { $type = 'noticesearch'; // TRANS: ShortName in the OpenSearch interface when trying to find notices. $short_name = _('Notice Search'); } header('Content-Type: application/opensearchdescription+xml'); $this->startXML(); $this->elementStart('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/')); $short_name = common_config('site', 'name') . ' ' . $short_name; $this->element('ShortName', null, $short_name); $this->element('Contact', null, common_config('site', 'email')); $this->element('Url', array('type' => 'text/html', 'method' => 'get', 'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---'))))); $this->element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico')); $this->element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), Theme::path('logo.png')); $this->element('AdultContent', null, 'false'); $this->element('Language', null, common_language()); $this->element('OutputEncoding', null, 'UTF-8'); $this->element('InputEncoding', null, 'UTF-8'); $this->elementEnd('OpenSearchDescription'); $this->endXML(); }
function handle($args) { parent::handle($args); if (common_logged_in()) { // TRANS: Client error displayed trying to recover password while already logged in. $this->clientError(_('You are already logged in!')); return; } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($this->arg('recover')) { $this->recoverPassword(); } else { if ($this->arg('reset')) { $this->resetPassword(); } else { // TRANS: Client error displayed when unexpected data is posted in the password recovery form. $this->clientError(_('Unexpected form submission.')); } } } else { if ($this->trimmed('code')) { $this->checkCode(); } else { $this->showForm(); } } } }
/** * 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.'); } } }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); $xrdsOutputter = new XRDSOutputter(); $xrdsOutputter->startXRDS(); Event::handle('StartUserXRDS', array($this, &$xrdsOutputter)); //oauth $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xml:id' => 'oauth', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', 'version' => '2.0')); $xrdsOutputter->element('Type', null, 'xri://$xrds*simple'); $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_REQUEST, common_local_url('requesttoken'), array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1), null, $this->user->uri); $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_AUTHORIZE, common_local_url('userauthorization'), array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1)); $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_ACCESS, common_local_url('accesstoken'), array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1)); $xrdsOutputter->showXrdsService(OAUTH_ENDPOINT_RESOURCE, null, array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY, OAUTH_HMAC_SHA1)); $xrdsOutputter->elementEnd('XRD'); //omb $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xml:id' => 'omb', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', 'version' => '2.0')); $xrdsOutputter->element('Type', null, 'xri://$xrds*simple'); $xrdsOutputter->showXrdsService(OMB_ENDPOINT_POSTNOTICE, common_local_url('postnotice')); $xrdsOutputter->showXrdsService(OMB_ENDPOINT_UPDATEPROFILE, common_local_url('updateprofile')); $xrdsOutputter->elementEnd('XRD'); Event::handle('EndUserXRDS', array($this, &$xrdsOutputter)); //misc $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'version' => '2.0')); $xrdsOutputter->showXrdsService(OAUTH_DISCOVERY, '#oauth'); $xrdsOutputter->showXrdsService(OMB_VERSION, '#omb'); $xrdsOutputter->elementEnd('XRD'); $xrdsOutputter->endXRDS(); }
/** * Handle input and output a page * * @param array $args $_REQUEST 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.')); } else { if (!common_is_real_login()) { // Cookie theft means that automatic logins can't // change important settings or see private info, and // _all_ our settings are important common_set_returnto($this->selfUrl()); $user = common_current_user(); if (Event::handle('RedirectToLogin', array($this, $user))) { common_redirect(common_local_url('login'), 303); } } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->handlePost(); } else { $this->showForm(); } } } }
function handle($args) { parent::handle($args); if (common_is_real_login()) { // TRANS: Client error message trying to log on with OpenID while already logged on. $this->clientError(_m('Already logged in.')); } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { // TRANS: Message given when there is a problem with the user's session token. $this->showForm(_m('There was a problem with your session token. Try again, please.')); return; } if ($this->arg('create')) { if (!$this->boolean('license')) { // TRANS: Message given if user does not agree with the site's license. $this->showForm(_m('You can\'t register if you don\'t agree to the license.'), $this->trimmed('newname')); return; } $this->createNewUser(); } else { if ($this->arg('connect')) { $this->connectUser(); } else { // TRANS: Messag given on an unknown error. $this->showForm(_m('An unknown error has occured.'), $this->trimmed('newname')); } } } else { $this->tryLogin(); } } }
/** * Handle input, produce output * * Switches based on GET or POST method. On GET, shows a form * for posting a notice. On POST, saves the results of that form. * * Results may be a full page, or just a single notice list item, * depending on whether AJAX was requested. * * @param array $args $_REQUEST contents * * @return void */ function 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.')); } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { // check for this before token since all POST and FILES data // is losts when size is exceeded if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) { // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit. // TRANS: %s is the number of bytes of the CONTENT_LENGTH. $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH'])); $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH'])); } parent::handle($args); $user = common_current_user(); $group = User_group::staticGet('id', $this->trimmed('groupid')); $taskid = $this->trimmed('taskid'); try { $this->saveNewNotice(); Task::completeTask($user->id, $taskid); } catch (Exception $e) { $this->ajaxErrorMsg($e->getMessage(), $taskid, $group); return; } } } }
/** * Handle input and output a page * * @param array $args $_REQUEST arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } else { if (!common_is_real_login()) { // Cookie theft means that automatic logins can't // change important settings or see private info, and // _all_ our settings are important common_set_returnto($this->selfUrl()); $user = common_current_user(); if ($user->hasOpenID()) { common_redirect(common_local_url('openidlogin')); } else { common_redirect(common_local_url('login')); } } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->handlePost(); } else { $this->showForm(); } } } }
function handle($args) { parent::handle($args); if (common_is_real_login()) { $this->clientError(_('Already logged in.')); } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->showForm(_('There was a problem with your session token. Try again, please.')); return; } if ($this->arg('create')) { if (!$this->boolean('license')) { $this->showForm(_('You can\'t register if you don\'t agree to the license.'), $this->trimmed('newname')); return; } $this->createNewUser(); } else { if ($this->arg('connect')) { $this->connectUser(); } else { common_debug(print_r($this->args, true), __FILE__); $this->showForm(_('Something weird happened.'), $this->trimmed('newname')); } } } else { $this->tryLogin(); } } }
/** * Class handler. * * @param array $args query arguments * * @return boolean false if nickname or user isn't found */ protected function handle() { parent::handle(); $nickname = $this->trimmed('nickname'); if (!$nickname) { // TRANS: Client error displayed trying to get an avatar without providing a nickname. $this->clientError(_('No nickname.')); } $size = $this->trimmed('size') ?: 'original'; $user = User::getKV('nickname', $nickname); if (!$user) { // TRANS: Client error displayed trying to get an avatar for a non-existing user. $this->clientError(_('No such user.')); } $profile = $user->getProfile(); if (!$profile) { // TRANS: Error message displayed when referring to a user without a profile. $this->clientError(_('User has no profile.')); } if ($size === 'original') { try { $avatar = Avatar::getUploaded($profile); $url = $avatar->displayUrl(); } catch (NoAvatarException $e) { $url = Avatar::defaultImage(AVATAR_PROFILE_SIZE); } } else { $url = $profile->avatarUrl($size); } common_redirect($url, 302); }
/** * Handle the request * * @param array $args $_REQUEST data (unused) * * @return void */ function handle($args) { parent::handle($args); if (empty($this->url)) { $this->showError('Hey, you have to provide a url parameter.'); return; } if (!empty($this->challenge)) { // must be a GET if ($_SERVER['REQUEST_METHOD'] != 'GET') { $this->showError('This resource requires an HTTP GET.'); return; } header('Content-Type: text/xml'); echo $this->challenge; } else { // must be a POST if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->showError('This resource requires an HTTP POST.'); return; } header('Content-Type: text/xml'); echo "<notifyResult success='true' msg='Thanks for the update.' />\n"; } $this->ip = $_SERVER['REMOTE_ADDR']; common_log(LOG_INFO, 'RSSCloud Logging Aggregator - ' . $this->ip . ' claims the feed at ' . $this->url . ' has been updated.'); }
function handle($args) { parent::handle($args); if (common_logged_in()) { $this->clientError(_('You are already logged in!')); return; } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($this->arg('recover')) { $this->recoverPassword(); } else { if ($this->arg('reset')) { $this->resetPassword(); } else { $this->clientError(_('Unexpected form submission.')); } } } else { if ($this->trimmed('code')) { $this->checkCode(); } else { $this->showForm(); } } } }
function handle($args = null) { parent::handle($args); header('Content-Type: text/plain'); $shortened_text = common_shorten_links($this->text); print $shortened_text; }
/** * Handler method * * @param array $args is ignored since it's now passed in in prepare() */ function handle($args) { parent::handle($args); $data = $this->facebook->getSignedRequest(); if (isset($data['user_id'])) { $fbuid = $data['user_id']; $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); $user = $flink->getUser(); // Remove the link to Facebook $result = $flink->delete(); if (!$result) { common_log_db_error($flink, 'DELETE', __FILE__); common_log(LOG_WARNING, sprintf('Unable to delete Facebook foreign link ' . 'for %s (%d), fbuid %d', $user->nickname, $user->id, $fbuid), __FILE__); return; } common_log(LOG_INFO, sprintf('Facebook callback: %s (%d), fbuid %d has deauthorized ' . 'the Facebook application.', $user->nickname, $user->id, $fbuid), __FILE__); // Warn the user about being locked out of their account // if we can. if (empty($user->password) && !empty($user->email)) { Facebookclient::emailWarn($user); } else { common_log(LOG_WARNING, sprintf('%s (%d), fbuid %d has deauthorized his/her Facebook ' . 'connection but hasn\'t set a password so s/he ' . 'is locked out.', $user->nickname, $user->id, $fbuid), __FILE__); } } else { if (!empty($data)) { common_log(LOG_WARNING, sprintf('Facebook called the deauthorize callback ' . ' but didn\'t provide a user ID.'), __FILE__); } else { // It probably wasn't Facebook that hit this action, // so redirect to the public timeline common_redirect(common_local_url('public'), 303); } } }
/** * Accept a confirmation code * * Checks the code and confirms the address in the * user record * * @param args $args $_REQUEST array * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { common_set_returnto($this->selfUrl()); common_redirect(common_local_url('login')); return; } $code = $this->trimmed('code'); if (!$code) { $this->clientError(_('No confirmation code.')); return; } $confirm = Confirm_address::staticGet('code', $code); if (!$confirm) { $this->clientError(_('Confirmation code not found.')); return; } $cur = common_current_user(); if ($cur->id != $confirm->user_id) { $this->clientError(_('That confirmation code is not for you!')); return; } $type = $confirm->address_type; if (!in_array($type, array('email', 'jabber', 'sms'))) { $this->serverError(sprintf(_('Unrecognized address type %s'), $type)); return; } if ($cur->{$type} == $confirm->address) { $this->clientError(_('That address has already been confirmed.')); return; } $cur->query('BEGIN'); $orig_user = clone $cur; $cur->{$type} = $confirm->address; if ($type == 'sms') { $cur->carrier = $confirm->address_extra + 0; $carrier = Sms_carrier::staticGet($cur->carrier); $cur->smsemail = $carrier->toEmailAddress($cur->sms); } $result = $cur->updateKeys($orig_user); if (!$result) { common_log_db_error($cur, 'UPDATE', __FILE__); $this->serverError(_('Couldn\'t update user.')); return; } if ($type == 'email') { $cur->emailChanged(); } $result = $confirm->delete(); if (!$result) { common_log_db_error($confirm, 'DELETE', __FILE__); $this->serverError(_('Couldn\'t delete email confirmation.')); return; } $cur->query('COMMIT'); $this->type = $type; $this->showPage(); }
function handle($args) { parent::handle($args); if (common_is_real_login()) { $this->clientError(_('Already logged in.')); } $this->showPage(); }
function handle($args) { parent::handle($args); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->handlePost(); } $this->showPage(); }
function handle($args) { parent::handle($args); if (common_is_real_login()) { // TRANS: Client error displayed when trying to log in using Twitter while already logged in to StatusNet. $this->clientError(_m('Already logged in.')); } $this->showPage(); }
function handle($args) { parent::handle($args); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->saveTags(); } else { $this->showForm($profile); } }
function handle($args) { parent::handle($args); if (!$this->user) { $this->clientError(_('No such user.')); return; } $this->showPage(); }
/** * Handle the redirect back from OpenID confirmation * * Check to see if the user's logged in, and then try * to use the OpenID login system. * * @param array $args $_REQUEST arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_m('Not logged in.')); } else { $this->tryLogin(); } }
/** * Handle the submission. */ protected function handle() { parent::handle(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->handlePost(); } else { $this->showForm(); } }
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); } }
/** * Handle request * * This is the main method for handling a request. Note that * most preparation should be done in the prepare() method; * by the time handle() is called the action should be * more or less ready to go. * * @param array $args $_REQUEST args; handled in prepare() * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } $this->showPage(); }
/** * Handle the request * * On GET, show the form. On POST, try to save the group. * * @param array $args unused * * @return void */ function handle($args) { parent::handle($args); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->trySave(); } else { $this->showForm(); } }
function handle($args) { parent::handle($args); if ($this->isPost()) { $this->handlePost($args); } else { $this->showPage(); } }