X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Funsubscribe.php;h=fabb7148e1404a27a65b60740afced403d58bf0c;hb=1ef5cf964ef65b248dc150660124e95dcd933106;hp=c4e6b989172c67f5b8dc8029d3d26fe6456abadd;hpb=67a347bafb875be60e7554f308d80d7f0a1d2747;p=quix0rs-gnu-social.git diff --git a/actions/unsubscribe.php b/actions/unsubscribe.php index c4e6b98917..fabb7148e1 100644 --- a/actions/unsubscribe.php +++ b/actions/unsubscribe.php @@ -1,4 +1,21 @@ . + */ class UnsubscribeAction extends Action { function handle($args) { @@ -13,23 +30,28 @@ class UnsubscribeAction extends Action { common_user_error(_t('No such user.')); return; } - + $user = common_current_user(); if (!$user->isSubscribed($other)) { common_server_error(_t('Not subscribed!.')); } + + $sub = DB_DataObject::factory('subscription'); - $sub = new Subscription(); $sub->subscriber = $user->id; $sub->subscribed = $other->id; + + $sub->find(true); + + // note we checked for existence above if (!$sub->delete()) { common_server_error(_t('Couldn\'t delete subscription.')); return; } - - common_redirect(common_local_url('all', array('nickname' => - $user->nickname))); + + common_redirect(common_local_url('subscriptions', array('nickname' => + $user->nickname))); } }