fix subscriptions a bit

darcs-hash:20080521185602-84dde-9e058c34c251d96cf557c1dd459523aa434bed79.gz
This commit is contained in:
Evan Prodromou 2008-05-21 14:56:02 -04:00
parent 5172a73e28
commit b791a83592
3 changed files with 16 additions and 15 deletions

View File

@ -136,7 +136,9 @@ class ShowstreamAction extends StreamAction {
'name' => 'subscribeto', 'name' => 'subscribeto',
'type' => 'hidden', 'type' => 'hidden',
'value' => $profile->nickname)); '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'); common_element_end('form');
} }
@ -147,7 +149,9 @@ class ShowstreamAction extends StreamAction {
'name' => 'unsubscribeto', 'name' => 'unsubscribeto',
'type' => 'hidden', 'type' => 'hidden',
'value' => $profile->nickname)); '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'); common_element_end('form');
} }

View File

@ -50,20 +50,12 @@ class SubscribeAction extends Action {
$sub->created = DB_DataObject_Cast::dateTime(); # current time $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()) { if (!$sub->insert()) {
common_server_error(_t('Couldn\'t create subscription.')); common_server_error(_t('Couldn\'t create subscription.'));
return; return;
} }
common_redirect(common_local_url('all', array('nickname' => common_redirect(common_local_url('subscriptions', array('nickname' =>
$user->nickname))); $user->nickname)));
} }
} }

View File

@ -37,16 +37,21 @@ class UnsubscribeAction extends Action {
common_server_error(_t('Not subscribed!.')); common_server_error(_t('Not subscribed!.'));
} }
$sub = new Subscription(); $sub = DB_DataObject::factory('subscription');
$sub->subscriber = $user->id; $sub->subscriber = $user->id;
$sub->subscribed = $other->id; $sub->subscribed = $other->id;
$sub->find(true);
// note we checked for existence above
if (!$sub->delete()) { if (!$sub->delete()) {
common_server_error(_t('Couldn\'t delete subscription.')); common_server_error(_t('Couldn\'t delete subscription.'));
return; return;
} }
common_redirect(common_local_url('all', array('nickname' => common_redirect(common_local_url('subscriptions', array('nickname' =>
$user->nickname))); $user->nickname)));
} }
} }