return;
}
- $user = common_current_user();
-
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
common_redirect(common_local_url('subscriptions',
- array('nickname' => $user->nickname)));
+ array('nickname' => $this->scoped->nickname)));
return;
}
$other = Profile::getKV('id', $other_id);
- if (!$other) {
+ if (!($other instanceof Profile)) {
// 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;
+ try {
+ Subscription::cancel($this->scoped, $other);
+ } catch (Exception $e) {
+ $this->clientError($e->getMessage());
}
if ($this->boolean('ajax')) {
$this->elementEnd('html');
} else {
common_redirect(common_local_url('subscriptions',
- array('nickname' => $user->nickname)),
+ array('nickname' => $this->scoped->nickname)),
303);
}
}