123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class UnsubscribeAction extends Action
- {
- function handle()
- {
- parent::handle();
- if (!common_logged_in()) {
-
- $this->clientError(_('Not logged in.'));
- }
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- common_redirect(common_local_url('subscriptions',
- array('nickname' => $this->scoped->nickname)));
- }
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_('There was a problem with your session token. ' .
- 'Try again, please.'));
- }
- $other_id = $this->arg('unsubscribeto');
- if (!$other_id) {
-
- $this->clientError(_('No profile ID in request.'));
- }
- $other = Profile::getKV('id', $other_id);
- if (!($other instanceof Profile)) {
-
- $this->clientError(_('No profile with that ID.'));
- }
- try {
- Subscription::cancel($this->scoped, $other);
- } catch (Exception $e) {
- $this->clientError($e->getMessage());
- }
- if ($this->boolean('ajax')) {
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
-
- $this->element('title', null, _('Unsubscribed'));
- $this->elementEnd('head');
- $this->elementStart('body');
- $subscribe = new SubscribeForm($this, $other);
- $subscribe->show();
- $this->elementEnd('body');
- $this->endHTML();
- } else {
- common_redirect(common_local_url('subscriptions', array('nickname' => $this->scoped->nickname)), 303);
- }
- }
- }
|