index.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <?php // $Id: index.php,v 1.46 2005/09/26 10:20:25 pcool Exp $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2006-2008 Dokeos S.A.
  6. Copyright (c) 2006 Ghent University (UGent)
  7. Copyright (c) various contributors
  8. For a full list of contributors, see "credits.txt".
  9. The full license can be read in "license.txt".
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. See the GNU General Public License for more details.
  15. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  16. Mail: info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * @desc The dropbox is a personal (peer to peer) file exchange module that allows
  22. * you to send documents to a certain (group of) users.
  23. *
  24. * @version 1.3
  25. *
  26. * @author Jan Bols <jan@ivpv.UGent.be>, main programmer, initial version
  27. * @author Ren� Haentjens <rene.haentjens@UGent.be>, several contributions (see RH)
  28. * @author Roan Embrechts, virtual course support
  29. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (see history version 1.3)
  30. *
  31. * @package dokeos.dropbox
  32. *
  33. * @todo complete refactoring. Currently there are about at least 3 sql queries needed for every individual dropbox document.
  34. * first we find all the documents that were sent (resp. received) by the user
  35. * then for every individual document the user(s)information who received (resp. sent) the document is searched
  36. * then for every individual document the feedback is retrieved
  37. * @todo the implementation of the dropbox categories could (on the database level) have been done more elegantly by storing the category
  38. * in the dropbox_person table because this table stores the relationship between the files (sent OR received) and the users
  39. ==============================================================================
  40. */
  41. /**
  42. ==============================================================================
  43. HISTORY
  44. ==============================================================================
  45. Version 1.1
  46. ------------
  47. - dropbox_init1.inc.php: changed include statements to require statements. This way if a file is not found, it stops the execution of a script instead of continuing with warnings.
  48. - dropbox_init1.inc.php: the include files "claro_init_global.inc.php" & "debug.lib.inc.php" are first checked for their existence before including them. If they don't exist, in the .../include dir, they get loaded from the .../inc dir. This change is necessary because the UCL changed the include dir to inc.
  49. - dropbox_init1.inc.php: the databasetable name in the variable $dropbox_cnf["introTbl"] is chnged from "introduction" to "tool_intro"
  50. - install.php: after submit, checks if the database uses accueil or tool_list as a tablename
  51. - index.php: removed the behaviour of only the teachers that are allowed to delete entries
  52. - index.php: added field "lastUploadDate" in table dropbox_file to store information about last update when resubmiting a file
  53. - dropbox.inc.php: added $lang["lastUpdated"]
  54. - index.php: entries in received list show when file was last updated if it is updated
  55. - index.php: entries in sent list show when file was last resent if it was resent
  56. - dropbox_submit.php: add a unique id to every uploaded file
  57. - index.php: add POST-variable to the upload form with overwrite data when user decides to overwrite the previous sent file with new file
  58. - dropbox_submit.php: add sanity checks on POST['overwrite'] data
  59. - index.php: remove title field in upload form
  60. - dropbox_submit.php: remove use of POST['title'] variable
  61. - dropbox_init1.inc.php: added $dropbox_cnf["version"] variable
  62. - dropbox_class.inc.php: add $this->lastUploadDate to Dropbox_work class
  63. - dropbox.inc.php: added $lang['emptyTable']
  64. - index.php: if the received or sent list is empty, a message is displayed
  65. - dropbox_download.php: the $file var is set equal to the title-field of the filetable. So not constructed anymore by substracting the username from the filename
  66. - index.php: add check to see if column lastUploadDate exists in filetable
  67. - index.php: moved javascripts from dropbox_init2.inc.php to index.php
  68. - index.php: when specifying an uploadfile in the form, a checkbox allowing the user to overwrite a previously sent file is shown when the specified file has the same name as a previously uploaded file of that user.
  69. - index.php: assign all the metadata (author, description, date, recipient, sender) of an entry in a list to the class="dropbox_detail" and add css to html-header
  70. - index.php: assign all dates of entries in list to the class="dropbox_date" and add CSS
  71. - index.php: assign all persons in entries of list to the class="dropbox_person" and add CSS
  72. - dropbox.inc.php: added $lang['dropbox_version'] to indicate the lates version. This must be equal to the $dropbox_cnf['version'] variable.
  73. - dropbox_init1.inc.php: if the newest lang file isn't loaded by claro_init_global.inc.php from the .../lang dir it will be loaded locally from the .../plugin/dropbox/ dir. This way an administrator must not install the dropbox.inc.php in the .../lang/english dir, but he can leave it in the local .../plugin/dropbox/ dir. However if you want to present multiple language translations of the file you must still put the file in the /lang/ dir, because there is no language management system inside the .../plugin/dropbox dir.
  74. - mime.inc.php: created this file. It contains an array $mimetype with all the mimetypes that are used by dropbox_download.php to give hinst to the browser during download about content
  75. - dropbox_download.php: remove https specific headers because they're not necessary
  76. - dropbox_download.php: use application/octet-stream as the default mime and inline as the default Content-Disposition
  77. - dropbox.inc.php: add lang vars for "order by" action
  78. - dropbox_class.inc.php: add methods orderSentWork, orderReceivedWork en _cmpWork and propery _orderBy to class Dropbox_person to take care of sorting
  79. - index.php: add selectionlist to headers of sent/received lists to select "order by" and add code to keep selected value in sessionvar.
  80. - index.php: moved part of a <a> hyperlink to previous line to remove the underlined space between symbol and title of a work entry in the sent/received list
  81. - index.php: add filesize info in sent/received lists
  82. - dropbox_submit.php: resubmit prevention only for GET action, because it gives some annoying behaviour in POST situation: white screen in IE6
  83. Version 1.2
  84. -----------
  85. - adapted entire dropbox tool so it can be used as a default tool in Dokeos 1.5
  86. - index.php: add event registration to log use of tool in stats tables
  87. - index.php: upload form checks for correct user selection and file specification before uploading the script
  88. - dropbox_init1.inc.php: added dropbox_cnf["allowOverwrite"] to allow or disallow overwriting of files
  89. - index.php: author name textbox is automatically filled in
  90. - mailing functionality (see RH comments in code)
  91. - allowStudentToStudent and allowJustUpload options (id.)
  92. - help in separate window (id.)
  93. Version 1.3 (Patrick Cool)
  94. --------------------------
  95. - sortable table
  96. - categories
  97. - fixing a security hole
  98. - tabs (which can be disabled: see $dropbox_cnf['sent_received_tabs'])
  99. - same action on multiple documents ([zip]download, move, delete)
  100. - consistency with the docuements tool (open/download file, icons of documents, ...)
  101. - zip download of complete folder
  102. Version 1.4 (Yannick Warnier)
  103. -----------------------------
  104. - removed all self-built database tables names
  105. ==============================================================================
  106. */
  107. /*
  108. ==============================================================================
  109. INIT SECTION
  110. ==============================================================================
  111. */
  112. // the file that contains all the initialisation stuff (and includes all the configuration stuff)
  113. require_once( "dropbox_init.inc.php");
  114. // get the last time the user accessed the tool
  115. if ($_SESSION['last_access'][$_course['id']][TOOL_DROPBOX]=='') {
  116. $last_access=get_last_tool_access(TOOL_DROPBOX,$_course['code'],$_user['user_id']);
  117. $_SESSION['last_access'][$_course['id']][TOOL_DROPBOX]=$last_access;
  118. } else {
  119. $last_access=$_SESSION['last_access'][$_course['id']][TOOL_DROPBOX];
  120. }
  121. // do the tracking
  122. event_access_tool(TOOL_DROPBOX);
  123. //this var is used to give a unique value to every page request. This is to prevent resubmiting data
  124. $dropbox_unid = md5( uniqid( rand( ), true));
  125. /*
  126. ==============================================================================
  127. DISPLAY SECTION
  128. ==============================================================================
  129. */
  130. // introduction section
  131. $fck_attribute['Width'] = '100%';
  132. $fck_attribute['Height'] = '400';
  133. $fck_attribute['ToolbarSet'] = 'Full';
  134. Display::display_introduction_section(TOOL_DROPBOX,'left');
  135. $fck_attribute = null; // Clearing this global variable immediatelly after it has been used.
  136. /*
  137. -----------------------------------------------------------
  138. ACTIONS: add a dropbox file, add a dropbox category.
  139. -----------------------------------------------------------
  140. */
  141. // *** display the form for adding a new dropbox item. ***
  142. if ($_GET['action']=="add") {
  143. display_add_form();
  144. }
  145. if (isset($_POST['submitWork'])) {
  146. $check = Security::check_token();
  147. if ($check) {
  148. Display :: display_confirmation_message(store_add_dropbox());
  149. //include_once('dropbox_submit.php');
  150. }
  151. }
  152. // *** display the form for adding a category ***
  153. if ($_GET['action']=="addreceivedcategory" or $_GET['action']=="addsentcategory") {
  154. display_addcategory_form($_POST['category_name']);
  155. }
  156. // *** editing a category: displaying the form ***
  157. if ($_GET['action']=='editcategory' and isset($_GET['id'])) {
  158. if (!$_POST) {
  159. display_addcategory_form('',$_GET['id']);
  160. }
  161. }
  162. // *** storing a new or edited category ***
  163. if (isset($_POST['StoreCategory'])) {
  164. Display :: display_confirmation_message(store_addcategory());
  165. }
  166. // *** Move a File ***
  167. if (($_GET['action']=='movesent' OR $_GET['action']=='movereceived') AND isset($_GET['move_id'])) {
  168. display_move_form(str_replace('move','',$_GET['action']), $_GET['move_id'], get_dropbox_categories(str_replace('move','',$_GET['action'])));
  169. }
  170. if ($_POST['do_move']) {
  171. Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part']));
  172. }
  173. // *** Delete a file ***
  174. if (($_GET['action']=='deletereceivedfile' OR $_GET['action']=='deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
  175. $dropboxfile=new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor);
  176. if ($_GET['action']=='deletereceivedfile') {
  177. $dropboxfile->deleteReceivedWork($_GET['id']);
  178. $message=get_lang('ReceivedFileDeleted');
  179. }
  180. if ($_GET['action']=='deletesentfile') {
  181. $dropboxfile->deleteSentWork($_GET['id']);
  182. $message=get_lang('SentFileDeleted');
  183. }
  184. Display :: display_confirmation_message($message);
  185. }
  186. // *** Delete a category ***
  187. if (($_GET['action']=='deletereceivedcategory' OR $_GET['action']=='deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
  188. $message=delete_category($_GET['action'], $_GET['id']);
  189. }
  190. // *** Do an action on multiple files ***
  191. // only the download has is handled separately in dropbox_init_inc.php because this has to be done before the headers are sent
  192. // (which also happens in dropbox_init.inc.php
  193. if (!isset($_POST['feedback']) && (strstr($_POST['action'],'move_received') OR
  194. $_POST['action'] == 'delete_received' OR $_POST['action'] == 'download_received' OR
  195. $_POST['action'] == 'delete_sent' OR $_POST['action'] == 'download_sent'))
  196. {
  197. $display_message=handle_multiple_actions();
  198. Display :: display_normal_message($display_message);
  199. }
  200. // *** Store Feedback ***
  201. if ($_POST['feedback']) {
  202. $display_message = store_feedback();
  203. Display :: display_normal_message($display_message);
  204. }
  205. // *** Error Message ***
  206. if (isset($_GET['error']) AND !empty($_GET['error'])) {
  207. Display :: display_normal_message(get_lang($_GET['error']));
  208. }
  209. if ($_GET['action']!="add") {
  210. // getting all the categories in the dropbox for the given user
  211. $dropbox_categories=get_dropbox_categories();
  212. // creating the arrays with the categories for the received files and for the sent files
  213. foreach ($dropbox_categories as $category) {
  214. if ($category['received']=='1') {
  215. $dropbox_received_category[]=$category;
  216. }
  217. if ($category['sent']=='1') {
  218. $dropbox_sent_category[]=$category;
  219. }
  220. }
  221. /*
  222. -----------------------------------------------------------
  223. THE MENU TABS
  224. -----------------------------------------------------------
  225. */
  226. if ($dropbox_cnf['sent_received_tabs']) {
  227. ?>
  228. <div id="tabbed_menu">
  229. <ul id="tabbed_menu_tabs">
  230. <li><a href="index.php?<?php echo api_get_cidreq();?>&view=received" <?php if (!$_GET['view'] OR $_GET['view']=='received'){echo 'class="active"';}?> ><?php echo get_lang('ReceivedFiles'); ?></a></li>
  231. <li><a href="index.php?<?php echo api_get_cidreq();?>&view=sent" <?php if ($_GET['view']=='sent'){echo 'class="active"';}?>><?php echo get_lang('SentFiles'); ?></a></li>
  232. </ul>
  233. </div>
  234. <?php
  235. }
  236. /*
  237. -----------------------------------------------------------
  238. RECEIVED FILES
  239. -----------------------------------------------------------
  240. */
  241. if (!$_GET['view'] OR $_GET['view']=='received' OR $dropbox_cnf['sent_received_tabs']==false) {
  242. //echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
  243. // This is for the categories
  244. if (isset($_GET['view_received_category']) AND $_GET['view_received_category']<>'') {
  245. $view_dropbox_category_received=$_GET['view_received_category'];
  246. } else {
  247. $view_dropbox_category_received=0;
  248. }
  249. /* *** Menu Received *** */
  250. echo '<div class="actions">';
  251. if ($view_dropbox_category_received<>0) {
  252. echo get_lang('CurrentlySeeing').': <strong>'.$dropbox_categories[$view_dropbox_category_received]['cat_name'].'</strong> ';
  253. echo '<img src="../img/folder_up.gif" alt="'.get_lang('Up').'" align="absmiddle" /><a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'">'.get_lang('Root')."</a>\n";
  254. $movelist[0] = 'Root'; // move_received selectbox content
  255. } else {
  256. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory"><img src="../img/folder_new.gif" align=\"absmiddle\"/> '.get_lang('AddNewCategory').'</a>';
  257. }
  258. echo '</div>';
  259. // object initialisation
  260. $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor); // note: are the $is_courseAdmin and $is_courseTutor parameters needed????
  261. // constructing the array that contains the total number of feedback messages per document.
  262. $number_feedback=get_total_number_feedback();
  263. // sorting and paging options
  264. $sorting_options = array();
  265. $paging_options = array();
  266. // the headers of the sortable tables
  267. $column_header=array();
  268. $column_header[] = array('',false,'');
  269. $column_header[] = array(get_lang('Type'),true,'style="width:40px"');
  270. $column_header[] = array(get_lang('ReceivedTitle'), TRUE, '');
  271. $column_header[] = array(get_lang('Size'), TRUE, '');
  272. $column_header[] = array(get_lang('Authors'), TRUE, '');
  273. $column_header[] = array(get_lang('LastResent'), true);
  274. $column_header[] = array(get_lang('Modify'), FALSE, '', 'nowrap style="text-align: right"');
  275. $column_header[] = array('RealDate', true);
  276. // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
  277. $column_show[]=1;
  278. $column_show[]=1;
  279. $column_show[]=1;
  280. $column_show[]=1;
  281. $column_show[]=1;
  282. $column_show[]=1;
  283. $column_show[]=1;
  284. $column_show[]=0;
  285. // Here we change the way how the colums are going to be sort
  286. // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
  287. // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
  288. $column_order[]=1;
  289. $column_order[]=2;
  290. $column_order[]=3;
  291. $column_order[]=4;
  292. $column_order[]=7;
  293. $column_order[]=6;
  294. $column_order[]=7;
  295. $column_order[]=8;
  296. // the content of the sortable table = the received files
  297. foreach ( $dropbox_person -> receivedWork as $dropbox_file) {
  298. $dropbox_file_data=array();
  299. if ($view_dropbox_category_received==$dropbox_file->category) {// we only display the files that are in the category that we are in.
  300. $dropbox_file_data[]=$dropbox_file->id;
  301. if (!is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
  302. $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array();
  303. }
  304. // new icon
  305. $new_icon='';
  306. if ($dropbox_file->last_upload_date > $last_access AND !in_array($dropbox_file->id,$_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
  307. $new_icon='&nbsp;<img src="../img/new.gif" align="absmiddle" alt="'.get_lang('New').'" />';
  308. }
  309. $dropbox_file_data[]=build_document_icon_tag('file',$dropbox_file->title);
  310. $dropbox_file_data[]='<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download"><img src="../img/filesave.gif" style="float:right;" alt="'.get_lang('Download').'"/></a><a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'.$dropbox_file->title.'</a>'.$new_icon.'<br>'.$dropbox_file->description;
  311. $dropbox_file_data[]=ceil(($dropbox_file->filesize)/1024).' '.get_lang('kB');
  312. $dropbox_file_data[]=$dropbox_file->author;
  313. //$dropbox_file_data[]=$dropbox_file->description;
  314. $dropbox_file_data[]=date_to_str_ago($dropbox_file->last_upload_date).'<br><span class="dropbox_date">'.$dropbox_file->last_upload_date.'</span>';
  315. $action_icons=check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
  316. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'"><img src="../img/comment_bubble.gif" alt="'.get_lang('Comment').'" align="absmiddle" /></a>
  317. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'"><img src="../img/deplacer_fichier.gif" alt="'.get_lang('Move').'" align="absmiddle"/></a>
  318. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'" onclick="return confirmation(\''.$dropbox_file->title.'\');"><img src="../img/delete.gif" alt="'.get_lang('Delete').'" align="absmiddle" /></a>';
  319. //$action_icons=' <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'"><img src="../img/deplacer.gif" alt="'.get_lang('Move').'"/></a>
  320. // <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'" onclick="return confirmation(\''.$dropbox_file->title.'\');"><img src="../img/delete.gif" alt="'.get_lang('Delete').'"/></a>';
  321. // this is a hack to have an additional row in a sortable table
  322. if ($_GET['action']=='viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id==$_GET['id']) {
  323. $action_icons.="</td></tr>\n"; // ending the normal row of the sortable table
  324. $action_icons.='<tr><td colspan="2"><a href="index.php?"'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category']."&amp;view_sent_category=".$_GET['view_sent_category']."&amp;view=".$_GET['view']."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td>\n</tr>\n";
  325. }
  326. $dropbox_file_data[]=$action_icons;
  327. $action_icons='';
  328. $dropbox_file_data[]=$dropbox_file->last_upload_date;//date
  329. $dropbox_data_recieved[]=$dropbox_file_data;
  330. }
  331. }
  332. // the content of the sortable table = the categories (if we are not in the root)
  333. if ($view_dropbox_category_received==0) {
  334. foreach ($dropbox_categories as $category) { // note: this can probably be shortened since the categories for the received files are already in the $dropbox_received_category array;
  335. $dropbox_category_data=array();
  336. if ($category['received']=='1') {
  337. $movelist[$category['cat_id']] = $category['cat_name'];
  338. $dropbox_category_data[]=$category['cat_id']; // this is where the checkbox icon for the files appear
  339. // the icon of the category
  340. $dropbox_category_data[]=build_document_icon_tag('folder',$category['cat_name']);
  341. $dropbox_category_data[]='<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=received"><img width="16" height="16" src="../img/folder_zip.gif" style="float:right;" alt="'.get_lang('Save').'"/></a><a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'">'.$category['cat_name'].'</a>';
  342. $dropbox_category_data[]='';
  343. $dropbox_category_data[]='';
  344. $dropbox_category_data[]='';
  345. $dropbox_category_data[]='<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=editcategory&amp;id='.$category['cat_id'].'"><img src="../img/edit.gif" alt="'.get_lang('Edit').'" /></a>
  346. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=deletereceivedcategory&amp;id='.$category['cat_id'].'" onclick="return confirmation(\''.$category['cat_name'].'\');"><img src="../img/delete.gif" alt="'.get_lang('Delete').'" /></a>';
  347. }
  348. if (is_array($dropbox_category_data) && count($dropbox_category_data)>0) {
  349. $dropbox_data_recieved[]=$dropbox_category_data;
  350. }
  351. }
  352. }
  353. // Displaying the table
  354. $additional_get_parameters=array('view'=>$_GET['view'], 'view_received_category'=>$_GET['view_received_category'],'view_sent_category'=>$_GET['view_sent_category']);
  355. $selectlist = array ('delete_received' => get_lang('Delete'),'download_received'=>get_lang('Download'));
  356. if (is_array($movelist)) {
  357. foreach ($movelist as $catid => $catname){
  358. $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. $catname;
  359. }
  360. }
  361. Display::display_sortable_config_table($column_header, $dropbox_data_recieved, $sorting_options, $paging_options, $additional_get_parameters,$column_show,$column_order, $selectlist);
  362. }
  363. /*
  364. -----------------------------------------------------------
  365. SENT FILES
  366. -----------------------------------------------------------
  367. */
  368. if ($_GET['view']=='sent' OR $dropbox_cnf['sent_received_tabs']==false) {
  369. //echo '<h3>'.get_lang('SentFiles').'</h3>';
  370. // This is for the categories
  371. if (isset($_GET['view_sent_category']) AND $_GET['view_sent_category']<>'') {
  372. $view_dropbox_category_sent=$_GET['view_sent_category'];
  373. } else {
  374. $view_dropbox_category_sent=0;
  375. }
  376. /* *** Menu Sent *** */
  377. echo '<div class="actions">';
  378. if ($view_dropbox_category_sent<>0) {
  379. echo get_lang('CurrentlySeeing').': <strong>'.$dropbox_categories[$view_dropbox_category_sent]['cat_name'].'</strong> ';
  380. echo '<img src="../img/folder_up.gif" alt="'.get_lang('Up').'" align="absmiddle" /><a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category=0&amp;view='.$_GET['view'].'">'.get_lang('Root')."</a>\n";
  381. } else {
  382. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$_GET['view']."&amp;action=addsentcategory\"><img src=\"../img/folder_new.gif\" align=\"absmiddle\" /> ".get_lang('AddNewCategory')."</a>\n";
  383. }
  384. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$_GET['view']."&amp;action=add\"><img src=\"../img/submit_file.gif\" align=\"absmiddle\"/> ".get_lang('UploadNewFile')."</a>&nbsp;\n";
  385. echo '</div>';
  386. //echo '<form name="sent_files" method="post" action="'.api_get_self().'?view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'">';
  387. // object initialisation
  388. $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor);
  389. // constructing the array that contains the total number of feedback messages per document.
  390. $number_feedback=get_total_number_feedback();
  391. // sorting and paging options
  392. $sorting_options = array();
  393. $paging_options = array();
  394. // the headers of the sortable tables
  395. $column_header=array();
  396. $column_header[] = array('',false,'');
  397. $column_header[] = array(get_lang('Type'),true,'style="width:40px"','style="text-align:center"');
  398. $column_header[] = array(get_lang('SentTitle'), TRUE, '');
  399. $column_header[] = array(get_lang('Size'), TRUE, '');
  400. $column_header[] = array(get_lang('SentTo'), TRUE, '');
  401. $column_header[] = array(get_lang('LastResent'), TRUE, '');
  402. $column_header[] = array(get_lang('Modify'), FALSE, '', 'nowrap style="text-align: right"');
  403. $column_header[] = array('RealDate', FALSE);
  404. $column_show=array();
  405. $column_order=array();
  406. // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
  407. $column_show[]=1;
  408. $column_show[]=1;
  409. $column_show[]=1;
  410. $column_show[]=1;
  411. $column_show[]=1;
  412. $column_show[]=1;
  413. $column_show[]=1;
  414. $column_show[]=0;
  415. // Here we change the way how the colums are going to be sort
  416. // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
  417. // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
  418. $column_order[]=1;
  419. $column_order[]=2;
  420. $column_order[]=3;
  421. $column_order[]=4;
  422. $column_order[]=7;
  423. $column_order[]=6;
  424. $column_order[]=7;
  425. $column_order[]=8;
  426. // the content of the sortable table = the received files
  427. foreach ( $dropbox_person -> sentWork as $dropbox_file) {
  428. $dropbox_file_data=array();
  429. if ($view_dropbox_category_sent==$dropbox_file->category) {
  430. $dropbox_file_data[]=$dropbox_file->id;
  431. $dropbox_file_data[]=build_document_icon_tag('file',$dropbox_file->title);
  432. $dropbox_file_data[]='<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download"><img src="../img/filesave.gif" style="float:right;" alt="'.get_lang('Save').'" /></a><a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'.$dropbox_file->title.'</a><br>'.$dropbox_file->description;
  433. $dropbox_file_data[]=ceil(($dropbox_file->filesize)/1024).' '.get_lang('kB');
  434. foreach ($dropbox_file->recipients as $recipient) {
  435. $receivers_celldata=display_user_link($recipient['user_id'], $recipient['name']).', '.$receivers_celldata;
  436. }
  437. $dropbox_file_data[]=$receivers_celldata;
  438. $dropbox_file_data[]=date_to_str_ago($dropbox_file->last_upload_date).'<br><span class="dropbox_date">'.$dropbox_file->last_upload_date.'</span>';
  439. //$dropbox_file_data[]=$dropbox_file->author;
  440. $receivers_celldata='';
  441. $action_icons=check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
  442. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'"><img src="../img/comment_bubble.gif" alt="'.get_lang('Comment').'" align="absmiddle" /></a>
  443. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=movesent&amp;move_id='.$dropbox_file->id.'"><img src="../img/deplacer_fichier.gif" alt="'.get_lang('Move').'" align="absmiddle"/></a>
  444. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=deletesentfile&amp;id='.$dropbox_file->id.'" onclick="return confirmation(\''.$dropbox_file->title.'\');"><img src="../img/delete.gif" alt="'.get_lang('Delete').'" align="absmiddle" /></a>';
  445. // this is a hack to have an additional row in a sortable table
  446. if ($_GET['action']=='viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id==$_GET['id']) {
  447. $action_icons.="</td></tr>\n"; // ending the normal row of the sortable table
  448. $action_icons.="<tr>\n\t<td colspan=\"2\"><a href=\"index.php?".api_get_cidreq()."&view_received_category=".$_GET['view_received_category']."&amp;view_sent_category=".$_GET['view_sent_category']."&amp;view=".$_GET['view']."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td>\n</tr>\n";
  449. }
  450. $dropbox_file_data[]=$action_icons;
  451. $dropbox_file_data[]=$dropbox_file->last_upload_date;
  452. $action_icons='';
  453. $dropbox_data_sent[]=$dropbox_file_data;
  454. }
  455. }
  456. // the content of the sortable table = the categories (if we are not in the root)
  457. if ($view_dropbox_category_sent==0) {
  458. foreach ($dropbox_categories as $category) {
  459. $dropbox_category_data=array();
  460. if ($category['sent']=='1') {
  461. $dropbox_category_data[]=$category['cat_id']; // this is where the checkbox icon for the files appear
  462. $dropbox_category_data[]=build_document_icon_tag('folder',$category['cat_name']);
  463. $dropbox_category_data[]='<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=sent"><img width="16" height="16" src="../img/folder_zip.gif" style="float:right;" alt="'.get_lang('Save').'" /></a><a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$category['cat_id'].'&amp;view='.$_GET['view'].'">'.$category['cat_name'].'</a>';
  464. //$dropbox_category_data[]='';
  465. $dropbox_category_data[]='';
  466. //$dropbox_category_data[]='';
  467. $dropbox_category_data[]='';
  468. $dropbox_category_data[]='';
  469. $dropbox_category_data[]='<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=editcategory&id='.$category['cat_id'].'"><img src="../img/edit.gif" alt="'.get_lang('Edit').'"/></a>
  470. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$_GET['view_received_category'].'&amp;view_sent_category='.$_GET['view_sent_category'].'&amp;view='.$_GET['view'].'&amp;action=deletesentcategory&amp;id='.$category['cat_id'].'" onclick="return confirmation(\''.$category['cat_name'].'\');"><img src="../img/delete.gif" alt="'.get_lang('Delete').'" /></a>';
  471. }
  472. if (is_array($dropbox_category_data) && count($dropbox_category_data)>0) {
  473. $dropbox_data_sent[]=$dropbox_category_data;
  474. }
  475. }
  476. }
  477. // Displaying the table
  478. $additional_get_parameters=array('view'=>$_GET['view'], 'view_received_category'=>$_GET['view_received_category'],'view_sent_category'=>$_GET['view_sent_category']);
  479. Display::display_sortable_config_table($column_header, $dropbox_data_sent, $sorting_options, $paging_options, $additional_get_parameters,$column_show,$column_order, array ('delete_received' => get_lang('Delete'),'download_received'=>get_lang('Download')));
  480. }
  481. }
  482. Display::display_footer();