function check_unzip() { if(document.upload.unzip.checked){ document.upload.if_exists[0].disabled=true; document.upload.if_exists[1].checked=true; document.upload.if_exists[2].disabled=true; } else { document.upload.if_exists[0].checked=true; document.upload.if_exists[0].disabled=false; document.upload.if_exists[2].disabled=false; } } function advanced_parameters() { if(document.getElementById(\'options\').style.display == \'none\') { document.getElementById(\'options\').style.display = \'block\'; document.getElementById(\'img_plus_and_minus\').innerHTML=\' '.get_lang('AdvancedParameters').'\'; } else { document.getElementById(\'options\').style.display = \'none\'; document.getElementById(\'img_plus_and_minus\').innerHTML=\' '.get_lang('AdvancedParameters').'\'; } } function setFocus(){ $("#title_file").focus(); } '; $htmlHeadXtra[] = " "; // Variables $is_allowed_to_edit = api_is_allowed_to_edit(null, true); $_course = api_get_course_info(); $courseDir = $_course['path'].'/document'; $sys_course_path = api_get_path(SYS_COURSE_PATH); $base_work_dir = $sys_course_path.$courseDir; $selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : null; $document_data = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id(), true); if (empty($document_data)) { $document_id = $parent_id = 0; $path = '/'; } else { $document_id = $document_data['id']; $path = $document_data['path']; $parent_id = DocumentManager::get_document_id(api_get_course_info(), dirname($path)); } $group_properties = array(); // This needs cleaning! if (api_get_group_id()) { // If the group id is set, check if the user has the right to be here // Get group info $group_properties = GroupManager::get_group_properties(api_get_group_id()); if ($is_allowed_to_edit || GroupManager::is_user_in_group($_user['user_id'], api_get_group_id())) { // Only courseadmin or group members allowed $to_group_id = api_get_group_id(); $req_gid = '&gidReq='.api_get_group_id(); $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.api_get_group_id(), 'name' => get_lang('GroupSpace')); } else { api_not_allowed(true); } } elseif ($is_allowed_to_edit || is_my_shared_folder(api_get_user_id(), $path, api_get_session_id())) { // Admin for "regular" upload, no group documents. And check if is my shared folder $to_group_id = 0; $req_gid = ''; } else { // No course admin and no group member... api_not_allowed(true); } // Group docs can only be uploaded in the group directory if ($to_group_id != 0 && $path == '/') { $path = $group_properties['directory']; } // I'm in the certification module? $is_certificate_mode = false; $is_certificate_array = explode('/', $path); array_shift($is_certificate_array); if ($is_certificate_array[0] == 'certificates') { $is_certificate_mode = true; } // Title of the tool if ($to_group_id != 0) { // Add group name after for group documents $add_group_to_title = ' ('.$group_properties['name'].')'; } if (isset($_REQUEST['certificate'])) { $nameTools = get_lang('UploadCertificate').$add_group_to_title; } else { $nameTools = get_lang('UplUploadDocument').$add_group_to_title; } // Breadcrumbs if ($is_certificate_mode) { $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); } else { $interbreadcrumb[] = array('url' => './document.php?id='.$document_id.$req_gid, 'name'=> get_lang('Documents')); } // Interbreadcrumb for the current directory root path if (empty($document_data['parents'])) { $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']); } else { foreach($document_data['parents'] as $document_sub_data) { $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']); } } $this_section = SECTION_COURSES; // Display the header Display::display_header($nameTools, 'Doc'); /* Here we do all the work */ // User has submitted a file if (!empty($_FILES)) { DocumentManager::upload_document($_FILES, $_POST['curdirpath'], $_POST['title'], $_POST['comment'], $_POST['unzip'], $_POST['if_exists'], $_POST['index_document'], true); } // Actions echo '