deactivate.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Deactivate a plugin or plugins.
  4. *
  5. * Plugins to be deactivated are passed via $_REQUEST['plugin_guids'] as GUIDs.
  6. * After deactivating the plugin(s), the views cache and simplecache are invalidated.
  7. *
  8. * @uses mixed $_GET['plugin_guids'] The GUIDs of the plugin to deactivate. Can be an array.
  9. *
  10. * @package Elgg.Core
  11. * @subpackage Administration.Plugins
  12. */
  13. $plugin_guids = get_input('plugin_guids');
  14. if (!is_array($plugin_guids)) {
  15. $plugin_guids = array($plugin_guids);
  16. }
  17. foreach ($plugin_guids as $guid) {
  18. $plugin = get_entity($guid);
  19. if (!($plugin instanceof ElggPlugin)) {
  20. register_error(elgg_echo('admin:plugins:deactivate:no', array($guid)));
  21. continue;
  22. }
  23. if ($plugin->deactivate()) {
  24. //system_message(elgg_echo('admin:plugins:deactivate:yes', array($plugin->getManifest()->getName())));
  25. } else {
  26. $msg = $plugin->getError();
  27. $string = ($msg) ? 'admin:plugins:deactivate:no_with_msg' : 'admin:plugins:deactivate:no';
  28. register_error(elgg_echo($string, array($plugin->getFriendlyName(), $plugin->getError())));
  29. }
  30. }
  31. // don't regenerate the simplecache because the plugin won't be
  32. // loaded until next run. Just invalidate and let it regnerate as needed
  33. elgg_flush_caches();
  34. if (count($plugin_guids) == 1) {
  35. $url = 'admin/plugins';
  36. $query = (string)parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY);
  37. if ($query) {
  38. $url .= "?$query";
  39. }
  40. $plugin = get_entity($plugin_guids[0]);
  41. $id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID());
  42. forward("$url#$id");
  43. } else {
  44. forward(REFERER);
  45. }