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) {
139 if (array_key_exists($plugin_id, $id_map)) {
141 $plugin = $known_plugins[$index];
150 unset($known_plugins[$index]);
154 $plugin = new \ElggPlugin($mod_dir . $plugin_id);
162 foreach ($known_plugins as
$plugin) {
163 if ($plugin->isActive()) {
164 $plugin->deactivate();
169 if ($plugin->isEnabled()) {
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")) {
343 $id = $plugin->getID();
345 $plugin->start($start_flags);
346 $this->active_ids[
$id] =
true;
348 $plugin->deactivate();
349 $msg =
_elgg_services()->translator->translate(
'PluginException:CannotStart',
350 array(
$id, $plugin->guid, $e->getMessage()));
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);
552 if (!isset($ELGG_PLUGINS_PROVIDES_CACHE)) {
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()
573 $ELGG_PLUGINS_PROVIDES_CACHE = $provides;
577 if (isset($ELGG_PLUGINS_PROVIDES_CACHE[
$type][
$name])) {
578 return $ELGG_PLUGINS_PROVIDES_CACHE[
$type][
$name];
583 if (isset($ELGG_PLUGINS_PROVIDES_CACHE[
$type])) {
584 return $ELGG_PLUGINS_PROVIDES_CACHE[
$type];
601 $ELGG_PLUGINS_PROVIDES_CACHE = null;
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;
_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_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.
__construct(\Elgg\EventsService $events,\Elgg\Cache\MemoryPool $pool)
Constructor.
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.
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
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)
Sanitize a string for database use.
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.
_elgg_namespace_plugin_private_setting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
invalidateIsActiveCache()
Delete the cache holding whether plugins are active or not.
const ELGG_PLUGIN_USER_SETTING_PREFIX
Prefix for plugin setting names.
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
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...
global $ELGG_PLUGINS_PROVIDES_CACHE
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...
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.
elgg global
Pointer to the global context.
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.
access_get_show_hidden_status()
Return current status of showing disabled entities.
elgg system_message
Wrapper function for system_messages.
get_data($query, $callback="")
Retrieve rows from the database.
elgg_get_plugins($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
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_reindex_plugin_priorities()
Reindexes all plugin priorities starting at 1.
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.
_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.
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.
if(!$num_display) $db_prefix
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
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.