'; //jQuery $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; //session if (isset($_GET['id_session'])) { $_SESSION['id_session'] = intval($_GET['id_session']); } //create directory certificates $course_id=api_get_course_id(); DocumentManager::create_directory_certificate_in_course($course_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 $course_id=api_get_course_id(); $content_html=DocumentManager::replace_user_info_into_html($course_id); $new_content_html=$content_html; $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); $path_image_in_dokeos_main=api_get_path(WEB_IMG_PATH); $new_content_html=str_replace('/main/img/',$path_image_in_dokeos_main,$new_content_html); echo ' '; echo ' ' . get_lang('Print') . ''; print_r($new_content_html); exit; } } // Is the document tool visible? // Check whether the tool is actually visible $table_course_tool = Database::get_course_table(TABLE_TOOL_LIST, $_course['dbName']); $tool_sql = 'SELECT visibility FROM ' . $table_course_tool . ' WHERE name = "'. TOOL_DOCUMENT .'" LIMIT 1'; $tool_result = Database::query($tool_sql); $tool_row = Database::fetch_array($tool_result); $tool_visibility = $tool_row['visibility']; if ($tool_visibility == '0' && $to_group_id == '0' && !($is_allowed_to_edit || $group_member_with_upload_rights)) { api_not_allowed(true); } $htmlHeadXtra[] = ""; /* Variables - some need defining before inclusion of libraries */ // 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); //I'm in the certification module? $is_certificate_mode = DocumentManager::is_certificate_mode($curdirpath); $course_dir = $_course['path'].'/document'; $sys_course_path = api_get_path(SYS_COURSE_PATH); $base_work_dir = $sys_course_path.$course_dir; $http_www = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'; $dbl_click_id = 0; // Used for avoiding double-click $is_allowed_to_edit = api_is_allowed_to_edit(null, true); $group_member_with_upload_rights = false; // If the group id is set, we show them group documents if (isset($_SESSION['_gid']) && $_SESSION['_gid']!='') { // Needed for group related stuff require_once($lib_path. 'groupmanager.lib.php'); // Get group info $group_properties = GroupManager::get_group_properties($_SESSION['_gid']); $noPHP_SELF=true; // Let's assume the user cannot upload files for the group $group_member_with_upload_rights = false; if ($group_properties['doc_state'] == 2) { // Documents are private if ($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'], $_SESSION['_gid'])) { // Only courseadmin or group members (members + tutors) allowed $to_group_id = $_SESSION['_gid']; $req_gid = '&gidReq='.$_SESSION['_gid']; $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['_gid'], '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 = $_SESSION['_gid']; $req_gid = '&gidReq='.$_SESSION['_gid']; $interbreadcrumb[] = array ('url' => '../group/group.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$_SESSION['_gid'], 'name' => get_lang('GroupSpace').' ('.$group_properties['name'].')'); //allowed to upload? if ($is_allowed_to_edit || GroupManager::is_subscribed($_user['user_id'], $_SESSION['_gid'])) { // 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 { $to_group_id = 0; $req_gid = ''; } // For sessions we should check the parameters of visibility if (api_get_session_id() != 0) { $group_member_with_upload_rights = $group_member_with_upload_rights && api_is_allowed_to_session_edit(false, true); } /* Libraries */ require_once $lib_path.'fileDisplay.lib.php'; require_once $lib_path.'document.lib.php'; require_once $lib_path.'tablesort.lib.php'; require_once $lib_path.'fileUpload.lib.php'; // Check the path // If the path is not found (no document id), set the path to / if (!DocumentManager::get_document_id($_course, $curdirpath)) { $curdirpath = '/'; // Urlencoded version $curdirpathurl = '%2F'; } // If they are looking at group documents they can't see the root if ($to_group_id != 0 && $curdirpath == '/') { $curdirpath = $group_properties['directory']; $curdirpathurl = urlencode($group_properties['directory']); } // Check visibility of the current dir path. Don't show anything if not allowed if (!(DocumentManager::is_visible($curdirpath, $_course)||$is_allowed_to_edit)) { api_not_allowed(); } /* Constants and variables */ $course_quota = DocumentManager::get_course_quota(); $current_session_id = api_get_session_id(); /* Create the current user shared folder if no exist */ if (!file_exists($base_work_dir.'/shared_folder/sf_user_'.api_get_user_id())) { $usf_dir_title = api_get_person_name($_user['firstName'], $_user['lastName']); $usf_dir_name = '/shared_folder/sf_user_'.api_get_user_id(); $to_group_id = 0; create_unexisting_directory($_course, $_user['user_id'], $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title); } /* MAIN SECTION */ if (isset($_GET['action']) && $_GET['action'] == 'download') { $my_get_id = Security::remove_XSS($_GET['id']); // Check whether the document is in the database if (!DocumentManager::get_document_id($_course, $my_get_id)) { // File not found! header('HTTP/1.0 404 Not Found'); $error404 = ''; $error404 .= '
'; $error404 .= 'The requested URL was not found on this server.
'; $error404 .= '