]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
work in progress...
authorBrion Vibber <brion@pobox.com>
Thu, 24 Mar 2011 00:05:55 +0000 (17:05 -0700)
committerBrion Vibber <brion@pobox.com>
Mon, 28 Mar 2011 20:59:48 +0000 (13:59 -0700)
actions/subscribe.php
classes/Profile.php

index 3837915d538cd1e09ab237245dfd0689d2af1c0e..fad153fc6e39f1f0110775527eabdce15717f970 100644 (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 {
index b582451350f94551e74b30a8df31ffa21dcfe941..9a145a001843269517dfb5f494a257c4a7ea7b45 100644 (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,