add autosubscribe
darcs-hash:20080720201620-84dde-f782e01bdf7f267b3b02e20e851aa7b643ed8590.gz
This commit is contained in:
parent
48ac5b9e85
commit
d294c91d82
|
@ -49,19 +49,21 @@ class SubscribeAction extends Action {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sub = new Subscription();
|
if (!$user->subscribeTo($other)) {
|
||||||
$sub->subscriber = $user->id;
|
$this->server_error(_('Could not subscribe.'));
|
||||||
$sub->subscribed = $other->id;
|
|
||||||
|
|
||||||
$sub->created = DB_DataObject_Cast::dateTime(); # current time
|
|
||||||
|
|
||||||
if (!$sub->insert()) {
|
|
||||||
common_server_error(_('Couldn\'t create subscription.'));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->notify($other, $user);
|
$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' =>
|
common_redirect(common_local_url('subscriptions', array('nickname' =>
|
||||||
$user->nickname)));
|
$user->nickname)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,4 +112,18 @@ class User extends DB_DataObject
|
||||||
function getCarrier() {
|
function getCarrier() {
|
||||||
return Sms_carrier::staticGet($this->carrier);
|
return Sms_carrier::staticGet($this->carrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function subscribeTo($other) {
|
||||||
|
$sub = new Subscription();
|
||||||
|
$sub->subscriber = $this->id;
|
||||||
|
$sub->subscribed = $other->id;
|
||||||
|
|
||||||
|
$sub->created = DB_DataObject_Cast::dateTime(); # current time
|
||||||
|
|
||||||
|
if (!$sub->insert()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user