+ function exists($subscriber, $other)
+ {
+ $sub = Subscription_queue::pkeyGet(array('subscriber' => $subscriber->id,
+ 'subscribed' => $other->id));
+ return (empty($sub)) ? false : true;
+ }
+
+ /**
+ * Complete a pending subscription, as we've got approval of some sort.
+ *
+ * @return Subscription
+ */
+ public function complete()
+ {
+ $subscriber = Profile::staticGet('id', $this->subscriber);
+ $subscribed = Profile::staticGet('id', $this->subscribed);
+ $sub = Subscription::start($subscriber, $subscribed, Subscription::FORCE);
+ if ($sub) {
+ $this->delete();
+ }
+ return $sub;
+ }
+
+ /**
+ * Cancel an outstanding subscription request to the other profile.
+ */
+ public function abort()
+ {
+ $subscriber = Profile::staticGet('id', $this->subscriber);
+ $subscribed = Profile::staticGet('id', $this->subscribed);
+ if (Event::handle('StartCancelSubscription', array($subscriber, $subscribed))) {
+ $this->delete();
+ Event::handle('EndCancelSubscription', array($subscriber, $subscribed));
+ }
+ }
+