BxDolInstallerUtils.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Dolphin Core
  7. * @{
  8. */
  9. bx_import('BxDolIO');
  10. class BxDolInstallerUtils extends BxDolIO
  11. {
  12. function __construct()
  13. {
  14. parent::__construct();
  15. }
  16. static public function isXsltEnabled()
  17. {
  18. if (((int)phpversion()) >= 5) {
  19. if (class_exists ('DOMDocument') && class_exists ('XsltProcessor'))
  20. return true;
  21. } else {
  22. if (function_exists('domxml_xslt_stylesheet_file'))
  23. return true;
  24. elseif (function_exists ('xslt_create'))
  25. return true;
  26. }
  27. return false;
  28. }
  29. static public function isAllowUrlInclude()
  30. {
  31. if (version_compare(phpversion(), "5.2", ">") == 1) {
  32. $sAllowUrlInclude = ini_get('allow_url_include');
  33. return !($sAllowUrlInclude == 0);
  34. };
  35. return false;
  36. }
  37. static public function isModuleInstalled($sUri)
  38. {
  39. bx_import('BxDolModuleQuery');
  40. return BxDolModuleQuery::getInstance()->isModule($sUri);
  41. }
  42. /**
  43. * Set module for delayed uninstall
  44. */
  45. static public function setModulePendingUninstall($sUri, $bPendingUninstall = true)
  46. {
  47. bx_import('BxDolModuleQuery');
  48. return BxDolModuleQuery::getInstance()->setModulePendingUninstall($sUri, $bPendingUninstall);
  49. }
  50. /**
  51. * Check if module is pending for uninstall
  52. */
  53. static public function isModulePendingUninstall($sUri)
  54. {
  55. bx_import('BxDolModuleQuery');
  56. $a = BxDolModuleQuery::getInstance()->getModuleByUri($sUri);
  57. return $a['pending_uninstall'];
  58. }
  59. /**
  60. * Check all pending for uninstallation modules and uninstall them if no pending for deletion files are found
  61. */
  62. static public function checkModulesPendingUninstall()
  63. {
  64. bx_import('BxDolModuleQuery');
  65. $a = BxDolModuleQuery::getInstance()->getModules();
  66. foreach ($a as $aModule) {
  67. // after we make sure that all pending for deletion files are deleted
  68. if (!$aModule['pending_uninstall'] || BxDolStorage::isQueuedFilesForDeletion($aModule['name']))
  69. continue;
  70. // remove pending uninstall flag
  71. self::setModulePendingUninstall($aModule['uri'], false);
  72. // perform uninstallation
  73. bx_import('BxDolStudioInstallerUtils');
  74. $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall');
  75. // send email nofitication
  76. $aTemplateKeys = array(
  77. 'Module' => $aModule['title'],
  78. 'Result' => _t('_Success'),
  79. 'Message' => '',
  80. );
  81. if ($aResult['code'] > 0) {
  82. $aTemplateKeys['Result'] = _t('_Failed');
  83. $aTemplateKeys['Message'] = $aResult['message'];
  84. }
  85. bx_import('BxDolEmailTemplates');
  86. $aMessage = BxDolEmailTemplates::getInstance()->parseTemplate('t_DelayedModuleUninstall', $aTemplateKeys);
  87. sendMail (getParam('site_email'), $aMessage['Subject'], $aMessage['Body'], 0, array(), BX_EMAIL_SYSTEM);
  88. }
  89. }
  90. }
  91. /** @} */