summaryrefslogtreecommitdiff
path: root/actions/subscribe.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-07-20 16:16:20 -0400
committerEvan Prodromou <evan@prodromou.name>2008-07-20 16:16:20 -0400
commitd294c91d82804e8e8b83abaaa6c831561f5872bc (patch)
tree4e3d4108cf5ff9c3fd9a627926e961478af9df44 /actions/subscribe.php
parent48ac5b9e85f48b2adfb34209a26d1119fdeaf172 (diff)
add autosubscribe
darcs-hash:20080720201620-84dde-f782e01bdf7f267b3b02e20e851aa7b643ed8590.gz
Diffstat (limited to 'actions/subscribe.php')
-rw-r--r--actions/subscribe.php18
1 files changed, 10 insertions, 8 deletions
diff --git a/actions/subscribe.php b/actions/subscribe.php
index 45dffa62b..f37095c1c 100644
--- a/actions/subscribe.php
+++ b/actions/subscribe.php
@@ -49,19 +49,21 @@ class SubscribeAction extends Action {
return;
}
- $sub = new Subscription();
- $sub->subscriber = $user->id;
- $sub->subscribed = $other->id;
-
- $sub->created = DB_DataObject_Cast::dateTime(); # current time
-
- if (!$sub->insert()) {
- common_server_error(_('Couldn\'t create subscription.'));
+ if (!$user->subscribeTo($other)) {
+ $this->server_error(_('Could not subscribe.'));
return;
}
$this->notify($other, $user);
+ if ($other->autosubscribe && !$other->isSubscribed($user)) {
+ if (!$other->subscribeTo($user)) {
+ $this->server_error(_('Could not subscribe other to you.'));
+ return;
+ }
+ $this->notify($user, $other);
+ }
+
common_redirect(common_local_url('subscriptions', array('nickname' =>
$user->nickname)));
}