Elgg  Version 1.9
Namespaces | Functions | Variables
plugins.php File Reference

Go to the source code of this file.

Namespaces

 Elgg\Core
 Activate a plugin or plugins.
 

Functions

 _elgg_get_plugin_dirs_in_dir ($dir=null)
 Returns a list of plugin directory names from a base directory. More...
 
 _elgg_generate_plugin_entities ()
 Discovers plugins in the plugins_path setting and creates ElggPlugin entities for them if they don't exist. More...
 
 _elgg_cache_plugin_by_id (ElggPlugin $plugin)
 Cache a reference to this plugin by its ID. More...
 
 elgg_get_plugin_from_id ($plugin_id)
 Returns an ElggPlugin object with the path $path. More...
 
 elgg_plugin_exists ($id)
 Returns if a plugin exists in the system. More...
 
 _elgg_get_max_plugin_priority ()
 Returns the highest priority of the plugins. More...
 
 elgg_is_active_plugin ($plugin_id, $site_guid=null)
 Returns if a plugin is active for a current site. More...
 
 _elgg_load_plugins ()
 Loads all active plugins in the order specified in the tool admin panel. More...
 
 elgg_get_plugins ($status= 'active', $site_guid=null)
 Returns an ordered list of plugins. More...
 
 _elgg_set_plugin_priorities (array $order)
 Reorder plugins to an order specified by the array. More...
 
 _elgg_reindex_plugin_priorities ()
 Reindexes all plugin priorities starting at 1. More...
 
 _elgg_namespace_plugin_private_setting ($type, $name, $id=null)
 Namespaces a string to be used as a private setting name for a plugin. More...
 
 _elgg_get_plugins_provides ($type=null, $name=null)
 Returns an array of all provides from all active plugins. More...
 
 _elgg_invalidate_plugins_provides_cache ()
 Deletes all cached data on plugins being provided. More...
 
 _elgg_check_plugins_provides ($type, $name, $version=null, $comparison= 'ge')
 Checks if a plugin is currently providing $type and $name, and optionally checking a version. More...
 
 _elgg_get_plugin_dependency_strings ($dep)
 Returns an array of parsed strings for a dependency in the format: array( 'type' => requires, conflicts, or provides. More...
 
 elgg_get_calling_plugin_entity ()
 Returns the ElggPlugin entity of the last plugin called. More...
 
 elgg_get_all_plugin_user_settings ($user_guid=0, $plugin_id=null, $return_obj=false)
 Returns an array of all plugin user settings for a user. More...
 
 elgg_set_plugin_user_setting ($name, $value, $user_guid=0, $plugin_id=null)
 Set a user specific setting for a plugin. More...
 
 elgg_unset_plugin_user_setting ($name, $user_guid=0, $plugin_id=null)
 Unsets a user-specific plugin setting. More...
 
 elgg_get_plugin_user_setting ($name, $user_guid=0, $plugin_id=null)
 Get a user specific setting for a plugin. More...
 
 elgg_set_plugin_setting ($name, $value, $plugin_id=null)
 Set a setting for a plugin. More...
 
 elgg_get_plugin_setting ($name, $plugin_id=null, $default=null)
 Get setting for a plugin. More...
 
 elgg_unset_plugin_setting ($name, $plugin_id=null)
 Unsets a plugin setting. More...
 
 elgg_unset_all_plugin_settings ($plugin_id=null)
 Unsets all plugin settings for a plugin. More...
 
 elgg_get_entities_from_plugin_user_settings (array $options=array())
 Returns entities based upon plugin user settings. More...
 
 _elgg_plugins_test ($hook, $type, $value, $params)
 Runs unit tests for plugin API. More...
 
 _plugins_deactivate_dependency_check ($event, $type, $params)
 Checks on deactivate plugin event if disabling it won't create unmet dependencies and blocks disable in such case. More...
 
 _elgg_plugins_init ()
 Initialize the plugin system. More...
 

Variables

const ELGG_PLUGIN_INCLUDE_START 1
 Tells ElggPlugin::start() to include the start.php file. More...
 
const ELGG_PLUGIN_REGISTER_VIEWS 2
 Tells ElggPlugin::start() to automatically register the plugin's views. More...
 
const ELGG_PLUGIN_REGISTER_LANGUAGES 4
 Tells ElggPlugin::start() to automatically register the plugin's languages. More...
 
const ELGG_PLUGIN_REGISTER_CLASSES 8
 Tells ElggPlugin::start() to automatically register the plugin's classes. More...
 
const ELGG_PLUGIN_USER_SETTING_PREFIX 'plugin:user_setting:'
 Prefix for plugin setting names. More...
 
const ELGG_PLUGIN_INTERNAL_PREFIX 'elgg:internal:'
 Internal settings prefix. More...
 
global $ELGG_PLUGINS_PROVIDES_CACHE
 

Function Documentation

_elgg_cache_plugin_by_id ( ElggPlugin  $plugin)

Cache a reference to this plugin by its ID.

Parameters
ElggPlugin$pluginprivate

Definition at line 191 of file plugins.php.

_elgg_check_plugins_provides (   $type,
  $name,
  $version = null,
  $comparison = 'ge' 
)

Checks if a plugin is currently providing $type and $name, and optionally checking a version.

Parameters
string$typeThe type of the provide
string$nameThe name of the provide
string$versionA version to check against
string$comparisonThe comparison operator to use in version_compare()
Returns
array An array in the form array( 'status' => bool Does the provide exist?, 'value' => string The version provided )
Since
1.8.0 private

Definition at line 632 of file plugins.php.

_elgg_generate_plugin_entities ( )

Discovers plugins in the plugins_path setting and creates ElggPlugin entities for them if they don't exist.

If there are plugins with entities but not actual files, will disable the ElggPlugin entities and mark as inactive. The ElggPlugin object holds config data, so don't delete.

Returns
bool
Since
1.8.0 private

Definition at line 93 of file plugins.php.

_elgg_get_max_plugin_priority ( )

Returns the highest priority of the plugins.

Returns
int
Since
1.8.0 private

Definition at line 255 of file plugins.php.

_elgg_get_plugin_dependency_strings (   $dep)

Returns an array of parsed strings for a dependency in the format: array( 'type' => requires, conflicts, or provides.

'name' => The name of the requirement / conflict 'value' => A string representing the expected value: <1, >=3, !=enabled 'local_value' => The current value, ("Not installed") 'comment' => Free form text to help resovle the problem ("Enable / Search for plugin <link>") )

Parameters
array$depAn ElggPluginPackage dependency array
Returns
array
Since
1.8.0 private

Definition at line 668 of file plugins.php.

_elgg_get_plugin_dirs_in_dir (   $dir = null)

Returns a list of plugin directory names from a base directory.

Parameters
string$dirA dir to scan for plugins. Defaults to config's plugins_path. Must have a trailing slash.
Returns
array Array of directory names (not full paths)
Since
1.8.0 private

Definition at line 61 of file plugins.php.

_elgg_get_plugins_provides (   $type = null,
  $name = null 
)

Returns an array of all provides from all active plugins.

Array in the form array( 'provide_type' => array( 'provided_name' => array( 'version' => '1.8', 'provided_by' => 'provider_plugin_id' ) ) )

Parameters
string$typeThe type of provides to return
string$nameA specific provided name to return. Requires $provide_type.
Returns
array
Since
1.8.0 private

Definition at line 560 of file plugins.php.

_elgg_invalidate_plugins_provides_cache ( )

Deletes all cached data on plugins being provided.

Returns
boolean
Since
1.9.0 private

Definition at line 610 of file plugins.php.

_elgg_load_plugins ( )

Loads all active plugins in the order specified in the tool admin panel.

Note
This is called on every page load. If a plugin is active and problematic, it will be disabled and a visible error emitted. This does not check the deps system because that was too slow.
Returns
bool
Since
1.8.0 private

Definition at line 316 of file plugins.php.

_elgg_namespace_plugin_private_setting (   $type,
  $name,
  $id = null 
)

Namespaces a string to be used as a private setting name for a plugin.

For user_settings, two namespaces are added: a user setting namespace and the plugin id.

For internal (plugin priority), there is a single internal namespace added.

Parameters
string$typeThe type of setting: user_setting or internal.
string$nameThe name to namespace.
string$idThe plugin's ID to namespace with. Required for user_setting.
Returns
string
Since
1.8.0 private

Definition at line 512 of file plugins.php.

_elgg_plugins_init ( )

Initialize the plugin system.

Returns
void private

Definition at line 1153 of file plugins.php.

_elgg_plugins_test (   $hook,
  $type,
  $value,
  $params 
)

Runs unit tests for plugin API.

Parameters
string$hookunit_test
string$typesystem
mixed$valueArray of tests
mixed$paramsParams
Returns
array private

Definition at line 1098 of file plugins.php.

_elgg_reindex_plugin_priorities ( )

Reindexes all plugin priorities starting at 1.

Returns
bool
Since
1.8.0 private

Definition at line 493 of file plugins.php.

_elgg_set_plugin_priorities ( array  $order)

Reorder plugins to an order specified by the array.

Plugins not included in this array will be appended to the end.

Note
This doesn't use the ElggPlugin->setPriority() method because all plugins are being changed and we don't want it to automatically reorder plugins.
Parameters
array$orderAn array of plugin ids in the order to set them
Returns
bool
Since
1.8.0 private

Definition at line 435 of file plugins.php.

_plugins_deactivate_dependency_check (   $event,
  $type,
  $params 
)

Checks on deactivate plugin event if disabling it won't create unmet dependencies and blocks disable in such case.

Parameters
string$eventdeactivate
string$typeplugin
array$paramsParameters array containing entry with ELggPlugin instance under 'plugin_entity' key
Returns
bool false to block plugin deactivation action

private

Definition at line 1114 of file plugins.php.

elgg_get_all_plugin_user_settings (   $user_guid = 0,
  $plugin_id = null,
  $return_obj = false 
)

Returns an array of all plugin user settings for a user.

Parameters
int$user_guidThe user GUID or 0 for the currently logged in user.
string$plugin_idThe plugin ID (Required)
bool$return_objReturn settings as an object? This can be used to in reusable views where the settings are passed as $vars['entity'].
Returns
array
Since
1.8.0
See also
ElggPlugin::getAllUserSettings()

Definition at line 811 of file plugins.php.

elgg_get_calling_plugin_entity ( )

Returns the ElggPlugin entity of the last plugin called.

Returns
mixed ElggPlugin or false
Since
1.8.0 private

Definition at line 789 of file plugins.php.

elgg_get_entities_from_plugin_user_settings ( array  $options = array())

Returns entities based upon plugin user settings.

Takes all the options for elgg_get_entities_from_private_settings() in addition to the ones below.

Parameters
array$optionsArray in the format:
plugin_id => STR The plugin id. Required.

plugin_user_setting_names => null|ARR private setting names

plugin_user_setting_values => null|ARR metadata values

plugin_user_setting_name_value_pairs => null|ARR (
                                    name => 'name',
                                    value => 'value',
                                    'operand' => '=',
                                   )
                             Currently if multiple values are sent via
                          an array (value => array('value1', 'value2')
                          the pair's operand will be forced to "IN".

plugin_user_setting_name_value_pairs_operator => null|STR The operator to use for combining
                                   (name = value) OPERATOR (name = value); default AND
Returns
mixed int If count, int. If not count, array. false on errors.
Since
1.8.0

Definition at line 1046 of file plugins.php.

elgg_get_plugin_from_id (   $plugin_id)

Returns an ElggPlugin object with the path $path.

Parameters
string$plugin_idThe id (dir name) of the plugin. NOT the guid.
Returns
ElggPlugin|null
Since
1.8.0

Definition at line 204 of file plugins.php.

elgg_get_plugin_setting (   $name,
  $plugin_id = null,
  $default = null 
)

Get setting for a plugin.

Parameters
string$nameThe name of the setting.
string$plugin_idThe plugin ID (Required)
mixed$defaultThe default value to return if none is set
Returns
mixed
Since
1.8.0
See also
ElggPlugin::getSetting()

Definition at line 954 of file plugins.php.

elgg_get_plugin_user_setting (   $name,
  $user_guid = 0,
  $plugin_id = null 
)

Get a user specific setting for a plugin.

Parameters
string$nameThe name of the setting.
int$user_guidThe user GUID or 0 for the currently logged in user.
string$plugin_idThe plugin ID (Required)
Returns
mixed
Since
1.8.0
See also
ElggPlugin::getUserSetting()

Definition at line 902 of file plugins.php.

elgg_get_plugins (   $status = 'active',
  $site_guid = null 
)

Returns an ordered list of plugins.

Parameters
string$statusThe status of the plugins. active, inactive, or all.
mixed$site_guidOptional site guid
Returns
ElggPlugin[]
Since
1.8.0

Definition at line 372 of file plugins.php.

elgg_is_active_plugin (   $plugin_id,
  $site_guid = null 
)

Returns if a plugin is active for a current site.

Parameters
string$plugin_idThe plugin ID
int$site_guidThe site guid
Since
1.8.0
Returns
bool

Definition at line 285 of file plugins.php.

elgg_plugin_exists (   $id)

Returns if a plugin exists in the system.

Warning
This checks only plugins that are registered in the system! If the plugin cache is outdated, be sure to regenerate it with _elgg_generate_plugin_objects() first.
Parameters
string$idThe plugin ID.
Since
1.8.0
Returns
bool

Definition at line 242 of file plugins.php.

elgg_set_plugin_setting (   $name,
  $value,
  $plugin_id = null 
)

Set a setting for a plugin.

Parameters
string$nameThe name of the setting - note, can't be "title".
mixed$valueThe value.
string$plugin_idThe plugin ID (Required)
Returns
bool
Since
1.8.0
See also
ElggPlugin::setSetting()

Definition at line 928 of file plugins.php.

elgg_set_plugin_user_setting (   $name,
  $value,
  $user_guid = 0,
  $plugin_id = null 
)

Set a user specific setting for a plugin.

Parameters
string$nameThe name. Note: cannot be "title".
mixed$valueThe value.
int$user_guidThe user GUID or 0 for the currently logged in user.
string$plugin_idThe plugin ID (Required)
Returns
bool
Since
1.8.0
See also
ElggPlugin::setUserSetting()

Definition at line 850 of file plugins.php.

elgg_unset_all_plugin_settings (   $plugin_id = null)

Unsets all plugin settings for a plugin.

Parameters
string$plugin_idThe plugin ID (Required)
Returns
bool
Since
1.8.0
See also
ElggPlugin::unsetAllSettings()

Definition at line 1003 of file plugins.php.

elgg_unset_plugin_setting (   $name,
  $plugin_id = null 
)

Unsets a plugin setting.

Parameters
string$nameThe name of the setting.
string$plugin_idThe plugin ID (Required)
Returns
bool
Since
1.8.0
See also
ElggPlugin::unsetSetting()

Definition at line 979 of file plugins.php.

elgg_unset_plugin_user_setting (   $name,
  $user_guid = 0,
  $plugin_id = null 
)

Unsets a user-specific plugin setting.

Parameters
string$nameName of the setting
int$user_guidThe user GUID or 0 for the currently logged in user.
string$plugin_idThe plugin ID (Required)
Returns
bool
Since
1.8.0
See also
ElggPlugin::unsetUserSetting()

Definition at line 876 of file plugins.php.

Variable Documentation

global $ELGG_PLUGINS_PROVIDES_CACHE

Definition at line 539 of file plugins.php.

const ELGG_PLUGIN_INCLUDE_START 1

Tells ElggPlugin::start() to include the start.php file.

Definition at line 13 of file plugins.php.

const ELGG_PLUGIN_INTERNAL_PREFIX 'elgg:internal:'

Internal settings prefix.

Definition at line 48 of file plugins.php.

const ELGG_PLUGIN_REGISTER_CLASSES 8

Tells ElggPlugin::start() to automatically register the plugin's classes.

Definition at line 28 of file plugins.php.

const ELGG_PLUGIN_REGISTER_LANGUAGES 4

Tells ElggPlugin::start() to automatically register the plugin's languages.

Definition at line 23 of file plugins.php.

const ELGG_PLUGIN_REGISTER_VIEWS 2

Tells ElggPlugin::start() to automatically register the plugin's views.

Definition at line 18 of file plugins.php.

const ELGG_PLUGIN_USER_SETTING_PREFIX 'plugin:user_setting:'

Prefix for plugin setting names.

Prefix for plugin user setting names

Definition at line 41 of file plugins.php.