index.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. // The file that contains all the initialisation stuff (and includes all the configuration stuff)
  4. require_once 'dropbox_init.inc.php';
  5. // get the last time the user accessed the tool
  6. if ($_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') {
  7. $last_access = get_last_tool_access(TOOL_DROPBOX);
  8. $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access;
  9. } else {
  10. $last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX];
  11. }
  12. $postAction = isset($_POST['action']) ? $_POST['action'] : null;
  13. $view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
  14. $viewReceivedCategory = isset($_GET['view_received_category']) ? Security::remove_XSS($_GET['view_received_category']) : null;
  15. $viewSentCategory = isset($_GET['view_sent_category']) ? Security::remove_XSS($_GET['view_sent_category']) : null;
  16. // Do the tracking
  17. event_access_tool(TOOL_DROPBOX);
  18. // This var is used to give a unique value to every page request. This is to prevent resubmiting data
  19. $dropbox_unid = md5(uniqid(rand(), true));
  20. /* DISPLAY SECTION */
  21. Display::display_introduction_section(TOOL_DROPBOX);
  22. // Build URL-parameters for table-sorting
  23. $sort_params = array();
  24. if (isset($_GET['dropbox_column'])) {
  25. $sort_params[] = 'dropbox_column='.$_GET['dropbox_column'];
  26. }
  27. if (isset($_GET['dropbox_page_nr'])) {
  28. $sort_params[] = 'page_nr='.intval($_GET['page_nr']);
  29. }
  30. if (isset($_GET['dropbox_per_page'])) {
  31. $sort_params[] = 'dropbox_per_page='.intval($_GET['dropbox_per_page']);
  32. }
  33. if (isset($_GET['dropbox_direction'])) {
  34. $sort_params[] = 'dropbox_direction='.$_GET['dropbox_direction'];
  35. }
  36. $sort_params = Security::remove_XSS(implode('&', $sort_params));
  37. $action = isset($_GET['action']) ? $_GET['action'] : null;
  38. /* ACTIONS: add a dropbox file, add a dropbox category. */
  39. // Display the form for adding a new dropbox item.
  40. if ($action == 'add') {
  41. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  42. api_not_allowed();
  43. }
  44. display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view);
  45. }
  46. if (isset($_POST['submitWork'])) {
  47. $check = Security::check_token();
  48. if ($check) {
  49. $message = store_add_dropbox();
  50. if (!empty($message)) {
  51. Display :: display_confirmation_message($message);
  52. }
  53. }
  54. }
  55. // Display the form for adding a category
  56. if ($action == 'addreceivedcategory' or $action == 'addsentcategory') {
  57. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  58. api_not_allowed();
  59. }
  60. display_addcategory_form($_POST['category_name'],'',$_GET['action']);
  61. }
  62. // Editing a category: displaying the form
  63. if ($action == 'editcategory' and isset($_GET['id'])) {
  64. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  65. api_not_allowed();
  66. }
  67. if (!$_POST) {
  68. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  69. api_not_allowed();
  70. }
  71. display_addcategory_form('', $_GET['id'], 'editcategory');
  72. }
  73. }
  74. // Storing a new or edited category
  75. if (isset($_POST['StoreCategory'])) {
  76. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  77. api_not_allowed();
  78. }
  79. $return_information = store_addcategory();
  80. if ($return_information['type'] == 'confirmation') {
  81. Display :: display_confirmation_message($return_information['message']);
  82. }
  83. if ($return_information['type'] == 'error') {
  84. Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']);
  85. display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction);
  86. }
  87. }
  88. // Move a File
  89. if (($action == 'movesent' OR $action == 'movereceived') AND isset($_GET['move_id'])) {
  90. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  91. api_not_allowed();
  92. }
  93. display_move_form(
  94. str_replace('move', '', $action),
  95. $_GET['move_id'],
  96. get_dropbox_categories(str_replace('move', '', $action)),
  97. $sort_params,
  98. $viewReceivedCategory,
  99. $viewSentCategory,
  100. $view
  101. );
  102. }
  103. if (isset($_POST['do_move'])) {
  104. Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part']));
  105. }
  106. // Delete a file
  107. if (($action == 'deletereceivedfile' OR $action == 'deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
  108. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  109. api_not_allowed();
  110. }
  111. $dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
  112. if ($action == 'deletereceivedfile') {
  113. $dropboxfile->deleteReceivedWork($_GET['id']);
  114. $message = get_lang('ReceivedFileDeleted');
  115. }
  116. if ($action == 'deletesentfile') {
  117. $dropboxfile->deleteSentWork($_GET['id']);
  118. $message = get_lang('SentFileDeleted');
  119. }
  120. Display :: display_confirmation_message($message);
  121. }
  122. // Delete a category
  123. if (($action == 'deletereceivedcategory' OR $action == 'deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
  124. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  125. api_not_allowed();
  126. }
  127. $message = delete_category($action, $_GET['id']);
  128. Display :: display_confirmation_message($message);
  129. }
  130. // Do an action on multiple files
  131. // only the download has is handled separately in dropbox_init_inc.php because this has to be done before the headers are sent
  132. // (which also happens in dropbox_init.inc.php
  133. if (!isset($_POST['feedback']) && (strstr($postAction, 'move_received') OR
  134. $postAction == 'delete_received' OR $postAction == 'download_received' OR
  135. $postAction == 'delete_sent' OR $postAction == 'download_sent')) {
  136. $display_message = handle_multiple_actions();
  137. Display :: display_normal_message($display_message);
  138. }
  139. // Store Feedback
  140. if (isset($_POST['feedback'])) {
  141. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  142. api_not_allowed();
  143. }
  144. $check = Security::check_token();
  145. if ($check) {
  146. $display_message = store_feedback();
  147. Display :: display_normal_message($display_message);
  148. Security::check_token();
  149. }
  150. }
  151. // Error Message
  152. if (isset($_GET['error']) AND !empty($_GET['error'])) {
  153. Display :: display_normal_message(get_lang($_GET['error']));
  154. }
  155. if ($action != 'add') {
  156. // Getting all the categories in the dropbox for the given user
  157. $dropbox_categories = get_dropbox_categories();
  158. // Greating the arrays with the categories for the received files and for the sent files
  159. foreach ($dropbox_categories as $category) {
  160. if ($category['received'] == '1') {
  161. $dropbox_received_category[] = $category;
  162. }
  163. if ($category['sent'] == '1') {
  164. $dropbox_sent_category[] = $category;
  165. }
  166. }
  167. // ACTIONS
  168. if ($view == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
  169. //echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
  170. // This is for the categories
  171. if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
  172. $view_dropbox_category_received = $viewReceivedCategory;
  173. } else {
  174. $view_dropbox_category_received = 0;
  175. }
  176. /* Menu Received */
  177. if (api_get_session_id() == 0) {
  178. echo '<div class="actions">';
  179. if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) {
  180. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
  181. echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
  182. $movelist[0] = 'Root'; // move_received selectbox content
  183. } else {
  184. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
  185. }
  186. echo '</div>';
  187. } else {
  188. if (api_is_allowed_to_session_edit(false, true)) {
  189. echo '<div class="actions">';
  190. if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) {
  191. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
  192. echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
  193. $movelist[0] = 'Root'; // move_received selectbox content
  194. } else {
  195. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
  196. }
  197. echo '</div>';
  198. }
  199. }
  200. }
  201. if (!$view OR $view == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
  202. // This is for the categories
  203. if (isset($viewSentCategory) AND $viewSentCategory != '') {
  204. $view_dropbox_category_sent = $viewSentCategory;
  205. } else {
  206. $view_dropbox_category_sent = 0;
  207. }
  208. /* Menu Sent */
  209. if (api_get_session_id() == 0) {
  210. echo '<div class="actions">';
  211. if ($view_dropbox_category_sent != 0) {
  212. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category=0&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
  213. echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
  214. } else {
  215. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
  216. }
  217. if (empty($viewSentCategory)) {
  218. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
  219. }
  220. echo '</div>';
  221. } else {
  222. if (api_is_allowed_to_session_edit(false, true)) {
  223. echo '<div class="actions">';
  224. if ($view_dropbox_category_sent != 0) {
  225. echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
  226. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category=0&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
  227. } else {
  228. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
  229. }
  230. if (empty($viewSentCategory)) {
  231. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
  232. }
  233. echo '</div>';
  234. }
  235. }
  236. }
  237. /* THE MENU TABS */
  238. if ($dropbox_cnf['sent_received_tabs']) {
  239. ?>
  240. <ul class="nav nav-tabs">
  241. <li <?php if (!$view OR $view == 'sent') { echo 'class="active"'; } ?> >
  242. <a href="index.php?<?php echo api_get_cidreq(); ?>&view=sent" ><?php echo get_lang('SentFiles'); ?></a></li>
  243. <li <?php if ($view == 'received') { echo 'class="active"'; } ?> >
  244. <a href="index.php?<?php echo api_get_cidreq(); ?>&view=received" ><?php echo get_lang('ReceivedFiles'); ?></a></li>
  245. </ul>
  246. <?php
  247. }
  248. /* RECEIVED FILES */
  249. if ($view == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
  250. // This is for the categories
  251. if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
  252. $view_dropbox_category_received = $viewReceivedCategory;
  253. } else {
  254. $view_dropbox_category_received = 0;
  255. }
  256. // Object initialisation
  257. $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); // note: are the $is_courseAdmin and $is_courseTutor parameters needed????
  258. // Constructing the array that contains the total number of feedback messages per document.
  259. $number_feedback = get_total_number_feedback();
  260. // Sorting and paging options
  261. $sorting_options = array();
  262. $paging_options = array();
  263. // The headers of the sortable tables
  264. $column_header = array();
  265. $column_header[] = array('', false, '');
  266. $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
  267. $column_header[] = array(get_lang('ReceivedTitle'), true, '');
  268. $column_header[] = array(get_lang('Size'), true, '');
  269. $column_header[] = array(get_lang('Authors'), true, '');
  270. $column_header[] = array(get_lang('LastResent'), true);
  271. if (api_get_session_id() == 0) {
  272. $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
  273. } elseif (api_is_allowed_to_session_edit(false,true)) {
  274. $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
  275. }
  276. $column_header[] = array('RealDate', true);
  277. $column_header[] = array('RealSize', true);
  278. // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
  279. $column_show[] = 1;
  280. $column_show[] = 1;
  281. $column_show[] = 1;
  282. $column_show[] = 1;
  283. $column_show[] = 1;
  284. $column_show[] = 1;
  285. if (api_get_session_id() == 0) {
  286. $column_show[] = 1;
  287. } elseif (api_is_allowed_to_session_edit(false, true)) {
  288. $column_show[] = 1;
  289. }
  290. $column_show[] = 0;
  291. // Here we change the way how the colums are going to be sort
  292. // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
  293. // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
  294. $column_order[3] = 8;
  295. $column_order[5] = 7;
  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) {
  300. // we only display the files that are in the category that we are in.
  301. $dropbox_file_data[] = $dropbox_file->id;
  302. if (!is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
  303. $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array();
  304. }
  305. // New icon
  306. $new_icon = '';
  307. if ($dropbox_file->last_upload_date > $last_access AND !in_array($dropbox_file->id, $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) {
  308. $new_icon = '&nbsp;'.Display::return_icon('new_dropbox_message.png', get_lang('New'),'',ICON_SIZE_SMALL);
  309. }
  310. $link_open = '<a href="dropbox_download.php?'.api_get_cidreq().'&amp;id='.$dropbox_file->id.'">';
  311. $dropbox_file_data[] = $link_open.build_document_icon_tag('file', $dropbox_file->title).'</a>';
  312. $dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download">'.Display::return_icon('save.png', get_lang('Download'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a>'.$new_icon.'<br />'.$dropbox_file->description;
  313. $file_size = $dropbox_file->filesize;
  314. $dropbox_file_data[] = Text::format_file_size($file_size);
  315. $dropbox_file_data[] = $dropbox_file->author;
  316. //$dropbox_file_data[] = $dropbox_file->description;
  317. $last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
  318. $dropbox_file_data[] = date_to_str_ago($last_upload_date).'<br /><span class="dropbox_date">'.api_format_date($last_upload_date).'</span>';
  319. $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
  320. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
  321. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
  322. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.
  323. Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
  324. // This is a hack to have an additional row in a sortable table
  325. if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
  326. $action_icons .= "</td></tr>"; // Ending the normal row of the sortable table
  327. $action_icons .= '<tr><td colspan="2"><a href="index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&amp;view_sent_category=".$viewSentCategory."&amp;view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
  328. }
  329. if (api_get_session_id() == 0) {
  330. $dropbox_file_data[] = $action_icons;
  331. } elseif (api_is_allowed_to_session_edit(false, true)) {
  332. $dropbox_file_data[] = $action_icons;
  333. }
  334. $action_icons = '';
  335. $dropbox_file_data[] = $last_upload_date;
  336. $dropbox_file_data[] = $file_size;
  337. $dropbox_data_recieved[] = $dropbox_file_data;
  338. }
  339. }
  340. // The content of the sortable table = the categories (if we are not in the root)
  341. if ($view_dropbox_category_received == 0) {
  342. 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;
  343. $dropbox_category_data = array();
  344. if ($category['received'] == '1') {
  345. $movelist[$category['cat_id']] = $category['cat_name'];
  346. $dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear
  347. // The icon of the category
  348. $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">';
  349. $dropbox_category_data[] = $link_open.build_document_icon_tag('folder', $category['cat_name']).'</a>';
  350. $dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>';
  351. $dropbox_category_data[] = '';
  352. $dropbox_category_data[] = '';
  353. $dropbox_category_data[] = '';
  354. $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=editcategory&amp;id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
  355. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletereceivedcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
  356. }
  357. if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
  358. $dropbox_data_recieved[] = $dropbox_category_data;
  359. }
  360. }
  361. }
  362. // Displaying the table
  363. $additional_get_parameters = array('view' => $view, 'view_received_category' => $viewReceivedCategory, 'view_sent_category' => $viewSentCategory);
  364. $selectlist = array('delete_received' => get_lang('Delete'), 'download_received' => get_lang('Download'));
  365. if (is_array($movelist)) {
  366. foreach ($movelist as $catid => $catname){
  367. $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. Security::remove_XSS($catname);
  368. }
  369. }
  370. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  371. $selectlist = array();
  372. }
  373. Display::display_sortable_config_table('dropbox', $column_header, $dropbox_data_recieved, $sorting_options, $paging_options, $additional_get_parameters, $column_show, $column_order, $selectlist);
  374. }
  375. /* SENT FILES */
  376. if (!$view OR $view == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
  377. // This is for the categories
  378. if (isset($viewSentCategory) AND $viewSentCategory != '') {
  379. $view_dropbox_category_sent = $viewSentCategory;
  380. } else {
  381. $view_dropbox_category_sent = 0;
  382. }
  383. // Object initialisation
  384. $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
  385. // Constructing the array that contains the total number of feedback messages per document.
  386. $number_feedback = get_total_number_feedback();
  387. // Sorting and paging options
  388. $sorting_options = array();
  389. $paging_options = array();
  390. // The headers of the sortable tables
  391. $column_header = array();
  392. $column_header[] = array('', false, '');
  393. $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"');
  394. $column_header[] = array(get_lang('SentTitle'), true, '');
  395. $column_header[] = array(get_lang('Size'), true, '');
  396. $column_header[] = array(get_lang('SentTo'), true, '');
  397. $column_header[] = array(get_lang('LastResent'), true, '');
  398. if (api_get_session_id() == 0) {
  399. $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
  400. } elseif (api_is_allowed_to_session_edit(false, true)) {
  401. $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"');
  402. }
  403. $column_header[] = array('RealDate', true);
  404. $column_header[] = array('RealSize', true);
  405. $column_show = array();
  406. $column_order = array();
  407. // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide
  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. if (api_get_session_id() == 0) {
  415. $column_show[] = 1;
  416. } elseif (api_is_allowed_to_session_edit(false, true)) {
  417. $column_show[] = 1;
  418. }
  419. $column_show[] = 0;
  420. // Here we change the way how the colums are going to be sort
  421. // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate
  422. // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48"
  423. $column_order[3] = 8;
  424. $column_order[5] = 7;
  425. // The content of the sortable table = the received files
  426. foreach ($dropbox_person -> sentWork as $dropbox_file) {
  427. $dropbox_file_data = array();
  428. if ($view_dropbox_category_sent == $dropbox_file->category) {
  429. $dropbox_file_data[] = $dropbox_file->id;
  430. $link_open = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">';
  431. $dropbox_file_data[] = $link_open.build_document_icon_tag('file', $dropbox_file->title).'</a>';
  432. $dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download">'.Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a><br />'.$dropbox_file->description;
  433. $file_size = $dropbox_file->filesize;
  434. $dropbox_file_data[] = Text::format_file_size($file_size);
  435. $receivers_celldata = null;
  436. foreach ($dropbox_file->recipients as $recipient) {
  437. $receivers_celldata = display_user_link_work($recipient['user_id'], $recipient['name']).', '.$receivers_celldata;
  438. }
  439. $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma.
  440. $dropbox_file_data[] = $receivers_celldata;
  441. $last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
  442. $dropbox_file_data[] = date_to_str_ago($last_upload_date).'<br /><span class="dropbox_date">'.api_format_date($last_upload_date).'</span>';
  443. //$dropbox_file_data[] = $dropbox_file->author;
  444. $receivers_celldata = '';
  445. $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
  446. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
  447. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=movesent&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
  448. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletesentfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
  449. // This is a hack to have an additional row in a sortable table
  450. if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
  451. $action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
  452. $action_icons .= "<tr><td colspan=\"2\">";
  453. $action_icons .= "<a href=\"index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>";
  454. $action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
  455. }
  456. $dropbox_file_data[] = $action_icons;
  457. $dropbox_file_data[] = $last_upload_date;
  458. $dropbox_file_data[] = $file_size;
  459. $action_icons = '';
  460. $dropbox_data_sent[] = $dropbox_file_data;
  461. }
  462. }
  463. // The content of the sortable table = the categories (if we are not in the root)
  464. if ($view_dropbox_category_sent == 0) {
  465. foreach ($dropbox_categories as $category) {
  466. $dropbox_category_data = array();
  467. if ($category['sent'] == '1') {
  468. $dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear.
  469. $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$category['cat_id'].'&amp;view='.$view.'">';
  470. $dropbox_category_data[] = $link_open.build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
  471. $dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>';
  472. //$dropbox_category_data[] = '';
  473. $dropbox_category_data[] = '';
  474. //$dropbox_category_data[] = '';
  475. $dropbox_category_data[] = '';
  476. $dropbox_category_data[] = '';
  477. $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=editcategory&id='.$category['cat_id'].'">'.
  478. Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
  479. <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletesentcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.
  480. Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
  481. }
  482. if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
  483. $dropbox_data_sent[] = $dropbox_category_data;
  484. }
  485. }
  486. }
  487. // Displaying the table
  488. $additional_get_parameters = array('view' => $view, 'view_received_category' => $viewReceivedCategory, 'view_sent_category' => $viewSentCategory);
  489. $selectlist = array('delete_received' => get_lang('Delete'), 'download_received' => get_lang('Download'));
  490. if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
  491. $selectlist = array('download_received' => get_lang('Download'));
  492. }
  493. Display::display_sortable_config_table('dropbox', $column_header, $dropbox_data_sent, $sorting_options, $paging_options, $additional_get_parameters, $column_show, $column_order, $selectlist);
  494. }
  495. }
  496. Display::display_footer();