/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); $profile = AnonymousFavePlugin::getAnonProfile(); if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') { // TRANS: Client error. $this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.')); } $id = $this->trimmed('notice'); $notice = Notice::getKV($id); $token = $this->checkSessionToken(); // Throws exception $stored = Fave::addNew($profile, $notice); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title. $this->element('title', null, _m('Disfavor favorite')); $this->elementEnd('head'); $this->elementStart('body'); $disfavor = new AnonDisFavorForm($this, $notice); $disfavor->show(); $this->elementEnd('body'); $this->endHTML(); } else { $this->returnToPrevious(); } }
/** * Handle request * * @param array $args $_REQUEST args; handled in prepare() * * @return void */ function handle($args) { parent::handle($args); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->makeGrader(); } }
/** * Handle request * * Shows a page with list of favorite notices * * @param array $args $_REQUEST args; handled in prepare() * * @return void */ function handle($args) { parent::handle($args); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->handlePost(); $this->returnToArgs(); } }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); $profile = AnonymousFavePlugin::getAnonProfile(); if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') { $this->clientError(_m('Could not disfavor notice! Please make sure your browser has cookies enabled.')); return; } $id = $this->trimmed('notice'); $notice = Notice::staticGet($id); $token = $this->trimmed('token-' . $notice->id); if (!$token || $token != common_session_token()) { // TRANS: Client error. $this->clientError(_m('There was a problem with your session token. Try again, please.')); return; } $fave = new Fave(); $fave->user_id = $profile->id; $fave->notice_id = $notice->id; if (!$fave->find(true)) { // TRANS: Client error. $this->clientError(_m('This notice is not a favorite!')); return; } $result = $fave->delete(); if (!$result) { common_log_db_error($fave, 'DELETE', __FILE__); // TRANS: Server error. $this->serverError(_m('Could not delete favorite.')); return; } $profile->blowFavesCache(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title. $this->element('title', null, _m('Add to favorites')); $this->elementEnd('head'); $this->elementStart('body'); $favor = new AnonFavorForm($this, $notice); $favor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { $this->returnToPrevious(); } }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); $profile = AnonymousFavePlugin::getAnonProfile(); if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') { // TRANS: Client error. $this->clientError(_m('Could not favor notice! Please make sure your browser has cookies enabled.')); return; } $id = $this->trimmed('notice'); $notice = Notice::staticGet($id); $token = $this->trimmed('token-' . $notice->id); if (empty($token) || $token != common_session_token()) { // TRANS: Client error. $this->clientError(_m('There was a problem with your session token. Try again, please.')); return; } if ($profile->hasFave($notice)) { // TRANS: Client error. $this->clientError(_m('This notice is already a favorite!')); return; } $fave = Fave::addNew($profile, $notice); if (!$fave) { // TRANS: Server error. $this->serverError(_m('Could not create favorite.')); return; } $profile->blowFavesCache(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title. $this->element('title', null, _m('Disfavor favorite')); $this->elementEnd('head'); $this->elementStart('body'); $disfavor = new AnonDisFavorForm($this, $notice); $disfavor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { $this->returnToPrevious(); } }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); $profile = AnonymousFavePlugin::getAnonProfile(); if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') { $this->clientError(_m('Could not disfavor notice! Please make sure your browser has cookies enabled.')); } $id = $this->trimmed('notice'); $notice = Notice::getKV($id); $token = $this->checkSessionToken(); $fave = new Fave(); $fave->user_id = $profile->id; $fave->notice_id = $notice->id; if (!$fave->find(true)) { throw new NoResultException($fave); } $result = $fave->delete(); if (!$result) { common_log_db_error($fave, 'DELETE', __FILE__); // TRANS: Server error. $this->serverError(_m('Could not delete favorite.')); } Fave::blowCacheForProfileId($profile->id); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title. $this->element('title', null, _m('Add to favorites')); $this->elementEnd('head'); $this->elementStart('body'); $favor = new AnonFavorForm($this, $notice); $favor->show(); $this->elementEnd('body'); $this->endHTML(); } else { $this->returnToPrevious(); } }
function showScripts() { parent::showScripts(); $this->autofocus('form_action-yes'); }
/** * Handle the request * * On POST, delete the group. * * @param array $args unused * * @return void */ function handle($args) { parent::handle($args); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($this->arg('no')) { $this->returnToPrevious(); return; } elseif ($this->arg('yes')) { $this->handlePost(); return; } } $this->showPage(); }