1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class CancelsubscriptionAction extends FormAction
- {
- protected $needPost = true;
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- $profile_id = $this->int('unsubscribeto');
- $this->target = Profile::getKV('id', $profile_id);
- if (!$this->target instanceof Profile) {
- throw new NoProfileException($profile_id);
- }
- return true;
- }
- protected function handlePost()
- {
- parent::handlePost();
- try {
- $request = Subscription_queue::pkeyGet(array('subscriber' => $this->scoped->id,
- 'subscribed' => $this->target->id));
- if ($request instanceof Subscription_queue) {
- $request->abort();
- }
- } catch (AlreadyFulfilledException $e) {
- common_debug('Tried to cancel a non-existing pending subscription');
- }
- if (StatusNet::isAjax()) {
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
-
- $this->element('title', null, _m('TITLE','Unsubscribed'));
- $this->elementEnd('head');
- $this->elementStart('body');
- $subscribe = new SubscribeForm($this, $this->target);
- $subscribe->show();
- $this->elementEnd('body');
- $this->endHTML();
- exit();
- } else {
- common_redirect(common_local_url('subscriptions',
- array('nickname' => $this->scoped->nickname)),
- 303);
- }
- }
- }
|