Elgg  Version 1.9
plugins.php
Go to the documentation of this file.
1 <?php
13 define('ELGG_PLUGIN_INCLUDE_START', 1);
14 
18 define('ELGG_PLUGIN_REGISTER_VIEWS', 2);
19 
23 define('ELGG_PLUGIN_REGISTER_LANGUAGES', 4);
24 
28 define('ELGG_PLUGIN_REGISTER_CLASSES', 8);
29 
36 //define('ELGG_PLUGIN_SETTING_PREFIX', 'plugin:setting:');
37 
41 define('ELGG_PLUGIN_USER_SETTING_PREFIX', 'plugin:user_setting:');
42 
48 define('ELGG_PLUGIN_INTERNAL_PREFIX', 'elgg:internal:');
49 
50 
61 function _elgg_get_plugin_dirs_in_dir($dir = null) {
62  if (!$dir) {
63  $dir = elgg_get_plugins_path();
64  }
65 
66  $plugin_dirs = array();
67  $handle = opendir($dir);
68 
69  if ($handle) {
70  while ($plugin_dir = readdir($handle)) {
71  // must be directory and not begin with a .
72  if (substr($plugin_dir, 0, 1) !== '.' && is_dir($dir . $plugin_dir)) {
73  $plugin_dirs[] = $plugin_dir;
74  }
75  }
76  }
77 
78  sort($plugin_dirs);
79 
80  return $plugin_dirs;
81 }
82 
94 
95  $mod_dir = elgg_get_plugins_path();
96  $db_prefix = elgg_get_config('dbprefix');
97 
98  // ignore access in case this is called with no admin logged in - needed for creating plugins perhaps?
99  $old_ia = elgg_set_ignore_access(true);
100 
101  // show hidden entities so that we can enable them if appropriate
102  $old_access = access_get_show_hidden_status();
104 
105  $options = array(
106  'type' => 'object',
107  'subtype' => 'plugin',
108  'selects' => array('plugin_oe.*'),
109  'joins' => array("JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"),
110  'limit' => ELGG_ENTITIES_NO_VALUE,
111  );
113  /* @var ElggPlugin[] $known_plugins */
114 
115  if (!$known_plugins) {
116  $known_plugins = array();
117  }
118 
119  // map paths to indexes
120  $id_map = array();
121  foreach ($known_plugins as $i => $plugin) {
122  // if the ID is wrong, delete the plugin because we can never load it.
123  $id = $plugin->getID();
124  if (!$id) {
125  $plugin->delete();
126  unset($known_plugins[$i]);
127  continue;
128  }
129  $id_map[$plugin->getID()] = $i;
130  }
131 
132  $physical_plugins = _elgg_get_plugin_dirs_in_dir($mod_dir);
133 
134  if (!$physical_plugins) {
135  return false;
136  }
137 
138  // check real plugins against known ones
139  foreach ($physical_plugins as $plugin_id) {
140  // is this already in the db?
141  if (array_key_exists($plugin_id, $id_map)) {
142  $index = $id_map[$plugin_id];
143  $plugin = $known_plugins[$index];
144  // was this plugin deleted and its entity disabled?
145  if (!$plugin->isEnabled()) {
146  $plugin->enable();
147  $plugin->deactivate();
148  $plugin->setPriority('last');
149  }
150 
151  // remove from the list of plugins to disable
152  unset($known_plugins[$index]);
153  } else {
154  // create new plugin
155  // priority is forced to last in save() if not set.
156  $plugin = new ElggPlugin($mod_dir . $plugin_id);
157  $plugin->save();
158  }
159  }
160 
161  // everything remaining in $known_plugins needs to be disabled
162  // because they are entities, but their dirs were removed.
163  // don't delete the entities because they hold settings.
164  foreach ($known_plugins as $plugin) {
165  if ($plugin->isActive()) {
166  $plugin->deactivate();
167  }
168  // remove the priority.
169  $name = _elgg_namespace_plugin_private_setting('internal', 'priority');
170  remove_private_setting($plugin->guid, $name);
171  if ($plugin->isEnabled()) {
172  $plugin->disable();
173  }
174  }
175 
176  access_show_hidden_entities($old_access);
177  elgg_set_ignore_access($old_ia);
178 
180 
181  return true;
182 }
183 
192  $map = (array) elgg_get_config('plugins_by_id_map');
193  $map[$plugin->getID()] = $plugin;
194  elgg_set_config('plugins_by_id_map', $map);
195 }
196 
205  $map = (array) elgg_get_config('plugins_by_id_map');
206  if (isset($map[$plugin_id])) {
207  return $map[$plugin_id];
208  }
209 
210  $plugin_id = sanitize_string($plugin_id);
211  $db_prefix = get_config('dbprefix');
212 
213  $options = array(
214  'type' => 'object',
215  'subtype' => 'plugin',
216  'joins' => array("JOIN {$db_prefix}objects_entity oe on oe.guid = e.guid"),
217  'selects' => array("oe.title", "oe.description"),
218  'wheres' => array("oe.title = '$plugin_id'"),
219  'limit' => 1,
220  );
221 
223 
224  if ($plugins) {
225  return $plugins[0];
226  }
227 
228  return null;
229 }
230 
244 
245  return ($plugin) ? true : false;
246 }
247 
256  $db_prefix = get_config('dbprefix');
257  $priority = _elgg_namespace_plugin_private_setting('internal', 'priority');
258  $plugin_subtype = get_subtype_id('object', 'plugin');
259 
260  $q = "SELECT MAX(CAST(ps.value AS unsigned)) as max
261  FROM {$db_prefix}entities e, {$db_prefix}private_settings ps
262  WHERE ps.name = '$priority'
263  AND ps.entity_guid = e.guid
264  AND e.type = 'object' and e.subtype = $plugin_subtype";
265 
266  $data = get_data($q);
267  if ($data) {
268  $max = $data[0]->max;
269  } else {
270  $max = 1;
271  }
272 
273  // can't have a priority of 0.
274  return ($max) ? $max : 1;
275 }
276 
285 function elgg_is_active_plugin($plugin_id, $site_guid = null) {
286  if ($site_guid) {
287  $site = get_entity($site_guid);
288  } else {
290  }
291 
292  if (!($site instanceof ElggSite)) {
293  return false;
294  }
295 
297 
298  if (!$plugin) {
299  return false;
300  }
301 
302  return $plugin->isActive($site->guid);
303 }
304 
316 function _elgg_load_plugins() {
317  $plugins_path = elgg_get_plugins_path();
318  $start_flags = ELGG_PLUGIN_INCLUDE_START |
322 
323  if (!$plugins_path) {
324  return false;
325  }
326 
327  // temporary disable all plugins if there is a file called 'disabled' in the plugin dir
328  if (file_exists("$plugins_path/disabled")) {
329  if (elgg_is_admin_logged_in() && elgg_in_context('admin')) {
330  system_message(elgg_echo('plugins:disabled'));
331  }
332  return false;
333  }
334 
335  if (elgg_get_config('system_cache_loaded')) {
336  $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_VIEWS;
337  }
338 
339  if (elgg_get_config('i18n_loaded_from_cache')) {
340  $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_LANGUAGES;
341  }
342 
343  $return = true;
344  $plugins = elgg_get_plugins('active');
345  if ($plugins) {
346  foreach ($plugins as $plugin) {
347  try {
348  $plugin->start($start_flags);
349  } catch (Exception $e) {
350  $plugin->deactivate();
351  $msg = elgg_echo('PluginException:CannotStart',
352  array($plugin->getID(), $plugin->guid, $e->getMessage()));
353  elgg_add_admin_notice('cannot_start' . $plugin->getID(), $msg);
354  $return = false;
355 
356  continue;
357  }
358  }
359  }
360 
361  return $return;
362 }
363 
372 function elgg_get_plugins($status = 'active', $site_guid = null) {
373  $db_prefix = get_config('dbprefix');
374  $priority = _elgg_namespace_plugin_private_setting('internal', 'priority');
375 
376  if (!$site_guid) {
377  $site = get_config('site');
378  $site_guid = $site->guid;
379  }
380 
381  // grab plugins
382  $options = array(
383  'type' => 'object',
384  'subtype' => 'plugin',
385  'limit' => ELGG_ENTITIES_NO_VALUE,
386  'selects' => array('plugin_oe.*'),
387  'joins' => array(
388  "JOIN {$db_prefix}private_settings ps on ps.entity_guid = e.guid",
389  "JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"
390  ),
391  'wheres' => array("ps.name = '$priority'"),
392  'order_by' => "CAST(ps.value as unsigned), e.guid"
393  );
394 
395  switch ($status) {
396  case 'active':
397  $options['relationship'] = 'active_plugin';
398  $options['relationship_guid'] = $site_guid;
399  $options['inverse_relationship'] = true;
400  break;
401 
402  case 'inactive':
403  $options['wheres'][] = "NOT EXISTS (
404  SELECT 1 FROM {$db_prefix}entity_relationships active_er
405  WHERE active_er.guid_one = e.guid
406  AND active_er.relationship = 'active_plugin'
407  AND active_er.guid_two = $site_guid)";
408  break;
409 
410  case 'all':
411  default:
412  break;
413  }
414 
415  $old_ia = elgg_set_ignore_access(true);
417  elgg_set_ignore_access($old_ia);
418 
419  return $plugins;
420 }
421 
435 function _elgg_set_plugin_priorities(array $order) {
436  $name = _elgg_namespace_plugin_private_setting('internal', 'priority');
437 
438  $plugins = elgg_get_plugins('any');
439  if (!$plugins) {
440  return false;
441  }
442 
443  $return = true;
444 
445  // reindex to get standard counting. no need to increment by 10.
446  // though we do start with 1
447  $order = array_values($order);
448 
449  $missing_plugins = array();
450  /* @var ElggPlugin[] $missing_plugins */
451 
452  foreach ($plugins as $plugin) {
453  $plugin_id = $plugin->getID();
454 
455  if (!in_array($plugin_id, $order)) {
456  $missing_plugins[] = $plugin;
457  continue;
458  }
459 
460  $priority = array_search($plugin_id, $order) + 1;
461 
462  if (!$plugin->setPrivateSetting($name, $priority)) {
463  $return = false;
464  break;
465  }
466  }
467 
468  // set the missing plugins' priorities
469  if ($return && $missing_plugins) {
470  if (!isset($priority)) {
471  $priority = 0;
472  }
473  foreach ($missing_plugins as $plugin) {
474  $priority++;
475  if (!$plugin->setPrivateSetting($name, $priority)) {
476  $return = false;
477  break;
478  }
479  }
480  }
481 
482  return $return;
483 }
484 
494  return _elgg_set_plugin_priorities(array());
495 }
496 
513  switch ($type) {
514  // commented out because it breaks $plugin->$name access to variables
515  //case 'setting':
516  // $name = ELGG_PLUGIN_SETTING_PREFIX . $name;
517  // break;
518 
519  case 'user_setting':
520  if (!$id) {
521  elgg_deprecated_notice("You must pass the plugin id to _elgg_namespace_plugin_private_setting() for user settings", 1.9);
523  }
524  $name = ELGG_PLUGIN_USER_SETTING_PREFIX . "$id:$name";
525  break;
526 
527  case 'internal':
529  break;
530  }
531 
532  return $name;
533 }
534 
540 
560 function _elgg_get_plugins_provides($type = null, $name = null) {
562  if (!isset($ELGG_PLUGINS_PROVIDES_CACHE)) {
563  $active_plugins = elgg_get_plugins('active');
564 
565  $provides = array();
566 
567  foreach ($active_plugins as $plugin) {
568  $plugin_provides = array();
569  $manifest = $plugin->getManifest();
570  if ($manifest instanceof ElggPluginManifest) {
571  $plugin_provides = $plugin->getManifest()->getProvides();
572  }
573  if ($plugin_provides) {
574  foreach ($plugin_provides as $provided) {
575  $provides[$provided['type']][$provided['name']] = array(
576  'version' => $provided['version'],
577  'provided_by' => $plugin->getID()
578  );
579  }
580  }
581  }
582 
583  $ELGG_PLUGINS_PROVIDES_CACHE = $provides;
584  }
585 
586  if ($type && $name) {
587  if (isset($ELGG_PLUGINS_PROVIDES_CACHE[$type][$name])) {
588  return $ELGG_PLUGINS_PROVIDES_CACHE[$type][$name];
589  } else {
590  return false;
591  }
592  } elseif ($type) {
593  if (isset($ELGG_PLUGINS_PROVIDES_CACHE[$type])) {
594  return $ELGG_PLUGINS_PROVIDES_CACHE[$type];
595  } else {
596  return false;
597  }
598  }
599 
601 }
602 
612  $ELGG_PLUGINS_PROVIDES_CACHE = null;
613  return true;
614 }
615 
632 function _elgg_check_plugins_provides($type, $name, $version = null, $comparison = 'ge') {
633  $provided = _elgg_get_plugins_provides($type, $name);
634  if (!$provided) {
635  return array(
636  'status' => false,
637  'value' => ''
638  );
639  }
640 
641  if ($version) {
642  $status = version_compare($provided['version'], $version, $comparison);
643  } else {
644  $status = true;
645  }
646 
647  return array(
648  'status' => $status,
649  'value' => $provided['version']
650  );
651 }
652 
669  $dep_system = elgg_extract('type', $dep);
670  $info = elgg_extract('dep', $dep);
671  $type = elgg_extract('type', $info);
672 
673  if (!$dep_system || !$info || !$type) {
674  return false;
675  }
676 
677  // rewrite some of these to be more readable
678  $comparison = elgg_extract('comparison', $info);
679  switch($comparison) {
680  case 'lt':
681  $comparison = '<';
682  break;
683  case 'gt':
684  $comparison = '>';
685  break;
686  case 'ge':
687  $comparison = '>=';
688  break;
689  case 'le':
690  $comparison = '<=';
691  break;
692  default:
693  //keep $comparison value intact
694  break;
695  }
696 
697  /*
698  'requires' 'plugin oauth_lib' <1.3 1.3 'downgrade'
699  'requires' 'php setting bob' >3 3 'change it'
700  'conflicts' 'php setting' >3 4 'change it'
701  'conflicted''plugin profile' any 1.8 'disable profile'
702  'provides' 'plugin oauth_lib' 1.3 -- --
703  'priority' 'before blog' -- after 'move it'
704  */
705  $strings = array();
706  $strings['type'] = elgg_echo('ElggPlugin:Dependencies:' . ucwords($dep_system));
707 
708  switch ($type) {
709  case 'elgg_version':
710  case 'elgg_release':
711  // 'Elgg Version'
712  $strings['name'] = elgg_echo('ElggPlugin:Dependencies:Elgg');
713  $strings['expected_value'] = "$comparison {$info['version']}";
714  $strings['local_value'] = $dep['value'];
715  $strings['comment'] = '';
716  break;
717 
718  case 'php_version':
719  // 'PHP version'
720  $strings['name'] = elgg_echo('ElggPlugin:Dependencies:PhpVersion');
721  $strings['expected_value'] = "$comparison {$info['version']}";
722  $strings['local_value'] = $dep['value'];
723  $strings['comment'] = '';
724  break;
725 
726  case 'php_extension':
727  // PHP Extension %s [version]
728  $strings['name'] = elgg_echo('ElggPlugin:Dependencies:PhpExtension', array($info['name']));
729  if ($info['version']) {
730  $strings['expected_value'] = "$comparison {$info['version']}";
731  $strings['local_value'] = $dep['value'];
732  } else {
733  $strings['expected_value'] = '';
734  $strings['local_value'] = '';
735  }
736  $strings['comment'] = '';
737  break;
738 
739  case 'php_ini':
740  $strings['name'] = elgg_echo('ElggPlugin:Dependencies:PhpIni', array($info['name']));
741  $strings['expected_value'] = "$comparison {$info['value']}";
742  $strings['local_value'] = $dep['value'];
743  $strings['comment'] = '';
744  break;
745 
746  case 'plugin':
747  $strings['name'] = elgg_echo('ElggPlugin:Dependencies:Plugin', array($info['name']));
748  $expected = $info['version'] ? "$comparison {$info['version']}" : elgg_echo('any');
749  $strings['expected_value'] = $expected;
750  $strings['local_value'] = $dep['value'] ? $dep['value'] : '--';
751  $strings['comment'] = '';
752  break;
753 
754  case 'priority':
755  $expected_priority = ucwords($info['priority']);
756  $real_priority = ucwords($dep['value']);
757  $strings['name'] = elgg_echo('ElggPlugin:Dependencies:Priority');
758  $strings['expected_value'] = elgg_echo("ElggPlugin:Dependencies:Priority:$expected_priority", array($info['plugin']));
759  $strings['local_value'] = elgg_echo("ElggPlugin:Dependencies:Priority:$real_priority", array($info['plugin']));
760  $strings['comment'] = '';
761  break;
762  }
763 
764  if ($dep['type'] == 'suggests') {
765  if ($dep['status']) {
766  $strings['comment'] = elgg_echo('ok');
767  } else {
768  $strings['comment'] = elgg_echo('ElggPlugin:Dependencies:Suggests:Unsatisfied');
769  }
770  } else {
771  if ($dep['status']) {
772  $strings['comment'] = elgg_echo('ok');
773  } else {
774  $strings['comment'] = elgg_echo('error');
775  }
776  }
777 
778  return $strings;
779 }
780 
790  elgg_deprecated_notice("elgg_get_calling_plugin_entity() is deprecated.", 1.9);
792 
793  if ($plugin_id) {
795  }
796 
797  return false;
798 }
799 
811 function elgg_get_all_plugin_user_settings($user_guid = 0, $plugin_id = null, $return_obj = false) {
812  if ($plugin_id) {
814  } else {
815  elgg_deprecated_notice('elgg_get_all_plugin_user_settings() requires plugin_id to be set', 1.9);
817  }
818 
819  if (!$plugin instanceof ElggPlugin) {
820  return false;
821  }
822 
823  $settings = $plugin->getAllUserSettings((int)$user_guid);
824 
825  if ($settings && $return_obj) {
826  $return = new stdClass;
827 
828  foreach ($settings as $k => $v) {
829  $return->$k = $v;
830  }
831 
832  return $return;
833  } else {
834  return $settings;
835  }
836 }
837 
851  if ($plugin_id) {
853  } else {
854  elgg_deprecated_notice('elgg_set_plugin_user_setting() requires plugin_id to be set', 1.9);
856  }
857 
858  if (!$plugin) {
859  return false;
860  }
861 
862  return $plugin->setUserSetting($name, $value, (int)$user_guid);
863 }
864 
877  if ($plugin_id) {
879  } else {
880  elgg_deprecated_notice('elgg_unset_plugin_user_setting() requires plugin_id to be set', 1.9);
882  }
883 
884  if (!$plugin) {
885  return false;
886  }
887 
888  return $plugin->unsetUserSetting($name, (int)$user_guid);
889 }
890 
903  if ($plugin_id) {
905  } else {
906  elgg_deprecated_notice('elgg_get_plugin_user_setting() requires plugin_id to be set', 1.9);
908  }
909 
910  if (!$plugin) {
911  return false;
912  }
913 
914  return $plugin->getUserSetting($name, (int)$user_guid);
915 }
916 
929  if ($plugin_id) {
931  } else {
932  elgg_deprecated_notice('elgg_set_plugin_setting() requires plugin_id to be set', 1.9);
934  }
935 
936  if (!$plugin) {
937  return false;
938  }
939 
940  return $plugin->setSetting($name, $value);
941 }
942 
955  if ($plugin_id) {
957  } else {
958  elgg_deprecated_notice('elgg_get_plugin_setting() requires plugin_id to be set', 1.9);
960  }
961 
962  if (!$plugin) {
963  return false;
964  }
965 
966  return $plugin->getSetting($name, $default);
967 }
968 
980  if ($plugin_id) {
982  } else {
983  elgg_deprecated_notice('elgg_unset_plugin_setting() requires plugin_id to be set', 1.9);
985  }
986 
987  if (!$plugin) {
988  return false;
989  }
990 
991  return $plugin->unsetSetting($name);
992 }
993 
1004  if ($plugin_id) {
1006  } else {
1007  elgg_deprecated_notice('elgg_unset_all_plugin_settings() requires plugin_id to be set', 1.9);
1009  }
1010 
1011  if (!$plugin) {
1012  return false;
1013  }
1014 
1015  return $plugin->unsetAllSettings();
1016 }
1017 
1047  if (!isset($options['plugin_id'])) {
1048  elgg_deprecated_notice("'plugin_id' is now required for elgg_get_entities_from_plugin_user_settings()", 1.9);
1049  $options['plugin_id'] = elgg_get_calling_plugin_id();
1050  }
1051 
1052  $singulars = array('plugin_user_setting_name', 'plugin_user_setting_value',
1053  'plugin_user_setting_name_value_pair');
1054 
1056 
1057  // rewrite plugin_user_setting_name_* to the right PS ones.
1058  $map = array(
1059  'plugin_user_setting_names' => 'private_setting_names',
1060  'plugin_user_setting_values' => 'private_setting_values',
1061  'plugin_user_setting_name_value_pairs' => 'private_setting_name_value_pairs',
1062  'plugin_user_setting_name_value_pairs_operator' => 'private_setting_name_value_pairs_operator',
1063  );
1064 
1065  foreach ($map as $plugin => $private) {
1066  if (!isset($options[$plugin])) {
1067  continue;
1068  }
1069 
1070  if (isset($options[$private])) {
1071  if (!is_array($options[$private])) {
1072  $options[$private] = array($options[$private]);
1073  }
1074 
1075  $options[$private] = array_merge($options[$private], $options[$plugin]);
1076  } else {
1077  $options[$private] = $options[$plugin];
1078  }
1079  }
1080 
1081  $prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $options['plugin_id']);
1082  $options['private_setting_name_prefix'] = $prefix;
1083 
1085 }
1086 
1099  global $CONFIG;
1100  $value[] = $CONFIG->path . 'engine/tests/ElggCorePluginsAPITest.php';
1101  return $value;
1102 }
1103 
1115  $plugin_id = $params['plugin_entity']->getManifest()->getPluginID();
1116  $plugin_name = $params['plugin_entity']->getManifest()->getName();
1117 
1118  $active_plugins = elgg_get_plugins();
1119 
1120  $dependents = array();
1121  foreach ($active_plugins as $plugin) {
1122  $manifest = $plugin->getManifest();
1123  $requires = $manifest->getRequires();
1124 
1125  foreach ($requires as $required) {
1126  if ($required['type'] == 'plugin' && $required['name'] == $plugin_id) {
1127  // there are active dependents
1128  $dependents[$manifest->getPluginID()] = $plugin;
1129  }
1130  }
1131  }
1132 
1133  if ($dependents) {
1134  $list = '<ul>';
1135  // construct error message and prevent disabling
1136  foreach ($dependents as $dependent) {
1137  $list .= '<li>' . $dependent->getManifest()->getName() . '</li>';
1138  }
1139  $list .= '</ul>';
1140 
1141  register_error(elgg_echo('ElggPlugin:Dependencies:ActiveDependent', array($plugin_name, $list)));
1142 
1143  return false;
1144  }
1145 }
1146 
1154 
1155  if (elgg_is_admin_logged_in()) {
1156  elgg_register_ajax_view('object/plugin/full');
1157  }
1158 
1159  elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_plugins_test');
1160 
1161  // note - plugins are booted by the time this handler is registered
1162  // deactivation due to error may have already occurred
1163  elgg_register_event_handler('deactivate', 'plugin', '_plugins_deactivate_dependency_check');
1164 
1165  elgg_register_action("plugins/settings/save", '', 'admin');
1166  elgg_register_action("plugins/usersettings/save");
1167 
1168  elgg_register_action('admin/plugins/activate', '', 'admin');
1169  elgg_register_action('admin/plugins/deactivate', '', 'admin');
1170  elgg_register_action('admin/plugins/activate_all', '', 'admin');
1171  elgg_register_action('admin/plugins/deactivate_all', '', 'admin');
1172 
1173  elgg_register_action('admin/plugins/set_priority', '', 'admin');
1174 
1175  elgg_register_library('elgg:markdown', elgg_get_root_path() . 'vendors/markdown/markdown.php');
1176 }
1177 
1178 elgg_register_event_handler('init', 'system', '_elgg_plugins_init');
_elgg_get_plugins_provides($type=null, $name=null)
Returns an array of all provides from all active plugins.
Definition: plugins.php:560
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_entities_from_plugin_user_settings(array $options=array())
Returns entities based upon plugin user settings.
Definition: plugins.php:1046
elgg_get_site_entity($site_guid=0)
Get an ElggSite entity (default is current site)
Definition: sites.php:18
getID()
Returns the ID (dir name) of this plugin.
Definition: ElggPlugin.php:120
$plugin
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:65
elgg_set_plugin_setting($name, $value, $plugin_id=null)
Set a setting for a plugin.
Definition: plugins.php:928
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
_elgg_check_plugins_provides($type, $name, $version=null, $comparison= 'ge')
Checks if a plugin is currently providing $type and $name, and optionally checking a version...
Definition: plugins.php:632
elgg_get_all_plugin_user_settings($user_guid=0, $plugin_id=null, $return_obj=false)
Returns an array of all plugin user settings for a user.
Definition: plugins.php:811
$e
Definition: metadata.php:12
get_subtype_id($type, $subtype)
Return the id for a given subtype.
Definition: entities.php:166
const ELGG_ENTITIES_NO_VALUE
Definition: elgglib.php:2143
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
$return
Definition: opendd.php:15
$default
Definition: checkbox.php:36
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells ElggPlugin::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:1464
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Register a callback as a plugin hook handler.
Definition: elgglib.php:853
elgg_get_plugin_user_setting($name, $user_guid=0, $plugin_id=null)
Get a user specific setting for a plugin.
Definition: plugins.php:902
_elgg_load_plugins()
Loads all active plugins in the order specified in the tool admin panel.
Definition: plugins.php:316
sanitize_string($string)
Sanitize a string for database use.
Definition: database.php:140
$params
Definition: login.php:72
$options
Definition: index.php:14
_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:512
elgg_unset_all_plugin_settings($plugin_id=null)
Unsets all plugin settings for a plugin.
Definition: plugins.php:1003
$plugins
const ELGG_PLUGIN_USER_SETTING_PREFIX
Prefix for plugin setting names.
Definition: plugins.php:41
_plugins_deactivate_dependency_check($event, $type, $params)
Checks on deactivate plugin event if disabling it won&#39;t create unmet dependencies and blocks disable ...
Definition: plugins.php:1114
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
_elgg_get_plugin_dependency_strings($dep)
Returns an array of parsed strings for a dependency in the format: array( &#39;type&#39; => requires...
Definition: plugins.php:668
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
global $CONFIG
const ELGG_PLUGIN_INCLUDE_START
Tells ElggPlugin::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:273
elgg_set_plugin_user_setting($name, $value, $user_guid=0, $plugin_id=null)
Set a user specific setting for a plugin.
Definition: plugins.php:850
const ELGG_PLUGIN_REGISTER_VIEWS
Tells ElggPlugin::start() to automatically register the plugin&#39;s views.
Definition: plugins.php:18
elgg_get_root_path()
Get the root directory path for this installation.
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
Definition: entities.php:777
_elgg_get_max_plugin_priority()
Returns the highest priority of the plugins.
Definition: plugins.php:255
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:1171
elgg global
Pointer to the global context.
Definition: elgglib.js:12
$type
Definition: add.php:8
_elgg_cache_plugin_by_id(ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
Definition: plugins.php:191
elgg_register_library($name, $location)
Register a php library.
Definition: elgglib.php:19
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:299
elgg system_message
Wrapper function for system_messages.
Definition: elgglib.js:374
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
Definition: elgglib.php:669
elgg_get_calling_plugin_entity()
Returns the ElggPlugin entity of the last plugin called.
Definition: plugins.php:789
elgg_plugin_exists($id)
Returns if a plugin exists in the system.
Definition: plugins.php:242
_elgg_plugins_init()
Initialize the plugin system.
Definition: plugins.php:1153
elgg_unset_plugin_user_setting($name, $user_guid=0, $plugin_id=null)
Unsets a user-specific plugin setting.
Definition: plugins.php:876
_elgg_plugins_test($hook, $type, $value, $params)
Runs unit tests for plugin API.
Definition: plugins.php:1098
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:372
elgg_unset_plugin_setting($name, $plugin_id=null)
Unsets a plugin setting.
Definition: plugins.php:979
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
Definition: access.php:286
_elgg_set_plugin_priorities(array $order)
Reorder plugins to an order specified by the array.
Definition: plugins.php:435
elgg register_error
Wrapper function for system_messages.
Definition: elgglib.js:383
elgg_get_plugin_setting($name, $plugin_id=null, $default=null)
Get setting for a plugin.
Definition: plugins.php:954
elgg_register_ajax_view($view)
Register a view to be available for ajax calls.
Definition: views.php:208
_elgg_reindex_plugin_priorities()
Reindexes all plugin priorities starting at 1.
Definition: plugins.php:493
elgg_is_active_plugin($plugin_id, $site_guid=null)
Returns if a plugin is active for a current site.
Definition: plugins.php:285
global $ELGG_PLUGINS_PROVIDES_CACHE
Definition: plugins.php:539
const ELGG_PLUGIN_REGISTER_CLASSES
Tells ElggPlugin::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_invalidate_plugins_provides_cache()
Deletes all cached data on plugins being provided.
Definition: plugins.php:610
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
Definition: actions.php:85
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:1594
_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
if(!$collection_name) $id
Definition: add.php:17
$settings
$version
Definition: version.php:14
A Site entity.
Definition: ElggSite.php:28
if(!$num_display) $db_prefix
Definition: content.php:12
$priority
_elgg_generate_plugin_entities()
Discovers plugins in the plugins_path setting and creates ElggPlugin entities for them if they don&#39;t ...
Definition: plugins.php:93
elgg_get_plugin_from_id($plugin_id)
Returns an ElggPlugin object with the path $path.
Definition: plugins.php:204
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:604
if(!($plugin instanceof ElggPlugin)) $plugin_name
Definition: save.php:24