Elgg  Version 1.11
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 {
25 
29  protected $active_ids = array();
30 
34  protected $active_ids_known = false;
35 
39  protected $plugins_by_id;
40 
47  public function __construct(\Elgg\EventsService $events, \Elgg\Cache\MemoryPool $pool) {
48  $this->plugins_by_id = $pool;
49  }
50 
60  function getDirsInDir($dir = null) {
61  if (!$dir) {
62  $dir = elgg_get_plugins_path();
63  }
64 
65  $plugin_dirs = array();
66  $handle = opendir($dir);
67 
68  if ($handle) {
69  while ($plugin_dir = readdir($handle)) {
70  // must be directory and not begin with a .
71  if (substr($plugin_dir, 0, 1) !== '.' && is_dir($dir . $plugin_dir)) {
72  $plugin_dirs[] = $plugin_dir;
73  }
74  }
75  }
76 
77  sort($plugin_dirs);
78 
79  return $plugin_dirs;
80  }
81 
91  function generateEntities() {
92 
93  $mod_dir = elgg_get_plugins_path();
94  $db_prefix = elgg_get_config('dbprefix');
95 
96  // ignore access in case this is called with no admin logged in - needed for creating plugins perhaps?
97  $old_ia = elgg_set_ignore_access(true);
98 
99  // show hidden entities so that we can enable them if appropriate
100  $old_access = access_get_show_hidden_status();
102 
103  $options = array(
104  'type' => 'object',
105  'subtype' => 'plugin',
106  'selects' => array('plugin_oe.*'),
107  'joins' => array("JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"),
108  'limit' => ELGG_ENTITIES_NO_VALUE,
109  );
111  /* @var \ElggPlugin[] $known_plugins */
112 
113  if (!$known_plugins) {
114  $known_plugins = array();
115  }
116 
117  // map paths to indexes
118  $id_map = array();
119  foreach ($known_plugins as $i => $plugin) {
120  // if the ID is wrong, delete the plugin because we can never load it.
121  $id = $plugin->getID();
122  if (!$id) {
123  $plugin->delete();
124  unset($known_plugins[$i]);
125  continue;
126  }
127  $id_map[$plugin->getID()] = $i;
128  }
129 
130  $physical_plugins = _elgg_get_plugin_dirs_in_dir($mod_dir);
131 
132  if (!$physical_plugins) {
133  return false;
134  }
135 
136  // check real plugins against known ones
137  foreach ($physical_plugins as $plugin_id) {
138  // is this already in the db?
139  if (array_key_exists($plugin_id, $id_map)) {
140  $index = $id_map[$plugin_id];
141  $plugin = $known_plugins[$index];
142  // was this plugin deleted and its entity disabled?
143  if (!$plugin->isEnabled()) {
144  $plugin->enable();
145  $plugin->deactivate();
146  $plugin->setPriority('last');
147  }
148 
149  // remove from the list of plugins to disable
150  unset($known_plugins[$index]);
151  } else {
152  // create new plugin
153  // priority is forced to last in save() if not set.
154  $plugin = new \ElggPlugin($mod_dir . $plugin_id);
155  $plugin->save();
156  }
157  }
158 
159  // everything remaining in $known_plugins needs to be disabled
160  // because they are entities, but their dirs were removed.
161  // don't delete the entities because they hold settings.
162  foreach ($known_plugins as $plugin) {
163  if ($plugin->isActive()) {
164  $plugin->deactivate();
165  }
166  // remove the priority.
167  $name = _elgg_namespace_plugin_private_setting('internal', 'priority');
168  remove_private_setting($plugin->guid, $name);
169  if ($plugin->isEnabled()) {
170  $plugin->disable();
171  }
172  }
173 
174  access_show_hidden_entities($old_access);
175  elgg_set_ignore_access($old_ia);
176 
178 
179  return true;
180  }
181 
189  function cache(\ElggPlugin $plugin) {
190  $this->plugins_by_id->put($plugin->getID(), $plugin);
191  }
192 
199  function get($plugin_id) {
200  return $this->plugins_by_id->get($plugin_id, function () use ($plugin_id) {
202  $db_prefix = get_config('dbprefix');
203 
204  $options = array(
205  'type' => 'object',
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'"),
210  'limit' => 1,
211  'distinct' => false,
212  );
213 
215 
216  if ($plugins) {
217  return $plugins[0];
218  }
219 
220  return null;
221  });
222  }
223 
234  function exists($id) {
236 
237  return ($plugin) ? true : false;
238  }
239 
246  function getMaxPriority() {
247  $db_prefix = get_config('dbprefix');
248  $priority = _elgg_namespace_plugin_private_setting('internal', 'priority');
249  $plugin_subtype = get_subtype_id('object', 'plugin');
250 
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";
256 
257  $data = get_data($q);
258  if ($data) {
259  $max = $data[0]->max;
260  } else {
261  $max = 1;
262  }
263 
264  // can't have a priority of 0.
265  return ($max) ? $max : 1;
266  }
267 
275  function isActive($plugin_id, $site_guid = null) {
276  $current_site_guid = elgg_get_site_entity()->guid;
277 
278  if ($this->active_ids_known
279  && ($site_guid === null || $site_guid == $current_site_guid)) {
280  return isset($this->active_ids[$plugin_id]);
281  }
282 
283  if ($site_guid) {
284  $site = get_entity($site_guid);
285  } else {
287  }
288 
289  if (!($site instanceof \ElggSite)) {
290  return false;
291  }
292 
294 
295  if (!$plugin) {
296  return false;
297  }
298 
299  return $plugin->isActive($site->guid);
300  }
301 
312  function load() {
313  $plugins_path = elgg_get_plugins_path();
314  $start_flags = ELGG_PLUGIN_INCLUDE_START |
318 
319  if (!$plugins_path) {
320  return false;
321  }
322 
323  // temporary disable all plugins if there is a file called 'disabled' in the plugin dir
324  if (file_exists("$plugins_path/disabled")) {
325  if (elgg_is_admin_logged_in() && elgg_in_context('admin')) {
326  system_message(_elgg_services()->translator->translate('plugins:disabled'));
327  }
328  return false;
329  }
330 
331  if (elgg_get_config('system_cache_loaded')) {
332  $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_VIEWS;
333  }
334 
335  if (elgg_get_config('i18n_loaded_from_cache')) {
336  $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_LANGUAGES;
337  }
338 
339  $return = true;
340  $plugins = $this->find('active');
341  if ($plugins) {
342  foreach ($plugins as $plugin) {
343  $id = $plugin->getID();
344  try {
345  $plugin->start($start_flags);
346  $this->active_ids[$id] = true;
347  } catch (Exception $e) {
348  $plugin->deactivate();
349  $msg = _elgg_services()->translator->translate('PluginException:CannotStart',
350  array($id, $plugin->guid, $e->getMessage()));
351  elgg_add_admin_notice("cannot_start $id", $msg);
352  $return = false;
353 
354  continue;
355  }
356  }
357  }
358 
359  $this->active_ids_known = true;
360  return $return;
361  }
362 
370  function find($status = 'active', $site_guid = null) {
371  $db_prefix = get_config('dbprefix');
372  $priority = _elgg_namespace_plugin_private_setting('internal', 'priority');
373 
374  if (!$site_guid) {
375  $site = get_config('site');
376  $site_guid = $site->guid;
377  }
378 
379  // grab plugins
380  $options = array(
381  'type' => 'object',
382  'subtype' => 'plugin',
383  'limit' => ELGG_ENTITIES_NO_VALUE,
384  'selects' => array('plugin_oe.*'),
385  'joins' => array(
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"
388  ),
389  'wheres' => array("ps.name = '$priority'"),
390  'order_by' => "CAST(ps.value as unsigned), e.guid",
391  'distinct' => false,
392  );
393 
394  switch ($status) {
395  case 'active':
396  $options['relationship'] = 'active_plugin';
397  $options['relationship_guid'] = $site_guid;
398  $options['inverse_relationship'] = true;
399  break;
400 
401  case 'inactive':
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)";
407  break;
408 
409  case 'all':
410  default:
411  break;
412  }
413 
414  $old_ia = elgg_set_ignore_access(true);
416  elgg_set_ignore_access($old_ia);
417 
418  return $plugins;
419  }
420 
433  function setPriorities(array $order) {
434  $name = _elgg_namespace_plugin_private_setting('internal', 'priority');
435 
436  $plugins = elgg_get_plugins('any');
437  if (!$plugins) {
438  return false;
439  }
440 
441  $return = true;
442 
443  // reindex to get standard counting. no need to increment by 10.
444  // though we do start with 1
445  $order = array_values($order);
446 
447  $missing_plugins = array();
448  /* @var \ElggPlugin[] $missing_plugins */
449 
450  foreach ($plugins as $plugin) {
451  $plugin_id = $plugin->getID();
452 
453  if (!in_array($plugin_id, $order)) {
454  $missing_plugins[] = $plugin;
455  continue;
456  }
457 
458  $priority = array_search($plugin_id, $order) + 1;
459 
460  if (!$plugin->setPrivateSetting($name, $priority)) {
461  $return = false;
462  break;
463  }
464  }
465 
466  // set the missing plugins' priorities
467  if ($return && $missing_plugins) {
468  if (!isset($priority)) {
469  $priority = 0;
470  }
471  foreach ($missing_plugins as $plugin) {
472  $priority++;
473  if (!$plugin->setPrivateSetting($name, $priority)) {
474  $return = false;
475  break;
476  }
477  }
478  }
479 
480  return $return;
481  }
482 
490  function reindexPriorities() {
491  return _elgg_set_plugin_priorities(array());
492  }
493 
508  function namespacePrivateSetting($type, $name, $id = null) {
509  switch ($type) {
510  // commented out because it breaks $plugin->$name access to variables
511  //case 'setting':
512  // $name = ELGG_PLUGIN_SETTING_PREFIX . $name;
513  // break;
514 
515  case 'user_setting':
516  if (!$id) {
517  elgg_deprecated_notice("You must pass the plugin id to _elgg_namespace_plugin_private_setting() for user settings", 1.9);
519  }
520  $name = ELGG_PLUGIN_USER_SETTING_PREFIX . "$id:$name";
521  break;
522 
523  case 'internal':
525  break;
526  }
527 
528  return $name;
529  }
530 
531 
550  function getProvides($type = null, $name = null) {
552  if (!isset($ELGG_PLUGINS_PROVIDES_CACHE)) {
553  $active_plugins = elgg_get_plugins('active');
554 
555  $provides = array();
556 
557  foreach ($active_plugins as $plugin) {
558  $plugin_provides = array();
559  $manifest = $plugin->getManifest();
560  if ($manifest instanceof \ElggPluginManifest) {
561  $plugin_provides = $plugin->getManifest()->getProvides();
562  }
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()
568  );
569  }
570  }
571  }
572 
573  $ELGG_PLUGINS_PROVIDES_CACHE = $provides;
574  }
575 
576  if ($type && $name) {
577  if (isset($ELGG_PLUGINS_PROVIDES_CACHE[$type][$name])) {
578  return $ELGG_PLUGINS_PROVIDES_CACHE[$type][$name];
579  } else {
580  return false;
581  }
582  } elseif ($type) {
583  if (isset($ELGG_PLUGINS_PROVIDES_CACHE[$type])) {
584  return $ELGG_PLUGINS_PROVIDES_CACHE[$type];
585  } else {
586  return false;
587  }
588  }
589 
591  }
592 
601  $ELGG_PLUGINS_PROVIDES_CACHE = null;
602  return true;
603  }
604 
611  public function invalidateIsActiveCache() {
612  $this->active_ids = array();
613  $this->active_ids_known = false;
614  }
615 
631  function checkProvides($type, $name, $version = null, $comparison = 'ge') {
632  $provided = _elgg_get_plugins_provides($type, $name);
633  if (!$provided) {
634  return array(
635  'status' => false,
636  'value' => ''
637  );
638  }
639 
640  if ($version) {
641  $status = version_compare($provided['version'], $version, $comparison);
642  } else {
643  $status = true;
644  }
645 
646  return array(
647  'status' => $status,
648  'value' => $provided['version']
649  );
650  }
651 
666  function getDependencyStrings($dep) {
667  $translator = _elgg_services()->translator;
668  $dep_system = elgg_extract('type', $dep);
669  $info = elgg_extract('dep', $dep);
670  $type = elgg_extract('type', $info);
671 
672  if (!$dep_system || !$info || !$type) {
673  return false;
674  }
675 
676  // rewrite some of these to be more readable
677  $comparison = elgg_extract('comparison', $info);
678  switch($comparison) {
679  case 'lt':
680  $comparison = '<';
681  break;
682  case 'gt':
683  $comparison = '>';
684  break;
685  case 'ge':
686  $comparison = '>=';
687  break;
688  case 'le':
689  $comparison = '<=';
690  break;
691  default:
692  //keep $comparison value intact
693  break;
694  }
695 
696  /*
697  'requires' 'plugin oauth_lib' <1.3 1.3 'downgrade'
698  'requires' 'php setting bob' >3 3 'change it'
699  'conflicts' 'php setting' >3 4 'change it'
700  'conflicted''plugin profile' any 1.8 'disable profile'
701  'provides' 'plugin oauth_lib' 1.3 -- --
702  'priority' 'before blog' -- after 'move it'
703  */
704  $strings = array();
705  $strings['type'] = $translator->translate('ElggPlugin:Dependencies:' . ucwords($dep_system));
706 
707  switch ($type) {
708  case 'elgg_version':
709  case 'elgg_release':
710  // 'Elgg Version'
711  $strings['name'] = $translator->translate('ElggPlugin:Dependencies:Elgg');
712  $strings['expected_value'] = "$comparison {$info['version']}";
713  $strings['local_value'] = $dep['value'];
714  $strings['comment'] = '';
715  break;
716 
717  case 'php_version':
718  // 'PHP version'
719  $strings['name'] = $translator->translate('ElggPlugin:Dependencies:PhpVersion');
720  $strings['expected_value'] = "$comparison {$info['version']}";
721  $strings['local_value'] = $dep['value'];
722  $strings['comment'] = '';
723  break;
724 
725  case 'php_extension':
726  // PHP Extension %s [version]
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'];
731  } else {
732  $strings['expected_value'] = '';
733  $strings['local_value'] = '';
734  }
735  $strings['comment'] = '';
736  break;
737 
738  case 'php_ini':
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'] = '';
743  break;
744 
745  case 'plugin':
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'] = '';
751  break;
752 
753  case 'priority':
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'] = '';
760  break;
761  }
762 
763  if ($dep['type'] == 'suggests') {
764  if ($dep['status']) {
765  $strings['comment'] = $translator->translate('ok');
766  } else {
767  $strings['comment'] = $translator->translate('ElggPlugin:Dependencies:Suggests:Unsatisfied');
768  }
769  } else {
770  if ($dep['status']) {
771  $strings['comment'] = $translator->translate('ok');
772  } else {
773  $strings['comment'] = $translator->translate('error');
774  }
775  }
776 
777  return $strings;
778  }
779 
790  function getAllUserSettings($user_guid = 0, $plugin_id = null, $return_obj = false) {
791  if ($plugin_id) {
793  } else {
794  elgg_deprecated_notice('elgg_get_all_plugin_user_settings() requires plugin_id to be set', 1.9);
796  }
797 
798  if (!$plugin instanceof \ElggPlugin) {
799  return false;
800  }
801 
802  $settings = $plugin->getAllUserSettings((int)$user_guid);
803 
804  if ($settings && $return_obj) {
805  $return = new \stdClass;
806 
807  foreach ($settings as $k => $v) {
808  $return->$k = $v;
809  }
810 
811  return $return;
812  } else {
813  return $settings;
814  }
815  }
816 
828  function setUserSetting($name, $value, $user_guid = 0, $plugin_id = null) {
829  if ($plugin_id) {
831  } else {
832  elgg_deprecated_notice('elgg_set_plugin_user_setting() requires plugin_id to be set', 1.9);
834  }
835 
836  if (!$plugin) {
837  return false;
838  }
839 
840  return $plugin->setUserSetting($name, $value, (int)$user_guid);
841  }
842 
853  function unsetUserSetting($name, $user_guid = 0, $plugin_id = null) {
854  if ($plugin_id) {
856  } else {
857  elgg_deprecated_notice('elgg_unset_plugin_user_setting() requires plugin_id to be set', 1.9);
859  }
860 
861  if (!$plugin) {
862  return false;
863  }
864 
865  return $plugin->unsetUserSetting($name, (int)$user_guid);
866  }
867 
879  function getUserSetting($name, $user_guid = 0, $plugin_id = null, $default = null) {
880  if ($plugin_id) {
882  } else {
883  elgg_deprecated_notice('elgg_get_plugin_user_setting() requires plugin_id to be set', 1.9);
885  }
886 
887  if (!$plugin) {
888  return false;
889  }
890 
891  return $plugin->getUserSetting($name, (int)$user_guid, $default);
892  }
893 
904  function setSetting($name, $value, $plugin_id = null) {
905  if ($plugin_id) {
907  } else {
908  elgg_deprecated_notice('elgg_set_plugin_setting() requires plugin_id to be set', 1.9);
910  }
911 
912  if (!$plugin) {
913  return false;
914  }
915 
916  return $plugin->setSetting($name, $value);
917  }
918 
929  function getSetting($name, $plugin_id = null, $default = null) {
930  if ($plugin_id) {
932  } else {
933  elgg_deprecated_notice('elgg_get_plugin_setting() requires plugin_id to be set', 1.9);
935  }
936 
937  if (!$plugin) {
938  return false;
939  }
940 
941  return $plugin->getSetting($name, $default);
942  }
943 
953  function unsetSetting($name, $plugin_id = null) {
954  if ($plugin_id) {
956  } else {
957  elgg_deprecated_notice('elgg_unset_plugin_setting() requires plugin_id to be set', 1.9);
959  }
960 
961  if (!$plugin) {
962  return false;
963  }
964 
965  return $plugin->unsetSetting($name);
966  }
967 
976  function unsetAllSettings($plugin_id = null) {
977  if ($plugin_id) {
979  } else {
980  elgg_deprecated_notice('elgg_unset_all_plugin_settings() requires plugin_id to be set', 1.9);
982  }
983 
984  if (!$plugin) {
985  return false;
986  }
987 
988  return $plugin->unsetAllSettings();
989  }
990 
1018  function getEntitiesFromUserSettings(array $options = array()) {
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);
1021  $options['plugin_id'] = elgg_get_calling_plugin_id();
1022  }
1023 
1024  $singulars = array('plugin_user_setting_name', 'plugin_user_setting_value',
1025  'plugin_user_setting_name_value_pair');
1026 
1028 
1029  // rewrite plugin_user_setting_name_* to the right PS ones.
1030  $map = array(
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',
1035  );
1036 
1037  foreach ($map as $plugin => $private) {
1038  if (!isset($options[$plugin])) {
1039  continue;
1040  }
1041 
1042  if (isset($options[$private])) {
1043  if (!is_array($options[$private])) {
1044  $options[$private] = array($options[$private]);
1045  }
1046 
1047  $options[$private] = array_merge($options[$private], $options[$plugin]);
1048  } else {
1049  $options[$private] = $options[$plugin];
1050  }
1051  }
1052 
1053  $prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $options['plugin_id']);
1054  $options['private_setting_name_prefix'] = $prefix;
1055 
1057  }
1058 }
_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:490
getSetting($name, $plugin_id=null, $default=null)
Get setting for a plugin.
Definition: Plugins.php:929
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:60
__construct(\Elgg\EventsService $events,\Elgg\Cache\MemoryPool $pool)
Constructor.
Definition: Plugins.php:47
getMaxPriority()
Returns the highest priority of the plugins.
Definition: Plugins.php:246
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:1976
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:26
$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:666
getEntitiesFromUserSettings(array $options=array())
Returns entities based upon plugin user settings.
Definition: Plugins.php:1018
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:1246
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:60
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:953
$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:790
_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
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:85
invalidateIsActiveCache()
Delete the cache holding whether plugins are active or not.
Definition: Plugins.php:611
const ELGG_PLUGIN_USER_SETTING_PREFIX
Prefix for plugin setting names.
Definition: plugins.php:41
Save menu items.
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:904
elgg_set_ignore_access($ignore=true)
Set if Elgg&#39;s access system should be ignored.
Definition: access.php:43
_elgg_services()
Definition: autoloader.php:14
$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:91
global $ELGG_PLUGINS_PROVIDES_CACHE
Definition: Plugins.php:10
find($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
Definition: Plugins.php:370
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:631
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:1006
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:275
unsetAllSettings($plugin_id=null)
Unsets all plugin settings for a plugin.
Definition: Plugins.php:976
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:172
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:159
_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:508
setPriorities(array $order)
Reorder plugins to an order specified by the array.
Definition: Plugins.php:433
setUserSetting($name, $value, $user_guid=0, $plugin_id=null)
Set a user specific setting for a plugin.
Definition: Plugins.php:828
load()
Loads all active plugins in the order specified in the tool admin panel.
Definition: Plugins.php:312
getProvides($type=null, $name=null)
Returns an array of all provides from all active plugins.
Definition: Plugins.php:550
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:1376
_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:189
getUserSetting($name, $user_guid=0, $plugin_id=null, $default=null)
Get a user specific setting for a plugin.
Definition: Plugins.php:879
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:234
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:599
unsetUserSetting($name, $user_guid=0, $plugin_id=null)
Unsets a user-specific plugin setting.
Definition: Plugins.php:853