/********************************************************************************************************* "Ensemble" is the proprietary property of The Regents of the University of California ("The Regents.") Copyright (c) 2005-10 The Regents of the University of California, Davis campus. All Rights Reserved. Redistribution and use in source and binary forms, with or without modification, are permitted by nonprofit, research institutions for research use only, provided the conditions in the included license agreement are met. Refer to the file "ensemble_license.txt" for the license agreement, located in the top level directory of this distribution. **********************************************************************************************************/ // // This interface allows one to edit a form header or footer and associate an audio file with it // // Author(s): // 3/29/2010 - Stefan Tomic, First Version require_once('../include/researcher_includes.php'); ?>
printf("");
//allow for either $_GET or $_POST methods
//the link from question_list.php passes question_id and subquestion as $_GET
//while file submission happens via $_POST
$form_id = (isset($_GET['form_id']))? $_GET['form_id'] : $_POST['form_id'];
$section = (isset($_GET['section']))? $_GET['section'] : $_POST['section'];
$audio_path_field = sprintf("%s_audio_path",$section);
if(isset($_POST['section_text'])) {
$sql_update_section = sprintf("update form set %s='%s' where form_id = %d",$section,$_POST['section_text'],$form_id);
mysql_update($sql_update_section);
}
if(isset($_POST['submit_audio'])) {
$tmp_filename = $_FILES['audio_file']['tmp_name'];
$orig_name = $_FILES['audio_file']['name'];
$dotloc = strrpos($orig_name,".");
if(!$dotloc)
printf("Please submit a file with a valid filename extension.");
$extension = substr($orig_name,$dotloc+1);
$dest_fname = sprintf("formID_%d_%s.%s",$form_id,$section,$extension);
$dest_fullpath = $form_head_foot_audio_path. "/" . $dest_fname;
if(!is_uploaded_file($tmp_filename))
die("Error with file upload.");
$move_succeeded = move_uploaded_file($tmp_filename,$dest_fullpath);
if(!$move_succeeded)
die("Error moving file to destination");
chmod($dest_fullpath,0755);
$sql_add_audio_path = sprintf("update form set %s = \"%s\" where form_id=%d",
$audio_path_field,$dest_fname,$form_id);
mysql_update($sql_add_audio_path);
}
$sql_get_form_info = sprintf("select %s,%s,locked from form where form_id = %d",
$section,$audio_path_field,$form_id);
$row_form_info = mysql_select($sql_get_form_info);
printf("Form ID: %d",$form_id);
if($row_form_info['locked'] != 'T') {
printf("\n\n");
}
else {
print " |
"; print ""; printf(" |