function import_update($modulenode) { $dirName = 'cache/updates'; $result = false; if (file_exists($dirName . "/init.php")) { require_once $dirName . "/init.php"; $Instance = new YetiForceUpdate($modulenode); $Instance->preupdate(); $Instance->update(); if ($Instance->filesToDelete) { foreach ($Instance->filesToDelete as $path) { $this->deleteDirFile($path); } } $result = $Instance->postupdate(); } $adb = PearDatabase::getInstance(); $currentUser = Users_Record_Model::getCurrentUserModel(); $adb->query("INSERT INTO `yetiforce_updates` (`user`, `name`, `from_version`, `to_version`, `result`) VALUES ('" . $currentUser->get('user_name') . "', '" . $modulenode->label . "', '" . $modulenode->from_version . "', '" . $modulenode->to_version . "','" . $result . "');", true); $adb->query("UPDATE vtiger_version SET `current_version` = '" . $modulenode->to_version . "';"); if ($result && ($dirHandle = opendir($dirName))) { while (false !== ($dirFile = readdir($dirHandle))) { if ($dirFile != "." && $dirFile != "..") { if (!unlink($dirName . "/" . $dirFile)) { return false; } } } closedir($dirHandle); } if (is_dir($dirName . '/files')) { $this->cleanUpdate($dirName . '/files'); } }
function import_update($modulenode) { $dirName = 'cache/updates'; $result = false; $adb = PearDatabase::getInstance(); if (file_exists($dirName . "/init.php")) { require_once $dirName . "/init.php"; $adb->query('SET FOREIGN_KEY_CHECKS = 0;'); $Instance = new YetiForceUpdate($modulenode); $Instance->preupdate(); $Instance->update(); if ($Instance->filesToDelete) { foreach ($Instance->filesToDelete as $path) { $this->deleteDirFile($path); } } $result = $Instance->postupdate(); $adb->query('SET FOREIGN_KEY_CHECKS = 1;'); } $currentUser = Users_Record_Model::getCurrentUserModel(); $adb->query("INSERT INTO `yetiforce_updates` (`user`, `name`, `from_version`, `to_version`, `result`) VALUES ('" . $currentUser->get('user_name') . "', '" . $modulenode->label . "', '" . $modulenode->from_version . "', '" . $modulenode->to_version . "','" . $result . "');", true); $adb->query("UPDATE vtiger_version SET `current_version` = '" . $modulenode->to_version . "';"); if ($result) { $this->deleteDirFile($dirName . '/files'); $this->deleteDirFile($dirName . '/init.php'); } }
function import_update($modulenode) { $dirName = 'cache/updates'; $result = false; $adb = PearDatabase::getInstance(); if (file_exists($dirName . '/init.php')) { require_once $dirName . '/init.php'; $adb->query('SET FOREIGN_KEY_CHECKS = 0;'); $Instance = new YetiForceUpdate($modulenode); $Instance->package = $this; $result = $Instance->preupdate(); if ($result != false) { $Instance->update(); if ($Instance->filesToDelete) { foreach ($Instance->filesToDelete as $path) { Vtiger_Functions::recurseDelete($path); } } Vtiger_Functions::recurseCopy($dirName . '/files', '', true); $result = $Instance->postupdate(); } $adb->query('SET FOREIGN_KEY_CHECKS = 1;'); } $currentUser = Users_Record_Model::getCurrentUserModel(); $adb->query("INSERT INTO `yetiforce_updates` (`user`, `name`, `from_version`, `to_version`, `result`) VALUES ('" . $currentUser->get('user_name') . "', '" . $modulenode->label . "', '" . $modulenode->from_version . "', '" . $modulenode->to_version . "','" . $result . "');", true); if ($result) { $adb->update('vtiger_version', ['current_version' => $modulenode->to_version]); } Vtiger_Functions::recurseDelete($dirName . '/files'); Vtiger_Functions::recurseDelete($dirName . '/init.php'); Vtiger_Functions::recurseDelete('cache/templates_c'); }