Subscription.php

Summary
Subscription.php
SubscriptionTable definition for subscription
SubscriptionSuperclass containing the table definition for a subscription entry in the database and related interfaces.
schemaDefReturns an array representing the table schema for the subscription entry.
startMake a new subscription, save the database entry, and fire the neccesary events.
matchesFilterListLoads the site subscription filter setting and returns whether $subscriber matches it or not.
ensureStartHelper function to call the neccesary low-level functions to start a subscription from $subscriber to the givern $other profile.
saveNewLow-level subscription save.
notifyNorify a user of a subscription.
notifyEmailNotify a user of a subscription by email
cancelCancel a subscription, delete the entry, and fire related events.
existsReturns true/false whether a subscription between a user and another profile.
getSubscriptionReturns the subscription entry for a given subscriber and the profile they subscribe to, if one exists.
getSubscriberReturns the user doing the subscribing in this subscription table entry.
getSubscribedReturns the user subscribed to in this subscription table entry.
asActivityReturns an OStatus (0.5) ActivityVerb representation of a subscription.
bySubscriberStream of subscriptions with the same subscriber
bySubscribedReturns a stream of subscriptions with the same subscriber
getSubscribedIDsReturns an array of all the people who the given profile has subscribed to
getSubcriberIDsReturns an array of all the people who subscribe to the given profile
getSubscriptionIDsReturns an array of subscription entries associated with the given profile_id of the type specified in get_type.
updateUpdates the entry for a subscription.
getUriReturns the URI of a subscription

Subscription

Table definition for subscription

postActiv

the micro-blogging software

Copyright

Copyright © 2016-2017, Maiyannah Bishop

Derived from code copyright various sources

  • GNU Social © 2013-2016, Free Software Foundation, Inc
  • StatusNet © 2008-2012, StatusNet, Inc

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses/.

https://www.gnu.org/licenses/agpl.html

About

Table definition for subscription

PHP version

Tested with PHP 7

File Authors

Web

Subscription

Superclass containing the table definition for a subscription entry in the database and related interfaces.

Properties

  • $__table = ‘subscription’ - table name
  • $subscriber - int(4) primary_key not_null
  • $subscribed - int(4) primary_key not_null
  • $jabber - tinyint(1) default_1
  • $sms - tinyint(1) default_1
  • $token - varchar(191) not 255 because utf8mb4 takes more space
  • $secret - varchar(191) not 255 because utf8mb4 takes more space
  • $uri - varchar(191) not 255 because utf8mb4 takes more space
  • $created - datetime() not_null
  • $modified - timestamp() not_null default_CURRENT_TIMESTAMP
Summary
schemaDefReturns an array representing the table schema for the subscription entry.
startMake a new subscription, save the database entry, and fire the neccesary events.
matchesFilterListLoads the site subscription filter setting and returns whether $subscriber matches it or not.
ensureStartHelper function to call the neccesary low-level functions to start a subscription from $subscriber to the givern $other profile.
saveNewLow-level subscription save.
notifyNorify a user of a subscription.
notifyEmailNotify a user of a subscription by email
cancelCancel a subscription, delete the entry, and fire related events.
existsReturns true/false whether a subscription between a user and another profile.
getSubscriptionReturns the subscription entry for a given subscriber and the profile they subscribe to, if one exists.
getSubscriberReturns the user doing the subscribing in this subscription table entry.
getSubscribedReturns the user subscribed to in this subscription table entry.
asActivityReturns an OStatus (0.5) ActivityVerb representation of a subscription.
bySubscriberStream of subscriptions with the same subscriber
bySubscribedReturns a stream of subscriptions with the same subscriber
getSubscribedIDsReturns an array of all the people who the given profile has subscribed to
getSubcriberIDsReturns an array of all the people who subscribe to the given profile
getSubscriptionIDsReturns an array of subscription entries associated with the given profile_id of the type specified in get_type.
updateUpdates the entry for a subscription.
getUriReturns the URI of a subscription

schemaDef

public static function schemaDef()

Returns an array representing the table schema for the subscription entry.

start

static function start(Profile $subscriber,  
Profile $other,  
 $force = false)

Make a new subscription, save the database entry, and fire the neccesary events.

Parameters

  • Profile $subscriber party to receive new notices
  • Profile $other party sending notices; publisher
  • bool $force pass Subscription::FORCE to override local subscription approval

Returns

  • mixed Subscription or Subscription_queue: new subscription info

matchesFilterList

function matchesFilterList($subscriber)

Loads the site subscription filter setting and returns whether $subscriber matches it or not.

ensureStart

static function ensureStart(Profile $subscriber,  
Profile $other,  
 $force = false)

Helper function to call the neccesary low-level functions to start a subscription from $subscriber to the givern $other profile.

saveNew

protected static function saveNew(Profile $subscriber,
Profile $other)

Low-level subscription save.  Outside callers should use Subscription::start()

notify

function notify()

Norify a user of a subscription.  Essentially a notifyEmail alias currently, but we could also add other notifications such as Jabber, SMS, etc here.

notifyEmail

function notifyEmail()

Notify a user of a subscription by email

cancel

static function cancel(Profile $subscriber,
Profile $other)

Cancel a subscription, delete the entry, and fire related events.

exists

static function exists(Profile $subscriber,
Profile $other)

Returns true/false whether a subscription between a user and another profile.

getSubscription

static function getSubscription(Profile $subscriber,
Profile $other)

Returns the subscription entry for a given subscriber and the profile they subscribe to, if one exists.

This is essentially a pkeyGet but we have an object to return in NoResultException.

getSubscriber

public function getSubscriber()

Returns the user doing the subscribing in this subscription table entry.

getSubscribed

public function getSubscribed()

Returns the user subscribed to in this subscription table entry.

asActivity

function asActivity()

Returns an OStatus (0.5) ActivityVerb representation of a subscription.

bySubscriber

public static function bySubscriber($profile_id,  
$offset =  0,
$limit =  PROFILES_PER_PAGE)

Stream of subscriptions with the same subscriber

Useful for showing pages that list subscriptions in reverse chronological order.  Has offset & limit to make paging easy.

Parameters

  • integer $profile_id - ID of the subscriber profile
  • integer $offset - Offset from latest
  • $limit - Maximum number to fetch

Returns

  • Subscription stream of subscriptions; use fetch() to iterate

bySubscribed

public static function bySubscribed($profile_id,  
$offset =  0,
$limit =  PROFILES_PER_PAGE)

Returns a stream of subscriptions with the same subscriber

Useful for showing pages that list subscriptions in reverse chronological order.  Has offset & limit to make paging easy.

  • integer $profile_id - ID of the subscribed profile
  • integer $offset - Offset from latest
  • integer $limit - Maximum number to fetch

Returns

  • Subscription stream of subscriptions; use fetch() to iterate

getSubscribedIDs

public static function getSubscribedIDs($profile_id,
$offset,
$limit)

Returns an array of all the people who the given profile has subscribed to

getSubcriberIDs

Returns an array of all the people who subscribe to the given profile

getSubscriptionIDs

private static function getSubscriptionIDs($get_type,
$profile_id,
$offset,
$limit)

Returns an array of subscription entries associated with the given profile_id of the type specified in get_type.

Parameters

  • get_type - one of “subscriber”, or “subscribed”
  • profile_id - profile id of user we’re looking up subs for
  • offset - start at subscription entry X
  • limit - number of records to pull

update

function update($dataObject = false)

Updates the entry for a subscription.

Because we cache subscriptions, it’s useful to flush them here.

Parameters

  • mixed $dataObject Original version of object

Returns

  • boolean success flag.

getUri

public function getUri()

Returns the URI of a subscription

public static function schemaDef()
Returns an array representing the table schema for the subscription entry.
static function start(Profile $subscriber,  
Profile $other,  
 $force = false)
Make a new subscription, save the database entry, and fire the neccesary events.
function matchesFilterList($subscriber)
Loads the site subscription filter setting and returns whether $subscriber matches it or not.
static function ensureStart(Profile $subscriber,  
Profile $other,  
 $force = false)
Helper function to call the neccesary low-level functions to start a subscription from $subscriber to the givern $other profile.
protected static function saveNew(Profile $subscriber,
Profile $other)
Low-level subscription save.
function notify()
Norify a user of a subscription.
function notifyEmail()
Notify a user of a subscription by email
static function cancel(Profile $subscriber,
Profile $other)
Cancel a subscription, delete the entry, and fire related events.
static function exists(Profile $subscriber,
Profile $other)
Returns true/false whether a subscription between a user and another profile.
static function getSubscription(Profile $subscriber,
Profile $other)
Returns the subscription entry for a given subscriber and the profile they subscribe to, if one exists.
public function getSubscriber()
Returns the user doing the subscribing in this subscription table entry.
public function getSubscribed()
Returns the user subscribed to in this subscription table entry.
function asActivity()
Returns an OStatus (0.5) ActivityVerb representation of a subscription.
public static function bySubscriber($profile_id,  
$offset =  0,
$limit =  PROFILES_PER_PAGE)
Stream of subscriptions with the same subscriber
public static function bySubscribed($profile_id,  
$offset =  0,
$limit =  PROFILES_PER_PAGE)
Returns a stream of subscriptions with the same subscriber
public static function getSubscribedIDs($profile_id,
$offset,
$limit)
Returns an array of all the people who the given profile has subscribed to
private static function getSubscriptionIDs($get_type,
$profile_id,
$offset,
$limit)
Returns an array of subscription entries associated with the given profile_id of the type specified in get_type.
function update($dataObject = false)
Updates the entry for a subscription.
public function getUri()
Returns the URI of a subscription