Elgg  Version 1.10
Plugins.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Database;
3 
4 use Exception;
5 
11 
12 
24 class Plugins {
34  function getDirsInDir($dir = null) {
35  if (!$dir) {
36  $dir = elgg_get_plugins_path();
37  }
38 
39  $plugin_dirs = array();
40  $handle = opendir($dir);
41 
42  if ($handle) {
43  while ($plugin_dir = readdir($handle)) {
44  // must be directory and not begin with a .
45  if (substr($plugin_dir, 0, 1) !== '.' && is_dir($dir . $plugin_dir)) {
46  $plugin_dirs[] = $plugin_dir;
47  }
48  }
49  }
50 
51  sort($plugin_dirs);
52 
53  return $plugin_dirs;
54  }
55 
65  function generateEntities() {
66 
67  $mod_dir = elgg_get_plugins_path();
68  $db_prefix = elgg_get_config('dbprefix');
69 
70  // ignore access in case this is called with no admin logged in - needed for creating plugins perhaps?
71  $old_ia = elgg_set_ignore_access(true);
72 
73  // show hidden entities so that we can enable them if appropriate
74  $old_access = access_get_show_hidden_status();
76 
77  $options = array(
78  'type' => 'object',
79  'subtype' => 'plugin',
80  'selects' => array('plugin_oe.*'),
81  'joins' => array("JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"),
82  'limit' => ELGG_ENTITIES_NO_VALUE,
83  );
85  /* @var \ElggPlugin[] $known_plugins */
86 
87  if (!$known_plugins) {
88  $known_plugins = array();
89  }
90 
91  // map paths to indexes
92  $id_map = array();
93  foreach ($known_plugins as $i => $plugin) {
94  // if the ID is wrong, delete the plugin because we can never load it.
95  $id = $plugin->getID();
96  if (!$id) {
97  $plugin->delete();
98  unset($known_plugins[$i]);
99  continue;
100  }
101  $id_map[$plugin->getID()] = $i;
102  }
103 
104  $physical_plugins = _elgg_get_plugin_dirs_in_dir($mod_dir);
105 
106  if (!$physical_plugins) {
107  return false;
108  }
109 
110  // check real plugins against known ones
111  foreach ($physical_plugins as $plugin_id) {
112  // is this already in the db?
113  if (array_key_exists($plugin_id, $id_map)) {
114  $index = $id_map[$plugin_id];
115  $plugin = $known_plugins[$index];
116  // was this plugin deleted and its entity disabled?
117  if (!$plugin->isEnabled()) {
118  $plugin->enable();
119  $plugin->deactivate();
120  $plugin->setPriority('last');
121  }
122 
123  // remove from the list of plugins to disable
124  unset($known_plugins[$index]);
125  } else {
126  // create new plugin
127  // priority is forced to last in save() if not set.
128  $plugin = new \ElggPlugin($mod_dir . $plugin_id);
129  $plugin->save();
130  }
131  }
132 
133  // everything remaining in $known_plugins needs to be disabled
134  // because they are entities, but their dirs were removed.
135  // don't delete the entities because they hold settings.
136  foreach ($known_plugins as $plugin) {
137  if ($plugin->isActive()) {
138  $plugin->deactivate();
139  }
140  // remove the priority.
141  $name = _elgg_namespace_plugin_private_setting('internal', 'priority');
142  remove_private_setting($plugin->guid, $name);
143  if ($plugin->isEnabled()) {
144  $plugin->disable();
145  }
146  }
147 
148  access_show_hidden_entities($old_access);
149  elgg_set_ignore_access($old_ia);
150 
152 
153  return true;
154  }
155 
163  function cache(\ElggPlugin $plugin) {
164  $map = (array) elgg_get_config('plugins_by_id_map');
165  $map[$plugin->getID()] = $plugin;
166  elgg_set_config('plugins_by_id_map', $map);
167  }
168 
175  function get($plugin_id) {
176  $map = (array) elgg_get_config('plugins_by_id_map');
177  if (isset($map[$plugin_id])) {
178  return $map[$plugin_id];
179  }
180 
181  $plugin_id = sanitize_string($plugin_id);
182  $db_prefix = get_config('dbprefix');
183 
184  $options = array(
185  'type' => 'object',
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'"),
190  'limit' => 1,
191  'distinct' => false,
192  );
193 
195 
196  if ($plugins) {
197  return $plugins[0];
198  }
199 
200  return null;
201  }
202 
213  function exists($id) {
215 
216  return ($plugin) ? true : false;
217  }
218 
225  function getMaxPriority() {
226  $db_prefix = get_config('dbprefix');
227  $priority = _elgg_namespace_plugin_private_setting('internal', 'priority');
228  $plugin_subtype = get_subtype_id('object', 'plugin');
229 
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";
235 
236  $data = get_data($q);
237  if ($data) {
238  $max = $data[0]->max;
239  } else {
240  $max = 1;
241  }
242 
243  // can't have a priority of 0.
244  return ($max) ? $max : 1;
245  }
246 
254  function isActive($plugin_id, $site_guid = null) {
255  if ($site_guid) {
256  $site = get_entity($site_guid);
257  } else {
259  }
260 
261  if (!($site instanceof \ElggSite)) {
262  return false;
263  }
264 
266 
267  if (!$plugin) {
268  return false;
269  }
270 
271  return $plugin->isActive($site->guid);
272  }
273 
284  function load() {
285  $plugins_path = elgg_get_plugins_path();
286  $start_flags = ELGG_PLUGIN_INCLUDE_START |
290 
291  if (!$plugins_path) {
292  return false;
293  }
294 
295  // temporary disable all plugins if there is a file called 'disabled' in the plugin dir
296  if (file_exists("$plugins_path/disabled")) {
297  if (elgg_is_admin_logged_in() && elgg_in_context('admin')) {
298  system_message(_elgg_services()->translator->translate('plugins:disabled'));
299  }
300  return false;
301  }
302 
303  if (elgg_get_config('system_cache_loaded')) {
304  $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_VIEWS;
305  }
306 
307  if (elgg_get_config('i18n_loaded_from_cache')) {
308  $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_LANGUAGES;
309  }
310 
311  $return = true;
312  $plugins = elgg_get_plugins('active');
313  if ($plugins) {
314  foreach ($plugins as $plugin) {
315  try {
316  $plugin->start($start_flags);
317  } catch (Exception $e) {
318  $plugin->deactivate();
319  $msg = _elgg_services()->translator->translate('PluginException:CannotStart',
320  array($plugin->getID(), $plugin->guid, $e->getMessage()));
321  elgg_add_admin_notice('cannot_start' . $plugin->getID(), $msg);
322  $return = false;
323 
324  continue;
325  }
326  }
327  }
328 
329  return $return;
330  }
331 
339  function find($status = 'active', $site_guid = null) {
340  $db_prefix = get_config('dbprefix');
341  $priority = _elgg_namespace_plugin_private_setting('internal', 'priority');
342 
343  if (!$site_guid) {
344  $site = get_config('site');
345  $site_guid = $site->guid;
346  }
347 
348  // grab plugins
349  $options = array(
350  'type' => 'object',
351  'subtype' => 'plugin',
352  'limit' => ELGG_ENTITIES_NO_VALUE,
353  'selects' => array('plugin_oe.*'),
354  'joins' => array(
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"
357  ),
358  'wheres' => array("ps.name = '$priority'"),
359  'order_by' => "CAST(ps.value as unsigned), e.guid",
360  'distinct' => false,
361  );
362 
363  switch ($status) {
364  case 'active':
365  $options['relationship'] = 'active_plugin';
366  $options['relationship_guid'] = $site_guid;
367  $options['inverse_relationship'] = true;
368  break;
369 
370  case 'inactive':
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)";
376  break;
377 
378  case 'all':
379  default:
380  break;
381  }
382 
383  $old_ia = elgg_set_ignore_access(true);
385  elgg_set_ignore_access($old_ia);
386 
387  return $plugins;
388  }
389 
402  function setPriorities(array $order) {
403  $name = _elgg_namespace_plugin_private_setting('internal', 'priority');
404 
405  $plugins = elgg_get_plugins('any');
406  if (!$plugins) {
407  return false;
408  }
409 
410  $return = true;
411 
412  // reindex to get standard counting. no need to increment by 10.
413  // though we do start with 1
414  $order = array_values($order);
415 
416  $missing_plugins = array();
417  /* @var \ElggPlugin[] $missing_plugins */
418 
419  foreach ($plugins as $plugin) {
420  $plugin_id = $plugin->getID();
421 
422  if (!in_array($plugin_id, $order)) {
423  $missing_plugins[] = $plugin;
424  continue;
425  }
426 
427  $priority = array_search($plugin_id, $order) + 1;
428 
429  if (!$plugin->setPrivateSetting($name, $priority)) {
430  $return = false;
431  break;
432  }
433  }
434 
435  // set the missing plugins' priorities
436  if ($return && $missing_plugins) {
437  if (!isset($priority)) {
438  $priority = 0;
439  }
440  foreach ($missing_plugins as $plugin) {
441  $priority++;
442  if (!$plugin->setPrivateSetting($name, $priority)) {
443  $return = false;
444  break;
445  }
446  }
447  }
448 
449  return $return;
450  }
451 
459  function reindexPriorities() {
460  return _elgg_set_plugin_priorities(array());
461  }
462 
477  function namespacePrivateSetting($type, $name, $id = null) {
478  switch ($type) {
479  // commented out because it breaks $plugin->$name access to variables
480  //case 'setting':
481  // $name = ELGG_PLUGIN_SETTING_PREFIX . $name;
482  // break;
483 
484  case 'user_setting':
485  if (!$id) {
486  elgg_deprecated_notice("You must pass the plugin id to _elgg_namespace_plugin_private_setting() for user settings", 1.9);
488  }
489  $name = ELGG_PLUGIN_USER_SETTING_PREFIX . "$id:$name";
490  break;
491 
492  case 'internal':
494  break;
495  }
496 
497  return $name;
498  }
499 
500 
519  function getProvides($type = null, $name = null) {
521  if (!isset($ELGG_PLUGINS_PROVIDES_CACHE)) {
522  $active_plugins = elgg_get_plugins('active');
523 
524  $provides = array();
525 
526  foreach ($active_plugins as $plugin) {
527  $plugin_provides = array();
528  $manifest = $plugin->getManifest();
529  if ($manifest instanceof \ElggPluginManifest) {
530  $plugin_provides = $plugin->getManifest()->getProvides();
531  }
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()
537  );
538  }
539  }
540  }
541 
542  $ELGG_PLUGINS_PROVIDES_CACHE = $provides;
543  }
544 
545  if ($type && $name) {
546  if (isset($ELGG_PLUGINS_PROVIDES_CACHE[$type][$name])) {
547  return $ELGG_PLUGINS_PROVIDES_CACHE[$type][$name];
548  } else {
549  return false;
550  }
551  } elseif ($type) {
552  if (isset($ELGG_PLUGINS_PROVIDES_CACHE[$type])) {
553  return $ELGG_PLUGINS_PROVIDES_CACHE[$type];
554  } else {
555  return false;
556  }
557  }
558 
560  }
561 
570  $ELGG_PLUGINS_PROVIDES_CACHE = null;
571  return true;
572  }
573 
589  function checkProvides($type, $name, $version = null, $comparison = 'ge') {
590  $provided = _elgg_get_plugins_provides($type, $name);
591  if (!$provided) {
592  return array(
593  'status' => false,
594  'value' => ''
595  );
596  }
597 
598  if ($version) {
599  $status = version_compare($provided['version'], $version, $comparison);
600  } else {
601  $status = true;
602  }
603 
604  return array(
605  'status' => $status,
606  'value' => $provided['version']
607  );
608  }
609 
624  function getDependencyStrings($dep) {
625  $translator = _elgg_services()->translator;
626  $dep_system = elgg_extract('type', $dep);
627  $info = elgg_extract('dep', $dep);
628  $type = elgg_extract('type', $info);
629 
630  if (!$dep_system || !$info || !$type) {
631  return false;
632  }
633 
634  // rewrite some of these to be more readable
635  $comparison = elgg_extract('comparison', $info);
636  switch($comparison) {
637  case 'lt':
638  $comparison = '<';
639  break;
640  case 'gt':
641  $comparison = '>';
642  break;
643  case 'ge':
644  $comparison = '>=';
645  break;
646  case 'le':
647  $comparison = '<=';
648  break;
649  default:
650  //keep $comparison value intact
651  break;
652  }
653 
654  /*
655  'requires' 'plugin oauth_lib' <1.3 1.3 'downgrade'
656  'requires' 'php setting bob' >3 3 'change it'
657  'conflicts' 'php setting' >3 4 'change it'
658  'conflicted''plugin profile' any 1.8 'disable profile'
659  'provides' 'plugin oauth_lib' 1.3 -- --
660  'priority' 'before blog' -- after 'move it'
661  */
662  $strings = array();
663  $strings['type'] = $translator->translate('ElggPlugin:Dependencies:' . ucwords($dep_system));
664 
665  switch ($type) {
666  case 'elgg_version':
667  case 'elgg_release':
668  // 'Elgg Version'
669  $strings['name'] = $translator->translate('ElggPlugin:Dependencies:Elgg');
670  $strings['expected_value'] = "$comparison {$info['version']}";
671  $strings['local_value'] = $dep['value'];
672  $strings['comment'] = '';
673  break;
674 
675  case 'php_version':
676  // 'PHP version'
677  $strings['name'] = $translator->translate('ElggPlugin:Dependencies:PhpVersion');
678  $strings['expected_value'] = "$comparison {$info['version']}";
679  $strings['local_value'] = $dep['value'];
680  $strings['comment'] = '';
681  break;
682 
683  case 'php_extension':
684  // PHP Extension %s [version]
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'];
689  } else {
690  $strings['expected_value'] = '';
691  $strings['local_value'] = '';
692  }
693  $strings['comment'] = '';
694  break;
695 
696  case 'php_ini':
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'] = '';
701  break;
702 
703  case 'plugin':
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'] = '';
709  break;
710 
711  case 'priority':
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'] = '';
718  break;
719  }
720 
721  if ($dep['type'] == 'suggests') {
722  if ($dep['status']) {
723  $strings['comment'] = $translator->translate('ok');
724  } else {
725  $strings['comment'] = $translator->translate('ElggPlugin:Dependencies:Suggests:Unsatisfied');
726  }
727  } else {
728  if ($dep['status']) {
729  $strings['comment'] = $translator->translate('ok');
730  } else {
731  $strings['comment'] = $translator->translate('error');
732  }
733  }
734 
735  return $strings;
736  }
737 
748  function getAllUserSettings($user_guid = 0, $plugin_id = null, $return_obj = false) {
749  if ($plugin_id) {
751  } else {
752  elgg_deprecated_notice('elgg_get_all_plugin_user_settings() requires plugin_id to be set', 1.9);
754  }
755 
756  if (!$plugin instanceof \ElggPlugin) {
757  return false;
758  }
759 
760  $settings = $plugin->getAllUserSettings((int)$user_guid);
761 
762  if ($settings && $return_obj) {
763  $return = new \stdClass;
764 
765  foreach ($settings as $k => $v) {
766  $return->$k = $v;
767  }
768 
769  return $return;
770  } else {
771  return $settings;
772  }
773  }
774 
786  function setUserSetting($name, $value, $user_guid = 0, $plugin_id = null) {
787  if ($plugin_id) {
789  } else {
790  elgg_deprecated_notice('elgg_set_plugin_user_setting() requires plugin_id to be set', 1.9);
792  }
793 
794  if (!$plugin) {
795  return false;
796  }
797 
798  return $plugin->setUserSetting($name, $value, (int)$user_guid);
799  }
800 
811  function unsetUserSetting($name, $user_guid = 0, $plugin_id = null) {
812  if ($plugin_id) {
814  } else {
815  elgg_deprecated_notice('elgg_unset_plugin_user_setting() requires plugin_id to be set', 1.9);
817  }
818 
819  if (!$plugin) {
820  return false;
821  }
822 
823  return $plugin->unsetUserSetting($name, (int)$user_guid);
824  }
825 
837  function getUserSetting($name, $user_guid = 0, $plugin_id = null, $default = null) {
838  if ($plugin_id) {
840  } else {
841  elgg_deprecated_notice('elgg_get_plugin_user_setting() requires plugin_id to be set', 1.9);
843  }
844 
845  if (!$plugin) {
846  return false;
847  }
848 
849  return $plugin->getUserSetting($name, (int)$user_guid, $default);
850  }
851 
862  function setSetting($name, $value, $plugin_id = null) {
863  if ($plugin_id) {
865  } else {
866  elgg_deprecated_notice('elgg_set_plugin_setting() requires plugin_id to be set', 1.9);
868  }
869 
870  if (!$plugin) {
871  return false;
872  }
873 
874  return $plugin->setSetting($name, $value);
875  }
876 
887  function getSetting($name, $plugin_id = null, $default = null) {
888  if ($plugin_id) {
890  } else {
891  elgg_deprecated_notice('elgg_get_plugin_setting() requires plugin_id to be set', 1.9);
893  }
894 
895  if (!$plugin) {
896  return false;
897  }
898 
899  return $plugin->getSetting($name, $default);
900  }
901 
911  function unsetSetting($name, $plugin_id = null) {
912  if ($plugin_id) {
914  } else {
915  elgg_deprecated_notice('elgg_unset_plugin_setting() requires plugin_id to be set', 1.9);
917  }
918 
919  if (!$plugin) {
920  return false;
921  }
922 
923  return $plugin->unsetSetting($name);
924  }
925 
934  function unsetAllSettings($plugin_id = null) {
935  if ($plugin_id) {
937  } else {
938  elgg_deprecated_notice('elgg_unset_all_plugin_settings() requires plugin_id to be set', 1.9);
940  }
941 
942  if (!$plugin) {
943  return false;
944  }
945 
946  return $plugin->unsetAllSettings();
947  }
948 
976  function getEntitiesFromUserSettings(array $options = array()) {
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);
979  $options['plugin_id'] = elgg_get_calling_plugin_id();
980  }
981 
982  $singulars = array('plugin_user_setting_name', 'plugin_user_setting_value',
983  'plugin_user_setting_name_value_pair');
984 
986 
987  // rewrite plugin_user_setting_name_* to the right PS ones.
988  $map = array(
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',
993  );
994 
995  foreach ($map as $plugin => $private) {
996  if (!isset($options[$plugin])) {
997  continue;
998  }
999 
1000  if (isset($options[$private])) {
1001  if (!is_array($options[$private])) {
1002  $options[$private] = array($options[$private]);
1003  }
1004 
1005  $options[$private] = array_merge($options[$private], $options[$plugin]);
1006  } else {
1007  $options[$private] = $options[$plugin];
1008  }
1009  }
1010 
1011  $prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $options['plugin_id']);
1012  $options['private_setting_name_prefix'] = $prefix;
1013 
1015  }
1016 }
_elgg_get_plugins_provides($type=null, $name=null)
Returns an array of all provides from all active plugins.
Definition: plugins.php:233
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)
Definition: sites.php:18
getID()
Returns the ID (dir name) of this plugin.
Definition: ElggPlugin.php:120
$plugin
reindexPriorities()
Reindexes all plugin priorities starting at 1.
Definition: Plugins.php:459
getSetting($name, $plugin_id=null, $default=null)
Get setting for a plugin.
Definition: Plugins.php:887
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:60
getMaxPriority()
Returns the highest priority of the plugins.
Definition: Plugins.php:225
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
$e
Definition: metadata.php:12
get_subtype_id($type, $subtype)
Return the id for a given subtype.
Definition: entities.php:157
const ELGG_ENTITIES_NO_VALUE
Definition: elgglib.php:2068
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.
Definition: admin.php:77
$data
Definition: opendd.php:13
$value
Definition: longtext.php:29
if(!$autoload_available) _elgg_services()
Definition: autoloader.php:20
$return
Definition: opendd.php:15
$default
Definition: checkbox.php:36
getDependencyStrings($dep)
Returns an array of parsed strings for a dependency in the format: array( &#39;type&#39; => requires...
Definition: Plugins.php:624
getEntitiesFromUserSettings(array $options=array())
Returns entities based upon plugin user settings.
Definition: Plugins.php:976
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells ::start() to automatically register the plugin&#39;s languages.
Definition: plugins.php:23
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1349
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.
Definition: Plugins.php:34
sanitize_string($string)
Sanitize a string for database use.
Definition: database.php:140
unsetSetting($name, $plugin_id=null)
Unsets a plugin setting.
Definition: Plugins.php:911
$options
Definition: index.php:14
getAllUserSettings($user_guid=0, $plugin_id=null, $return_obj=false)
Returns an array of all plugin user settings for a user.
Definition: Plugins.php:748
_elgg_namespace_plugin_private_setting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
Definition: plugins.php:210
$plugins
const ELGG_PLUGIN_USER_SETTING_PREFIX
Prefix for plugin setting names.
Definition: plugins.php:41
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.
Definition: Plugins.php:862
elgg_set_ignore_access($ignore=true)
Set if Elgg&#39;s access system should be ignored.
Definition: access.php:43
elgg_set_config($name, $value)
Set an Elgg configuration value.
$plugin_id
Definition: save.php:16
generateEntities()
Discovers plugins in the plugins_path setting and creates entities for them if they don&#39;t exist...
Definition: Plugins.php:65
global $ELGG_PLUGINS_PROVIDES_CACHE
Definition: Plugins.php:10
find($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
Definition: Plugins.php:339
const ELGG_PLUGIN_INCLUDE_START
Tells ::start() to include the start.php file.
Definition: plugins.php:13
elgg_in_context($context)
Check if this context exists anywhere in the stack.
Definition: pageowner.php:250
const ELGG_PLUGIN_REGISTER_VIEWS
Tells ::start() to automatically register the plugin&#39;s views.
Definition: plugins.php:18
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
Definition: entities.php:490
checkProvides($type, $name, $version=null, $comparison= 'ge')
Checks if a plugin is currently providing $type and $name, and optionally checking a version...
Definition: Plugins.php:589
const ELGG_PLUGIN_INTERNAL_PREFIX
Internal settings prefix.
Definition: plugins.php:48
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1055
elgg global
Pointer to the global context.
Definition: elgglib.js:12
$type
Definition: add.php:8
isActive($plugin_id, $site_guid=null)
Returns if a plugin is active for a current site.
Definition: Plugins.php:254
unsetAllSettings($plugin_id=null)
Unsets all plugin settings for a plugin.
Definition: Plugins.php:934
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:170
elgg system_message
Wrapper function for system_messages.
Definition: elgglib.js:374
get_data($query, $callback="")
Retrieve rows from the database.
Definition: database.php:50
elgg_get_plugins($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
Definition: plugins.php:162
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
Definition: access.php:157
_elgg_set_plugin_priorities(array $order)
Reorder plugins to an order specified by the array.
Definition: plugins.php:179
_elgg_reindex_plugin_priorities()
Reindexes all plugin priorities starting at 1.
Definition: plugins.php:191
namespacePrivateSetting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
Definition: Plugins.php:477
setPriorities(array $order)
Reorder plugins to an order specified by the array.
Definition: Plugins.php:402
setUserSetting($name, $value, $user_guid=0, $plugin_id=null)
Set a user specific setting for a plugin.
Definition: Plugins.php:786
load()
Loads all active plugins in the order specified in the tool admin panel.
Definition: Plugins.php:284
getProvides($type=null, $name=null)
Returns an array of all provides from all active plugins.
Definition: Plugins.php:519
const ELGG_PLUGIN_REGISTER_CLASSES
Tells ::start() to automatically register the plugin&#39;s classes.
Definition: plugins.php:28
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.
Definition: elgglib.php:1479
_elgg_get_plugin_dirs_in_dir($dir=null)
Returns a list of plugin directory names from a base directory.
Definition: plugins.php:61
$user_guid
Avatar remove action.
Definition: remove.php:6
cache(\ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
Definition: Plugins.php:163
getUserSetting($name, $user_guid=0, $plugin_id=null, $default=null)
Get a user specific setting for a plugin.
Definition: Plugins.php:837
if(!$collection_name) $id
Definition: add.php:17
$settings
$version
Definition: version.php:14
exists($id)
Returns if a plugin exists in the system.
Definition: Plugins.php:213
if(!$num_display) $db_prefix
Definition: content.php:12
$priority
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:97
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:382
invalidateProvidesCache()
Deletes all cached data on plugins being provided.
Definition: Plugins.php:568
unsetUserSetting($name, $user_guid=0, $plugin_id=null)
Unsets a user-specific plugin setting.
Definition: Plugins.php:811