PHP Class BP_Reply_By_Email_Extension, bp-reply-by-email

This class relies on the activity component. If your plugin doesn't rely on the activity component (eg. PMs), don't extend this class. Extend this class and in your constructor call the bootstrap() method. See inline docs in the bootstrap() method for more details. Next, override the post_by_email() method to do your custom checks and posting routine. You should call this class anytime *after* the 'bp_include' hook of priority 10, but before or equal to the 'bp_loaded' hook.
Since: 1.0-RC1
Datei anzeigen Open project: r-a-y/bp-reply-by-email

Protected Properties

Property Type Description
$data array These variables are stored in a protected array that is magically updated using PHP 5.2+ methods.

Public Methods

Method Description
__get ( string $key ) Magic method for getting a certain data variable.
__isset ( string $key ) Magic method for checking the existence of a certain data variable.
extend_activity_listener ( obj $listener, obj $item ) RBE activity listener for your plugin.
extend_querystring ( string $querystring, obj $listener ) Sets up the querystring used in the 'Reply-To' email address.
failure_message_to_sender ( mixed $message, string $type, array $headers, integer $i, resource $connection ) : mixed Setup your extension's failure message to send back to the sender.
internal_rbe_log ( mixed $log, string $type, array $headers, integer $i, resource $connection ) : mixed Log your extension's error messages during the post_by_email() method.
post ( boolean $retval, array $data, array $params ) : array | object Detect your extension and do your post routine in this method.
register_params ( array $params ) : array This method registers your 'item_id_param' / 'secondary_item_id_param' with RBE.

Protected Methods

Method Description
bootstrap ( array $data = [] ) Extensions must use this method in their constructor.
setup_hooks ( ) Hooks! We do the dirty work here, so you don't have to! :)

Method Details

__get() public method

Magic method for getting a certain data variable.
public __get ( string $key )
$key string

__isset() public method

Magic method for checking the existence of a certain data variable.
public __isset ( string $key )
$key string

bootstrap() protected method

Extensions must use this method in their constructor.
protected bootstrap ( array $data = [] )
$data array See inline doc.

extend_activity_listener() public method

Override this in your class if your 'item_id' / 'secondary_item_id' needs to be calculated in a different manner. If your plugin doesn't rely on the activity component, you will probably want to override this method and make it an empty method.
public extend_activity_listener ( obj $listener, obj $item )
$listener obj Registers your component with RBE's activity listener
$item obj The activity object generated by BP during save.

extend_querystring() public method

Override this if needed.
public extend_querystring ( string $querystring, obj $listener )
$querystring string Querystring used to form the "Reply-To" email address.
$listener obj The listener object registered in the extend_activity_listener() method.

failure_message_to_sender() public method

Extend away!
public failure_message_to_sender ( mixed $message, string $type, array $headers, integer $i, resource $connection ) : mixed
$message mixed Should override to string in method. Defaults to boolean false.
$type string Type of error message
$headers array The email headers
$i integer The message number from the inbox loop
$connection resource The current IMAP connection. Chances are you probably don't have to do anything with this!
return mixed $message

internal_rbe_log() public method

Extend away!
public internal_rbe_log ( mixed $log, string $type, array $headers, integer $i, resource $connection ) : mixed
$log mixed Should override to string in method. Defaults to boolean false.
$type string Type of error message
$headers array The email headers
$i integer The message number from the inbox loop
$connection resource The current IMAP connection. Chances are you probably don't have to do anything with this!
return mixed $log

post() abstract public method

Yup, you must declare this in your class and actually write some code! :) The actual contents of this method will differ for each extension. See {@link BP_Reply_By_Email::post()} for an example. You should return the posted ID of your extension on success and a {@link WP_Error} object on failure.
abstract public post ( boolean $retval, array $data, array $params ) : array | object
$retval boolean Defeults to boolean true.
$data array The data from the parsing. Includes email content, user ID, subject.
$params array Holds an array of params used by RBE. Also holds the params registered in the bootstrap() method.
return array | object On success, return an array of the posted ID recommended. On failure, return a WP_Error object.

register_params() public method

You shouldn't have to override this.
public register_params ( array $params ) : array
$params array Whitelisted parameters used by RBE for the querystring
return array $params

setup_hooks() protected method

Hooks! We do the dirty work here, so you don't have to! :)
protected setup_hooks ( )

Property Details

$data protected_oe property

These variables are stored in a protected array that is magically updated using PHP 5.2+ methods.
See also: BP_Reply_By_Email::bootstrap() This is where $data is defined
protected array $data
return array