From: Brion Vibber Date: Wed, 23 Mar 2011 23:42:36 +0000 (-0700) Subject: Subscription_queue class for subscription approval X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4eb02c624e152e58b37a3999f8570b49166361be;p=quix0rs-gnu-social.git Subscription_queue class for subscription approval --- diff --git a/classes/Subscription_queue.php b/classes/Subscription_queue.php new file mode 100644 index 0000000000..6bf4a681b2 --- /dev/null +++ b/classes/Subscription_queue.php @@ -0,0 +1,69 @@ + 'Holder for subscription requests awaiting moderation.', + 'fields' => array( + 'subscriber' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile making the request'), + 'subscribed' => array('type' => 'int', 'not null' => true, 'description' => 'remote or local profile being subscribed to'), + 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), + ), + 'primary key' => array('subscriber', 'subscribed'), + 'indexes' => array( + 'group_join_queue_profile_id_created_idx' => array('subscriber', 'created'), + 'group_join_queue_group_id_created_idx' => array('subscribed', 'created'), + ), + 'foreign keys' => array( + 'group_join_queue_subscriber_fkey' => array('profile', array('subscriber' => 'id')), + 'group_join_queue_subscribed_fkey' => array('profile', array('subscribed' => 'id')), + ) + ); + } + + public static function saveNew(Profile $subscriber, Profile $other) + { + $rq = new Group_join_queue(); + $rq->subscriber = $subscriber->id; + $rq->subscribed = $subscribed->id; + $rq->created = common_sql_now(); + $rq->insert(); + return $rq; + } + + /** + * Send notifications via email etc to group administrators about + * this exciting new pending moderation queue item! + */ + public function notify() + { + $subscriber = Profile::staticGet('id', $this->subscriber); + $subscribed = Profile::staticGet('id', $this->subscribed); + mail_notify_subscription_pending($subscribed, $subscriber); + } +} diff --git a/db/core.php b/db/core.php index 928186d94d..dfba0f8cd4 100644 --- a/db/core.php +++ b/db/core.php @@ -1028,3 +1028,5 @@ $schema['schema_version'] = array( ); $schema['group_join_queue'] = Group_join_queue::schemaDef(); + +$schema['subscription_queue'] = Subscription_queue::schemaDef();