39 $plugin_dirs = array();
40 $handle = opendir($dir);
43 while ($plugin_dir = readdir($handle)) {
45 if (substr($plugin_dir, 0, 1) !==
'.' && is_dir($dir . $plugin_dir)) {
46 $plugin_dirs[] = $plugin_dir;
79 'subtype' =>
'plugin',
80 'selects' => array(
'plugin_oe.*'),
81 'joins' => array(
"JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"),
87 if (!$known_plugins) {
88 $known_plugins = array();
93 foreach ($known_plugins as $i =>
$plugin) {
98 unset($known_plugins[$i]);
101 $id_map[
$plugin->getID()] = $i;
106 if (!$physical_plugins) {
113 if (array_key_exists($plugin_id, $id_map)) {
115 $plugin = $known_plugins[$index];
124 unset($known_plugins[$index]);
128 $plugin = new \ElggPlugin($mod_dir . $plugin_id);
136 foreach ($known_plugins as
$plugin) {
137 if ($plugin->isActive()) {
138 $plugin->deactivate();
143 if ($plugin->isEnabled()) {
186 'subtype' =>
'plugin',
187 'joins' => array(
"JOIN {$db_prefix}objects_entity oe on oe.guid = e.guid"),
188 'selects' => array(
"oe.title",
"oe.description"),
189 'wheres' => array(
"oe.title = '$plugin_id'"),
216 return (
$plugin) ?
true :
false;
230 $q =
"SELECT MAX(CAST(ps.value AS unsigned)) as max 231 FROM {$db_prefix}entities e, {$db_prefix}private_settings ps 232 WHERE ps.name = '$priority' 233 AND ps.entity_guid = e.guid 234 AND e.type = 'object' and e.subtype = $plugin_subtype";
238 $max =
$data[0]->max;
244 return ($max) ? $max : 1;
291 if (!$plugins_path) {
296 if (file_exists(
"$plugins_path/disabled")) {
316 $plugin->start($start_flags);
318 $plugin->deactivate();
319 $msg =
_elgg_services()->translator->translate(
'PluginException:CannotStart',
320 array($plugin->getID(), $plugin->guid, $e->getMessage()));
339 function find($status =
'active', $site_guid = null) {
345 $site_guid =
$site->guid;
351 'subtype' =>
'plugin',
353 'selects' => array(
'plugin_oe.*'),
355 "JOIN {$db_prefix}private_settings ps on ps.entity_guid = e.guid",
356 "JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid" 358 'wheres' => array(
"ps.name = '$priority'"),
359 'order_by' =>
"CAST(ps.value as unsigned), e.guid",
365 $options[
'relationship'] =
'active_plugin';
366 $options[
'relationship_guid'] = $site_guid;
367 $options[
'inverse_relationship'] =
true;
371 $options[
'wheres'][] =
"NOT EXISTS ( 372 SELECT 1 FROM {$db_prefix}entity_relationships active_er 373 WHERE active_er.guid_one = e.guid 374 AND active_er.relationship = 'active_plugin' 375 AND active_er.guid_two = $site_guid)";
414 $order = array_values($order);
416 $missing_plugins = array();
436 if (
$return && $missing_plugins) {
440 foreach ($missing_plugins as $plugin) {
486 elgg_deprecated_notice(
"You must pass the plugin id to _elgg_namespace_plugin_private_setting() for user settings", 1.9);
521 if (!isset($ELGG_PLUGINS_PROVIDES_CACHE)) {
526 foreach ($active_plugins as
$plugin) {
527 $plugin_provides = array();
528 $manifest = $plugin->getManifest();
530 $plugin_provides = $plugin->getManifest()->getProvides();
532 if ($plugin_provides) {
533 foreach ($plugin_provides as $provided) {
534 $provides[$provided[
'type']][$provided[
'name']] = array(
535 'version' => $provided[
'version'],
536 'provided_by' => $plugin->getID()
542 $ELGG_PLUGINS_PROVIDES_CACHE = $provides;
546 if (isset($ELGG_PLUGINS_PROVIDES_CACHE[
$type][
$name])) {
547 return $ELGG_PLUGINS_PROVIDES_CACHE[
$type][
$name];
552 if (isset($ELGG_PLUGINS_PROVIDES_CACHE[
$type])) {
553 return $ELGG_PLUGINS_PROVIDES_CACHE[
$type];
570 $ELGG_PLUGINS_PROVIDES_CACHE = null;
599 $status = version_compare($provided[
'version'],
$version, $comparison);
606 'value' => $provided[
'version']
630 if (!$dep_system || !$info || !
$type) {
636 switch($comparison) {
663 $strings[
'type'] = $translator->translate(
'ElggPlugin:Dependencies:' . ucwords($dep_system));
669 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:Elgg');
670 $strings[
'expected_value'] =
"$comparison {$info['version']}";
671 $strings[
'local_value'] = $dep[
'value'];
672 $strings[
'comment'] =
'';
677 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:PhpVersion');
678 $strings[
'expected_value'] =
"$comparison {$info['version']}";
679 $strings[
'local_value'] = $dep[
'value'];
680 $strings[
'comment'] =
'';
683 case 'php_extension':
685 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:PhpExtension', array($info[
'name']));
686 if ($info[
'version']) {
687 $strings[
'expected_value'] =
"$comparison {$info['version']}";
688 $strings[
'local_value'] = $dep[
'value'];
690 $strings[
'expected_value'] =
'';
691 $strings[
'local_value'] =
'';
693 $strings[
'comment'] =
'';
697 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:PhpIni', array($info[
'name']));
698 $strings[
'expected_value'] =
"$comparison {$info['value']}";
699 $strings[
'local_value'] = $dep[
'value'];
700 $strings[
'comment'] =
'';
704 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:Plugin', array($info[
'name']));
705 $expected = $info[
'version'] ?
"$comparison {$info['version']}" : $translator->translate(
'any');
706 $strings[
'expected_value'] = $expected;
707 $strings[
'local_value'] = $dep[
'value'] ? $dep[
'value'] :
'--';
708 $strings[
'comment'] =
'';
712 $expected_priority = ucwords($info[
'priority']);
713 $real_priority = ucwords($dep[
'value']);
714 $strings[
'name'] = $translator->translate(
'ElggPlugin:Dependencies:Priority');
715 $strings[
'expected_value'] = $translator->translate(
"ElggPlugin:Dependencies:Priority:$expected_priority", array($info[
'plugin']));
716 $strings[
'local_value'] = $translator->translate(
"ElggPlugin:Dependencies:Priority:$real_priority", array($info[
'plugin']));
717 $strings[
'comment'] =
'';
721 if ($dep[
'type'] ==
'suggests') {
722 if ($dep[
'status']) {
723 $strings[
'comment'] = $translator->translate(
'ok');
725 $strings[
'comment'] = $translator->translate(
'ElggPlugin:Dependencies:Suggests:Unsatisfied');
728 if ($dep[
'status']) {
729 $strings[
'comment'] = $translator->translate(
'ok');
731 $strings[
'comment'] = $translator->translate(
'error');
946 return $plugin->unsetAllSettings();
977 if (!isset(
$options[
'plugin_id'])) {
978 elgg_deprecated_notice(
"'plugin_id' is now required for elgg_get_entities_from_plugin_user_settings()", 1.9);
982 $singulars = array(
'plugin_user_setting_name',
'plugin_user_setting_value',
983 'plugin_user_setting_name_value_pair');
989 'plugin_user_setting_names' =>
'private_setting_names',
990 'plugin_user_setting_values' =>
'private_setting_values',
991 'plugin_user_setting_name_value_pairs' =>
'private_setting_name_value_pairs',
992 'plugin_user_setting_name_value_pairs_operator' =>
'private_setting_name_value_pairs_operator',
995 foreach ($map as
$plugin => $private) {
1001 if (!is_array(
$options[$private])) {
1012 $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.
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.
if(!$autoload_available) _elgg_services()
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.
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.
elgg_set_config($name, $value)
Set an Elgg configuration value.
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)
Sends 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.