From ed6da65ffa26ded062fa2e0540cae21394d665bf Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 14 Feb 2012 18:22:58 +0100 Subject: [PATCH] Adding missing nanogong ajax file --- main/inc/ajax/nanogong.ajax.php | 105 ++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 main/inc/ajax/nanogong.ajax.php diff --git a/main/inc/ajax/nanogong.ajax.php b/main/inc/ajax/nanogong.ajax.php new file mode 100644 index 0000000000..2672359bf2 --- /dev/null +++ b/main/inc/ajax/nanogong.ajax.php @@ -0,0 +1,105 @@ +get_param_value('user_id') == api_get_user_id() || api_is_allowed_to_edit()) { + $file_path = $nano->load_filename_if_exists(); + //$file_path = '/var/www/rocio/courses/GREAT123/exercises/0/2/5/1/1-0-1-2-5-38.mp3'; + if ($file_path) { + $info = pathinfo($file_path); + $user_info = api_get_user_info($nano->params['user_id']); + $name = get_lang('Quiz').'-'.$user_info['firstname'].'-'.$user_info['lastname'].'.'.$info['extension']; + $download = true; + if (isset($_REQUEST['download']) && $_REQUEST['download'] == 0) { + $download = false; + } + DocumentManager::file_send_for_download($file_path, $download); + exit; + } + } + break; + case 'show_audio': + if (!$is_nano) { + echo $nano->return_js($_REQUEST); + } + echo $nano->show_audio_file($is_nano); + break; + case 'delete': + $return = $nano->delete_files(); + if ($return == 1) { + //cant' do this because the post that nano send doesnt take into account the session + Display::display_confirmation_message(get_lang('FileDeleted')); + } else { + Display::display_confirmation_message(get_lang('FileNotFound')); + } + break; + case 'show_form': + api_protect_course_script(true); + Display::display_reduced_header(); + echo $nano->return_js($_REQUEST); + echo $nano->return_form(); + break; + case 'save_file': + //User access same as upload.php + + $return = $nano->upload_file($is_nano); + + if ($is_nano) { + //nano looks for numbers + if ($return == 1) { + //cant' do this because the post that nano send doesnt take into account the session + echo 1; //Display::display_confirmation_message(get_lang('UplUploadSucceeded')); + } else { + echo 0; + //Display::display_warning_message(get_lang('UplUnableToSaveFileFilteredExtension')); + } + } else { + Display::display_reduced_header(); + echo $nano->return_js($_REQUEST); + //normal form + if ($return == 1) { + //cant' do this because the post that nano send doesnt take into account the session + $message = Display::return_message(get_lang('UplUploadSucceeded'), 'confirm'); + } else { + $message = Display::return_message(get_lang('UplUnableToSaveFileFilteredExtension'), 'warning'); + } + echo $nano->return_form($message); + } + break; + default: + echo ''; +} +exit; \ No newline at end of file