48 $this->plugins_by_id = $pool;
65 $plugin_dirs = array();
66 $handle = opendir($dir);
69 while ($plugin_dir = readdir($handle)) {
71 if (substr($plugin_dir, 0, 1) !==
'.' && is_dir($dir . $plugin_dir)) {
72 $plugin_dirs[] = $plugin_dir;
105 'subtype' =>
'plugin',
106 'selects' => array(
'plugin_oe.*'),
107 'joins' => array(
"JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"),
113 if (!$known_plugins) {
114 $known_plugins = array();
119 foreach ($known_plugins as $i =>
$plugin) {
124 unset($known_plugins[$i]);
127 $id_map[
$plugin->getID()] = $i;
132 if (!$physical_plugins) {
141 $plugin = $known_plugins[$index];
150 unset($known_plugins[$index]);
162 foreach ($known_plugins as
$plugin) {
206 'subtype' =>
'plugin',
207 'joins' => array(
"JOIN {$db_prefix}objects_entity oe on oe.guid = e.guid"),
208 'selects' => array(
"oe.title",
"oe.description"),
209 'wheres' => array(
"oe.title = '$plugin_id'"),
237 return (
$plugin) ? true :
false;
251 $q =
"SELECT MAX(CAST(ps.value AS unsigned)) as max
252 FROM {$db_prefix}entities e, {$db_prefix}private_settings ps
253 WHERE ps.name = '$priority'
254 AND ps.entity_guid = e.guid
255 AND e.type = 'object' and e.subtype = $plugin_subtype";
278 if ($this->active_ids_known
279 && ($site_guid ===
null || $site_guid == $current_site_guid)) {
319 if (!$plugins_path) {
324 if (file_exists(
"$plugins_path/disabled")) {
346 $this->active_ids[
$id] =
true;
347 }
catch (Exception
$e) {
349 $msg =
_elgg_services()->translator->translate(
'PluginException:CannotStart',
359 $this->active_ids_known =
true;
370 function find($status =
'active', $site_guid =
null) {
376 $site_guid =
$site->guid;
382 'subtype' =>
'plugin',
384 'selects' => array(
'plugin_oe.*'),
386 "JOIN {$db_prefix}private_settings ps on ps.entity_guid = e.guid",
387 "JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"
389 'wheres' => array(
"ps.name = '$priority'"),
390 'order_by' =>
"CAST(ps.value as unsigned), e.guid",
396 $options[
'relationship'] =
'active_plugin';
397 $options[
'relationship_guid'] = $site_guid;
398 $options[
'inverse_relationship'] =
true;
402 $options[
'wheres'][] =
"NOT EXISTS (
403 SELECT 1 FROM {$db_prefix}entity_relationships active_er
404 WHERE active_er.guid_one = e.guid
405 AND active_er.relationship = 'active_plugin'
406 AND active_er.guid_two = $site_guid)";
445 $order = array_values($order);
447 $missing_plugins = array();
467 if (
$return && $missing_plugins) {
471 foreach ($missing_plugins as
$plugin) {
517 elgg_deprecated_notice(
"You must pass the plugin id to _elgg_namespace_plugin_private_setting() for user settings", 1.9);
557 foreach ($active_plugins as
$plugin) {
558 $plugin_provides = array();
559 $manifest =
$plugin->getManifest();
561 $plugin_provides =
$plugin->getManifest()->getProvides();
563 if ($plugin_provides) {
564 foreach ($plugin_provides as $provided) {
565 $provides[$provided[
'type']][$provided[
'name']] = array(
566 'version' => $provided[
'version'],
567 'provided_by' =>
$plugin->getID()
612 $this->active_ids = array();
613 $this->active_ids_known =
false;
641 $status = version_compare($provided[
'version'],
$version, $comparison);
648 'value' => $provided[
'version']
672 if (!$dep_system || !$info || !
$type) {
678 switch($comparison) {
705 $strings[
'type'] = $translator->translate(
'ElggPlugin:Dependencies:' . ucwords($dep_system));
711 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:Elgg');
712 $strings[
'expected_value'] =
"$comparison {$info['version']}";
713 $strings[
'local_value'] = $dep[
'value'];
714 $strings[
'comment'] =
'';
719 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:PhpVersion');
720 $strings[
'expected_value'] =
"$comparison {$info['version']}";
721 $strings[
'local_value'] = $dep[
'value'];
722 $strings[
'comment'] =
'';
725 case 'php_extension':
727 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:PhpExtension', array($info[
'name']));
728 if ($info[
'version']) {
729 $strings[
'expected_value'] =
"$comparison {$info['version']}";
730 $strings[
'local_value'] = $dep[
'value'];
732 $strings[
'expected_value'] =
'';
733 $strings[
'local_value'] =
'';
735 $strings[
'comment'] =
'';
739 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:PhpIni', array($info[
'name']));
740 $strings[
'expected_value'] =
"$comparison {$info['value']}";
741 $strings[
'local_value'] = $dep[
'value'];
742 $strings[
'comment'] =
'';
746 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:Plugin', array($info[
'name']));
747 $expected = $info[
'version'] ?
"$comparison {$info['version']}" : $translator->translate(
'any');
748 $strings[
'expected_value'] = $expected;
749 $strings[
'local_value'] = $dep[
'value'] ? $dep[
'value'] :
'--';
750 $strings[
'comment'] =
'';
754 $expected_priority = ucwords($info[
'priority']);
755 $real_priority = ucwords($dep[
'value']);
756 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:Priority');
757 $strings[
'expected_value'] = $translator->translate(
"ElggPlugin:Dependencies:Priority:$expected_priority", array($info[
'plugin']));
758 $strings[
'local_value'] = $translator->translate(
"ElggPlugin:Dependencies:Priority:$real_priority", array($info[
'plugin']));
759 $strings[
'comment'] =
'';
763 if ($dep[
'type'] ==
'suggests') {
764 if ($dep[
'status']) {
765 $strings[
'comment'] = $translator->translate(
'ok');
767 $strings[
'comment'] = $translator->translate(
'ElggPlugin:Dependencies:Suggests:Unsatisfied');
770 if ($dep[
'status']) {
771 $strings[
'comment'] = $translator->translate(
'ok');
773 $strings[
'comment'] = $translator->translate(
'error');
988 return $plugin->unsetAllSettings();
1019 if (!isset(
$options[
'plugin_id'])) {
1020 elgg_deprecated_notice(
"'plugin_id' is now required for elgg_get_entities_from_plugin_user_settings()", 1.9);
1024 $singulars = array(
'plugin_user_setting_name',
'plugin_user_setting_value',
1025 'plugin_user_setting_name_value_pair');
1031 'plugin_user_setting_names' =>
'private_setting_names',
1032 'plugin_user_setting_values' =>
'private_setting_values',
1033 'plugin_user_setting_name_value_pairs' =>
'private_setting_name_value_pairs',
1034 'plugin_user_setting_name_value_pairs_operator' =>
'private_setting_name_value_pairs_operator',
1037 foreach ($map as
$plugin => $private) {
1043 if (!is_array(
$options[$private])) {
1054 $options[
'private_setting_name_prefix'] = $prefix;
if(! $collection_name) $id
if($guid==elgg_get_logged_in_user_guid()) $name
$user_guid
Avatar remove action.
getDependencyStrings($dep)
Returns an array of parsed strings for a dependency in the format: array( 'type' => requires,...
__construct(\Elgg\EventsService $events, \Elgg\Cache\MemoryPool $pool)
Constructor.
setUserSetting($name, $value, $user_guid=0, $plugin_id=null)
Set a user specific setting for a plugin.
reindexPriorities()
Reindexes all plugin priorities starting at 1.
setSetting($name, $value, $plugin_id=null)
Set a setting for a plugin.
setPriorities(array $order)
Reorder plugins to an order specified by the array.
exists($id)
Returns if a plugin exists in the system.
getMaxPriority()
Returns the highest priority of the plugins.
find($status='active', $site_guid=null)
Returns an ordered list of plugins.
getProvides($type=null, $name=null)
Returns an array of all provides from all active plugins.
invalidateProvidesCache()
Deletes all cached data on plugins being provided.
isActive($plugin_id, $site_guid=null)
Returns if a plugin is active for a current site.
getDirsInDir($dir=null)
Returns a list of plugin directory names from a base directory.
unsetSetting($name, $plugin_id=null)
Unsets a plugin setting.
invalidateIsActiveCache()
Delete the cache holding whether plugins are active or not.
unsetUserSetting($name, $user_guid=0, $plugin_id=null)
Unsets a user-specific plugin setting.
load()
Loads all active plugins in the order specified in the tool admin panel.
generateEntities()
Discovers plugins in the plugins_path setting and creates \ElggPlugin entities for them if they don't...
getSetting($name, $plugin_id=null, $default=null)
Get setting for a plugin.
getAllUserSettings($user_guid=0, $plugin_id=null, $return_obj=false)
Returns an array of all plugin user settings for a user.
getEntitiesFromUserSettings(array $options=array())
Returns entities based upon plugin user settings.
unsetAllSettings($plugin_id=null)
Unsets all plugin settings for a plugin.
namespacePrivateSetting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
checkProvides($type, $name, $version=null, $comparison='ge')
Checks if a plugin is currently providing $type and $name, and optionally checking a version.
getUserSetting($name, $user_guid=0, $plugin_id=null, $default=null)
Get a user specific setting for a plugin.
cache(\ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
global $ELGG_PLUGINS_PROVIDES_CACHE
elgg_get_plugins_path()
Get the plugin path for this installation.
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
get_config($name, $site_guid=0)
Gets a 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_calling_plugin_entity()
Returns the \ElggPlugin entity of the last plugin called.
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
system_message($message)
Display a system message on next page load.
const ELGG_ENTITIES_NO_VALUE
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
access_get_show_hidden_status()
Return current status of showing disabled entities.
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
elgg_set_ignore_access($ignore=true)
Set if Elgg's access system should be ignored.
elgg_add_admin_notice($id, $message)
Write a persistent message to the admin view.
sanitize_string($string)
Sanitize a string for database use.
get_data($query, $callback="")
Retrieve rows from the database.
elgg_get_plugin_from_id($plugin_id)
Returns an \ElggPlugin object with the path $path.
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells \ElggPlugin::start() to automatically register the plugin's languages.
_elgg_get_plugin_dirs_in_dir($dir=null)
Returns a list of plugin directory names from a base directory.
const ELGG_PLUGIN_REGISTER_VIEWS
Tells \ElggPlugin::start() to automatically register the plugin's views.
const ELGG_PLUGIN_REGISTER_CLASSES
Tells \ElggPlugin::start() to automatically register the plugin's classes.
_elgg_set_plugin_priorities(array $order)
Reorder plugins to an order specified by the array.
elgg_get_plugins($status='active', $site_guid=null)
Returns an ordered list of plugins.
const ELGG_PLUGIN_INTERNAL_PREFIX
Internal settings prefix.
const ELGG_PLUGIN_INCLUDE_START
Tells \ElggPlugin::start() to include the start.php file.
const ELGG_PLUGIN_USER_SETTING_PREFIX
Prefix for plugin setting names.
_elgg_namespace_plugin_private_setting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
_elgg_get_plugins_provides($type=null, $name=null)
Returns an array of all provides from all active plugins.
_elgg_reindex_plugin_priorities()
Reindexes all plugin priorities starting at 1.
get_entity($guid)
Loads and returns an entity object from a guid.
get_subtype_id($type, $subtype)
Return the id for a given subtype.
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
elgg_in_context($context)
Check if this context exists anywhere in the stack.
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
elgg_get_entities_from_private_settings(array $options=array())
Returns entities based upon private settings.
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
elgg_get_site_entity($site_guid=0)
Get an \ElggSite entity (default is current site)
if(! $num_display) $db_prefix