0) { print "It appears that the old subject ID form handler(s) 'form_subject_id.php' and/or 'form_subect_id_with_validation.php' \n"; print "are in use. These form handlers are no longer supported. Please reconfigure your experiments to use one of the newer \n"; print "form handlers (e.g. form_subject_register.php). Then rerun the upgrade script. This upgrade script will exit now without\n"; print "performing any changes.\n"; die(); } $versionInfoFile = $ensroot."/include/version_info.php"; if(!file_exists($versionInfoFile)) { print "\n\nFile $versionInfoFile does not exist.\n"; print "Make sure you have the most recent Ensemble distribution.\n"; print "If you are using svn, perform an svn update.\n"; print "Exiting the upgrade script now.\n"; die(); } else { if(!function_exists('compareVersionStrings')) { print "Function \"compareVersionStrings\" doesn't exist in functions.php.\n"; print "Your Ensemble distribution is probably not up to date.\n"; print "Make sure that you have upgraded your Ensemble scripts to the latest version.\n"; print "Exiting the upgrade script now.\n"; die(); } include($versionInfoFile); if(compareVersionStrings($ENSEMBLE_VERSION,"1.5.3") == 0) { print "WARNING: Your current Ensemble version appears to be ". $versionInfoFile . "\n"; print "If you have properly updated your distribution with svn, the current version should be 1.6.0\n"; print "You may have updated your Ensemble distribution without svn.\n"; print "If this is the case, make sure all of your Ensemble scripts are up to date.\n"; print "You may then proceed with this upgrade script.\n"; print "If you are not sure whether your Ensemble scripts are up to date, then\n" . print "do not update the Ensemble version info and quit the upgrade script now.\n"; changeConfigFile($versionInfoFile,"ENSEMBLE_VERSION","1.6.0"); } elseif(compareVersionStrings($ENSEMBLE_VERSION,"1.5.3") < 0) { print "Your current Ensemble version appears to be " . $ENSEMBLE_VERSION . "\n"; print "This was reported by " . $versionInfoFile . "\n"; print "Your Ensemble version must be at least 1.5.3 in order to run this script.\n"; print "Exiting the upgrade script now.\n"; die(); } elseif(compareVersionStrings($ENSEMBLE_VERSION,"1.6.0") >= 0) { print "Current Ensemble version is " . $ENSEMBLE_VERSION . "\n"; print "Proceeding with upgrade.\n"; } else { print "Your Ensemble version could not be determined.\n"; print "This is usually reported by " . $versionInfoFile . "\n"; print "Your Ensemble version must be at least 1.5.3 in order to run this script.\n"; print "Exiting the upgrade script now.\n"; die(); } } //END VERSION, FILE, AND DIRECTORY CHECKING /********************************************************************************************************/ // BACKUP THE DATABASE print "\nDirectory to save database backup "; $backupDir = checkDirectoryInput($_ENV['HOME']); $dbBackupFpath = backupDB($backupDir,$versionInfo); /********************************************************************************************************/ //VARIABLE UPDATES //Add $DEFAULT_LANGUAGE variable to variables_config.php if it doesn't already exist if(!variableInFile("DEFAULT_LANGUAGE",$variables_config_path)) { changeConfigFile($variables_config_path,"DEFAULT_LANGUAGE","english"); } //DATABASE UPDATES //convert experiment.language field from an enum to a varchar field $sql_alter_tbl = "ALTER TABLE `experiment` CHANGE `language` `language` VARCHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'english'"; print "\nperforming query: " .$sql_alter_tbl."\n\n"; mysql_query($sql_alter_tbl) or die(mysql_error()); //add play_question_audio and encrypted_response_table fields to experiment table if(!fieldInTable('play_question_audio','experiment') && !fieldInTable('encrypted_response_table','experiment')) { $sql_alter_tbl = "ALTER TABLE `experiment` ADD `play_question_audio` ENUM( 'T', 'F' ) NOT NULL DEFAULT 'F' AFTER `language` , ". "ADD `encrypted_response_table` ENUM( 'T', 'F' ) NOT NULL DEFAULT 'F' AFTER `play_question_audio`"; print "performing query: " .$sql_alter_tbl."\n\n"; mysql_query($sql_alter_tbl) or die(mysql_error()); } //convert form_handler field from an enum to a varchar(50) $sql_alter_tbl = "ALTER TABLE `experiment_x_form` CHANGE `form_handler` `form_handler` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; mysql_query($sql_alter_tbl) or die(mysql_error()); //add header_audio_path and footer_audio_path to form table if(!fieldInTable('header_audio_path','form') && !fieldInTable('footer_audio_path','form')) { $sql_alter_tbl = "ALTER TABLE `form` ADD `header_audio_path` VARCHAR( 50 ) NULL DEFAULT NULL AFTER `footer` , ". "ADD `footer_audio_path` VARCHAR( 50 ) NULL DEFAULT NULL AFTER `header_audio_path`"; print "performing query: " .$sql_alter_tbl."\n\n"; mysql_query($sql_alter_tbl) or die(mysql_error()); } //add audio_path to question_x_data_format if(!fieldInTable('audio_path','question_x_data_format')) { $sql_alter_tbl = "ALTER TABLE `question_x_data_format` ADD `audio_path` VARCHAR( 50 ) NULL DEFAULT NULL AFTER `html_field_type`"; print "performing query: " .$sql_alter_tbl."\n\n"; mysql_query($sql_alter_tbl) or die(mysql_error()); } //add passphrase, security_questions, and security_responses fields to subject table if(!fieldInTable('passphrase','subject') && !fieldInTable('security_questions','subject') && !fieldInTable('security_responses','subject')) { $sql_alter_tbl = "ALTER TABLE `subject` ADD `passphrase` BLOB NULL DEFAULT NULL AFTER `name_suffix` , ". "ADD `security_questions` TEXT NULL DEFAULT NULL AFTER `passphrase` , ". "ADD `security_responses` BLOB NULL DEFAULT NULL AFTER `security_questions` "; print "performing query: " .$sql_alter_tbl."\n\n"; mysql_query($sql_alter_tbl) or die(mysql_error()); } //add county field to subject table if(!fieldInTable('county','subject')) { $sql_alter_tbl = "ALTER TABLE `subject` ADD `county` BLOB NULL DEFAULT NULL AFTER `city`"; print "performing query: " .$sql_alter_tbl."\n\n"; mysql_query($sql_alter_tbl) or die(mysql_error()); } //retrieve the names of all response tables and add the "decline" field to each of them $sql_get_response_tables = "select response_table from experiment"; $get_response_tables = mysql_query($sql_get_response_tables) or die(mysql_error()); while($row_response_tables = mysql_fetch_assoc($get_response_tables)) { $resp_table = $row_response_tables['response_table']; $sql_check_table_exist = sprintf("show tables like '%s'",$resp_table); $check_table_exist = mysql_query($sql_check_table_exist) or die(mysql_error()); if(mysql_num_rows($check_table_exist) == 0) { printf("WARNING: Table %s doesn't exist. However, it is specified in the response_table field in the experiment table.\n",$resp_table); print "Ignoring this table name and continuing with the update. You may want to review the response_table\n"; print "values in the experiment table for data integrity.\n\n"; continue; } if(!fieldInTable('decline',$resp_table)) { $sql_alter_tbl = sprintf("ALTER TABLE `%s` ADD `decline` ENUM( 'T', 'F' ) NOT NULL DEFAULT 'F'",$resp_table); print "performing query: " .$sql_alter_tbl."\n\n"; mysql_query($sql_alter_tbl) or die(mysql_error()); } } print "DONE UPDATING!\n\n"; print "Please test your installation by verifying that old experiments still run\n"; ?>