work in progress...

This commit is contained in:
Brion Vibber 2011-03-23 17:05:55 -07:00
parent 4eb02c624e
commit 11b40ddb1b
2 changed files with 49 additions and 4 deletions

View File

@ -139,8 +139,8 @@ class SubscribeAction extends Action
{
// Throws exception on error
Subscription::start($this->user->getProfile(),
$this->other);
$sub = Subscription::start($this->user->getProfile(),
$this->other);
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
@ -149,8 +149,12 @@ class SubscribeAction extends Action
$this->element('title', null, _('Subscribed'));
$this->elementEnd('head');
$this->elementStart('body');
$unsubscribe = new UnsubscribeForm($this, $this->other);
$unsubscribe->show();
if ($sub instanceof Subscription) {
$form = new UnsubscribeForm($this, $this->other);
} else {
$form = new CancelSubscriptionForm($this, $this->other);
}
$form->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {

View File

@ -363,6 +363,47 @@ class Profile extends Memcached_DataObject
}
}
/**
* Request a subscription to another local or remote profile.
* This will result in either the subscription going through
* immediately, being queued for approval, or being rejected
* immediately.
*
* @param Profile $profile
* @return mixed: Subscription or Subscription_queue object on success
* @throws Exception of various types on invalid state
*/
function subscribe($profile)
{
//
}
/**
* Cancel an outstanding subscription request to the other profile.
*
* @param Profile $profile
*/
function cancelSubscribe($profile)
{
$request = Subscribe_join_queue::pkeyGet(array('subscriber' => $this->id,
'subscribed' => $profile->id));
if ($request) {
if (Event::handle('StartCancelSubscription', array($this, $profile))) {
$request->delete();
Event::handle('EndCancelSubscription', array($this, $profile));
}
}
}
/**
*
* @param <type> $profile
*/
function completeSubscribe($profile)
{
}
function getSubscriptions($offset=0, $limit=null)
{
$subs = Subscription::bySubscriber($this->id,