Documentation

Subscriptions
in package
implements ActionInterface Uses BackwardCompatibility

Contains all the administration functions for paid subscriptions.

(and some more than that :P)

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Properties

$all  : array<string|int, mixed>
$subaction  : string
$subactions  : array<string|int, mixed>
$obj  : object
$backcompat  : array<string|int, mixed>

Methods

add()  : void
Add or extend a subscription of a user.
call()  : void
Convenience method to load() and execute() an instance of this class.
execute()  : void
Dispatcher to whichever sub-action method is necessary.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
getConfigVars()  : array<string|int, mixed>
Gets the configuration variables for this admin area.
getSubs()  : array<string|int, mixed>
Fetches data about all the configured subscriptions.
list_getSubscribedUserCount()  : int
Returns how many people are subscribed to a paid subscription.
list_getSubscribedUsers()  : array<string|int, mixed>
Return the subscribed users list, for the given parameters.
load()  : object
Static wrapper for constructor.
loadPaymentGateways()  : array<string|int, mixed>
Load all the payment gateways.
modify()  : void
Adding, editing and deleting subscriptions.
modifySubscription()  : void
Backward compatibility wrapper for the modify sub-action.
modifySubscriptionSettings()  : void|array<string|int, mixed>
Backward compatibility wrapper for the settings sub-action.
modifyUser()  : void
Edit or add a user subscription.
modifyUserSubscription()  : void
Backward compatibility wrapper for the modifyuser sub-action.
reapply()  : void
Reapplies all subscription rules for each of the users.
remove()  : void
Removes a subscription from a user, as in removes the groups.
settings()  : void
Set any setting related to paid subscriptions, i.e.
view()  : void
View a list of all the current subscriptions Requires the admin_forum permission.
viewSubscribedUsers()  : void
Backward compatibility wrapper for the viewsub sub-action.
viewSubscriptions()  : void
Backward compatibility wrapper for the view sub-action.
viewUsers()  : void
View all the users subscribed to a particular subscription.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().

Properties

$all

public static array<string|int, mixed> $all = []

Data about all the subscriptions the admin has created.

$subaction

public string $subaction = 'view'

The requested sub-action. This should be set by the constructor.

$subactions

public static array<string|int, mixed> $subactions = ['view' => ['view', 'admin_forum'], 'viewsub' => ['viewUsers', 'admin_forum'], 'modify' => ['modify', 'admin_forum'], 'modifyuser' => ['modifyUser', 'admin_forum'], 'settings' => ['settings', 'admin_forum']]

Available sub-actions.

Format: 'sa' => array('method', 'required_permission')

$obj

protected static object $obj

An instance of this class. This is used by the load() method to prevent mulitple instantiations.

$backcompat

private static array<string|int, mixed> $backcompat = ['func_names' => ['call' => 'ManagePaidSubscriptions', 'getSubs' => 'loadSubscriptions', 'add' => 'addSubscription', 'remove' => 'removeSubscription', 'reapply' => 'reapplySubscriptions', 'loadPaymentGateways' => 'loadPaymentGateways', 'list_getSubscribedUserCount' => 'list_getSubscribedUserCount', 'list_getSubscribedUsers' => 'list_getSubscribedUsers', 'viewSubscriptions' => 'ViewSubscriptions', 'viewSubscribedUsers' => 'ViewSubscribedUsers', 'modifySubscription' => 'ModifySubscription', 'modifyUserSubscription' => 'ModifyUserSubscription', 'modifySubscriptionSettings' => 'ModifySubscriptionSettings']]

BackwardCompatibility settings for this class.

Methods

add()

Add or extend a subscription of a user.

public static add(int $id_subscribe, int $id_member[, int|string $renewal = 0 ][, int $forceStartTime = 0 ][, int $forceEndTime = 0 ]) : void
Parameters
$id_subscribe : int

The subscription ID

$id_member : int

The ID of the member

$renewal : int|string = 0

0 if we're forcing start/end time, otherwise a string indicating how long to renew the subscription for ('D', 'W', 'M' or 'Y')

$forceStartTime : int = 0

If set, forces the subscription to start at the specified time

$forceEndTime : int = 0

If set, forces the subscription to end at the specified time

call()

Convenience method to load() and execute() an instance of this class.

public static call() : void

execute()

Dispatcher to whichever sub-action method is necessary.

public execute() : void

exportStatic()

Provides a way to export a class's public static properties and methods to global namespace.

public static exportStatic() : void

To do so:

  1. Use this trait in the class.
  2. At the END of the class's file, call its exportStatic() method.

Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.

Regarding the $backcompat items:

A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].

$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.

$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.

Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.

getConfigVars()

Gets the configuration variables for this admin area.

public static getConfigVars() : array<string|int, mixed>
Return values
array<string|int, mixed>

$config_vars for the news area.

getSubs()

Fetches data about all the configured subscriptions.

public static getSubs() : array<string|int, mixed>

Loads the data into self::$all. Sets Utils::$context['subscriptions'] as a reference to self::$all. Also returns a copy of self::$all.

Return values
array<string|int, mixed>

A copy of self::$all.

list_getSubscribedUserCount()

Returns how many people are subscribed to a paid subscription.

public static list_getSubscribedUserCount(int $id_sub, string $search_string[, array<string|int, mixed> $search_vars = [] ]) : int
Parameters
$id_sub : int

The ID of the subscription

$search_string : string

A search string

$search_vars : array<string|int, mixed> = []

An array of variables for the search string

Tags
todo

refactor away

Return values
int

The number of subscribed users matching the given parameters

list_getSubscribedUsers()

Return the subscribed users list, for the given parameters.

public static list_getSubscribedUsers(int $start, int $items_per_page, string $sort, int $id_sub, string $search_string[, array<string|int, mixed> $search_vars = [] ]) : array<string|int, mixed>
Parameters
$start : int

The item to start with (for pagination purposes)

$items_per_page : int

How many items to show on each page

$sort : string

A string indicating how to sort the results

$id_sub : int

The ID of the subscription

$search_string : string

A search string

$search_vars : array<string|int, mixed> = []

The variables for the search string

Tags
todo

refactor outta here

Return values
array<string|int, mixed>

An array of information about the subscribed users matching the given parameters

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

loadPaymentGateways()

Load all the payment gateways.

public static loadPaymentGateways() : array<string|int, mixed>
  • Looks for 3.x-style payment gateways in Sources/Subscriptions.
  • Looks for 2.x-style payment gateways in Sources.
Return values
array<string|int, mixed>

An array of information about available payment gateways

modify()

Adding, editing and deleting subscriptions.

public modify() : void

Accessed from ?action=admin;area=paidsubscribe;sa=modify.

modifySubscription()

Backward compatibility wrapper for the modify sub-action.

public static modifySubscription() : void

modifySubscriptionSettings()

Backward compatibility wrapper for the settings sub-action.

public static modifySubscriptionSettings([bool $return_config = false ]) : void|array<string|int, mixed>
Parameters
$return_config : bool = false

Whether to return the config_vars array.

Return values
void|array<string|int, mixed>

Returns nothing or returns the config_vars array.

modifyUser()

Edit or add a user subscription.

public modifyUser() : void

Accessed from ?action=admin;area=paidsubscribe;sa=modifyuser.

modifyUserSubscription()

Backward compatibility wrapper for the modifyuser sub-action.

public static modifyUserSubscription() : void

reapply()

Reapplies all subscription rules for each of the users.

public static reapply(array<string|int, mixed> $users) : void
Parameters
$users : array<string|int, mixed>

An array of user IDs

Tags
todo

This appears to be unused. Remove it?

remove()

Removes a subscription from a user, as in removes the groups.

public static remove(int $id_subscribe, int $id_member[, bool $delete = false ]) : void
Parameters
$id_subscribe : int

The ID of the subscription

$id_member : int

The ID of the member

$delete : bool = false

Whether to delete the subscription or just disable it

settings()

Set any setting related to paid subscriptions, i.e.

public settings() : void

modify which payment methods are to be used. It requires the moderate_forum permission Accessed from ?action=admin;area=paidsubscribe;sa=settings.

view()

View a list of all the current subscriptions Requires the admin_forum permission.

public view() : void

Accessed from ?action=admin;area=paidsubscribe;sa=view.

viewSubscribedUsers()

Backward compatibility wrapper for the viewsub sub-action.

public static viewSubscribedUsers() : void

viewSubscriptions()

Backward compatibility wrapper for the view sub-action.

public static viewSubscriptions() : void

viewUsers()

View all the users subscribed to a particular subscription.

public viewUsers() : void

Requires the admin_forum permission. Accessed from ?action=admin;area=paidsubscribe;sa=viewsub.

Subscription ID is required, in the form of $_GET['sid'].

__construct()

Constructor. Protected to force instantiation via self::load().

protected __construct() : mixed

        
On this page

Search results