activate_all.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Activates all specified installed and inactive plugins.
  4. *
  5. * All specified plugins in the mod/ directory that aren't active are activated and the views
  6. * cache and simplecache are invalidated.
  7. *
  8. * @package Elgg.Core
  9. * @subpackage Administration.Plugins
  10. */
  11. $guids = get_input('guids');
  12. $guids = explode(',', $guids);
  13. $plugins = array();
  14. foreach ($guids as $guid) {
  15. $plugin = get_entity($guid);
  16. if (!$plugin->isActive()) {
  17. $plugins[$plugin->getId()] = $plugin;
  18. }
  19. }
  20. do {
  21. $additional_plugins_activated = false;
  22. foreach ($plugins as $key => $plugin) {
  23. if ($plugin->activate()) {
  24. $ids = array(
  25. 'cannot_start' . $plugin->getID(),
  26. 'invalid_and_deactivated_' . $plugin->getID()
  27. );
  28. foreach ($ids as $id) {
  29. elgg_delete_admin_notice($id);
  30. }
  31. $additional_plugins_activated = true;
  32. unset($plugins[$key]);
  33. }
  34. }
  35. if (!$additional_plugins_activated) {
  36. // no updates in this pass, break the loop
  37. break;
  38. }
  39. } while (count($plugins) > 0);
  40. if (count($plugins) > 0) {
  41. foreach ($plugins as $key => $plugin) {
  42. $msg = $plugin->getError();
  43. $string = ($msg) ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
  44. register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
  45. }
  46. }
  47. // don't regenerate the simplecache because the plugin won't be
  48. // loaded until next run. Just invalidate and let it regnerate as needed
  49. elgg_flush_caches();
  50. forward(REFERER);