PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/class.nextgen_product_installer.php

https://github.com/Fishgate/privatecollectionswp
PHP | 59 lines | 46 code | 8 blank | 5 comment | 10 complexity | a8ad9f4bef75648e3caf879e27434ac0 MD5 | raw file
  1. <?php
  2. class C_NextGen_Product_Installer
  3. {
  4. function _filter_modules($pope_modules_list, $product)
  5. {
  6. foreach ($product as $module_name) {
  7. $module = C_Component_Registry::get_instance()->get_module($module_name);
  8. $str = $module->module_id . '|' . $module->module_version;
  9. $search = array_search($str, $pope_modules_list);
  10. if (FALSE !== $search)
  11. unset($pope_modules_list[$search]);
  12. }
  13. return $pope_modules_list;
  14. }
  15. function uninstall($hard)
  16. {
  17. // remove this products modules from the pope_module_list registry
  18. $pope_modules_list = get_option('pope_module_list', array());
  19. $pope_modules_list = $this->_filter_modules($pope_modules_list, P_Photocrati_NextGen::$modules);
  20. // run each modules respective uninstall routines
  21. foreach (P_Photocrati_NextGen::$modules as $module_name) {
  22. if (($handler = C_Photocrati_Installer::get_handler_instance($module_name))) {
  23. if (method_exists($handler, 'uninstall')) $handler->uninstall($hard);
  24. }
  25. }
  26. // lastly remove this product itself from the pope_module_list registry
  27. $search = array_search('photocrati-nextgen|' . NGG_PLUGIN_VERSION, $pope_modules_list);
  28. if (FALSE !== $search)
  29. unset($pope_modules_list[$search]);
  30. // TODO: remove this. NextGen Pro's uninstall routine will be updated in a separate release,
  31. // so to maintain proper support we run the same routine as above for it
  32. $pro_version = FALSE;
  33. if (defined('NGG_PRO_PLUGIN_VERSION'))
  34. $pro_version = 'NGG_PRO_PLUGIN_VERSION';
  35. if (defined('NEXTGEN_GALLERY_PRO_VERSION'))
  36. $pro_version = 'NEXTGEN_GALLERY_PRO_VERSION';
  37. if (FALSE !== $pro_version)
  38. $pro_version = constant($pro_version);
  39. if (FALSE !== $pro_version)
  40. {
  41. $pope_modules_list = $this->_filter_modules($pope_modules_list, P_Photocrati_NextGen_Pro::$modules);
  42. $search = array_search('photocrati-nextgen-pro|' . $pro_version, $pope_modules_list);
  43. if (FALSE !== $search)
  44. unset($pope_modules_list[$search]);
  45. }
  46. if (empty($pope_modules_list))
  47. delete_option('pope_module_list');
  48. else
  49. update_option('pope_module_list', $pope_modules_list);
  50. }
  51. }