forked from GNUsocial/gnu-social
2a4dc77a63
I used this hacky sed-command (run it from your GNU Social root, or change the first grep's path to where it actually lies) to do a rough fix on all ::staticGet calls and rename them to ::getKV sed -i -s -e '/DataObject::staticGet/I!s/::staticGet/::getKV/Ig' $(grep -R ::staticGet `pwd`/* | grep -v -e '^extlib' | grep -v DataObject:: |grep -v "function staticGet"|cut -d: -f1 |sort |uniq) If you're applying this, remember to change the Managed_DataObject and Memcached_DataObject function definitions of staticGet to getKV! This might of course take some getting used to, or modification fo StatusNet plugins, but the result is that all the static calls (to staticGet) are now properly made without breaking PHP Strict Standards. Standards are there to be followed (and they caused some very bad confusion when used with get_called_class) Reasonably any plugin or code that tests for the definition of 'GNUSOCIAL' or similar will take this change into consideration.
102 lines
3.6 KiB
PHP
102 lines
3.6 KiB
PHP
<?php
|
|
/**
|
|
* Table Definition for subscription_queue
|
|
*/
|
|
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
|
|
|
class Subscription_queue extends Managed_DataObject
|
|
{
|
|
###START_AUTOCODE
|
|
/* the code below is auto generated do not remove the above tag */
|
|
|
|
public $__table = 'subscription_queue'; // table name
|
|
public $subscriber;
|
|
public $subscribed;
|
|
public $created;
|
|
|
|
/* Pkey get */
|
|
function pkeyGet($k)
|
|
{ return Memcached_DataObject::pkeyGet('Subscription_queue',$k); }
|
|
|
|
/* the code above is auto generated do not remove the tag below */
|
|
###END_AUTOCODE
|
|
|
|
public static function schemaDef()
|
|
{
|
|
return array(
|
|
'description' => '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(
|
|
'subscription_queue_subscriber_created_idx' => array('subscriber', 'created'),
|
|
'subscription_queue_subscribed_created_idx' => array('subscribed', 'created'),
|
|
),
|
|
'foreign keys' => array(
|
|
'subscription_queue_subscriber_fkey' => array('profile', array('subscriber' => 'id')),
|
|
'subscription_queue_subscribed_fkey' => array('profile', array('subscribed' => 'id')),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function saveNew(Profile $subscriber, Profile $subscribed)
|
|
{
|
|
$rq = new Subscription_queue();
|
|
$rq->subscriber = $subscriber->id;
|
|
$rq->subscribed = $subscribed->id;
|
|
$rq->created = common_sql_now();
|
|
$rq->insert();
|
|
return $rq;
|
|
}
|
|
|
|
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::getKV('id', $this->subscriber);
|
|
$subscribed = Profile::getKV('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::getKV('id', $this->subscriber);
|
|
$subscribed = Profile::getKV('id', $this->subscribed);
|
|
if (Event::handle('StartCancelSubscription', array($subscriber, $subscribed))) {
|
|
$this->delete();
|
|
Event::handle('EndCancelSubscription', array($subscriber, $subscribed));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Send notifications via email etc to group administrators about
|
|
* this exciting new pending moderation queue item!
|
|
*/
|
|
public function notify()
|
|
{
|
|
$other = Profile::getKV('id', $this->subscriber);
|
|
$listenee = User::getKV('id', $this->subscribed);
|
|
mail_subscribe_pending_notify_profile($listenee, $other);
|
|
}
|
|
}
|