24 private $boot_plugins = [];
29 private $provides_cache;
34 private $active_guids = array();
39 private $active_guids_known =
false;
44 private $plugins_by_id;
49 private $settings_cache;
58 $this->plugins_by_id = $pool;
59 $this->settings_cache = $cache;
69 $this->boot_plugins = $plugins;
71 $this->plugins_by_id->put($plugin->getID(),
$plugin);
89 $plugin_dirs = array();
90 $handle = opendir($dir);
93 while ($plugin_dir = readdir($handle)) {
95 if (substr($plugin_dir, 0, 1) !==
'.' && is_dir($dir . $plugin_dir)) {
96 $plugin_dirs[] = $plugin_dir;
129 'subtype' =>
'plugin',
130 'selects' => array(
'plugin_oe.*'),
131 'joins' => array(
"JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"),
137 if (!$known_plugins) {
138 $known_plugins = array();
143 foreach ($known_plugins as $i =>
$plugin) {
148 unset($known_plugins[$i]);
151 $id_map[
$plugin->getID()] = $i;
156 if (!$physical_plugins) {
163 if (array_key_exists($plugin_id, $id_map)) {
174 unset($known_plugins[
$index]);
178 $plugin = new \ElggPlugin($mod_dir . $plugin_id);
186 foreach ($known_plugins as
$plugin) {
187 if ($plugin->isActive()) {
188 $plugin->deactivate();
193 if ($plugin->isEnabled()) {
231 'subtype' =>
'plugin',
232 'joins' => array(
"JOIN {$db_prefix}objects_entity oe on oe.guid = e.guid"),
233 'selects' => array(
"oe.title",
"oe.description"),
234 'wheres' => array(
"oe.title = '$plugin_id'"),
260 return (
bool)$this->
get(
$id);
274 $q =
"SELECT MAX(CAST(ps.value AS unsigned)) as max 275 FROM {$db_prefix}entities e, {$db_prefix}private_settings ps 276 WHERE ps.name = '$priority' 277 AND ps.entity_guid = e.guid 278 AND e.type = 'object' and e.subtype = $plugin_subtype";
301 if ($this->active_guids_known
302 && ($site_guid === null || $site_guid == $current_site_guid)) {
303 return isset($this->active_guids[
$plugin_id]);
337 $this->timer->begin([__METHOD__]);
346 if (!$plugins_path) {
351 if (file_exists(
"$plugins_path/disabled")) {
362 if (!empty($GLOBALS[
'_ELGG']->i18n_loaded_from_cache)) {
366 $plugins = $this->boot_plugins;
368 $this->active_guids_known =
true;
373 foreach ($plugins as
$plugin) {
374 $id = $plugin->getID();
376 $plugin->start($start_flags);
377 $this->active_guids[
$id] = $plugin->guid;
380 if ($disable_plugins === null) {
381 $disable_plugins =
true;
383 if ($disable_plugins) {
384 $plugin->deactivate();
386 $msg =
_elgg_services()->translator->translate(
'PluginException:CannotStart',
387 array(
$id, $plugin->guid, $e->getMessage()));
394 $this->active_guids_known =
true;
397 $this->timer->end([__METHOD__]);
409 function find($status =
'active', $site_guid = null) {
420 'subtype' =>
'plugin',
422 'selects' => array(
'plugin_oe.*',
'ps.value'),
424 "JOIN {$db_prefix}private_settings ps on ps.entity_guid = e.guid",
425 "JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid" 427 'wheres' => array(
"ps.name = '$priority'"),
435 $options[
'relationship'] =
'active_plugin';
436 $options[
'relationship_guid'] = $site_guid;
437 $options[
'inverse_relationship'] =
true;
441 $options[
'wheres'][] =
"NOT EXISTS ( 442 SELECT 1 FROM {$db_prefix}entity_relationships active_er 443 WHERE active_er.guid_one = e.guid 444 AND active_er.relationship = 'active_plugin' 445 AND active_er.guid_two = $site_guid)";
461 if ($b_value !== $a_value) {
462 return $a_value - $b_value;
464 return $a->guid - $b->guid;
487 $plugins = $this->
find(
'any');
496 $order = array_values($order);
498 $missing_plugins = array();
501 foreach ($plugins as
$plugin) {
518 if (
$return && $missing_plugins) {
522 foreach ($missing_plugins as $plugin) {
567 elgg_deprecated_notice(
"You must pass the plugin id to _elgg_namespace_plugin_private_setting() for user settings", 1.9);
601 if ($this->provides_cache === null) {
602 $active_plugins = $this->
find(
'active');
606 foreach ($active_plugins as
$plugin) {
607 $plugin_provides = array();
608 $manifest = $plugin->getManifest();
610 $plugin_provides = $plugin->getManifest()->getProvides();
612 if ($plugin_provides) {
613 foreach ($plugin_provides as $provided) {
614 $provides[$provided[
'type']][$provided[
'name']] = array(
615 'version' => $provided[
'version'],
616 'provided_by' => $plugin->getID()
622 $this->provides_cache = $provides;
626 if (isset($this->provides_cache[
$type][
$name])) {
632 if (isset($this->provides_cache[
$type])) {
633 return $this->provides_cache[
$type];
639 return $this->provides_cache;
649 $this->provides_cache = null;
660 $this->active_guids = array();
661 $this->active_guids_known =
false;
689 $status = version_compare($provided[
'version'],
$version, $comparison);
696 'value' => $provided[
'version']
726 switch($comparison) {
753 $strings[
'type'] = $translator->translate(
'ElggPlugin:Dependencies:' . ucwords($dep_system));
758 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:Elgg');
759 $strings[
'expected_value'] =
"$comparison {$info['version']}";
760 $strings[
'local_value'] = $dep[
'value'];
761 $strings[
'comment'] =
'';
766 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:PhpVersion');
767 $strings[
'expected_value'] =
"$comparison {$info['version']}";
768 $strings[
'local_value'] = $dep[
'value'];
769 $strings[
'comment'] =
'';
772 case 'php_extension':
774 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:PhpExtension', array(
$info[
'name']));
775 if (
$info[
'version']) {
776 $strings[
'expected_value'] =
"$comparison {$info['version']}";
777 $strings[
'local_value'] = $dep[
'value'];
779 $strings[
'expected_value'] =
'';
780 $strings[
'local_value'] =
'';
782 $strings[
'comment'] =
'';
786 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:PhpIni', array(
$info[
'name']));
787 $strings[
'expected_value'] =
"$comparison {$info['value']}";
788 $strings[
'local_value'] = $dep[
'value'];
789 $strings[
'comment'] =
'';
793 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:Plugin', array(
$info[
'name']));
794 $expected =
$info[
'version'] ?
"$comparison {$info['version']}" : $translator->translate(
'any');
795 $strings[
'expected_value'] = $expected;
796 $strings[
'local_value'] = $dep[
'value'] ? $dep[
'value'] :
'--';
797 $strings[
'comment'] =
'';
801 $expected_priority = ucwords(
$info[
'priority']);
802 $real_priority = ucwords($dep[
'value']);
803 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:Priority');
804 $strings[
'expected_value'] = $translator->translate(
"ElggPlugin:Dependencies:Priority:$expected_priority", array(
$info[
'plugin']));
805 $strings[
'local_value'] = $translator->translate(
"ElggPlugin:Dependencies:Priority:$real_priority", array(
$info[
'plugin']));
806 $strings[
'comment'] =
'';
810 if ($dep[
'type'] ==
'suggests') {
811 if ($dep[
'status']) {
812 $strings[
'comment'] = $translator->translate(
'ok');
814 $strings[
'comment'] = $translator->translate(
'ElggPlugin:Dependencies:Suggests:Unsatisfied');
817 if ($dep[
'status']) {
818 $strings[
'comment'] = $translator->translate(
'ok');
820 $strings[
'comment'] = $translator->translate(
'error');
1035 return $plugin->unsetAllSettings();
1066 if (!isset(
$options[
'plugin_id'])) {
1067 elgg_deprecated_notice(
"'plugin_id' is now required for elgg_get_entities_from_plugin_user_settings()", 1.9);
1071 $singulars = array(
'plugin_user_setting_name',
'plugin_user_setting_value',
1072 'plugin_user_setting_name_value_pair');
1078 'plugin_user_setting_names' =>
'private_setting_names',
1079 'plugin_user_setting_values' =>
'private_setting_values',
1080 'plugin_user_setting_name_value_pairs' =>
'private_setting_name_value_pairs',
1081 'plugin_user_setting_name_value_pairs_operator' =>
'private_setting_name_value_pairs_operator',
1084 foreach ($map as
$plugin => $private) {
1090 if (!is_array(
$options[$private])) {
1101 $options[
'private_setting_name_prefix'] = $prefix;
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_site_entity($site_guid=0)
Get an entity (default is current site)
getID()
Returns the ID (dir name) of this plugin.
reindexPriorities()
Reindexes all plugin priorities starting at 1.
getSetting($name, $plugin_id=null, $default=null)
Get setting for a plugin.
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
getMaxPriority()
Returns the highest priority of the plugins.
if($guid==elgg_get_logged_in_user_guid()) $name
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.
getDependencyStrings($dep)
Returns an array of parsed strings for a dependency in the format: array( 'type' => requires...
getEntitiesFromUserSettings(array $options=array())
Returns entities based upon plugin user settings.
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells ::start() to automatically register the plugin's languages.
trait Profilable
Make an object accept a timer.
elgg_get_calling_plugin_entity()
Returns the entity of the last plugin called.
getDirsInDir($dir=null)
Returns a list of plugin directory names from a base directory.
sanitize_string($string)
Sanitizes a string for use in a query.
unsetSetting($name, $plugin_id=null)
Unsets a plugin setting.
getAllUserSettings($user_guid=0, $plugin_id=null, $return_obj=false)
Returns an array of all plugin user settings for a user.
invalidateIsActiveCache()
Delete the cache holding whether plugins are active or not.
const ELGG_PLUGIN_USER_SETTING_PREFIX
Prefix for plugin setting names.
getVolatileData($name)
Get a piece of volatile (non-persisted) data on this entity.
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
In memory cache of (non-user-specific, non-internal) plugin settings.
setSetting($name, $value, $plugin_id=null)
Set a setting for a plugin.
elgg_set_ignore_access($ignore=true)
Set if Elgg's access system should be ignored.
generateEntities()
Discovers plugins in the plugins_path setting and creates entities for them if they don't exist...
find($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
const ELGG_PLUGIN_INCLUDE_START
Tells ::start() to include the start.php file.
elgg_in_context($context)
Check if this context exists anywhere in the stack.
const ELGG_PLUGIN_REGISTER_VIEWS
Tells ::start() to automatically register the plugin's views.
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
checkProvides($type, $name, $version=null, $comparison= 'ge')
Checks if a plugin is currently providing $type and $name, and optionally checking a version...
setBootPlugins(array $plugins)
Set the list of active plugins according to the boot data cache.
const ELGG_PLUGIN_INTERNAL_PREFIX
Internal settings prefix.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
get_data($query, $callback=null, array $params=[])
Retrieve rows from the database.
isActive($plugin_id, $site_guid=null)
Returns if a plugin is active for a current site.
unsetAllSettings($plugin_id=null)
Unsets all plugin settings for a plugin.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
access_get_show_hidden_status()
Return current status of showing disabled entities.
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg system_message
Wrapper function for system_messages.
__construct(Pool $pool, PluginSettingsCache $cache)
Constructor.
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
namespacePrivateSetting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
setPriorities(array $order)
Reorder plugins to an order specified by the array.
setUserSetting($name, $value, $user_guid=0, $plugin_id=null)
Set a user specific setting for a plugin.
load()
Loads all active plugins in the order specified in the tool admin panel.
getProvides($type=null, $name=null)
Returns an array of all provides from all active plugins.
const ELGG_PLUGIN_REGISTER_CLASSES
Tells ::start() to automatically register the plugin's classes.
elgg_get_plugins_path()
Get the plugin path for this installation.
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
Persistent, installation-wide key-value storage.
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
$user_guid
Avatar remove action.
cache(\ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
getUserSetting($name, $user_guid=0, $plugin_id=null, $default=null)
Get a user specific setting for a plugin.
if(!$collection_name) $id
exists($id)
Returns if a plugin exists in the system.
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
if(!$num_display) $db_prefix
get_entity($guid)
Loads and returns an entity object from a guid.
invalidateProvidesCache()
Deletes all cached data on plugins being provided.
unsetUserSetting($name, $user_guid=0, $plugin_id=null)
Unsets a user-specific plugin setting.