From 39208ff10fdb6e7f5b508c1ca455b74809c36d8b Mon Sep 17 00:00:00 2001 From: Cindy Li Date: Fri, 7 Oct 2011 17:34:32 +0000 Subject: [PATCH] http://atutor.ca/atutor/mantis/view.php?id=4865 Added in the upgrade step that copies over the content folder from the initial AContent installation that's being upgraded. --- docs/include/classes/FileUtility.class.php | 4 +- docs/install/include/upgrade_header.php | 7 +- docs/install/include/ustep4.php | 121 ++++++++++----------- docs/install/include/ustep5.php | 81 ++++++++++++-- docs/install/include/ustep6.php | 30 +++++ docs/install/upgrade.php | 14 ++- 6 files changed, 171 insertions(+), 86 deletions(-) create mode 100644 docs/install/include/ustep6.php diff --git a/docs/include/classes/FileUtility.class.php b/docs/include/classes/FileUtility.class.php index b2e0df4..8433c83 100644 --- a/docs/include/classes/FileUtility.class.php +++ b/docs/include/classes/FileUtility.class.php @@ -43,9 +43,9 @@ class FileUtility { if (($entry == '.') || ($entry == '..')) { continue; } - + if (is_dir("$source/$entry") && $dest!=="$source/$entry") { - copys("$source/$entry", "$dest/$entry"); + FileUtility::copys("$source/$entry", "$dest/$entry"); } else { @copy("$source/$entry", "$dest/$entry"); } diff --git a/docs/install/include/upgrade_header.php b/docs/install/include/upgrade_header.php index 3d939aa..f4857a1 100644 --- a/docs/install/include/upgrade_header.php +++ b/docs/install/include/upgrade_header.php @@ -32,9 +32,10 @@ $install_steps[1] = array('name' => 'Locate Old Version'); $install_steps[2] = array('name' => 'Database'); $install_steps[3] = array('name' => 'New '.$new_version.' Configuration Options'); $install_steps[4] = array('name' => 'Content Directory'); -$install_steps[5] = array('name' => 'Save Configuration'); -$install_steps[6] = array('name' => 'Anonymous Usage Collection'); -$install_steps[7] = array('name' => 'Done!'); +$install_steps[5] = array('name' => 'Content Files'); +$install_steps[6] = array('name' => 'Save Configuration'); +$install_steps[7] = array('name' => 'Anonymous Usage Collection'); +$install_steps[8] = array('name' => 'Done!'); ?> diff --git a/docs/install/include/ustep4.php b/docs/install/include/ustep4.php index 8ea551f..ca770de 100644 --- a/docs/install/include/ustep4.php +++ b/docs/install/include/ustep4.php @@ -1,91 +1,80 @@ ' . $file . ' is not writeable. Use chmod a+rw '.$file.' to change permissions.'; - }else{ - $progress[] = '' . $file . ' is writeable.'; +/* try copying the content over from the old dir to the new one */ +require('../include/classes/FileUtility.class.php'); // for copys() + +$content_dir = urldecode(trim($_POST['step4']['content_dir'])); +$_POST['step4']['copy_from'] = urldecode(trim($_POST['step4']['copy_from'])) . DIRECTORY_SEPARATOR; + +//copy if copy_from is not empty +if ($_POST['step4']['copy_from'] && ($_POST['step4']['copy_from'] != DIRECTORY_SEPARATOR)) { + if (is_dir($_POST['step4']['copy_from'])) { + $files = scandir($_POST['step4']['copy_from']); + + foreach ($files as $file) { + if ($file == '.' || $file == '..') { continue; } + if (is_dir($_POST['step4']['copy_from'] . $file)) { + FileUtility::copys($_POST['step4']['copy_from'] . $file, $content_dir . $file); + if (is_dir($content_dir.$course)) { + $progress[] = 'Course content directory '.$file.' copied successfully.'; + } else { + $errors[] = 'Course content directory '.$file.' NOT copied.'; + } + } else { + // a regular file + copy($_POST['step4']['copy_from'] . $file, $content_dir .$file); + } + } } } else { - $errors[] = '' . $file . ' does not exist.'; + $progress[] = 'Using existing content directory '.$content_dir.'.'; } -print_progress($step); - -echo '
'; - +if (isset($progress)) { + print_feedback($progress); +} if (isset($errors)) { - if (isset($progress)) { - print_feedback($progress); - } print_errors($errors); +} - echo''; - - unset($_POST['step']); - unset($_POST['action']); - unset($errors); - print_hidden($step); - - echo '

Note: To change permissions on Unix use chmod a+rw then the file name.

'; - - echo '

'; - -} else { - - if (!copy('../../'.$_POST['step1']['old_path'] . '/include/config.inc.php', '../include/config.inc.php')) { - echo ''; - - print_feedback($progress); - - $errors[] = 'include/config.inc.php cannot be written! Please verify that the file exists and is writeable. On Unix issue the command chmod a+rw include/config.inc.php to make the file writeable. On Windows edit the file\'s properties ensuring that the Read-only attribute is not checked and that Everyone access permissions are given to that file.'; - print_errors($errors); - - echo '

Note: To change permissions on Unix use chmod a+rw then the file name.

'; - - echo '

'; - - } else { - echo ''; - print_hidden($step); - - $progress[] = 'Data has been saved successfully.'; - - @chmod('../include/config.inc.php', 0444); - - print_feedback($progress); - - echo '

'; - - } +if ($_POST['step1']['cache_dir'] != '') { + define('CACHE_DIR', urldecode($_POST['step1']['cache_dir'])); + define('CACHE_ON', 1); + require('../include/phpCache/phpCache.inc.php'); + cache_gc(NULL, 1, true); } ?> + + + +

\ No newline at end of file diff --git a/docs/install/include/ustep5.php b/docs/install/include/ustep5.php index f86298b..8ea551f 100644 --- a/docs/install/include/ustep5.php +++ b/docs/install/include/ustep5.php @@ -12,19 +12,80 @@ if (!defined('TR_INCLUDE_PATH')) { exit; } +if(isset($_POST['submit'])) { + unset($_POST['submit']); + unset($action); + store_steps($step); + $step++; + return; +} + +$file = '../include/config.inc.php'; + +unset($errors); +unset($progress); + +if ( file_exists($file) ) { + @chmod($file, 0666); + if (!is_writeable($file)) { + $errors[] = '' . $file . ' is not writeable. Use chmod a+rw '.$file.' to change permissions.'; + }else{ + $progress[] = '' . $file . ' is writeable.'; + } +} else { + $errors[] = '' . $file . ' does not exist.'; +} + print_progress($step); -?> -

Congratulations on your upgrade of AContent !

+echo '
'; + +if (isset($errors)) { + if (isset($progress)) { + print_feedback($progress); + } + print_errors($errors); + + echo''; + + unset($_POST['step']); + unset($_POST['action']); + unset($errors); + print_hidden($step); + + echo '

Note: To change permissions on Unix use chmod a+rw then the file name.

'; + + echo '

'; + +} else { -

It is important that you login as the AContent administrator to review and set any new System Configuration options.

-

For security reasons, after you have confirmed the installation was successful, it is also important that you delete the install/ directory and reset the /include/config.inc.php file to read-only. On Linux/Unix systems, use chmod a-w include/config.inc.php.

-

See the Support Forums on atutor.ca for additional help & support.

+ if (!copy('../../'.$_POST['step1']['old_path'] . '/include/config.inc.php', '../include/config.inc.php')) { + echo ''; -
+ print_feedback($progress); + + $errors[] = 'include/config.inc.php cannot be written! Please verify that the file exists and is writeable. On Unix issue the command chmod a+rw include/config.inc.php to make the file writeable. On Windows edit the file\'s properties ensuring that the Read-only attribute is not checked and that Everyone access permissions are given to that file.'; + print_errors($errors); + + echo '

Note: To change permissions on Unix use chmod a+rw then the file name.

'; + + echo '

'; + + } else { + echo ''; + print_hidden($step); + + $progress[] = 'Data has been saved successfully.'; + + @chmod('../include/config.inc.php', 0444); + + print_feedback($progress); + + echo '

'; + + } +} + +?> - -
- -
\ No newline at end of file diff --git a/docs/install/include/ustep6.php b/docs/install/include/ustep6.php new file mode 100644 index 0000000..f86298b --- /dev/null +++ b/docs/install/include/ustep6.php @@ -0,0 +1,30 @@ + +

Congratulations on your upgrade of AContent !

+ +

It is important that you login as the AContent administrator to review and set any new System Configuration options.

+

For security reasons, after you have confirmed the installation was successful, it is also important that you delete the install/ directory and reset the /include/config.inc.php file to read-only. On Linux/Unix systems, use chmod a-w include/config.inc.php.

+

See the Support Forums on atutor.ca for additional help & support.

+ +
+ +
+
+ +
+
\ No newline at end of file diff --git a/docs/install/upgrade.php b/docs/install/upgrade.php index f2bbb43..8f1cc25 100644 --- a/docs/install/upgrade.php +++ b/docs/install/upgrade.php @@ -32,7 +32,6 @@ if (($step == 2) && isset($_POST['override']) && ($_POST['override'] == 0)) { } session_start(); require('include/upgrade_header.php'); - if ($step == 1) { if (!$new_version) { echo 'You cannot access this page directly. Upgrade from here using the Upgrade button.'; @@ -59,16 +58,21 @@ if ($step == 4) { require('include/step4.php'); } if ($step == 5) { - // in: copy the config file + // in: copy the content if needed // out: - require('include/ustep4.php'); } +if ($step == 6) { + // in: copy the config file + // out: - + require('include/ustep5.php'); +} /* anonymous data collection */ -if ($step == 6) { +if ($step == 7) { require('include/step6.php'); } -if ($step == 7) { - require('include/ustep5.php'); +if ($step == 8) { + require('include/ustep6.php'); } require('include/footer.inc.php'); ?> \ No newline at end of file -- 2.17.1