BxDolStudioInstallerUtils.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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 DolphinStudio Dolphin Studio
  7. * @{
  8. */
  9. bx_import('BxDolLanguages');
  10. bx_import('BxDolInstallerUtils');
  11. define('BX_DOL_UNITY_URL_ROOT', 'http://www.boonex.com/');
  12. define('BX_DOL_UNITY_URL_MARKET', BX_DOL_UNITY_URL_ROOT . 'market/');
  13. define('BX_DOL_STUDIO_IU_RC_SUCCESS', 0);
  14. define('BX_DOL_STUDIO_IU_RC_FAILED', 1);
  15. define('BX_DOL_STUDIO_IU_RC_SCHEDULED', 2);
  16. class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSingleton
  17. {
  18. protected $bUseFtp;
  19. protected $sAuthorizedAccessClass;
  20. public function __construct()
  21. {
  22. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  23. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  24. parent::__construct();
  25. $this->bUseFtp = BX_FORCE_USE_FTP_FILE_TRANSFER;
  26. $this->sAuthorizedAccessClass = 'BxDolStudioOAuthPlugin';
  27. }
  28. /**
  29. * Prevent cloning the instance
  30. */
  31. public function __clone()
  32. {
  33. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  34. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  35. }
  36. /**
  37. * Get singleton instance of the class
  38. */
  39. public static function getInstance()
  40. {
  41. if (!isset($GLOBALS['bxDolClasses'][__CLASS__]))
  42. $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolStudioInstallerUtils();
  43. return $GLOBALS['bxDolClasses'][__CLASS__];
  44. }
  45. public static function getNamePerformAction($sParam)
  46. {
  47. return 'sys_perform_action_' . md5($sParam);
  48. }
  49. public static function getNameDownloadFile($sParam)
  50. {
  51. return 'sys_download_file_complete_' . $sParam;
  52. }
  53. public static function getNamePerformModulesUpgrade()
  54. {
  55. return 'sys_upgrade_modules_transient';
  56. }
  57. /*
  58. * Is used to complete Downloading inside Transient Cron Job.
  59. */
  60. public function serviceDownloadFileComplete($sFilePath, $aParams = array())
  61. {
  62. return $this->downloadFileComplete($sFilePath, array_merge($aParams, array('transient' => true)));
  63. }
  64. /*
  65. * Is used to perform action inside Transient Cron Job.
  66. */
  67. public function servicePerformAction($sDirectory, $sOperation, $aParams)
  68. {
  69. return $this->perform($sDirectory, $sOperation, array_merge($aParams, array('transient' => true)));
  70. }
  71. /*
  72. * Is used to perform modules upgrade inside Transient Cron Job.
  73. */
  74. public function servicePerformModulesUpgrade($bEmailNotify)
  75. {
  76. return $this->performModulesUpgrade(true, $bEmailNotify);
  77. }
  78. public function getAccessObject($bAuthorizedAccess)
  79. {
  80. $sClass = $bAuthorizedAccess ? $this->sAuthorizedAccessClass : 'BxDolStudioJson';
  81. bx_import($sClass);
  82. return $sClass::getInstance();
  83. }
  84. public function getModules($bTitleAsKey = true)
  85. {
  86. $aModules = array();
  87. $oTemplate = BxDolStudioTemplate::getInstance();
  88. $aInstalledInfo = $this->getInstalledInfo();
  89. $sPath = BX_DIRECTORY_PATH_MODULES;
  90. if(($rHandleVendor = opendir($sPath)) !== false) {
  91. while(($sVendor = readdir($rHandleVendor)) !== false) {
  92. if(substr($sVendor, 0, 1) == '.' || !is_dir($sPath . $sVendor))
  93. continue;
  94. if(($rHandleModule = opendir($sPath . $sVendor)) !== false) {
  95. while(($sModule = readdir($rHandleModule)) !== false) {
  96. if(!is_dir($sPath . $sVendor . '/' . $sModule) || substr($sModule, 0, 1) == '.')
  97. continue;
  98. $sModulePath = $sVendor . '/' . $sModule . '/';
  99. $aModule = $this->getConfigModule($sPath . $sModulePath . 'install/config.php', !empty($aInstalledInfo[$sModulePath]) ? $aInstalledInfo[$sModulePath] : array());
  100. if(empty($aModule))
  101. continue;
  102. $aModules[$bTitleAsKey ? $aModule['title'] : $aModule['name']] = $aModule;
  103. }
  104. closedir($rHandleModule);
  105. }
  106. }
  107. closedir($rHandleVendor);
  108. }
  109. ksort($aModules);
  110. return $aModules;
  111. }
  112. public function getUpdates()
  113. {
  114. $aUpdates = array();
  115. bx_import('BxDolStudioTemplate');
  116. $oTemplate = BxDolStudioTemplate::getInstance();
  117. $aInstalledInfo = $this->getInstalledInfo();
  118. $sPath = BX_DIRECTORY_PATH_MODULES;
  119. if(($rHandleVendor = opendir($sPath)) !== false) {
  120. while(($sVendor = readdir($rHandleVendor)) !== false) {
  121. if(substr($sVendor, 0, 1) == '.' || !is_dir($sPath . $sVendor))
  122. continue;
  123. if(($rHandleModule = opendir($sPath . $sVendor . '/')) !== false) {
  124. while(($sModule = readdir($rHandleModule)) !== false) {
  125. if(!is_dir($sPath . $sVendor . '/' . $sModule) || substr($sModule, 0, 1) == '.')
  126. continue;
  127. $sModulePath = $sVendor . '/' . $sModule . '/';
  128. if(empty($aInstalledInfo[$sModulePath]))
  129. continue;
  130. $aUpdate = $this->getUpdate($aInstalledInfo[$sModulePath]);
  131. if(!empty($aUpdate))
  132. $aUpdates[$aUpdate['title']] = $aUpdate;
  133. }
  134. closedir($rHandleModule);
  135. }
  136. }
  137. closedir($rHandleVendor);
  138. }
  139. ksort($aUpdates);
  140. return $aUpdates;
  141. }
  142. public function getUpdate($mixedModule)
  143. {
  144. $aResult = array();
  145. if(!is_array($mixedModule)) {
  146. bx_import('BxDolModuleQuery');
  147. $mixedModule = BxDolModuleQuery::getInstance()->{is_numeric($mixedModule) ? 'getModuleById' : 'getModuleByName'}($mixedModule);
  148. }
  149. if(empty($mixedModule) || !is_array($mixedModule))
  150. return $aResult;
  151. $sPathModule = BX_DIRECTORY_PATH_MODULES . $mixedModule['path'];
  152. $sPathUpdates = $sPathModule . 'updates/';
  153. $rHandleUpdate = @opendir($sPathUpdates);
  154. if($rHandleUpdate === false)
  155. return $aResult;
  156. while(($sUpdate = readdir($rHandleUpdate)) !== false) {
  157. $sPathUpdate = $sPathUpdates . $sUpdate . '/';
  158. if(substr($sUpdate, 0, 1) == '.' || !is_dir($sPathUpdate))
  159. continue;
  160. $aUpdate = $this->getConfigUpdate($sPathModule . 'install/config.php', $sPathUpdate . 'install/config.php', $mixedModule);
  161. if(empty($aUpdate) || !is_array($aUpdate) || version_compare($aUpdate['module_version'], $aUpdate['version_from']) != 0)
  162. continue;
  163. $aResult = $aUpdate;
  164. break;
  165. }
  166. closedir($rHandleUpdate);
  167. return $aResult;
  168. }
  169. public function perform($sDirectory, $sOperation, $aParams = array())
  170. {
  171. $bTransient = false;
  172. if(isset($aParams['transient']) && $aParams['transient'] === true) {
  173. $bTransient = true;
  174. unset($aParams['transient']);
  175. }
  176. if(!defined('BX_DOL_CRON_EXECUTE') && !self::isRealOwner() && !in_array($sOperation, array('install', 'uninstall', 'enable', 'disable'))) {
  177. if($this->addTransientJob(self::getNamePerformAction($sDirectory), 'perform_action', array($sDirectory, $sOperation, $aParams)))
  178. return array('code' => BX_DOL_STUDIO_IU_RC_SCHEDULED, 'message' => _t('_adm_mod_msg_process_operation_scheduled'));
  179. else
  180. return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => _t('_adm_mod_err_process_operation_failed', $sOperation, $sDirectory));
  181. }
  182. $sConfigFile = 'install/config.php';
  183. $sInstallerFile = 'install/installer.php';
  184. $sInstallerClass = $sOperation == 'update' ? 'Updater' : 'Installer';
  185. $aConfig = self::getModuleConfig(BX_DIRECTORY_PATH_MODULES . $sDirectory . $sConfigFile);
  186. $sPathInstaller = BX_DIRECTORY_PATH_MODULES . $sDirectory . $sInstallerFile;
  187. if(empty($aConfig) || !file_exists($sPathInstaller)) {
  188. $sMessage = _t('_adm_mod_err_process_operation_failed', $sOperation, $sDirectory);
  189. if($bTransient)
  190. $this->emailNotify($sMessage);
  191. return array('code' => BX_DOL_STUDIO_IU_RC_FAILED, 'message' => $sMessage);
  192. }
  193. require_once($sPathInstaller);
  194. $sClassName = $aConfig['class_prefix'] . $sInstallerClass;
  195. $oInstaller = new $sClassName($aConfig);
  196. $aResult = $oInstaller->$sOperation($aParams);
  197. if(!$aResult['result'] && $bTransient)
  198. $this->emailNotify($aResult['message']);
  199. return array('code' => $aResult['result'] ? BX_DOL_STUDIO_IU_RC_SUCCESS : BX_DOL_STUDIO_IU_RC_FAILED, 'message' => $aResult['message']);
  200. }
  201. public function performModulesUpgrade($bDirectly = true, $bEmailNotify = true)
  202. {
  203. if(!defined('BX_DOL_CRON_EXECUTE') && !$bDirectly)
  204. return $this->addTransientJob(self::getNamePerformModulesUpgrade(), 'perform_modules_upgrade', array($bEmailNotify));
  205. $iUmaskSave = umask(0);
  206. $aFailed = array();
  207. $aUpdates = $this->checkUpdates();
  208. foreach($aUpdates as $aUpdate) {
  209. $mixedResult = $this->downloadUpdatePublic($aUpdate['name']);
  210. if($mixedResult !== true) {
  211. $aFailed[$aUpdate['name']] = $mixedResult;
  212. continue;
  213. }
  214. }
  215. umask($iUmaskSave);
  216. $aSuccess = array();
  217. $aUpdates = $this->getUpdates();
  218. foreach($aUpdates as $aUpdate) {
  219. $aResult = $this->perform($aUpdate['dir'], 'update');
  220. if((int)$aResult['code'] != 0) {
  221. $aFailed[$aUpdate['module_name']] = $aResult['message'];
  222. continue;
  223. }
  224. $aSuccess[$aUpdate['module_name']] = $aUpdate['version_to'];
  225. }
  226. if($bEmailNotify && !empty($aSuccess))
  227. $this->emailNotifyModulesUpgrade('success', $aSuccess);
  228. if($bEmailNotify && !empty($aFailed))
  229. $this->emailNotifyModulesUpgrade('failed', $aFailed);
  230. return empty($aFailed);
  231. }
  232. public function checkModules($bAuthorizedAccess = false)
  233. {
  234. if($bAuthorizedAccess)
  235. $aProducts = $this->getAccessObject(true)->loadItems(array('dol_type' => 'purchased_products', 'dol_domain' => BX_DOL_URL_ROOT));
  236. else
  237. $aProducts = $this->getAccessObject(false)->load(BX_DOL_UNITY_URL_MARKET . 'json_browse_purchased', array('key' => getParam('sys_oauth_key')));
  238. bx_import('BxDolModuleQuery');
  239. $oModuleDb = BxDolModuleQuery::getInstance();
  240. $oModuleDb->updateModule(array('hash' => ''));
  241. if(!empty($aProducts) && is_array($aProducts))
  242. foreach ($aProducts as $aProduct)
  243. $oModuleDb->updateModule(array('hash' => $aProduct['hash']), array('name' => $aProduct['name']));
  244. return $aProducts;
  245. }
  246. public function checkUpdates($bAuthorizedAccess = false)
  247. {
  248. bx_import('BxDolModuleQuery');
  249. $aModules = BxDolModuleQuery::getInstance()->getModules();
  250. $aProducts = array();
  251. foreach($aModules as $aModule) {
  252. if(empty($aModule['name']))
  253. continue;
  254. $aProducts[] = array(
  255. 'name' => $aModule['name'],
  256. 'version' => $aModule['version'],
  257. 'hash' => $aModule['hash'],
  258. );
  259. }
  260. $sProducts = base64_encode(serialize($aProducts));
  261. if($bAuthorizedAccess)
  262. return $this->getAccessObject(true)->loadItems(array('dol_type' => 'available_updates', 'dol_products' => $sProducts));
  263. return $this->getAccessObject(false)->load(BX_DOL_UNITY_URL_MARKET . 'json_browse_updates', array(
  264. 'key' => getParam('sys_oauth_key'),
  265. 'products' => $sProducts
  266. ));
  267. }
  268. public function downloadFileAuthorized($iFileId)
  269. {
  270. $aItem = $this->getAccessObject(true)->loadItems(array('dol_type' => 'product_file', 'dol_file_id' => $iFileId));
  271. return $this->downloadFileInit($aItem, array('module_name' => $aItem['module_name']));
  272. }
  273. public function downloadUpdatePublic($sModuleName, $bAutoUpdate = false)
  274. {
  275. bx_import('BxDolModuleQuery');
  276. $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sModuleName);
  277. $aItem = $this->getAccessObject(false)->load(BX_DOL_UNITY_URL_MARKET . 'json_download_update', array(
  278. 'key' => getParam('sys_oauth_key'),
  279. 'product' => base64_encode(serialize(array(
  280. 'name' => $aModule['name'],
  281. 'version' => $aModule['version'],
  282. 'hash' => $aModule['hash'],
  283. ))),
  284. ));
  285. return $this->downloadFileInit($aItem, array('module_name' => $sModuleName, 'auto_action' => $bAutoUpdate ? 'update' : ''));
  286. }
  287. protected function downloadFileInit($aItem, $aParams = array())
  288. {
  289. if(empty($aItem) || !is_array($aItem))
  290. return $aItem;
  291. //--- write ZIP archive.
  292. $sFilePath = '';
  293. $mixedResult = $this->performWrite($aItem, $sFilePath);
  294. if($mixedResult !== true)
  295. return $mixedResult;
  296. return $this->downloadFileComplete($sFilePath, $aParams);
  297. }
  298. protected function downloadFileComplete($sFilePath, $aParams = array())
  299. {
  300. $bTransient = false;
  301. if(isset($aParams['transient']) && $aParams['transient'] === true) {
  302. $bTransient = true;
  303. unset($aParams['transient']);
  304. }
  305. $sAutoAction = isset($aParams['auto_action']) ? $aParams['auto_action'] : '';
  306. $bAutoAction = !empty($sAutoAction);
  307. if(!defined('BX_DOL_CRON_EXECUTE') && !self::isRealOwner()) {
  308. if(!$this->addTransientJob(self::getNameDownloadFile($aParams['module_name']), 'download_file_complete', array($sFilePath, $aParams)))
  309. return _t('_adm_str_err_download_failed');
  310. return array('code' => BX_DOL_STUDIO_IU_RC_SCHEDULED, 'message' => _t('_adm_str_msg_download' . ($bAutoAction ? '_and_install' : '') . '_scheduled'));
  311. }
  312. //--- Unarchive package.
  313. $sPackagePath = '';
  314. $mixedResult = $this->performUnarchive($sFilePath, $sPackagePath);
  315. @unlink($sFilePath);
  316. if($mixedResult !== true) {
  317. if($bTransient)
  318. $this->emailNotify($mixedResult);
  319. return $mixedResult;
  320. }
  321. //--- Copy unarchived package.
  322. $sHomePath = '';
  323. $mixedResult = $this->performCopy($sPackagePath, $sHomePath);
  324. @bx_rrmdir($sPackagePath);
  325. if($mixedResult !== true) {
  326. if($bTransient)
  327. $this->emailNotify($mixedResult);
  328. return $mixedResult;
  329. }
  330. if(!$bAutoAction)
  331. return true;
  332. //--- Autoinstall the downloaded package if it's needed.
  333. $aResult = $this->perform($sHomePath, $sAutoAction, $aParams);
  334. if((int)$aResult['code'] != 0) {
  335. if($bTransient)
  336. $this->emailNotify($aResult['message']);
  337. return $aResult['message'];
  338. }
  339. return true;
  340. }
  341. protected function performWrite($aItem, &$sFilePath)
  342. {
  343. $iUmaskSave = umask(0);
  344. $sFilePath = BX_DIRECTORY_PATH_TMP . $aItem['name'];
  345. if(file_exists($sFilePath))
  346. @unlink($sFilePath);
  347. if(!$rHandler = fopen($sFilePath, 'w'))
  348. return _t('_adm_str_err_cannot_write');
  349. $sContent = urldecode($aItem['content']);
  350. if(!fwrite($rHandler, $sContent, strlen($sContent)))
  351. return _t('_adm_str_err_cannot_write');
  352. fclose($rHandler);
  353. umask($iUmaskSave);
  354. return true;
  355. }
  356. protected function performUnarchive($sFilePath, &$sPackagePath)
  357. {
  358. $iUmaskSave = umask(0);
  359. if(!class_exists('ZipArchive'))
  360. return _t('_adm_str_err_zip_not_available');
  361. $oZip = new ZipArchive();
  362. if($oZip->open($sFilePath) !== true)
  363. return _t('_adm_str_err_cannot_unzip_package');
  364. $sPackageFolder = '';
  365. if($oZip->numFiles > 0)
  366. $sPackageFolder = $oZip->getNameIndex(0);
  367. if(empty($sPackageFolder))
  368. return _t('_adm_str_err_cannot_unzip_package');
  369. $sPackagePath = BX_DIRECTORY_PATH_TMP . $sPackageFolder;
  370. if(file_exists($sPackagePath)) // remove existing tmp folder with the same name
  371. @bx_rrmdir($sPackagePath);
  372. if(!$oZip->extractTo(BX_DIRECTORY_PATH_TMP))
  373. return _t('_adm_str_err_cannot_unzip_package');
  374. $oZip->close();
  375. umask($iUmaskSave);
  376. return true;
  377. }
  378. protected function performCopy($sPackagePath, &$sHomePath)
  379. {
  380. if($this->bUseFtp) {
  381. $sLogin = getParam('sys_ftp_login');
  382. $sPassword = getParam('sys_ftp_password');
  383. $sPath = getParam('sys_ftp_dir');
  384. if(empty($sLogin) || empty($sPassword) || empty($sPath))
  385. return _t('_adm_str_err_no_ftp_info');
  386. bx_import('BxDolFtp');
  387. $oFile = new BxDolFtp($_SERVER['HTTP_HOST'], $sLogin, $sPassword, $sPath);
  388. if(!$oFile->connect())
  389. return _t('_adm_str_err_cannot_connect_to_ftp');
  390. if(!$oFile->isDolphin())
  391. return _t('_adm_str_err_destination_not_valid');
  392. }
  393. else {
  394. bx_import('BxDolFile');
  395. $oFile = BxDolFile::getInstance();
  396. }
  397. $aConfig = self::getModuleConfig($sPackagePath . 'install/config.php');
  398. if(empty($aConfig) || !is_array($aConfig) || empty($aConfig['home_dir']))
  399. return _t('_adm_str_err_wrong_package_format');
  400. $sHomePath = $aConfig['home_dir'];
  401. if(!$oFile->copy($sPackagePath, 'modules/' . $sHomePath))
  402. return _t('_adm_str_err_files_copy_failed');
  403. return true;
  404. }
  405. protected function getConfigModule($sConfigPath, $aInstalled = array())
  406. {
  407. $aConfig = self::getModuleConfig($sConfigPath);
  408. if(empty($aConfig) || !is_array($aConfig))
  409. return array();
  410. $bInstalled = !empty($aInstalled);
  411. $bEnabled = $bInstalled && (int)$aInstalled['enabled'] == 1;
  412. $sVersion = $bInstalled ? $aInstalled['version'] : $aConfig['version'];
  413. return array(
  414. 'type' => $aConfig['type'],
  415. 'name' => isset($aConfig['name']) ? $aConfig['name'] : $aConfig['home_uri'],
  416. 'title' => bx_process_output($aConfig['title']),
  417. 'vendor' => $aConfig['vendor'],
  418. 'version' => $sVersion,
  419. 'uri' => $aConfig['home_uri'],
  420. 'dir' => $aConfig['home_dir'],
  421. 'note' => isset($aConfig['note']) ? bx_process_output($aConfig['note']) : '',
  422. 'installed' => $bInstalled,
  423. 'enabled' => $bEnabled
  424. );
  425. }
  426. protected function getConfigUpdate($sConfigPathModule, $sConfigPathUpdate, $aInstalledModule = array())
  427. {
  428. $aModule = $this->getConfigModule($sConfigPathModule, $aInstalledModule);
  429. if(empty($aModule) || !$aModule['installed'])
  430. return array();
  431. $aConfig = self::getModuleConfig($sConfigPathUpdate);
  432. if(empty($aConfig) || !is_array($aConfig))
  433. return array();
  434. return array(
  435. 'title' => bx_process_output($aConfig['title']),
  436. 'vendor' => $aConfig['vendor'],
  437. 'version_from' => $aConfig['version_from'],
  438. 'version_to' => $aConfig['version_to'],
  439. 'dir' => $aConfig['home_dir'],
  440. 'module_type' => $aModule['type'],
  441. 'module_name' => $aModule['name'],
  442. 'module_dir' => $aModule['dir'],
  443. 'module_version' => $aModule['version']
  444. );
  445. }
  446. private function getInstalledInfo()
  447. {
  448. bx_import('BxDolModuleQuery');
  449. $aModules = BxDolModuleQuery::getInstance()->getModules();
  450. $aInstalledInfo = array();
  451. foreach($aModules as $aModule)
  452. $aInstalledInfo[$aModule['path']] = $aModule;
  453. return $aInstalledInfo;
  454. }
  455. private function addTransientJob($sName, $sAction, $aParams)
  456. {
  457. bx_import('BxDolCronQuery');
  458. if(BxDolCronQuery::getInstance()->addTransientJobService($sName, array('system', $sAction, $aParams, 'DolStudioInstallerUtils')))
  459. return true;
  460. return false;
  461. }
  462. private function emailNotify($sMessage)
  463. {
  464. sendMailTemplateSystem('t_BgOperationFailed', array (
  465. 'conclusion' => strip_tags($sMessage),
  466. ));
  467. }
  468. private function emailNotifyModulesUpgrade($sResult, $aData)
  469. {
  470. bx_import('BxDolModuleQuery');
  471. $oModuleQuery = BxDolModuleQuery::getInstance();
  472. $sConclusion = '';
  473. if(!empty($aData))
  474. foreach($aData as $sModule => $sMessage) {
  475. $aModule = $oModuleQuery->getModuleByName($sModule);
  476. $sConclusion .= _t('_sys_et_txt_body_modules_upgrade_' . $sResult, $aModule['title'], $sMessage);
  477. }
  478. sendMailTemplateSystem('t_UpgradeModules' . ucfirst($sResult), array (
  479. 'conclusion' => $sConclusion,
  480. ));
  481. }
  482. }
  483. /** @} */