13 define(
'ELGG_PLUGIN_INCLUDE_START', 1);
18 define(
'ELGG_PLUGIN_REGISTER_VIEWS', 2);
23 define(
'ELGG_PLUGIN_REGISTER_LANGUAGES', 4);
28 define(
'ELGG_PLUGIN_REGISTER_CLASSES', 8);
41 define(
'ELGG_PLUGIN_USER_SETTING_PREFIX',
'plugin:user_setting:');
48 define(
'ELGG_PLUGIN_INTERNAL_PREFIX',
'elgg:internal:');
66 $plugin_dirs = array();
67 $handle = opendir($dir);
70 while ($plugin_dir = readdir($handle)) {
72 if (substr($plugin_dir, 0, 1) !==
'.' && is_dir($dir . $plugin_dir)) {
73 $plugin_dirs[] = $plugin_dir;
107 'subtype' =>
'plugin',
108 'selects' => array(
'plugin_oe.*'),
109 'joins' => array(
"JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"),
115 if (!$known_plugins) {
116 $known_plugins = array();
121 foreach ($known_plugins as $i =>
$plugin) {
126 unset($known_plugins[$i]);
129 $id_map[
$plugin->getID()] = $i;
134 if (!$physical_plugins) {
141 if (array_key_exists($plugin_id, $id_map)) {
143 $plugin = $known_plugins[$index];
152 unset($known_plugins[$index]);
164 foreach ($known_plugins as
$plugin) {
165 if ($plugin->isActive()) {
166 $plugin->deactivate();
171 if ($plugin->isEnabled()) {
215 'subtype' =>
'plugin',
216 'joins' => array(
"JOIN {$db_prefix}objects_entity oe on oe.guid = e.guid"),
217 'selects' => array(
"oe.title",
"oe.description"),
218 'wheres' => array(
"oe.title = '$plugin_id'"),
245 return (
$plugin) ?
true :
false;
260 $q =
"SELECT MAX(CAST(ps.value AS unsigned)) as max 261 FROM {$db_prefix}entities e, {$db_prefix}private_settings ps 262 WHERE ps.name = '$priority' 263 AND ps.entity_guid = e.guid 264 AND e.type = 'object' and e.subtype = $plugin_subtype";
268 $max =
$data[0]->max;
274 return ($max) ? $max : 1;
323 if (!$plugins_path) {
328 if (file_exists(
"$plugins_path/disabled")) {
348 $plugin->start($start_flags);
349 }
catch (Exception
$e) {
350 $plugin->deactivate();
351 $msg =
elgg_echo(
'PluginException:CannotStart',
352 array($plugin->getID(), $plugin->guid, $e->getMessage()));
378 $site_guid =
$site->guid;
384 'subtype' =>
'plugin',
386 'selects' => array(
'plugin_oe.*'),
388 "JOIN {$db_prefix}private_settings ps on ps.entity_guid = e.guid",
389 "JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid" 391 'wheres' => array(
"ps.name = '$priority'"),
392 'order_by' =>
"CAST(ps.value as unsigned), e.guid" 397 $options[
'relationship'] =
'active_plugin';
398 $options[
'relationship_guid'] = $site_guid;
399 $options[
'inverse_relationship'] =
true;
403 $options[
'wheres'][] =
"NOT EXISTS ( 404 SELECT 1 FROM {$db_prefix}entity_relationships active_er 405 WHERE active_er.guid_one = e.guid 406 AND active_er.relationship = 'active_plugin' 407 AND active_er.guid_two = $site_guid)";
447 $order = array_values($order);
449 $missing_plugins = array();
469 if (
$return && $missing_plugins) {
473 foreach ($missing_plugins as $plugin) {
521 elgg_deprecated_notice(
"You must pass the plugin id to _elgg_namespace_plugin_private_setting() for user settings", 1.9);
562 if (!isset($ELGG_PLUGINS_PROVIDES_CACHE)) {
567 foreach ($active_plugins as
$plugin) {
568 $plugin_provides = array();
569 $manifest = $plugin->getManifest();
571 $plugin_provides = $plugin->getManifest()->getProvides();
573 if ($plugin_provides) {
574 foreach ($plugin_provides as $provided) {
575 $provides[$provided[
'type']][$provided[
'name']] = array(
576 'version' => $provided[
'version'],
577 'provided_by' => $plugin->getID()
583 $ELGG_PLUGINS_PROVIDES_CACHE = $provides;
587 if (isset($ELGG_PLUGINS_PROVIDES_CACHE[
$type][
$name])) {
588 return $ELGG_PLUGINS_PROVIDES_CACHE[
$type][
$name];
593 if (isset($ELGG_PLUGINS_PROVIDES_CACHE[
$type])) {
594 return $ELGG_PLUGINS_PROVIDES_CACHE[
$type];
612 $ELGG_PLUGINS_PROVIDES_CACHE = null;
642 $status = version_compare($provided[
'version'],
$version, $comparison);
649 'value' => $provided[
'version']
673 if (!$dep_system || !$info || !
$type) {
679 switch($comparison) {
706 $strings[
'type'] =
elgg_echo(
'ElggPlugin:Dependencies:' . ucwords($dep_system));
712 $strings[
'name'] =
elgg_echo(
'ElggPlugin:Dependencies:Elgg');
713 $strings[
'expected_value'] =
"$comparison {$info['version']}";
714 $strings[
'local_value'] = $dep[
'value'];
715 $strings[
'comment'] =
'';
720 $strings[
'name'] =
elgg_echo(
'ElggPlugin:Dependencies:PhpVersion');
721 $strings[
'expected_value'] =
"$comparison {$info['version']}";
722 $strings[
'local_value'] = $dep[
'value'];
723 $strings[
'comment'] =
'';
726 case 'php_extension':
728 $strings[
'name'] =
elgg_echo(
'ElggPlugin:Dependencies:PhpExtension', array($info[
'name']));
729 if ($info[
'version']) {
730 $strings[
'expected_value'] =
"$comparison {$info['version']}";
731 $strings[
'local_value'] = $dep[
'value'];
733 $strings[
'expected_value'] =
'';
734 $strings[
'local_value'] =
'';
736 $strings[
'comment'] =
'';
740 $strings[
'name'] =
elgg_echo(
'ElggPlugin:Dependencies:PhpIni', array($info[
'name']));
741 $strings[
'expected_value'] =
"$comparison {$info['value']}";
742 $strings[
'local_value'] = $dep[
'value'];
743 $strings[
'comment'] =
'';
747 $strings[
'name'] =
elgg_echo(
'ElggPlugin:Dependencies:Plugin', array($info[
'name']));
748 $expected = $info[
'version'] ?
"$comparison {$info['version']}" :
elgg_echo(
'any');
749 $strings[
'expected_value'] = $expected;
750 $strings[
'local_value'] = $dep[
'value'] ? $dep[
'value'] :
'--';
751 $strings[
'comment'] =
'';
755 $expected_priority = ucwords($info[
'priority']);
756 $real_priority = ucwords($dep[
'value']);
757 $strings[
'name'] =
elgg_echo(
'ElggPlugin:Dependencies:Priority');
758 $strings[
'expected_value'] =
elgg_echo(
"ElggPlugin:Dependencies:Priority:$expected_priority", array($info[
'plugin']));
759 $strings[
'local_value'] =
elgg_echo(
"ElggPlugin:Dependencies:Priority:$real_priority", array($info[
'plugin']));
760 $strings[
'comment'] =
'';
764 if ($dep[
'type'] ==
'suggests') {
765 if ($dep[
'status']) {
768 $strings[
'comment'] =
elgg_echo(
'ElggPlugin:Dependencies:Suggests:Unsatisfied');
771 if ($dep[
'status']) {
774 $strings[
'comment'] =
elgg_echo(
'error');
1015 return $plugin->unsetAllSettings();
1047 if (!isset(
$options[
'plugin_id'])) {
1048 elgg_deprecated_notice(
"'plugin_id' is now required for elgg_get_entities_from_plugin_user_settings()", 1.9);
1052 $singulars = array(
'plugin_user_setting_name',
'plugin_user_setting_value',
1053 'plugin_user_setting_name_value_pair');
1059 'plugin_user_setting_names' =>
'private_setting_names',
1060 'plugin_user_setting_values' =>
'private_setting_values',
1061 'plugin_user_setting_name_value_pairs' =>
'private_setting_name_value_pairs',
1062 'plugin_user_setting_name_value_pairs_operator' =>
'private_setting_name_value_pairs_operator',
1065 foreach ($map as
$plugin => $private) {
1071 if (!is_array(
$options[$private])) {
1082 $options[
'private_setting_name_prefix'] = $prefix;
1100 $value[] = $CONFIG->path .
'engine/tests/ElggCorePluginsAPITest.php';
1120 $dependents = array();
1121 foreach ($active_plugins as
$plugin) {
1122 $manifest = $plugin->getManifest();
1123 $requires = $manifest->getRequires();
1125 foreach ($requires as $required) {
1126 if ($required[
'type'] ==
'plugin' && $required[
'name'] ==
$plugin_id) {
1128 $dependents[$manifest->getPluginID()] =
$plugin;
1136 foreach ($dependents as $dependent) {
1137 $list .=
'<li>' . $dependent->getManifest()->getName() .
'</li>';
_elgg_get_plugins_provides($type=null, $name=null)
Returns an array of all provides from all active plugins.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
elgg_get_calling_plugin_id($mainfilename=false)
Get the name of the most recent plugin to be called in the call stack (or the plugin that owns the cu...
elgg_get_entities_from_plugin_user_settings(array $options=array())
Returns entities based upon plugin user settings.
elgg_get_site_entity($site_guid=0)
Get an ElggSite entity (default is current site)
getID()
Returns the ID (dir name) of this plugin.
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
elgg_set_plugin_setting($name, $value, $plugin_id=null)
Set a setting for a plugin.
if($guid==elgg_get_logged_in_user_guid()) $name
_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...
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.
get_subtype_id($type, $subtype)
Return the id for a given subtype.
const ELGG_ENTITIES_NO_VALUE
elgg_get_entities_from_private_settings(array $options=array())
Returns entities based upon private settings.
get_config($name, $site_guid=0)
Gets a configuration value.
elgg_add_admin_notice($id, $message)
Write a persistent message to the admin view.
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells ElggPlugin::start() to automatically register the plugin's languages.
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Register a callback as a plugin hook handler.
elgg_get_plugin_user_setting($name, $user_guid=0, $plugin_id=null)
Get a user specific setting for a plugin.
_elgg_load_plugins()
Loads all active plugins in the order specified in the tool admin panel.
sanitize_string($string)
Sanitize a string for database use.
_elgg_namespace_plugin_private_setting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
elgg_unset_all_plugin_settings($plugin_id=null)
Unsets all plugin settings for a plugin.
const ELGG_PLUGIN_USER_SETTING_PREFIX
Prefix for plugin setting names.
_plugins_deactivate_dependency_check($event, $type, $params)
Checks on deactivate plugin event if disabling it won't create unmet dependencies and blocks disable ...
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
_elgg_get_plugin_dependency_strings($dep)
Returns an array of parsed strings for a dependency in the format: array( 'type' => requires...
elgg_set_ignore_access($ignore=true)
Set if Elgg's access system should be ignored.
elgg_set_config($name, $value)
Set an Elgg configuration value.
const ELGG_PLUGIN_INCLUDE_START
Tells ElggPlugin::start() to include the start.php file.
elgg_in_context($context)
Check if this context exists anywhere in the stack.
elgg_set_plugin_user_setting($name, $value, $user_guid=0, $plugin_id=null)
Set a user specific setting for a plugin.
const ELGG_PLUGIN_REGISTER_VIEWS
Tells ElggPlugin::start() to automatically register the plugin's views.
elgg_get_root_path()
Get the root directory path for this installation.
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
_elgg_get_max_plugin_priority()
Returns the highest priority of the plugins.
const ELGG_PLUGIN_INTERNAL_PREFIX
Internal settings prefix.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
_elgg_cache_plugin_by_id(ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
elgg_register_library($name, $location)
Register a php library.
access_get_show_hidden_status()
Return current status of showing disabled entities.
elgg system_message
Wrapper function for system_messages.
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
elgg_get_calling_plugin_entity()
Returns the ElggPlugin entity of the last plugin called.
elgg_plugin_exists($id)
Returns if a plugin exists in the system.
_elgg_plugins_init()
Initialize the plugin system.
elgg_unset_plugin_user_setting($name, $user_guid=0, $plugin_id=null)
Unsets a user-specific plugin setting.
_elgg_plugins_test($hook, $type, $value, $params)
Runs unit tests for plugin API.
get_data($query, $callback="")
Retrieve rows from the database.
elgg_get_plugins($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
elgg_unset_plugin_setting($name, $plugin_id=null)
Unsets a plugin setting.
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
_elgg_set_plugin_priorities(array $order)
Reorder plugins to an order specified by the array.
elgg register_error
Wrapper function for system_messages.
elgg_get_plugin_setting($name, $plugin_id=null, $default=null)
Get setting for a plugin.
elgg_register_ajax_view($view)
Register a view to be available for ajax calls.
_elgg_reindex_plugin_priorities()
Reindexes all plugin priorities starting at 1.
elgg_is_active_plugin($plugin_id, $site_guid=null)
Returns if a plugin is active for a current site.
global $ELGG_PLUGINS_PROVIDES_CACHE
const ELGG_PLUGIN_REGISTER_CLASSES
Tells ElggPlugin::start() to automatically register the plugin's classes.
elgg_get_plugins_path()
Get the plugin path for this installation.
_elgg_invalidate_plugins_provides_cache()
Deletes all cached data on plugins being provided.
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
_elgg_get_plugin_dirs_in_dir($dir=null)
Returns a list of plugin directory names from a base directory.
$user_guid
Avatar remove action.
if(!$collection_name) $id
if(!$num_display) $db_prefix
_elgg_generate_plugin_entities()
Discovers plugins in the plugins_path setting and creates ElggPlugin entities for them if they don't ...
elgg_get_plugin_from_id($plugin_id)
Returns an ElggPlugin object with the path $path.
get_entity($guid)
Loads and returns an entity object from a guid.
if(!($plugin instanceof ElggPlugin)) $plugin_name