'../group/group.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.api_get_group_id(), 'name' => get_lang('GroupSpace').' '.$group_properties['name']); //they are allowed to upload $group_member_with_upload_rights = true; } else { $to_group_id = 0; $req_gid = ''; } } elseif ($group_properties['doc_state'] == 1) { // Documents are public $to_group_id = api_get_group_id(); $req_gid = '&gidReq='.api_get_group_id(); $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.api_get_group_id(), 'name' => get_lang('GroupSpace').' '.$group_properties['name']); //allowed to upload? if ($is_allowed_to_edit || GroupManager::is_subscribed(api_get_user_id(), api_get_group_id())) { // Only courseadmin or group members can upload $group_member_with_upload_rights = true; } } else { // Documents not active for this group $to_group_id = 0; $req_gid = ''; } $_SESSION['group_member_with_upload_rights'] = $group_member_with_upload_rights; } else { $_SESSION['group_member_with_upload_rights'] = false; $to_group_id = 0; $req_gid = ''; } //Actions $document_id = intval($_REQUEST['id']); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $message = ''; switch ($action) { case 'download': $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id()); // Check whether the document is in the database if (empty($document_data)) { // File not found! header('HTTP/1.0 404 Not Found'); $error404 = ''; $error404 .= '
'; $error404 .= 'The requested URL was not found on this server.
'; $error404 .= ''; $message .= ''.get_lang("No").' | '.get_lang('Yes').'
'; if (!isset($_GET['copy'])) { $message = Display::return_message($message, 'warning', false); } if (Security::remove_XSS($_GET['copy']) == 'yes') { if (!copy($file, $copyfile)) { $message = Display::return_message(get_lang('CopyFailed'), 'error'); } else { $message = Display::return_message(get_lang('OverwritenFile').' '.$file_link, 'confirmation', false); } } } else { if (!copy($file, $copyfile)) { $message = Display::return_message(get_lang('CopyFailed'), 'error'); } else { $message = Display::return_message(get_lang('CopyMade').' '.$file_link, 'confirmation', false); /*$doc_id = add_document($_course, $copyfile , 'file', filesize($copyfile), $document_info['title']); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], null, null, null, null, $session_id);*/ } } } break; } // I'm in the certification module? $is_certificate_mode = DocumentManager::is_certificate_mode($_GET['curdirpath']); if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') { $is_certificate_mode = true; } //If no actions we proceed to show the document (Hack in order to use document.php?id=X) if (isset($document_id) && empty($action)) { $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); //If the document is not a folder we show the document if ($document_data) { $parent_id = $document_data['parent_id']; //$visibility = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id()); $visibility = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), api_get_session_id(), api_get_user_id()); if (!empty($document_data['filetype']) && $document_data['filetype'] == 'file') { if ($visibility && api_is_allowed_to_session_edit()) { $url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document'.$document_data['path'].'?'.api_get_cidreq(); header("Location: $url"); } exit; } else { if (!$visibility && !api_is_allowed_to_edit()) { api_not_allowed(); } } $_GET['curdirpath'] = $document_data['path']; } // What's the current path? // We will verify this a bit further down if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '') { $curdirpath = Security::remove_XSS($_GET['curdirpath']); } elseif (isset($_POST['curdirpath']) && $_POST['curdirpath'] != '') { $curdirpath = Security::remove_XSS($_POST['curdirpath']); } else { $curdirpath = '/'; } $curdirpathurl = urlencode($curdirpath); } else { // What's the current path? // We will verify this a bit further down if (isset($_GET['curdirpath']) && $_GET['curdirpath'] != '') { $curdirpath = Security::remove_XSS($_GET['curdirpath']); } elseif (isset($_POST['curdirpath']) && $_POST['curdirpath'] != '') { $curdirpath = Security::remove_XSS($_POST['curdirpath']); } else { $curdirpath = '/'; } $curdirpathurl = urlencode($curdirpath); // Check the path // If the path is not found (no document id), set the path to / $document_id = DocumentManager::get_document_id($course_info, $curdirpath); if (!$document_id) { $document_id = DocumentManager::get_document_id($course_info, $curdirpath); } $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); $parent_id = $document_data['parent_id']; } if (isset($document_data) && $document_data['path'] == '/certificates') { $is_certificate_mode = true; } if (!$parent_id) { $parent_id = 0; } $current_folder_id = $document_id; // Show preview if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && isset($_GET['set_preview']) && $_GET['set_preview'] == strval(intval($_GET['set_preview']))) { if (isset($_GET['set_preview'])) { // Generate document HTML $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), api_get_course_id(), true); $new_content_html = $content_html['content']; $path_image = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/gallery'; $new_content_html = str_replace('../images/gallery', $path_image, $new_content_html); $path_image_in_default_course = api_get_path(WEB_CODE_PATH).'default_course_document'; $new_content_html = str_replace('/main/default_course_document', $path_image_in_default_course, $new_content_html); $new_content_html = str_replace('/main/img/', api_get_path(WEB_IMG_PATH), $new_content_html); echo ''; echo '