From b791a835929c659d8dcf174553f7786fb45cf978 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 21 May 2008 14:56:02 -0400 Subject: [PATCH] fix subscriptions a bit darcs-hash:20080521185602-84dde-9e058c34c251d96cf557c1dd459523aa434bed79.gz --- actions/showstream.php | 8 ++++++-- actions/subscribe.php | 12 ++---------- actions/unsubscribe.php | 11 ++++++++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/actions/showstream.php b/actions/showstream.php index 42f1f04cd3..bf9df04a34 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -136,7 +136,9 @@ class ShowstreamAction extends StreamAction { 'name' => 'subscribeto', 'type' => 'hidden', 'value' => $profile->nickname)); - common_element('input', array('type' => 'submit', 'value' => _t('Subscribe'))); + common_element('input', array('type' => 'submit', + 'class' => 'button', + 'value' => _t('Subscribe'))); common_element_end('form'); } @@ -147,7 +149,9 @@ class ShowstreamAction extends StreamAction { 'name' => 'unsubscribeto', 'type' => 'hidden', 'value' => $profile->nickname)); - common_element('input', array('type' => 'submit'), _t('Unsubscribe')); + common_element('input', array('type' => 'submit', + 'class' => 'button', + 'value' => _t('Unsubscribe'))); common_element_end('form'); } diff --git a/actions/subscribe.php b/actions/subscribe.php index 1ca57a43ba..522c315935 100644 --- a/actions/subscribe.php +++ b/actions/subscribe.php @@ -50,20 +50,12 @@ class SubscribeAction extends Action { $sub->created = DB_DataObject_Cast::dateTime(); # current time - $val = $sub->validate(); - - if ($val !== TRUE) { - # XXX: give some error notice - common_server_error(_t('Subscription did not validate.')); - return; - } - if (!$sub->insert()) { common_server_error(_t('Couldn\'t create subscription.')); return; } - common_redirect(common_local_url('all', array('nickname' => - $user->nickname))); + common_redirect(common_local_url('subscriptions', array('nickname' => + $user->nickname))); } } \ No newline at end of file diff --git a/actions/unsubscribe.php b/actions/unsubscribe.php index bac7523932..fabb7148e1 100644 --- a/actions/unsubscribe.php +++ b/actions/unsubscribe.php @@ -37,16 +37,21 @@ class UnsubscribeAction extends Action { common_server_error(_t('Not subscribed!.')); } - $sub = new Subscription(); + $sub = DB_DataObject::factory('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))); } } -- 2.39.5