$(document).ready( function() { for (i=0;i<$(".actions").length;i++) { if ($(".actions:eq("+i+")").html()=="
' . 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 {
$_SESSION['group_member_with_upload_rights'] = false;
$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 (!$is_allowed_to_edit || api_is_coach()) {
if (!(DocumentManager::is_visible($curdirpath, $_course, api_get_session_id()))) {
api_not_allowed();
}
}
/* Constants and variables */
$course_quota = DocumentManager::get_course_quota();
$current_session_id = api_get_session_id();
/* Create shared folders */
if($current_session_id==0){
//Create shared folder. Necessary for courses recycled. Allways session_id should be zero. Allway should be created from a base course, never from a session.
if (!file_exists($base_work_dir.'/shared_folder')) {
$usf_dir_title = get_lang('UserFolders');
$usf_dir_name = '/shared_folder';
$to_group_id = 0;
$visibility = 0;
create_unexisting_directory($_course, $_user['user_id'], $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
}
// Create dynamic user shared folder
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;
$visibility = 1;
create_unexisting_directory($_course, $_user['user_id'], $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
}
}
else{
//Create shared folder session
if (!file_exists($base_work_dir.'/shared_folder_session_'.$current_session_id)) {
$usf_dir_title = get_lang('UserFolders').' ('.api_get_session_name($current_session_id).')';
$usf_dir_name = '/shared_folder_session_'.$current_session_id;
$to_group_id = 0;
$visibility = 0;
create_unexisting_directory($_course, $_user['user_id'], $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
}
//Create dynamic user shared folder into a shared folder session
if (!file_exists($base_work_dir.'/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id())) {
$usf_dir_title = api_get_person_name($_user['firstName'], $_user['lastName']).' ('.api_get_session_name($current_session_id).')';
$usf_dir_name = '/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id();
$to_group_id = 0;
$visibility = 1;
create_unexisting_directory($_course, $_user['user_id'], $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
}
}
/* 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 .= ''.''.get_lang("No").' | '.get_lang("Yes").'
'; if (!isset($_GET['copy'])){ Display::display_warning_message($message,false); } if (Security::remove_XSS($_GET['copy']) == 'yes'){ if (!copy($file, $copyfile)) { Display::display_error_message(get_lang('CopyFailed')); }else{ Display::display_confirmation_message(get_lang('OverwritenFile')); } } }else{ if (!copy($file, $copyfile)) { Display::display_error_message(get_lang('CopyFailed')); }else{ Display::display_confirmation_message(get_lang('CopyMade')); } } } //START ACTION MENU /* MOVE FILE OR DIRECTORY */ //Only teacher and all users into their group and each user into his/her shared folder if($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder($_user['user_id'], $curdirpath, $current_session_id) || is_my_shared_folder($_user['user_id'], Security::remove_XSS($_POST['move_to']), $current_session_id)){ $my_get_move = Security::remove_XSS($_GET['move']); if (isset($_GET['move']) && $_GET['move'] != '') { if (api_is_coach()) { if (!DocumentManager::is_visible_by_id($my_get_move, $_course,api_get_session_id())) { api_not_allowed(); } } if (!$is_allowed_to_edit) { if (DocumentManager::check_readonly($_course, $_user['user_id'], $my_get_move)) { api_not_allowed(); } } if (DocumentManager::get_document_id($_course, $my_get_move)) { $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit || $group_member_with_upload_rights); //filter if is my shared folder. TODO: move this code to build_move_to_selector function if(is_my_shared_folder($_user['user_id'], $curdirpath, $current_session_id) && !$is_allowed_to_edit){ $main_user_shared_folder_main = '/shared_folder/sf_user_'.api_get_user_id();//only main user shared folder $main_user_shared_folder_sub = '/shared_folder\/sf_user_'.api_get_user_id().'\//';//all subfolders $user_shared_folders=array(); foreach($folders as $fold){ if($main_user_shared_folder_main==$fold || preg_match($main_user_shared_folder_sub, $fold)){ $user_shared_folders[]=$fold; } } echo '
'.get_lang('ViewSlideshow').'';
}
echo '