Elgg  Version 2.3
Plugins.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Database;
3 
8 
18 class Plugins {
20 
24  private $boot_plugins = [];
25 
29  private $provides_cache;
30 
34  private $active_guids = array();
35 
39  private $active_guids_known = false;
40 
44  private $plugins_by_id;
45 
49  private $settings_cache;
50 
57  public function __construct(Pool $pool, PluginSettingsCache $cache) {
58  $this->plugins_by_id = $pool;
59  $this->settings_cache = $cache;
60  }
61 
68  public function setBootPlugins(array $plugins) {
69  $this->boot_plugins = $plugins;
70  foreach ($plugins as $plugin) {
71  $this->plugins_by_id->put($plugin->getID(), $plugin);
72  }
73  }
74 
84  function getDirsInDir($dir = null) {
85  if (!$dir) {
86  $dir = elgg_get_plugins_path();
87  }
88 
89  $plugin_dirs = array();
90  $handle = opendir($dir);
91 
92  if ($handle) {
93  while ($plugin_dir = readdir($handle)) {
94  // must be directory and not begin with a .
95  if (substr($plugin_dir, 0, 1) !== '.' && is_dir($dir . $plugin_dir)) {
96  $plugin_dirs[] = $plugin_dir;
97  }
98  }
99  }
100 
101  sort($plugin_dirs);
102 
103  return $plugin_dirs;
104  }
105 
115  function generateEntities() {
116 
117  $mod_dir = elgg_get_plugins_path();
118  $db_prefix = elgg_get_config('dbprefix');
119 
120  // ignore access in case this is called with no admin logged in - needed for creating plugins perhaps?
121  $old_ia = elgg_set_ignore_access(true);
122 
123  // show hidden entities so that we can enable them if appropriate
124  $old_access = access_get_show_hidden_status();
126 
127  $options = array(
128  'type' => 'object',
129  'subtype' => 'plugin',
130  'selects' => array('plugin_oe.*'),
131  'joins' => array("JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"),
132  'limit' => ELGG_ENTITIES_NO_VALUE,
133  );
135  /* @var \ElggPlugin[] $known_plugins */
136 
137  if (!$known_plugins) {
138  $known_plugins = array();
139  }
140 
141  // map paths to indexes
142  $id_map = array();
143  foreach ($known_plugins as $i => $plugin) {
144  // if the ID is wrong, delete the plugin because we can never load it.
145  $id = $plugin->getID();
146  if (!$id) {
147  $plugin->delete();
148  unset($known_plugins[$i]);
149  continue;
150  }
151  $id_map[$plugin->getID()] = $i;
152  }
153 
154  $physical_plugins = $this->getDirsInDir($mod_dir);
155 
156  if (!$physical_plugins) {
157  return false;
158  }
159 
160  // check real plugins against known ones
161  foreach ($physical_plugins as $plugin_id) {
162  // is this already in the db?
163  if (array_key_exists($plugin_id, $id_map)) {
164  $index = $id_map[$plugin_id];
165  $plugin = $known_plugins[$index];
166  // was this plugin deleted and its entity disabled?
167  if (!$plugin->isEnabled()) {
168  $plugin->enable();
169  $plugin->deactivate();
170  $plugin->setPriority('last');
171  }
172 
173  // remove from the list of plugins to disable
174  unset($known_plugins[$index]);
175  } else {
176  // create new plugin
177  // priority is forced to last in save() if not set.
178  $plugin = new \ElggPlugin($mod_dir . $plugin_id);
179  $plugin->save();
180  }
181  }
182 
183  // everything remaining in $known_plugins needs to be disabled
184  // because they are entities, but their dirs were removed.
185  // don't delete the entities because they hold settings.
186  foreach ($known_plugins as $plugin) {
187  if ($plugin->isActive()) {
188  $plugin->deactivate();
189  }
190  // remove the priority.
191  $name = $this->namespacePrivateSetting('internal', 'priority');
192  remove_private_setting($plugin->guid, $name);
193  if ($plugin->isEnabled()) {
194  $plugin->disable();
195  }
196  }
197 
198  access_show_hidden_entities($old_access);
199  elgg_set_ignore_access($old_ia);
200 
201  $this->reindexPriorities();
202 
203 
204  return true;
205  }
206 
214  function cache(\ElggPlugin $plugin) {
215  $this->plugins_by_id->put($plugin->getID(), $plugin);
216  }
217 
224  function get($plugin_id) {
225  return $this->plugins_by_id->get($plugin_id, function () use ($plugin_id) {
227  $db_prefix = get_config('dbprefix');
228 
229  $options = array(
230  'type' => 'object',
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'"),
235  'limit' => 1,
236  'distinct' => false,
237  );
238 
239  $plugins = elgg_get_entities($options);
240 
241  if ($plugins) {
242  return $plugins[0];
243  }
244 
245  return null;
246  });
247  }
248 
259  function exists($id) {
260  return (bool)$this->get($id);
261  }
262 
269  function getMaxPriority() {
270  $db_prefix = get_config('dbprefix');
271  $priority = $this->namespacePrivateSetting('internal', 'priority');
272  $plugin_subtype = get_subtype_id('object', 'plugin');
273 
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";
279 
280  $data = get_data($q);
281  if ($data) {
282  $max = $data[0]->max;
283  } else {
284  $max = 1;
285  }
286 
287  // can't have a priority of 0.
288  return ($max) ? $max : 1;
289  }
290 
298  function isActive($plugin_id, $site_guid = null) {
299  $current_site_guid = elgg_get_site_entity()->guid;
300 
301  if ($this->active_guids_known
302  && ($site_guid === null || $site_guid == $current_site_guid)) {
303  return isset($this->active_guids[$plugin_id]);
304  }
305 
306  if ($site_guid) {
307  $site = get_entity($site_guid);
308  } else {
310  }
311 
312  if (!($site instanceof \ElggSite)) {
313  return false;
314  }
315 
316  $plugin = $this->get($plugin_id);
317 
318  if (!$plugin) {
319  return false;
320  }
321 
322  return $plugin->isActive($site->guid);
323  }
324 
335  function load() {
336  if ($this->timer) {
337  $this->timer->begin([__METHOD__]);
338  }
339 
340  $plugins_path = elgg_get_plugins_path();
341  $start_flags = ELGG_PLUGIN_INCLUDE_START |
345 
346  if (!$plugins_path) {
347  return false;
348  }
349 
350  // temporary disable all plugins if there is a file called 'disabled' in the plugin dir
351  if (file_exists("$plugins_path/disabled")) {
352  if (elgg_is_admin_logged_in() && elgg_in_context('admin')) {
353  system_message(_elgg_services()->translator->translate('plugins:disabled'));
354  }
355  return false;
356  }
357 
358  if (elgg_get_config('system_cache_loaded')) {
359  $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_VIEWS;
360  }
361 
362  if (!empty($GLOBALS['_ELGG']->i18n_loaded_from_cache)) {
363  $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_LANGUAGES;
364  }
365 
366  $plugins = $this->boot_plugins;
367  if (!$plugins) {
368  $this->active_guids_known = true;
369  return true;
370  }
371 
372  $return = true;
373  foreach ($plugins as $plugin) {
374  $id = $plugin->getID();
375  try {
376  $plugin->start($start_flags);
377  $this->active_guids[$id] = $plugin->guid;
378  } catch (Exception $e) {
379  $disable_plugins = elgg_get_config('auto_disable_plugins');
380  if ($disable_plugins === null) {
381  $disable_plugins = true;
382  }
383  if ($disable_plugins) {
384  $plugin->deactivate();
385 
386  $msg = _elgg_services()->translator->translate('PluginException:CannotStart',
387  array($id, $plugin->guid, $e->getMessage()));
388  elgg_add_admin_notice("cannot_start $id", $msg);
389  $return = false;
390  }
391  }
392  }
393 
394  $this->active_guids_known = true;
395 
396  if ($this->timer) {
397  $this->timer->end([__METHOD__]);
398  }
399  return $return;
400  }
401 
409  function find($status = 'active', $site_guid = null) {
410  $db_prefix = elgg_get_config('dbprefix');
411  $priority = $this->namespacePrivateSetting('internal', 'priority');
412 
413  if (!$site_guid) {
414  $site_guid = elgg_get_site_entity()->guid;
415  }
416 
417  // grab plugins
418  $options = array(
419  'type' => 'object',
420  'subtype' => 'plugin',
421  'limit' => ELGG_ENTITIES_NO_VALUE,
422  'selects' => array('plugin_oe.*', 'ps.value'),
423  'joins' => array(
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"
426  ),
427  'wheres' => array("ps.name = '$priority'"),
428  // ORDER BY CAST(ps.value) is super slow. We usort() below.
429  'order_by' => false,
430  'distinct' => false,
431  );
432 
433  switch ($status) {
434  case 'active':
435  $options['relationship'] = 'active_plugin';
436  $options['relationship_guid'] = $site_guid;
437  $options['inverse_relationship'] = true;
438  break;
439 
440  case 'inactive':
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)";
446  break;
447 
448  case 'all':
449  default:
450  break;
451  }
452 
453  $old_ia = elgg_set_ignore_access(true);
455  elgg_set_ignore_access($old_ia);
456 
457  usort($plugins, function (\ElggPlugin $a, \ElggPlugin $b) {
458  $a_value = $a->getVolatileData('select:value');
459  $b_value = $b->getVolatileData('select:value');
460 
461  if ($b_value !== $a_value) {
462  return $a_value - $b_value;
463  } else {
464  return $a->guid - $b->guid;
465  }
466  });
467 
468  return $plugins;
469  }
470 
484  function setPriorities(array $order) {
485  $name = $this->namespacePrivateSetting('internal', 'priority');
486 
487  $plugins = $this->find('any');
488  if (!$plugins) {
489  return false;
490  }
491 
492  $return = true;
493 
494  // reindex to get standard counting. no need to increment by 10.
495  // though we do start with 1
496  $order = array_values($order);
497 
498  $missing_plugins = array();
499  /* @var \ElggPlugin[] $missing_plugins */
500 
501  foreach ($plugins as $plugin) {
502  $plugin_id = $plugin->getID();
503 
504  if (!in_array($plugin_id, $order)) {
505  $missing_plugins[] = $plugin;
506  continue;
507  }
508 
509  $priority = array_search($plugin_id, $order) + 1;
510 
511  if (!$plugin->setPrivateSetting($name, $priority)) {
512  $return = false;
513  break;
514  }
515  }
516 
517  // set the missing plugins' priorities
518  if ($return && $missing_plugins) {
519  if (!isset($priority)) {
520  $priority = 0;
521  }
522  foreach ($missing_plugins as $plugin) {
523  $priority++;
524  if (!$plugin->setPrivateSetting($name, $priority)) {
525  $return = false;
526  break;
527  }
528  }
529  }
530 
531  return $return;
532  }
533 
540  function reindexPriorities() {
541  return $this->setPriorities([]);
542  }
543 
558  function namespacePrivateSetting($type, $name, $id = null) {
559  switch ($type) {
560  // commented out because it breaks $plugin->$name access to variables
561  //case 'setting':
562  // $name = ELGG_PLUGIN_SETTING_PREFIX . $name;
563  // break;
564 
565  case 'user_setting':
566  if (!$id) {
567  elgg_deprecated_notice("You must pass the plugin id to _elgg_namespace_plugin_private_setting() for user settings", 1.9);
569  }
570  $name = ELGG_PLUGIN_USER_SETTING_PREFIX . "$id:$name";
571  break;
572 
573  case 'internal':
575  break;
576  }
577 
578  return $name;
579  }
580 
581 
600  function getProvides($type = null, $name = null) {
601  if ($this->provides_cache === null) {
602  $active_plugins = $this->find('active');
603 
604  $provides = array();
605 
606  foreach ($active_plugins as $plugin) {
607  $plugin_provides = array();
608  $manifest = $plugin->getManifest();
609  if ($manifest instanceof \ElggPluginManifest) {
610  $plugin_provides = $plugin->getManifest()->getProvides();
611  }
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()
617  );
618  }
619  }
620  }
621 
622  $this->provides_cache = $provides;
623  }
624 
625  if ($type && $name) {
626  if (isset($this->provides_cache[$type][$name])) {
627  return $this->provides_cache[$type][$name];
628  } else {
629  return false;
630  }
631  } elseif ($type) {
632  if (isset($this->provides_cache[$type])) {
633  return $this->provides_cache[$type];
634  } else {
635  return false;
636  }
637  }
638 
639  return $this->provides_cache;
640  }
641 
649  $this->provides_cache = null;
650  return true;
651  }
652 
659  public function invalidateIsActiveCache() {
660  $this->active_guids = array();
661  $this->active_guids_known = false;
662  }
663 
679  function checkProvides($type, $name, $version = null, $comparison = 'ge') {
680  $provided = $this->getProvides($type, $name);
681  if (!$provided) {
682  return array(
683  'status' => false,
684  'value' => ''
685  );
686  }
687 
688  if ($version) {
689  $status = version_compare($provided['version'], $version, $comparison);
690  } else {
691  $status = true;
692  }
693 
694  return array(
695  'status' => $status,
696  'value' => $provided['version']
697  );
698  }
699 
714  function getDependencyStrings($dep) {
715  $translator = _elgg_services()->translator;
716  $dep_system = elgg_extract('type', $dep);
717  $info = elgg_extract('dep', $dep);
718  $type = elgg_extract('type', $info);
719 
720  if (!$dep_system || !$info || !$type) {
721  return false;
722  }
723 
724  // rewrite some of these to be more readable
725  $comparison = elgg_extract('comparison', $info);
726  switch($comparison) {
727  case 'lt':
728  $comparison = '<';
729  break;
730  case 'gt':
731  $comparison = '>';
732  break;
733  case 'ge':
734  $comparison = '>=';
735  break;
736  case 'le':
737  $comparison = '<=';
738  break;
739  default:
740  //keep $comparison value intact
741  break;
742  }
743 
744  /*
745  'requires' 'plugin oauth_lib' <1.3 1.3 'downgrade'
746  'requires' 'php setting bob' >3 3 'change it'
747  'conflicts' 'php setting' >3 4 'change it'
748  'conflicted''plugin profile' any 1.8 'disable profile'
749  'provides' 'plugin oauth_lib' 1.3 -- --
750  'priority' 'before blog' -- after 'move it'
751  */
752  $strings = array();
753  $strings['type'] = $translator->translate('ElggPlugin:Dependencies:' . ucwords($dep_system));
754 
755  switch ($type) {
756  case 'elgg_release':
757  // 'Elgg Version'
758  $strings['name'] = $translator->translate('ElggPlugin:Dependencies:Elgg');
759  $strings['expected_value'] = "$comparison {$info['version']}";
760  $strings['local_value'] = $dep['value'];
761  $strings['comment'] = '';
762  break;
763 
764  case 'php_version':
765  // 'PHP version'
766  $strings['name'] = $translator->translate('ElggPlugin:Dependencies:PhpVersion');
767  $strings['expected_value'] = "$comparison {$info['version']}";
768  $strings['local_value'] = $dep['value'];
769  $strings['comment'] = '';
770  break;
771 
772  case 'php_extension':
773  // PHP Extension %s [version]
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'];
778  } else {
779  $strings['expected_value'] = '';
780  $strings['local_value'] = '';
781  }
782  $strings['comment'] = '';
783  break;
784 
785  case 'php_ini':
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'] = '';
790  break;
791 
792  case 'plugin':
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'] = '';
798  break;
799 
800  case 'priority':
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'] = '';
807  break;
808  }
809 
810  if ($dep['type'] == 'suggests') {
811  if ($dep['status']) {
812  $strings['comment'] = $translator->translate('ok');
813  } else {
814  $strings['comment'] = $translator->translate('ElggPlugin:Dependencies:Suggests:Unsatisfied');
815  }
816  } else {
817  if ($dep['status']) {
818  $strings['comment'] = $translator->translate('ok');
819  } else {
820  $strings['comment'] = $translator->translate('error');
821  }
822  }
823 
824  return $strings;
825  }
826 
837  function getAllUserSettings($user_guid = 0, $plugin_id = null, $return_obj = false) {
838  if ($plugin_id) {
839  $plugin = $this->get($plugin_id);
840  } else {
841  elgg_deprecated_notice('elgg_get_all_plugin_user_settings() requires plugin_id to be set', 1.9);
843  }
844 
845  if (!$plugin instanceof \ElggPlugin) {
846  return false;
847  }
848 
849  $settings = $plugin->getAllUserSettings((int)$user_guid);
850 
851  if ($settings && $return_obj) {
852  $return = new \stdClass;
853 
854  foreach ($settings as $k => $v) {
855  $return->$k = $v;
856  }
857 
858  return $return;
859  } else {
860  return $settings;
861  }
862  }
863 
875  function setUserSetting($name, $value, $user_guid = 0, $plugin_id = null) {
876  if ($plugin_id) {
877  $plugin = $this->get($plugin_id);
878  } else {
879  elgg_deprecated_notice('elgg_set_plugin_user_setting() requires plugin_id to be set', 1.9);
881  }
882 
883  if (!$plugin) {
884  return false;
885  }
886 
887  return $plugin->setUserSetting($name, $value, (int)$user_guid);
888  }
889 
900  function unsetUserSetting($name, $user_guid = 0, $plugin_id = null) {
901  if ($plugin_id) {
902  $plugin = $this->get($plugin_id);
903  } else {
904  elgg_deprecated_notice('elgg_unset_plugin_user_setting() requires plugin_id to be set', 1.9);
906  }
907 
908  if (!$plugin) {
909  return false;
910  }
911 
912  return $plugin->unsetUserSetting($name, (int)$user_guid);
913  }
914 
926  function getUserSetting($name, $user_guid = 0, $plugin_id = null, $default = null) {
927  if ($plugin_id) {
928  $plugin = $this->get($plugin_id);
929  } else {
930  elgg_deprecated_notice('elgg_get_plugin_user_setting() requires plugin_id to be set', 1.9);
932  }
933 
934  if (!$plugin) {
935  return false;
936  }
937 
938  return $plugin->getUserSetting($name, (int)$user_guid, $default);
939  }
940 
951  function setSetting($name, $value, $plugin_id = null) {
952  if ($plugin_id) {
953  $plugin = $this->get($plugin_id);
954  } else {
955  elgg_deprecated_notice('elgg_set_plugin_setting() requires plugin_id to be set', 1.9);
957  }
958 
959  if (!$plugin) {
960  return false;
961  }
962 
963  return $plugin->setSetting($name, $value);
964  }
965 
976  function getSetting($name, $plugin_id = null, $default = null) {
977  if ($plugin_id) {
978  $plugin = $this->get($plugin_id);
979  } else {
980  elgg_deprecated_notice('elgg_get_plugin_setting() requires plugin_id to be set', 1.9);
982  }
983 
984  if (!$plugin) {
985  return false;
986  }
987 
988  return $plugin->getSetting($name, $default);
989  }
990 
1000  function unsetSetting($name, $plugin_id = null) {
1001  if ($plugin_id) {
1002  $plugin = $this->get($plugin_id);
1003  } else {
1004  elgg_deprecated_notice('elgg_unset_plugin_setting() requires plugin_id to be set', 1.9);
1006  }
1007 
1008  if (!$plugin) {
1009  return false;
1010  }
1011 
1012  return $plugin->unsetSetting($name);
1013  }
1014 
1023  function unsetAllSettings($plugin_id = null) {
1024  if ($plugin_id) {
1025  $plugin = $this->get($plugin_id);
1026  } else {
1027  elgg_deprecated_notice('elgg_unset_all_plugin_settings() requires plugin_id to be set', 1.9);
1029  }
1030 
1031  if (!$plugin) {
1032  return false;
1033  }
1034 
1035  return $plugin->unsetAllSettings();
1036  }
1037 
1065  function getEntitiesFromUserSettings(array $options = array()) {
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);
1068  $options['plugin_id'] = elgg_get_calling_plugin_id();
1069  }
1070 
1071  $singulars = array('plugin_user_setting_name', 'plugin_user_setting_value',
1072  'plugin_user_setting_name_value_pair');
1073 
1075 
1076  // rewrite plugin_user_setting_name_* to the right PS ones.
1077  $map = array(
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',
1082  );
1083 
1084  foreach ($map as $plugin => $private) {
1085  if (!isset($options[$plugin])) {
1086  continue;
1087  }
1088 
1089  if (isset($options[$private])) {
1090  if (!is_array($options[$private])) {
1091  $options[$private] = array($options[$private]);
1092  }
1093 
1094  $options[$private] = array_merge($options[$private], $options[$plugin]);
1095  } else {
1096  $options[$private] = $options[$plugin];
1097  }
1098  }
1099 
1100  $prefix = $this->namespacePrivateSetting('user_setting', '', $options['plugin_id']);
1101  $options['private_setting_name_prefix'] = $prefix;
1102 
1104  }
1105 }
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:130
$plugin
reindexPriorities()
Reindexes all plugin priorities starting at 1.
Definition: Plugins.php:540
$version
getSetting($name, $plugin_id=null, $default=null)
Get setting for a plugin.
Definition: Plugins.php:976
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:269
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:27
const ELGG_ENTITIES_NO_VALUE
Definition: elgglib.php:2104
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:75
$data
Definition: opendd.php:13
$value
Definition: longtext.php:42
$return
Definition: opendd.php:15
$default
Definition: checkbox.php:34
getDependencyStrings($dep)
Returns an array of parsed strings for a dependency in the format: array( &#39;type&#39; => requires...
Definition: Plugins.php:714
getEntitiesFromUserSettings(array $options=array())
Returns entities based upon plugin user settings.
Definition: Plugins.php:1065
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells ::start() to automatically register the plugin&#39;s languages.
Definition: plugins.php:23
trait Profilable
Make an object accept a timer.
Definition: Profilable.php:9
if($screenshots) $info
Definition: details.php:58
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:84
sanitize_string($string)
Sanitizes a string for use in a query.
Definition: database.php:153
$options
Elgg admin footer.
Definition: footer.php:6
unsetSetting($name, $plugin_id=null)
Unsets a plugin setting.
Definition: Plugins.php:1000
getAllUserSettings($user_guid=0, $plugin_id=null, $return_obj=false)
Returns an array of all plugin user settings for a user.
Definition: Plugins.php:837
if($prev_offset< 1) if($current_page==1) if(1< $start_page) if(1< ($start_page-2)) elseif($start_page==3) $max
Definition: pagination.php:95
invalidateIsActiveCache()
Delete the cache holding whether plugins are active or not.
Definition: Plugins.php:659
const ELGG_PLUGIN_USER_SETTING_PREFIX
Prefix for plugin setting names.
Definition: plugins.php:41
getVolatileData($name)
Get a piece of volatile (non-persisted) data on this entity.
Definition: ElggEntity.php:576
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.
Definition: Plugins.php:951
elgg_set_ignore_access($ignore=true)
Set if Elgg&#39;s access system should be ignored.
Definition: access.php:43
$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:115
find($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
Definition: Plugins.php:409
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:241
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:326
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:679
setBootPlugins(array $plugins)
Set the list of active plugins according to the boot data cache.
Definition: Plugins.php:68
const ELGG_PLUGIN_INTERNAL_PREFIX
Internal settings prefix.
Definition: plugins.php:48
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1098
get_data($query, $callback=null, array $params=[])
Retrieve rows from the database.
Definition: database.php:55
isActive($plugin_id, $site_guid=null)
Returns if a plugin is active for a current site.
Definition: Plugins.php:298
unsetAllSettings($plugin_id=null)
Unsets all plugin settings for a plugin.
Definition: Plugins.php:1023
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:170
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1375
elgg system_message
Wrapper function for system_messages.
Definition: elgglib.js:390
__construct(Pool $pool, PluginSettingsCache $cache)
Constructor.
Definition: Plugins.php:57
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
Definition: access.php:158
namespacePrivateSetting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
Definition: Plugins.php:558
setPriorities(array $order)
Reorder plugins to an order specified by the array.
Definition: Plugins.php:484
setUserSetting($name, $value, $user_guid=0, $plugin_id=null)
Set a user specific setting for a plugin.
Definition: Plugins.php:875
load()
Loads all active plugins in the order specified in the tool admin panel.
Definition: Plugins.php:335
getProvides($type=null, $name=null)
Returns an array of all provides from all active plugins.
Definition: Plugins.php:600
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.
$index
Definition: gallery.php:49
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
Persistent, installation-wide key-value storage.
Definition: Plugins.php:18
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
Definition: elgglib.php:1528
$user_guid
Avatar remove action.
Definition: remove.php:6
cache(\ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
Definition: Plugins.php:214
getUserSetting($name, $user_guid=0, $plugin_id=null, $default=null)
Get a user specific setting for a plugin.
Definition: Plugins.php:926
if(!$collection_name) $id
Definition: add.php:17
$settings
exists($id)
Returns if a plugin exists in the system.
Definition: Plugins.php:259
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
Definition: MIT-LICENSE.txt:5
if(!$num_display) $db_prefix
Definition: content.php:13
$priority
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:204
if(!$display_name) $type
Definition: delete.php:27
invalidateProvidesCache()
Deletes all cached data on plugins being provided.
Definition: Plugins.php:648
unsetUserSetting($name, $user_guid=0, $plugin_id=null)
Unsets a user-specific plugin setting.
Definition: Plugins.php:900