path = WEBEDIT_HOME; } /** * @return ChangeProject */ static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } /** * // TODO : make private when no more necessary * @param String $task * @param String[] $args * @return String[] the output of the command */ function executeTask($task, $args = array()) { $cmd = "change.php $task " . join(" ", $args); return $this->exec($cmd, $cmd); } /** * @return String */ function getProfile() { return trim(file_get_contents(WEBEDIT_HOME . "/profile")); } /** * @param String $cmd * @param String $msg * @return String[] the output of the command */ private function exec($cmd, $msg = null) { if ($msg !== null) { echo "$msg..."; } $output = array(); exec($cmd, $output, $retVal); if ("0" != $retVal) { throw new Exception("Could not execute $cmd (exit code $retVal):\n" . join("\n", $output)); } if ($msg !== null) { echo " done\n"; } return $output; } public function moduleExist($moduleName) { return file_exists(WEBEDIT_HOME . '/modules/' . $moduleName); } } } class c_ChangeMigrationScript { public static function main() { $project = ChangeProject::getInstance(); $profile = $project->getProfile(); unlink(WEBEDIT_HOME . '/framework'); exec("rm " . WEBEDIT_HOME . "/modules/*"); exec("rm -rf " . WEBEDIT_HOME . "/.change"); exec("rm -rf " . WEBEDIT_HOME . "/log/" . $profile); exec("rm -rf " . WEBEDIT_HOME . "/build/" . $profile); exec("rm -rf " . WEBEDIT_HOME . "/cache/" . $profile); $project->executeTask("update-autoload", array("--refresh-cli-autoload")); $project->executeTask("init-project"); $project->executeTask("init-generic-modules"); $project->executeTask("update-autoload", array("--refresh-cli-autoload")); //Convertion de la structure du dossier $project->executeTask("apply-patch", array("framework", "0311")); //Checks the correct implemtation of getNewDocumentInstance in Services $project->executeTask("apply-patch", array("framework", "0312")); $project->executeTask("compile-config"); $project->executeTask("compile-documents"); $project->executeTask("compile-db-schema"); if ($project->moduleExist('marketing')) { //Added field "multipleUsage" on coupons $project->executeTask("apply-patch", array("marketing", "0301")); } if ($project->moduleExist('blog')) { //Makes sure keywords are not duplicated $project->executeTask("apply-patch", array("blog", "0302")); } if ($project->moduleExist('customer')) { //Introduces a lastcartupdate property equivalent to the former meta modules.customer.lastCartUpdate $project->executeTask("apply-patch", array("customer", "0307")); } if ($project->moduleExist('ecomfilters')) { //Adds a static list for the abandonned shopping carts $project->executeTask("apply-patch", array("ecomfilters", "0300")); } if ($project->moduleExist('form')) { //aknowledgment handling. //add recipientGroupFolder and move all groups to it. $project->executeTask("apply-patch", array("form", "0301")); } if ($project->moduleExist('markergas')) { //Two new block parameters : allows to track with or without taxes and not yet paiud transactions $project->executeTask("apply-patch", array("markergas", "0301")); } if ($project->moduleExist('markergmaps')) { //Add new documents $project->executeTask("apply-patch", array("markergmaps", "0301")); //Copy media files $project->executeTask("apply-patch", array("markergmaps", "0302")); } if ($project->moduleExist('skin')) { //Correction de la list modules_skin/linkurl $project->executeTask("apply-patch", array("skin", "0302")); } if ($project->moduleExist('solrsearch')) { //Import new list. $project->executeTask("apply-patch", array("solrsearch", "0300")); } if ($project->moduleExist('task')) { //Ajout de changecron.php $project->executeTask("apply-patch", array("task", "0300")); } if ($project->moduleExist('videos')) { //Update preferences to reflect dailymotion embedded player API Change $project->executeTask("apply-patch", array("videos", "0300")); } if ($project->moduleExist('website')) { //Ajout d'un avertissement si pas de site par défaut. //Ajout du choix de la structure du site dans le formulaire de création. $project->executeTask("apply-patch", array("website", "0314")); } if ($project->moduleExist('workflow')) { //Import new 'modules_workflow/existingstarttasks' dynamic list. $project->executeTask("apply-patch", array("workflow", "0301")); } $project->executeTask("init-webapp"); $project->executeTask("clear-all"); $project->executeTask("compile-all"); $project->executeTask("init-patch-db"); } } define("WEBEDIT_HOME", dirname(dirname(__FILE__))); chdir(WEBEDIT_HOME); c_ChangeMigrationScript::main();