BxDolStudioInstallerUtils.php 20 KB

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