PHP Class ElggPlugin, Elgg

This class is currently a stub, allowing a plugin to save settings in an object's private settings for each site.
Inheritance: extends ElggObject
Mostra file Open project: elgg/elgg Class Usage Examples

Public Methods

Method Description
__construct ( string $path ) Creates a new plugin from path
__get ( string $name ) : mixed Get an attribute or private setting value
__set ( string $name, mixed $value ) : void Set a value as private setting or attribute.
activate ( ) : boolean Actives the plugin for the current site.
canActivate ( ) : boolean Checks if this plugin can be activated on the current Elgg installation.
canDeactivate ( ) : boolean Checks if this plugin can be deactivated on the current Elgg installation. Validates that this plugin has no active dependants.
deactivate ( ) : boolean Deactivates the plugin.
getAllSettings ( ) : array Returns an array of all settings saved for this plugin.
getAllUserSettings ( integer $user_guid ) : array Returns an array of all user settings saved for this plugin for the user.
getAvailableTextFiles ( ) : array Returns an array of available markdown files for this plugin
getError ( ) : string | null Returns the last error message registered.
getFriendlyName ( ) : string Returns the manifest's name if available, otherwise the ID.
getID ( ) : string Returns the ID (dir name) of this plugin
getManifest ( ) : ElggPluginManifest | null Returns this plugin's \ElggPluginManifest object
getPackage ( ) : ElggPluginPackage | null Returns this plugin's \ElggPluginPackage object
getPath ( ) : string Returns the plugin's full path with trailing slash.
getPriority ( ) : integer Gets the plugin's load priority.
getSetting ( string $name, mixed $default = null ) : mixed Returns a plugin setting
getStaticConfig ( string $key, mixed $default = null ) : mixed Get a value from the plugins's static config file.
getUserSetting ( string $name, integer $user_guid, mixed $default = null ) : mixed Returns a user's setting for this plugin
isActive ( ) : boolean Is this plugin active?
isValid ( ) : boolean Returns if the plugin is complete, meaning has all required files and Elgg can read them and they make sense.
save ( ) : boolean Save the plugin object. Make sure required values exist.
setID ( string $id ) : boolean Sets the location of this plugin.
setPriority ( mixed $priority ) : boolean Sets the priority of the plugin
setSetting ( string $name, string $value ) : boolean Set a plugin setting for the plugin
setUserSetting ( string $name, string $value, integer $user_guid ) : mixed Sets a user setting for a plugin
start ( integer $flags ) : true Start the plugin.
unsetAllSettings ( ) : boolean Removes all settings for this plugin.
unsetAllUserSettings ( integer $user_guid ) : boolean Removes all User Settings for this plugin for a particular user
unsetAllUsersSettings ( ) : boolean Removes this plugin's user settings for all users.
unsetSetting ( string $name ) : boolean Removes a plugin setting name and value.
unsetUserSetting ( string $name, integer $user_guid ) : boolean Removes a user setting name and value.

Protected Methods

Method Description
canReadFile ( string $filename ) : boolean Checks whether a plugin file with the given name exists
includeFile ( string $filename ) : mixed Includes one of the plugins files
initializeAttributes ( ) : void Set subtype to 'plugin'
registerActions ( ) : void Registers the plugin's actions provided in the plugin config file
registerClasses ( ) : true Registers the plugin's classes
registerLanguages ( ) : true Registers the plugin's languages
registerViews ( ) : void Registers the plugin's views
registerWidgets ( ) : void Registers the plugin's widgets provided in the plugin config file

Private Methods

Method Description
isStaticConfigValid ( ) : boolean If a static config file is present, is it a serializable array?
setStatus ( boolean $active ) : boolean Sets the plugin to active or inactive.

Method Details

__construct() public method

Creates a new plugin from path
public __construct ( string $path )
$path string The absolute path of the plugin

__get() public method

Get an attribute or private setting value
public __get ( string $name ) : mixed
$name string Name of the attribute or private setting
return mixed

__set() public method

Attributes include title and description.
public __set ( string $name, mixed $value ) : void
$name string Name of the attribute or private_setting
$value mixed Value to be set
return void

activate() public method

Actives the plugin for the current site.
public activate ( ) : boolean
return boolean

canActivate() public method

Checks if this plugin can be activated on the current Elgg installation.
public canActivate ( ) : boolean
return boolean

canDeactivate() public method

Checks if this plugin can be deactivated on the current Elgg installation. Validates that this plugin has no active dependants.
public canDeactivate ( ) : boolean
return boolean

canReadFile() protected method

Checks whether a plugin file with the given name exists
protected canReadFile ( string $filename ) : boolean
$filename string The name of the file
return boolean

deactivate() public method

Deactivates the plugin.
public deactivate ( ) : boolean
return boolean

getAllSettings() public method

Returns an array of all settings saved for this plugin.
public getAllSettings ( ) : array
return array An array of key/value pairs.

getAllUserSettings() public method

Returns an array of all user settings saved for this plugin for the user.
public getAllUserSettings ( integer $user_guid ) : array
$user_guid integer The user GUID. Defaults to logged in.
return array An array of key/value pairs.

getAvailableTextFiles() public method

Returns an array of available markdown files for this plugin
public getAvailableTextFiles ( ) : array
return array

getError() public method

Returns the last error message registered.
public getError ( ) : string | null
return string | null

getFriendlyName() public method

Returns the manifest's name if available, otherwise the ID.
Since: 1.8.1
public getFriendlyName ( ) : string
return string

getID() public method

Returns the ID (dir name) of this plugin
public getID ( ) : string
return string

getManifest() public method

Returns this plugin's \ElggPluginManifest object
public getManifest ( ) : ElggPluginManifest | null
return ElggPluginManifest | null

getPackage() public method

Returns this plugin's \ElggPluginPackage object
public getPackage ( ) : ElggPluginPackage | null
return ElggPluginPackage | null

getPath() public method

Returns the plugin's full path with trailing slash.
public getPath ( ) : string
return string

getPriority() public method

Gets the plugin's load priority.
public getPriority ( ) : integer
return integer

getSetting() public method

Returns a plugin setting
public getSetting ( string $name, mixed $default = null ) : mixed
$name string The setting name
$default mixed The default value to return if none is set
return mixed

getStaticConfig() public method

Get a value from the plugins's static config file.
public getStaticConfig ( string $key, mixed $default = null ) : mixed
$key string Config key
$default mixed Value returned if missing
return mixed

getUserSetting() public method

Returns a user's setting for this plugin
public getUserSetting ( string $name, integer $user_guid, mixed $default = null ) : mixed
$name string The setting name
$user_guid integer The user GUID
$default mixed The default value to return if none is set
return mixed The setting string value, the default value or false if there is no user

includeFile() protected method

Includes one of the plugins files
protected includeFile ( string $filename ) : mixed
$filename string The name of the file
return mixed The return value of the included file (or 1 if there is none)

initializeAttributes() protected method

Set subtype to 'plugin'
protected initializeAttributes ( ) : void
return void

isActive() public method

Is this plugin active?
public isActive ( ) : boolean
return boolean

isValid() public method

Returns if the plugin is complete, meaning has all required files and Elgg can read them and they make sense.
public isValid ( ) : boolean
return boolean

registerActions() protected method

Registers the plugin's actions provided in the plugin config file
protected registerActions ( ) : void
return void

registerClasses() protected method

Registers the plugin's classes
protected registerClasses ( ) : true
return true

registerLanguages() protected method

Registers the plugin's languages
protected registerLanguages ( ) : true
return true

registerViews() protected method

Registers the plugin's views
protected registerViews ( ) : void
return void

registerWidgets() protected method

Registers the plugin's widgets provided in the plugin config file
protected registerWidgets ( ) : void
return void

save() public method

Save the plugin object. Make sure required values exist.
See also: ElggObject::save()
public save ( ) : boolean
return boolean

setID() public method

Sets the location of this plugin.
public setID ( string $id ) : boolean
$id string The path to the plugin's dir.
return boolean

setPriority() public method

Sets the priority of the plugin
public setPriority ( mixed $priority ) : boolean
$priority mixed The priority to set. One of +1, -1, first, last, or a number. If given a number, this will displace all plugins at that number and set their priorities +1
return boolean

setSetting() public method

Set a plugin setting for the plugin
public setSetting ( string $name, string $value ) : boolean
$name string The name to set
$value string The value to set
return boolean

setUserSetting() public method

Sets a user setting for a plugin
public setUserSetting ( string $name, string $value, integer $user_guid ) : mixed
$name string The setting name
$value string The setting value
$user_guid integer The user GUID
return mixed The new setting ID or false

start() public method

Start the plugin.
public start ( integer $flags ) : true
$flags integer Start flags for the plugin. See the constants in lib/plugins.php for details.
return true

unsetAllSettings() public method

Removes all settings for this plugin.
public unsetAllSettings ( ) : boolean
return boolean

unsetAllUserSettings() public method

Use {@link removeAllUsersSettings()} to remove all user settings for all users. (Note the plural 'Users'.)
public unsetAllUserSettings ( integer $user_guid ) : boolean
$user_guid integer The user GUID to remove user settings.
return boolean

unsetAllUsersSettings() public method

Use {@link removeAllUserSettings()} if you just want to remove settings for a single user.
public unsetAllUsersSettings ( ) : boolean
return boolean

unsetSetting() public method

Removes a plugin setting name and value.
public unsetSetting ( string $name ) : boolean
$name string The setting name to remove
return boolean

unsetUserSetting() public method

Removes a user setting name and value.
public unsetUserSetting ( string $name, integer $user_guid ) : boolean
$name string The user setting name
$user_guid integer The user GUID
return boolean