document.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <?php // $Id: document.php 10839 2007-01-23 09:35:28Z elixir_julian $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2005 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) various contributors
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  17. Mail: info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. * Main script for the documents tool
  23. *
  24. * This script allows the user to manage files and directories on a remote http server.
  25. *
  26. * The user can : - navigate through files and directories.
  27. * - upload a file
  28. * - delete, copy a file or a directory
  29. * - edit properties & content (name, comments, html content)
  30. *
  31. * The script is organised in four sections.
  32. *
  33. * 1) Execute the command called by the user
  34. * Note: somme commands of this section are organised in two steps.
  35. * The script always begins with the second step,
  36. * so it allows to return more easily to the first step.
  37. *
  38. * Note (March 2004) some editing functions (renaming, commenting)
  39. * are moved to a separate page, edit_document.php. This is also
  40. * where xml and other stuff should be added.
  41. *
  42. * 2) Define the directory to display
  43. *
  44. * 3) Read files and directories from the directory defined in part 2
  45. * 4) Display all of that on an HTML page
  46. *
  47. * @todo eliminate code duplication between
  48. * document/document.php, scormdocument.php
  49. *
  50. * @package dokeos.document
  51. ==============================================================================
  52. */
  53. /*
  54. ==============================================================================
  55. INIT SECTION
  56. ==============================================================================
  57. */
  58. // name of the language file that needs to be included
  59. $language_file = 'document';
  60. include("../inc/global.inc.php");
  61. $this_section=SECTION_COURSES;
  62. include('document.inc.php');
  63. api_protect_course_script();
  64. //session
  65. if(isset($_GET['id_session']))
  66. $_SESSION['id_session'] = $_GET['id_session'];
  67. $htmlHeadXtra[] =
  68. "<script type=\"text/javascript\">
  69. function confirmation (name)
  70. {
  71. if (confirm(\" ". get_lang("AreYouSureToDelete") ." \"+ name + \" ?\"))
  72. {return true;}
  73. else
  74. {return false;}
  75. }
  76. </script>";
  77. /*
  78. -----------------------------------------------------------
  79. Variables
  80. - some need defining before inclusion of libraries
  81. -----------------------------------------------------------
  82. */
  83. //what's the current path?
  84. //we will verify this a bit further down
  85. if(isset($_GET['curdirpath']) && $_GET['curdirpath']!='')
  86. {
  87. $curdirpath = $_GET['curdirpath'];
  88. }
  89. elseif (isset($_POST['curdirpath']) && $_POST['curdirpath']!='')
  90. {
  91. $curdirpath = $_POST['curdirpath'];
  92. }
  93. else
  94. {
  95. $curdirpath = '/';
  96. }
  97. $curdirpathurl = urlencode($curdirpath);
  98. $course_dir = $_course['path']."/document";
  99. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  100. $base_work_dir = $sys_course_path.$course_dir;
  101. $http_www = api_get_path('WEB_COURSE_PATH').$_course['path'].'/document';
  102. $dbl_click_id = 0; // used to avoid double-click
  103. $is_allowed_to_edit = api_is_allowed_to_edit();
  104. $group_member_with_upload_rights = false;
  105. //if the group id is set, we show them group documents
  106. if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='')
  107. {
  108. //needed for group related stuff
  109. include_once(api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php');
  110. //get group info
  111. $group_properties = GroupManager::get_group_properties($_SESSION['_gid']);
  112. $noPHP_SELF=true;
  113. //let's assume the user cannot upload files for the group
  114. $group_member_with_upload_rights = false;
  115. if($group_properties['doc_state']==2) //documents are private
  116. {
  117. if($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'],$_SESSION['_gid'])) //only courseadmin or group members (members + tutors) allowed
  118. {
  119. $to_group_id = $_SESSION['_gid'];
  120. $req_gid = '&amp;gidReq='.$_SESSION['_gid'];
  121. $interbreadcrumb[]= array ("url"=>"../group/group.php", "name"=> get_lang('Groups'));
  122. $interbreadcrumb[]= array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['_gid'], "name"=> get_lang('GroupSpace'));
  123. //they are allowed to upload
  124. $group_member_with_upload_rights = true;
  125. }
  126. else
  127. {
  128. $to_group_id = 0;
  129. $req_gid = '';
  130. }
  131. }
  132. elseif($group_properties['doc_state']==1) //documents are public
  133. {
  134. $to_group_id = $_SESSION['_gid'];
  135. $req_gid = '&amp;gidReq='.$_SESSION['_gid'];
  136. $interbreadcrumb[]= array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['_gid'], "name"=> get_lang('GroupSpace'));
  137. //allowed to upload?
  138. if($is_allowed_to_edit || GroupManager::is_subscribed($_user['user_id'],$_SESSION['_gid'])) //only courseadmin or group members can upload
  139. {
  140. $group_member_with_upload_rights = true;
  141. }
  142. }
  143. else //documents not active for this group
  144. {
  145. $to_group_id = 0;
  146. $req_gid = '';
  147. }
  148. $_SESSION['group_member_with_upload_rights'] = $group_member_with_upload_rights;
  149. }
  150. else
  151. {
  152. $to_group_id = 0;
  153. $req_gid = '';
  154. }
  155. /*
  156. -----------------------------------------------------------
  157. Libraries
  158. -----------------------------------------------------------
  159. */
  160. //the main_api.lib.php, database.lib.php and display.lib.php
  161. //libraries are included by default
  162. include_once(api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php');
  163. include_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
  164. include_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
  165. include_once(api_get_path(LIBRARY_PATH) . 'tablesort.lib.php');
  166. include_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
  167. //-----------------------------------------------------------
  168. //check the path
  169. //if the path is not found (no document id), set the path to /
  170. if(!DocumentManager::get_document_id($_course,$curdirpath)){
  171. $curdirpath = '/';
  172. //urlencoded version
  173. $curdirpathurl = '%2F';
  174. }
  175. //if they are looking at group documents they can't see the root
  176. if($to_group_id!=0 && $curdirpath=='/')
  177. {
  178. $curdirpath = $group_properties['directory'];
  179. $curdirpathurl = urlencode($group_properties['directory']);
  180. }
  181. //-----------------------------------------------------------
  182. /*
  183. -----------------------------------------------------------
  184. Constants and variables
  185. -----------------------------------------------------------
  186. */
  187. $course_quota = DocumentManager::get_course_quota();
  188. /*
  189. ==============================================================================
  190. MAIN SECTION
  191. ==============================================================================
  192. */
  193. //-------------------------------------------------------------------//
  194. if ($_GET['action']=="download")
  195. {
  196. //check if the document is in the database
  197. if(!DocumentManager::get_document_id($_course,$_GET['id']))
  198. {
  199. //file not found!
  200. header("HTTP/1.0 404 Not Found");
  201. $error404 = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">';
  202. $error404 .= '<html><head>';
  203. $error404 .= '<title>404 Not Found</title>';
  204. $error404 .= '</head><body>';
  205. $error404 .= '<h1>Not Found</h1>';
  206. $error404 .= '<p>The requested URL was not found on this server.</p>';
  207. $error404 .= '<hr>';
  208. $error404 .= '</body></html>';
  209. echo($error404);
  210. exit;
  211. }
  212. // launch event
  213. event_download($_GET['id']);
  214. $doc_url=$_GET['id'];
  215. $full_file_name = $base_work_dir.$doc_url;
  216. DocumentManager::file_send_for_download($full_file_name,true);
  217. exit;
  218. }
  219. //-------------------------------------------------------------------//
  220. //download of an completed folder
  221. if($_GET['action']=="downloadfolder")
  222. {
  223. include('downloadfolder.inc.php');
  224. }
  225. //-------------------------------------------------------------------//
  226. // slideshow inititalisation
  227. $_SESSION["image_files_only"]="";
  228. $image_files_only="";
  229. /*
  230. -----------------------------------------------------------
  231. Header
  232. -----------------------------------------------------------
  233. */
  234. $tool_name = get_lang("Doc"); // title of the page (should come from the language file)
  235. Display::display_header($tool_name,"Doc");
  236. $is_allowed_to_edit = api_is_allowed_to_edit();
  237. /*
  238. * Lib for event log, stats & tracking
  239. * plus record of the access
  240. */
  241. event_access_tool(TOOL_DOCUMENT);
  242. /*
  243. ==============================================================================
  244. DISPLAY
  245. ==============================================================================
  246. */
  247. if($to_group_id !=0) //add group name after for group documents
  248. {
  249. $add_group_to_title = ' ('.$group_properties['name'].')';
  250. }
  251. //api_display_tool_title($tool_name.$add_group_to_title);
  252. /*
  253. -----------------------------------------------------------
  254. Introduction section
  255. (editable by course admins)
  256. -----------------------------------------------------------
  257. */
  258. Display::display_introduction_section(TOOL_DOCUMENT.$_SESSION['_gid']);
  259. /*============================================================================*/
  260. if($is_allowed_to_edit || $group_member_with_upload_rights) // TEACHER ONLY
  261. {
  262. /*======================================
  263. MOVE FILE OR DIRECTORY
  264. ======================================*/
  265. if (isset($_GET['move']) && $_GET['move']!='')
  266. {
  267. if(DocumentManager::get_document_id($_course,$_GET['move']))
  268. {
  269. $folders = DocumentManager::get_all_document_folders($_course,$to_group_id,$is_allowed_to_edit || $group_member_with_upload_rights);
  270. Display::display_normal_message(build_move_to_selector($folders,$_GET['curdirpath'],$_GET['move'],$group_properties['directory']));
  271. }
  272. }
  273. if (isset($_POST['move_to']) && isset($_POST['move_file']))
  274. {
  275. include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
  276. //this is needed for the update_db_info function
  277. //$dbTable = $_course['dbNameGlu']."document";
  278. $dbTable = Database::get_course_table(TABLE_DOCUMENT);
  279. //security fix: make sure they can't move files that are not in the document table
  280. if(DocumentManager::get_document_id($_course,$_POST['move_file'])) {
  281. //Display::display_normal_message('We want to move '.$_POST['move_file'].' to '.$_POST['move_to']);
  282. if ( move($base_work_dir.$_POST['move_file'],$base_work_dir.$_POST['move_to']) )
  283. {
  284. update_db_info("update", $_POST['move_file'], $_POST['move_to']."/".basename($_POST['move_file']));
  285. //set the current path
  286. $curdirpath = $_POST['move_to'];
  287. $curdirpathurl = urlencode($_POST['move_to']);
  288. Display::display_normal_message(get_lang('DirMv'));
  289. }
  290. else
  291. {
  292. Display::display_error_message(get_lang('Impossible'));
  293. }
  294. }
  295. else
  296. {
  297. Display::display_error_message(get_lang('Impossible'));
  298. }
  299. }
  300. /*======================================
  301. DELETE FILE OR DIRECTORY
  302. ======================================*/
  303. if ( isset($_GET['delete']) )
  304. {
  305. include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php');
  306. if(DocumentManager::delete_document($_course,$_GET['delete'],$base_work_dir))
  307. {
  308. Display::display_normal_message(get_lang('DocDeleted'));
  309. }
  310. else
  311. {
  312. Display::display_normal_message(get_lang('DocDeleteError'));
  313. }
  314. }
  315. if( isset($_POST['action']))
  316. {
  317. switch($_POST['action'])
  318. {
  319. case 'delete':
  320. foreach($_POST['path'] as $index => $path)
  321. {
  322. DocumentManager::delete_document($_course,$path,$base_work_dir);
  323. }
  324. Display::display_normal_message(get_lang('DocDeleted'));
  325. break;
  326. }
  327. }
  328. /*======================================
  329. CREATE DIRECTORY
  330. ======================================*/
  331. //create directory with $_POST data
  332. if(isset($_POST['create_dir']) && $_POST['dirname']!='')
  333. {
  334. //needed for directory creation
  335. include_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
  336. $added_slash = ($curdirpath=='/')?'':'/';
  337. $dir_name = $curdirpath.$added_slash.replace_dangerous_char($_POST['dirname']);
  338. $created_dir = create_unexisting_directory($_course,$_user['user_id'],$to_group_id,$to_user_id,$base_work_dir,$dir_name,$_POST['dirname']);
  339. if($created_dir)
  340. {
  341. //Display::display_normal_message("<strong>".$created_dir."</strong> was created!");
  342. Display::display_normal_message('<span title="'.$created_dir.'">'.get_lang('DirCr').'</span>');
  343. //uncomment if you want to enter the created dir
  344. //$curdirpath = $created_dir;
  345. //$curdirpathurl = urlencode($curdirpath);
  346. }
  347. else
  348. {
  349. Display::display_error_message(get_lang('CannotCreateDir'));
  350. }
  351. }
  352. //show them the form for the directory name
  353. if(isset($_GET['createdir']))
  354. {
  355. //create the form that asks for the directory name
  356. $new_folder_text = '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
  357. $new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$curdirpath.'" />';
  358. $new_folder_text .= get_lang('NewDir') .' ';
  359. $new_folder_text .= '<input type="text" name="dirname" />';
  360. $new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'" />';
  361. $new_folder_text .= '</form>';
  362. //show the form
  363. Display::display_normal_message($new_folder_text);
  364. }
  365. /*======================================
  366. VISIBILITY COMMANDS
  367. ======================================*/
  368. if ((isset($_GET['set_invisible']) && !empty($_GET['set_invisible'])) || (isset($_GET['set_visible']) && !empty($_GET['set_visible'])) AND $_GET['set_visible']<>'*' AND $_GET['set_invisible']<>'*')
  369. {
  370. //make visible or invisible?
  371. if(isset($_GET['set_visible']))
  372. {
  373. $update_id = $_GET['set_visible'];
  374. $visibility_command = 'visible';
  375. }
  376. else
  377. {
  378. $update_id = $_GET['set_invisible'];
  379. $visibility_command = 'invisible';
  380. }
  381. //update item_property to change visibility
  382. if(api_item_property_update($_course, TOOL_DOCUMENT, $update_id, $visibility_command, $_user['user_id']))
  383. {
  384. Display::display_normal_message(get_lang("ViMod"));
  385. }
  386. else
  387. {
  388. Display::display_error_message(get_lang("ViModProb"));
  389. }
  390. }
  391. } // END is allowed to edit
  392. /*
  393. -----------------------------------------------------------
  394. GET ALL DOCUMENT DATA FOR CURDIRPATH
  395. -----------------------------------------------------------
  396. */
  397. $docs_and_folders = DocumentManager::get_all_document_data($_course,$curdirpath,$to_group_id,NULL,$is_allowed_to_edit || $group_member_with_upload_rights);
  398. ?>
  399. <div id="folderselector" style="float:left;margin-right:10px;margin-top:5px;">
  400. <?php
  401. $folders = DocumentManager::get_all_document_folders($_course,$to_group_id,$is_allowed_to_edit || $group_member_with_upload_rights);
  402. echo(build_directory_selector($folders,$curdirpath,$group_properties['directory'],true));
  403. ?>
  404. </div>
  405. <?php
  406. echo "<div id=\"doc_links\">";
  407. /* GO TO PARENT DIRECTORY */
  408. if ($curdirpath!= '/'&& $curdirpath!=$group_properties['directory'])
  409. {
  410. ?>
  411. <a href="<?php echo $_SERVER['PHP_SELF']; ?>?curdirpath=<?php echo urlencode((dirname($curdirpath)=='\\')?'/':dirname($curdirpath)) ?>">
  412. <img src="../img/parent.gif" border="0" align="absbottom" hspace="5" alt="" />
  413. <?php echo get_lang("Up"); ?></a>&nbsp;
  414. <?php
  415. }
  416. if ($is_allowed_to_edit || $group_member_with_upload_rights)
  417. {
  418. /* CREATE NEW DOCUMENT OR NEW DIRECTORY / GO TO UPLOAD / DOWNLOAD ZIPPED FOLDER */
  419. ?>
  420. <!-- create new document or directory -->
  421. <a href="create_document.php?dir=<?php echo $curdirpathurl; ?>"><img src="../img/filenew.gif" border="0" alt="" title="<?php echo get_lang('CreateDoc'); ?>" /></a>
  422. <a href="create_document.php?dir=<?php echo $curdirpathurl; ?>"><?php echo get_lang("CreateDoc"); ?></a>&nbsp;&nbsp;
  423. <!-- file upload link -->
  424. <a href="upload.php?path=<?php echo $curdirpathurl.$req_gid; ?>"><img src="../img/submit_file.gif" border="0" title="<?php echo get_lang('UplUploadDocument'); ?>" alt="" /></a>
  425. <a href="upload.php?path=<?php echo $curdirpathurl.$req_gid; ?>"><?php echo get_lang('UplUploadDocument'); ?></a>&nbsp;
  426. <!-- create directory -->
  427. <a href="<?php echo $_SERVER['PHP_SELF']; ?>?curdirpath=<?php echo $curdirpathurl; ?>&amp;createdir=1"><img src="../img/folder_new.gif" border="0" alt ="" /></a>
  428. <a href="<?php echo $_SERVER['PHP_SELF']; ?>?curdirpath=<?php echo $curdirpathurl; ?>&amp;createdir=1"><?php echo get_lang("CreateDir"); ?></a>&nbsp;
  429. <?php
  430. }
  431. ?>
  432. <!-- download zipped folder -->
  433. <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=downloadfolder&amp;path=<?php echo $curdirpathurl; ?>"><img src="../img/zip_save.gif" border="0" title="<?php echo get_lang("Save"); ?> (ZIP)" alt="" /></a>
  434. <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=downloadfolder&amp;path=<?php echo $curdirpathurl; ?>"><?php echo get_lang("Save"); ?> (ZIP)</a>&nbsp;
  435. <?php
  436. // Slideshow by Patrick Cool, May 2004
  437. include("document_slideshow.inc.php");
  438. // including the language file for the slideshow
  439. include(api_get_path(SYS_LANG_PATH).$languageInterface."/"."slideshow.inc.php");
  440. if ($image_present)
  441. {
  442. echo "<a href=\"slideshow.php?curdirpath=".$curdirpathurl."\"><img src=\"../img/images_gallery.gif\" border=\"0\" title=\"".get_lang('ViewSlideshow')."\"/>&nbsp;". get_lang('ViewSlideshow') . "</a>";
  443. }
  444. echo "</div>";
  445. //==============================================================================
  446. if($docs_and_folders)
  447. {
  448. //echo('<pre>');
  449. //print_r($docs_and_folders);
  450. //echo('</pre>');
  451. //*************************************************************************************************
  452. //do we need the title field for the document name or not?
  453. //we get the setting here, so we only have to do it once
  454. $use_document_title = get_setting('use_document_title');
  455. //create a sortable table with our data
  456. $sortable_data = array();
  457. while (list ($key, $id) = each($docs_and_folders))
  458. {
  459. $row = array ();
  460. //if the item is invisible, wrap it in a span with class invisible
  461. $invisibility_span_open = ($id['visibility']==0)?'<span class="invisible">':'';
  462. $invisibility_span_close = ($id['visibility']==0)?'</span>':'';
  463. //size (or total size of a directory)
  464. $size = $id['filetype']=='folder' ? get_total_folder_size($id['path'],$is_allowed_to_edit) : $id[size];
  465. //get the title or the basename depending on what we're using
  466. if ($use_document_title=='true' AND $id['title']<>'')
  467. {
  468. $document_name=$id['title'];
  469. }
  470. else
  471. {
  472. $document_name=basename($id['path']);
  473. }
  474. //$row[] = $key; //testing
  475. //data for checkbox
  476. if (($is_allowed_to_edit || $group_member_with_upload_rights) AND count($docs_and_folders)>1)
  477. {
  478. $row[] = $id['path'];
  479. }
  480. //icons
  481. $row[]= build_document_icon_tag($id['filetype'],$id['path']);
  482. //document title with hyperlink
  483. $row[] = create_document_link($http_www,$document_name,$id['path'],$id['filetype'],$size,$id['visibility']).'<br />'.$invisibility_span_open.nl2br(htmlspecialchars($id['comment'])).$invisibility_span_close;
  484. //comments => display comment under the document name
  485. //$row[] = $invisibility_span_open.nl2br(htmlspecialchars($id['comment'])).$invisibility_span_close;
  486. $display_size = format_file_size($size);
  487. $row[] = '<span style="display:none;">'.$size.'</span>'.$invisibility_span_open.$display_size.$invisibility_span_close;
  488. //last edit date
  489. $display_date = format_date(strtotime($id['lastedit_date']));
  490. $row[] = '<span style="display:none;">'.$id['lastedit_date'].'</span>'.$invisibility_span_open.$display_date.$invisibility_span_close;
  491. //admins get an edit column
  492. if ($is_allowed_to_edit || $group_member_with_upload_rights)
  493. {
  494. $edit_icons = build_edit_icons($curdirpath,$id['filetype'],$id['path'],$id['visibility'],$key);
  495. $row[] = $edit_icons;
  496. }
  497. $sortable_data[] = $row;
  498. }
  499. //*******************************************************************************************
  500. }
  501. else
  502. {
  503. $sortable_data='';
  504. $table_footer='<div style="text-align:center;"><strong>'.get_lang('NoDocsInFolder').'</strong></div>';
  505. //echo('<p><strong>'.get_lang('NoDocsInFolder').'</strong></p>');
  506. }
  507. $table = new SortableTableFromArray($sortable_data,2,100);
  508. $query_vars['curdirpath'] = $curdirpath;
  509. if(isset($_SESSION['_gid']))
  510. {
  511. $query_vars['gidReq'] = $_SESSION['_gid'];
  512. }
  513. $table->set_additional_parameters($query_vars);
  514. $column = 0;
  515. if (($is_allowed_to_edit || $group_member_with_upload_rights) AND count($docs_and_folders)>1)
  516. {
  517. $table->set_header($column++,'',false);
  518. }
  519. $table->set_header($column++,get_lang('Type'));
  520. $table->set_header($column++,get_lang('Name'));
  521. //$column_header[] = array(get_lang('Comment'),true); => display comment under the document name
  522. $table->set_header($column++,get_lang('Size'));
  523. $table->set_header($column++,get_lang('Date'));
  524. //admins get an edit column
  525. if ($is_allowed_to_edit || $group_member_with_upload_rights)
  526. {
  527. $table->set_header($column++,'',false);
  528. }
  529. //actions on multiple selected documents
  530. //currently only delete action -> take only DELETE right into account
  531. if (count($docs_and_folders)>1)
  532. {
  533. if ($is_allowed_to_edit || $group_member_with_upload_rights)
  534. {
  535. $form_actions = array();
  536. $form_action['delete'] = get_lang('Delete');
  537. $table->set_form_actions($form_action,'path');
  538. }
  539. }
  540. $table->display();
  541. echo $table_footer;
  542. /*
  543. ==============================================================================
  544. Quota section
  545. Proposal: perhaps move/add the quota display to another section, e.g. course info
  546. ==============================================================================
  547. */
  548. if ($is_allowed_to_edit) display_document_options();
  549. /*
  550. ==============================================================================
  551. Footer
  552. ==============================================================================
  553. */
  554. Display::display_footer();
  555. ?>