From 57593d730f61cca4418c1a3adcde7d62bac99bd6 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Fri, 18 Apr 2014 10:17:48 +0100 Subject: [PATCH] Now copying over users template & settings Coping over system settings now won't set line if $thisKey is blank 2 more functions added to copy over users template and users settings files. These are largely the same as copying over settings, so will make a sub function and call will params as a next step. --- lib/updater.php | 72 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/lib/updater.php b/lib/updater.php index 95d54bf..5595a27 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -112,8 +112,6 @@ function openZipNew($icvInfo) { } function copyOverSettings($icvInfo) { - global $updateDone; - echo 'Getting old and new settings...
'; // Get old and new settings and start a new $contents $oldSettingsContent = file_get_contents(PATH."lib/config___settings.php",false,$context); @@ -131,7 +129,7 @@ function copyOverSettings($icvInfo) { $contentLine = $newSettingsArray[$i].PHP_EOL; for ($j=0; $j -1) { + if ($thisKey != "" && $thisKey != "versionNo" && $thisKey != "codeMirrorDir" && strpos($oldSettingsArray[$j],'"'.$thisKey.'"') > -1) { $contentLine = $oldSettingsArray[$j].PHP_EOL; } } @@ -142,6 +140,74 @@ function copyOverSettings($icvInfo) { fwrite($fh, $contents); fclose($fh); + echo 'Finished copying over settings...
'; + copyOverUsersTemplate($icvInfo); +} + +function copyOverUsersTemplate($icvInfo) { + echo 'Getting old and new users template...
'; + // Get old and new users template and start a new $contents + $oldSettingsContent = file_get_contents(PATH."lib/config___users-template.php",false,$context); + $oldSettingsArray = explode("\n",$oldSettingsContent); + $newSettingsContent = file_get_contents("config___users-template.php",false,$context); + $newSettingsArray = explode("\n",$newSettingsContent); + $contents = ""; + + echo 'Transposing old users template to new users template...
'; + // Now need to copy the old users template over to new users template... + for ($i=0; $i -1) { + $contentLine = $oldSettingsArray[$j].PHP_EOL; + } + } + $contents .= $contentLine; + } + echo 'Saving old users template to new ICEcoder users template file...
'; + $fh = fopen('config___users-template.php', 'w') or die("Sorry, cannot update the new ICEcoder users template file"); + fwrite($fh, $contents); + fclose($fh); + + echo 'Finished copying over users template...
'; + copyOverUserSettings($icvInfo); +} + +function copyOverUserSettings($icvInfo) { + global $updateDone; + + echo 'Getting old and new users settings...
'; + // Get old and new users settings and start a new $contents + $oldSettingsContent = file_get_contents(PATH."lib/config-localhost.php",false,$context); + $oldSettingsArray = explode("\n",$oldSettingsContent); + $newSettingsContent = file_get_contents("config___users-template.php",false,$context); + $newSettingsArray = explode("\n",$newSettingsContent); + $contents = ""; + + echo 'Transposing old users settings to new users settings...
'; + // Now need to copy the old users settings over to new users settings... + for ($i=0; $i -1) { + $contentLine = $oldSettingsArray[$j].PHP_EOL; + } + } + $contents .= $contentLine; + } + echo 'Saving old users settings to new ICEcoder users settings file...
'; + $fh = fopen('config-localhost.php', 'w') or die("Sorry, cannot add the new ICEcoder users settings file"); + fwrite($fh, $contents); + fclose($fh); + echo 'All update tasks completed...
'; $updateDone = true; }