Documentation

Register2 extends Register
in package
Uses BackwardCompatibility

Actually registers the new member.

Table of Contents

Properties

$errors  : array<string|int, mixed>
$possible_bools  : array<string|int, mixed>
$possible_floats  : array<string|int, mixed>
$possible_ints  : array<string|int, mixed>
$possible_strings  : array<string|int, mixed>
$subaction  : string
$subactions  : array<string|int, mixed>
$obj  : object
$backcompat  : array<string|int, mixed>

Methods

call()  : void
Convenience method to load() and execute() an instance of this class.
checkUsername()  : mixed
See if a username already exists.
execute()  : void
Actually register the member.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
load()  : object
Static wrapper for constructor.
register()  : void
Backward compatibility wrapper for show sub-action.
registerMember()  : int|array<string|int, mixed>
Registers a member to the forum.
show()  : void
Begin the registration process.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().

Properties

$errors

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

Errors encountered while trying to register.

$possible_bools

public array<string|int, mixed> $possible_bools = ['show_online']

Registration fields that take booleans.

$possible_floats

public array<string|int, mixed> $possible_floats = ['time_offset']

Registration fields that take floats.

$possible_ints

public array<string|int, mixed> $possible_ints = ['id_theme']

Registration fields that take integers.

$possible_strings

public array<string|int, mixed> $possible_strings = ['birthdate', 'timezone', 'buddy_list', 'pm_ignore_list', 'smiley_set', 'personal_text', 'avatar', 'lngfile', 'secret_question', 'secret_answer']

Registration fields that take strings.

$subaction

public string $subaction = 'show'

The sub-action to call.

$subactions

public static array<string|int, mixed> $subactions = ['show' => 'show', 'usernamecheck' => 'checkUsername']

Available sub-actions.

$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' => 'Register2', 'registerMember' => 'registerMember']]

BackwardCompatibility settings for this class.

Methods

call()

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

public static call() : void

checkUsername()

See if a username already exists.

public checkUsername() : mixed

execute()

Actually register the member.

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.

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

register()

Backward compatibility wrapper for show sub-action.

public static register([array<string|int, mixed> $reg_errors = [] ]) : void
Parameters
$reg_errors : array<string|int, mixed> = []

Holds information about any errors that occurred.

registerMember()

Registers a member to the forum.

public static registerMember(array<string|int, mixed> &$reg_options[, bool $return_errors = false ]) : int|array<string|int, mixed>

Allows two types of interface: 'guest' and 'admin'. The first includes hammering protection, the latter can perform the registration silently. The strings used in the options array are assumed to be escaped. Allows to perform several checks on the input, e.g. reserved names. The function will adjust member statistics. If an error is detected will fatal error on all errors unless return_errors is true.

Parameters
$reg_options : array<string|int, mixed>

An array of registration options

$return_errors : bool = false

Whether to return the errors

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

The ID of the newly registered user or an array of error info if $return_errors is true

show()

Begin the registration process.

public show() : void

__construct()

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

protected __construct() : mixed

        
On this page

Search results