http://atutor.ca/atutor/mantis/view.php?id=4865
authorCindy Li <cli@ocad.ca>
Fri, 7 Oct 2011 17:34:32 +0000 (17:34 -0000)
committerCindy Li <cli@ocad.ca>
Fri, 7 Oct 2011 17:34:32 +0000 (17:34 -0000)
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
docs/install/include/upgrade_header.php
docs/install/include/ustep4.php
docs/install/include/ustep5.php
docs/install/include/ustep6.php [new file with mode: 0644]
docs/install/upgrade.php

index b2e0df4..8433c83 100644 (file)
@@ -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");
                        }
index 3d939aa..f4857a1 100644 (file)
@@ -32,9 +32,10 @@ $install_steps[1] = array('name' => 'Locate Old Version');
 $install_steps[2] = array('name' => 'Database');\r
 $install_steps[3] = array('name' => 'New '.$new_version.' Configuration Options');\r
 $install_steps[4] = array('name' => 'Content Directory');\r
-$install_steps[5] = array('name' => 'Save Configuration');\r
-$install_steps[6] = array('name' => 'Anonymous Usage Collection');\r
-$install_steps[7] = array('name' => 'Done!');\r
+$install_steps[5] = array('name' => 'Content Files');\r
+$install_steps[6] = array('name' => 'Save Configuration');\r
+$install_steps[7] = array('name' => 'Anonymous Usage Collection');\r
+$install_steps[8] = array('name' => 'Done!');\r
 \r
 \r
 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
index 8ea551f..ca770de 100644 (file)
@@ -1,91 +1,80 @@
 <?php
 /************************************************************************/
-/* AContent                                                             */
+/* ATutor                                                                                                                              */
 /************************************************************************/
-/* Copyright (c) 2010                                                   */
-/* Inclusive Design Institute                                           */
-/*                                                                      */
+/* Copyright (c) 2002-2010                                              */
+/* http://atutor.ca                                                     */
 /* This program is free software. You can redistribute it and/or        */
 /* modify it under the terms of the GNU General Public License          */
 /* as published by the Free Software Foundation.                        */
 /************************************************************************/
+// $Id: ustep4.php 10055 2010-06-29 20:30:24Z cindy $
+
+ignore_user_abort(true); 
+@set_time_limit(0); 
 
 if (!defined('TR_INCLUDE_PATH')) { exit; }
 
-if(isset($_POST['submit'])) {
-       unset($_POST['submit']);
-       unset($action);
-       store_steps($step);
-       $step++;
-       return;
+if (isset($_POST['submit'])) {
+       if (!isset($errors)) {
+               unset($_POST['submit']);
+               unset($action);
+               store_steps($step);
+               $step++;
+               return;
+       }
 }
 
-$file = '../include/config.inc.php';
-
-unset($errors);
-unset($progress);
+print_progress($step);
 
-if ( file_exists($file) ) {
-       @chmod($file, 0666);
-       if (!is_writeable($file)) {
-               $errors[] = '<strong>' . $file . '</strong> is not writeable. Use <kbd>chmod a+rw '.$file.'</kbd> to change permissions.';
-       }else{
-               $progress[] = '<strong>' . $file . '</strong> 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 <b>'.$file.'</b> copied successfully.';
+                               } else {
+                                       $errors[] = 'Course content directory <b>'.$file.'</b> <strong>NOT</strong> copied.';
+                               }
+                       } else {
+                               // a regular file
+                               copy($_POST['step4']['copy_from'] . $file, $content_dir  .$file);
+                       }
+               }
        }
 } else {
-       $errors[] = '<strong>' . $file . '</strong> does not exist.';
+       $progress[] = 'Using existing content directory <strong>'.$content_dir.'</strong>.';
 }
 
-print_progress($step);
-
-echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">';
-
+if (isset($progress)) {
+       print_feedback($progress);
+}
 if (isset($errors)) {
-       if (isset($progress)) {
-               print_feedback($progress);
-       }
        print_errors($errors);
+}
 
-       echo'<input type="hidden" name="step" value="'.$step.'" />';
-
-       unset($_POST['step']);
-       unset($_POST['action']);
-       unset($errors);
-       print_hidden($step);
-
-       echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
-
-       echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
-
-} else {
-
-       if (!copy('../../'.$_POST['step1']['old_path'] . '/include/config.inc.php', '../include/config.inc.php')) {
-               echo '<input type="hidden" name="step" value="'.$step.'" />';
-
-               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 <kbd>chmod a+rw include/config.inc.php</kbd> to make the file writeable. On Windows edit the file\'s properties ensuring that the <kbd>Read-only</kbd> attribute is <em>not</em> checked and that <kbd>Everyone</kbd> access permissions are given to that file.';
-               print_errors($errors);
-
-               echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
-
-               echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
-
-       } else {
-               echo '<input type="hidden" name="step" value="'.$step.'" />';
-               print_hidden($step);
-
-               $progress[] =  'Data has been saved successfully.';
-
-               @chmod('../include/config.inc.php', 0444);
-
-               print_feedback($progress);
-
-               echo '<p align="center"><input type="submit" class="button" value=" Next &raquo; " name="submit" /></p>';
-               
-       }
+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);
 }
 
 ?>
+<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
+<input type="hidden" name="step" value="<?php echo $step;?>" />
+<?php print_hidden($step); ?>
 
+<br /><br /><p align="center"><input type="submit" class="button" value=" Next &raquo;" name="submit" /></p>
 </form>
\ No newline at end of file
index f86298b..8ea551f 100644 (file)
 
 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[] = '<strong>' . $file . '</strong> is not writeable. Use <kbd>chmod a+rw '.$file.'</kbd> to change permissions.';
+       }else{
+               $progress[] = '<strong>' . $file . '</strong> is writeable.';
+       }
+} else {
+       $errors[] = '<strong>' . $file . '</strong> does not exist.';
+}
+
 print_progress($step);
 
-?>
-<p><strong>Congratulations on your upgrade of AContent <?php echo $new_version; ?><i>!</i></strong></p>
+echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">';
+
+if (isset($errors)) {
+       if (isset($progress)) {
+               print_feedback($progress);
+       }
+       print_errors($errors);
+
+       echo'<input type="hidden" name="step" value="'.$step.'" />';
+
+       unset($_POST['step']);
+       unset($_POST['action']);
+       unset($errors);
+       print_hidden($step);
+
+       echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
+
+       echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
+
+} else {
 
-<p>It is important that you login as the AContent administrator to review and set any new System Configuration options.</p>
-<p>For security reasons,  after you have confirmed the installation was successful, it is also important that you delete the <kbd>install/</kbd> directory and reset the<kbd> /include/config.inc.php</kbd> file to read-only. On Linux/Unix systems, use <kbd>chmod a-w include/config.inc.php</kbd>.</p>
-<p>See the <a href="http://www.atutor.ca/forum/18/1.html">Support Forums</a> on <a href="http://www.atutor.ca/acontent/">atutor.ca</a> for additional help &amp; support.</p>
+       if (!copy('../../'.$_POST['step1']['old_path'] . '/include/config.inc.php', '../include/config.inc.php')) {
+               echo '<input type="hidden" name="step" value="'.$step.'" />';
 
-<br />
+               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 <kbd>chmod a+rw include/config.inc.php</kbd> to make the file writeable. On Windows edit the file\'s properties ensuring that the <kbd>Read-only</kbd> attribute is <em>not</em> checked and that <kbd>Everyone</kbd> access permissions are given to that file.';
+               print_errors($errors);
+
+               echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rw</kbd> then the file name.</p>';
+
+               echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
+
+       } else {
+               echo '<input type="hidden" name="step" value="'.$step.'" />';
+               print_hidden($step);
+
+               $progress[] =  'Data has been saved successfully.';
+
+               @chmod('../include/config.inc.php', 0444);
+
+               print_feedback($progress);
+
+               echo '<p align="center"><input type="submit" class="button" value=" Next &raquo; " name="submit" /></p>';
+               
+       }
+}
+
+?>
 
-<form method="get" action="../index.php">
-       <div align="center">
-               <input type="submit" name="submit" value="&raquo; Go To AContent!" class="button" />
-       </div>
 </form>
\ No newline at end of file
diff --git a/docs/install/include/ustep6.php b/docs/install/include/ustep6.php
new file mode 100644 (file)
index 0000000..f86298b
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+/************************************************************************/
+/* AContent                                                             */
+/************************************************************************/
+/* Copyright (c) 2010                                                   */
+/* Inclusive Design Institute                                           */
+/*                                                                      */
+/* This program is free software. You can redistribute it and/or        */
+/* modify it under the terms of the GNU General Public License          */
+/* as published by the Free Software Foundation.                        */
+/************************************************************************/
+
+if (!defined('TR_INCLUDE_PATH')) { exit; }
+
+print_progress($step);
+
+?>
+<p><strong>Congratulations on your upgrade of AContent <?php echo $new_version; ?><i>!</i></strong></p>
+
+<p>It is important that you login as the AContent administrator to review and set any new System Configuration options.</p>
+<p>For security reasons,  after you have confirmed the installation was successful, it is also important that you delete the <kbd>install/</kbd> directory and reset the<kbd> /include/config.inc.php</kbd> file to read-only. On Linux/Unix systems, use <kbd>chmod a-w include/config.inc.php</kbd>.</p>
+<p>See the <a href="http://www.atutor.ca/forum/18/1.html">Support Forums</a> on <a href="http://www.atutor.ca/acontent/">atutor.ca</a> for additional help &amp; support.</p>
+
+<br />
+
+<form method="get" action="../index.php">
+       <div align="center">
+               <input type="submit" name="submit" value="&raquo; Go To AContent!" class="button" />
+       </div>
+</form>
\ No newline at end of file
index f2bbb43..8f1cc25 100644 (file)
@@ -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. <a href="index.php">Upgrade from here</a> using the <em>Upgrade</em> 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