function confirmation (name) { if (confirm(\" ". get_lang("AreYouSureToDelete") ." \"+ name + \" ?\")) {return true;} else {return false;} } "; /* ----------------------------------------------------------- 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 = $_GET['curdirpath']; } elseif (isset($_POST['curdirpath']) && $_POST['curdirpath']!='') { $curdirpath = $_POST['curdirpath']; } else { $curdirpath = '/'; } $curdirpathurl = urlencode($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 to avoid double-click $is_allowed_to_edit = api_is_allowed_to_edit(); $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 include_once(api_get_path(LIBRARY_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')); //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_space.php?gidReq=".$_SESSION['_gid'], "name"=> get_lang('GroupSpace')); //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 = ''; } /* ----------------------------------------------------------- Libraries ----------------------------------------------------------- */ //the main_api.lib.php, database.lib.php and display.lib.php //libraries are included by default include_once(api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php'); include_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php'); include_once(api_get_path(LIBRARY_PATH) . 'document.lib.php'); include_once(api_get_path(LIBRARY_PATH) . 'tablesort.lib.php'); include_once(api_get_path(LIBRARY_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']); } //----------------------------------------------------------- /* ----------------------------------------------------------- Constants and variables ----------------------------------------------------------- */ $course_quota = DocumentManager::get_course_quota(); /* ============================================================================== MAIN SECTION ============================================================================== */ //-------------------------------------------------------------------// if ($_GET['action']=="download") { //check if the document is in the database if(!DocumentManager::get_document_id($_course,$_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 .= ''); //print_r($docs_and_folders); //echo(''); //************************************************************************************************* //do we need the title field for the document name or not? //we get the setting here, so we only have to do it once $use_document_title = get_setting('use_document_title'); //create a sortable table with our data $sortable_data = array(); while (list ($key, $id) = each($docs_and_folders)) { $row = array (); //if the item is invisible, wrap it in a span with class invisible $invisibility_span_open = ($id['visibility']==0)?'':''; $invisibility_span_close = ($id['visibility']==0)?'':''; //size (or total size of a directory) $size = $id['filetype']=='folder' ? get_total_folder_size($id['path'],$is_allowed_to_edit) : $id[size]; //get the title or the basename depending on what we're using if ($use_document_title=='true' AND $id['title']<>'') { $document_name=$id['title']; } else { $document_name=basename($id['path']); } //$row[] = $key; //testing //data for checkbox if (($is_allowed_to_edit || $group_member_with_upload_rights) AND count($docs_and_folders)>1) { $row[] = $id['path']; } //icons $row[]= build_document_icon_tag($id['filetype'],$id['path']); //document title with hyperlink $row[] = create_document_link($http_www,$document_name,$id['path'],$id['filetype'],$size,$id['visibility']).'
'.get_lang('NoDocsInFolder').'
'); } $table = new SortableTableFromArray($sortable_data,2,100); $query_vars['curdirpath'] = $curdirpath; if(isset($_SESSION['_gid'])) { $query_vars['gidReq'] = $_SESSION['_gid']; } $table->set_additional_parameters($query_vars); $column = 0; if (($is_allowed_to_edit || $group_member_with_upload_rights) AND count($docs_and_folders)>1) { $table->set_header($column++,'',false); } $table->set_header($column++,get_lang('Type')); $table->set_header($column++,get_lang('Name')); //$column_header[] = array(get_lang('Comment'),true); => display comment under the document name $table->set_header($column++,get_lang('Size')); $table->set_header($column++,get_lang('Date')); //admins get an edit column if ($is_allowed_to_edit || $group_member_with_upload_rights) { $table->set_header($column++,'',false); } //actions on multiple selected documents //currently only delete action -> take only DELETE right into account if (count($docs_and_folders)>1) { if ($is_allowed_to_edit || $group_member_with_upload_rights) { $form_actions = array(); $form_action['delete'] = get_lang('Delete'); $table->set_form_actions($form_action,'path'); } } $table->display(); echo $table_footer; /* ============================================================================== Quota section Proposal: perhaps move/add the quota display to another section, e.g. course info ============================================================================== */ if ($is_allowed_to_edit) display_document_options(); /* ============================================================================== Footer ============================================================================== */ Display::display_footer(); ?>