dropbox_submit.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <?php //$id: $
  2. /* For licensing terms, see /dokeos_license.txt */
  3. /*
  4. * ========================================
  5. * PREVENT RESUBMITING
  6. * ========================================
  7. * This part checks if the $dropbox_unid var has the same ID
  8. * as the session var $dropbox_uniqueid that was registered as a session
  9. * var before.
  10. * The resubmit prevention only works with GET requests, because it gives some annoying
  11. * behaviours with POST requests.
  12. */
  13. /*
  14. if (isset($_POST["dropbox_unid"])) {
  15. $dropbox_unid = $_POST["dropbox_unid"];
  16. } elseif (isset($_GET["dropbox_unid"]))
  17. {
  18. $dropbox_unid = $_GET["dropbox_unid"];
  19. } else {
  20. die(dropbox_lang("badFormData")." (code 400)");
  21. }
  22. if (isset($_SESSION["dropbox_uniqueid"]) && isset($_GET["dropbox_unid"]) && $dropbox_unid == $_SESSION["dropbox_uniqueid"]) {
  23. //resubmit : go to index.php
  24. // only prevent resending of data for GETS, not POSTS because this gives annoying results
  25. if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=="on") {
  26. $mypath = "https";
  27. } else {
  28. $mypath = "http";
  29. }
  30. $mypath=$mypath."://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/index.php";
  31. echo 'hier';
  32. header("Location: $mypath");
  33. }
  34. $dropbox_uniqueid = $dropbox_unid;
  35. api_session_register("dropbox_uniqueid");
  36. */
  37. /**
  38. * ========================================
  39. * FORM SUBMIT
  40. * ========================================
  41. * - VALIDATE POSTED DATA
  42. * - UPLOAD NEW FILE
  43. */
  44. if ( isset( $_POST["submitWork"]))
  45. {
  46. if (file_exists(api_get_path(INCLUDE_PATH) . "/fileUploadLib.inc.php"))
  47. {
  48. require_once(api_get_path(INCLUDE_PATH) . "/fileUploadLib.inc.php");
  49. }
  50. else
  51. {
  52. require_once(api_get_path(LIBRARY_PATH) . "/fileUpload.lib.php");
  53. }
  54. $error = FALSE;
  55. $errormsg = '';
  56. /**
  57. * --------------------------------------
  58. * FORM SUBMIT : VALIDATE POSTED DATA
  59. * --------------------------------------
  60. */
  61. // the author or description field is empty
  62. if ( !isset( $_POST['authors']) || !isset( $_POST['description']))
  63. {
  64. $error = TRUE;
  65. $errormsg = dropbox_lang("badFormData");
  66. }
  67. elseif ( !isset( $_POST['recipients']) || count( $_POST['recipients']) <= 0)
  68. {
  69. $error = TRUE;
  70. $errormsg = dropbox_lang("noUserSelected");
  71. }
  72. else
  73. {
  74. $thisIsAMailing = FALSE; // RH: Mailing selected as destination
  75. $thisIsJustUpload = FALSE; // RH
  76. foreach( $_POST['recipients'] as $rec)
  77. {
  78. if ( $rec == 'mailing')
  79. {
  80. $thisIsAMailing = TRUE;
  81. }
  82. elseif ( $rec == 'upload')
  83. {
  84. $thisIsJustUpload = TRUE;
  85. }
  86. elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_') ) ))
  87. {
  88. echo '401';
  89. die( dropbox_lang("badFormData")." (code 401)");
  90. }
  91. elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0)
  92. {
  93. echo '402';
  94. die( dropbox_lang("badFormData")." (code 402)");
  95. }
  96. }
  97. // we are doing a mailing but an additional recipient is selected
  98. if ( $thisIsAMailing && ( count($_POST['recipients']) != 1))
  99. {
  100. $error = TRUE;
  101. $errormsg = dropbox_lang("mailingSelectNoOther");
  102. }
  103. // we are doing a just upload but an additional recipient is selected.
  104. elseif ( $thisIsJustUpload && ( count($_POST['recipients']) != 1))
  105. {
  106. $error = TRUE;
  107. $errormsg = get_lang("MailingJustUploadSelectNoOther");
  108. }
  109. elseif ( empty( $_FILES['file']['name']))
  110. {
  111. $error = TRUE;
  112. $errormsg = dropbox_lang("noFileSpecified");
  113. }
  114. }
  115. //check if $_POST['cb_overwrite'] is true or false
  116. $dropbox_overwrite = false;
  117. if ( isset($_POST['cb_overwrite']) && $_POST['cb_overwrite']==true)
  118. {
  119. $dropbox_overwrite = true;
  120. }
  121. /**
  122. * --------------------------------------
  123. * FORM SUBMIT : UPLOAD NEW FILE
  124. * --------------------------------------
  125. */
  126. if ( !$error)
  127. {
  128. $dropbox_filename = $_FILES['file']['name'];
  129. $dropbox_filesize = $_FILES['file']['size'];
  130. $dropbox_filetype = $_FILES['file']['type'];
  131. $dropbox_filetmpname = $_FILES['file']['tmp_name'];
  132. if ( $dropbox_filesize <= 0 || $dropbox_filesize > dropbox_cnf("maxFilesize"))
  133. {
  134. $errormsg = dropbox_lang("tooBig");
  135. $error = TRUE;
  136. }elseif ( !is_uploaded_file( $dropbox_filetmpname)) // check user fraud : no clean error msg.
  137. {
  138. die ( dropbox_lang("badFormData")." (code 403)");
  139. }
  140. if ( !$error)
  141. {
  142. // Try to add an extension to the file if it hasn't got one
  143. $dropbox_filename = add_ext_on_mime( $dropbox_filename,$dropbox_filetype);
  144. // Replace dangerous characters
  145. $dropbox_filename = replace_dangerous_char( $dropbox_filename);
  146. // Transform any .php file in .phps fo security
  147. $dropbox_filename = php2phps ( $dropbox_filename);
  148. if(!filter_extension($dropbox_filename))
  149. {
  150. $error = true;
  151. $errormsg = get_lang('UplUnableToSaveFileFilteredExtension');
  152. }
  153. else
  154. {
  155. // set title
  156. $dropbox_title = $dropbox_filename;
  157. // set author
  158. if ( $_POST['authors'] == '')
  159. {
  160. $_POST['authors'] = getUserNameFromId( $_user['user_id']);
  161. }
  162. if ( $dropbox_overwrite) // RH: Mailing: adapted
  163. {
  164. $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor);
  165. foreach($dropbox_person->sentWork as $w)
  166. {
  167. if ($w->title == $dropbox_filename)
  168. {
  169. if ( ($w->recipients[0]['id'] > dropbox_cnf("mailingIdBase")) xor $thisIsAMailing)
  170. {
  171. $error = TRUE;
  172. $errormsg = dropbox_lang("mailingNonMailingError");
  173. }
  174. if ( ($w->recipients[0]['id'] == $_user['user_id']) xor $thisIsJustUpload)
  175. {
  176. $error = TRUE;
  177. $errormsg = get_lang("MailingJustUploadSelectNoOther");
  178. }
  179. $dropbox_filename = $w->filename; $found = true;
  180. break;
  181. }
  182. }
  183. }
  184. else // rename file to login_filename_uniqueId format
  185. {
  186. $dropbox_filename = getLoginFromId( $_user['user_id']) . "_" . $dropbox_filename . "_".uniqid('');
  187. }
  188. if ( ( ! is_dir( dropbox_cnf("sysPath"))))
  189. {
  190. //The dropbox subdir doesn't exist yet so make it and create the .htaccess file
  191. mkdir( dropbox_cnf("sysPath"), 0700) or die ( dropbox_lang("errorCreatingDir")." (code 404)");
  192. $fp = fopen( dropbox_cnf("sysPath")."/.htaccess", "w") or die (dropbox_lang("errorCreatingDir")." (code 405)");
  193. fwrite($fp, "AuthName AllowLocalAccess
  194. AuthType Basic
  195. order deny,allow
  196. deny from all
  197. php_flag zlib.output_compression off") or die (dropbox_lang("errorCreatingDir")." (code 406)");
  198. }
  199. if ( $error) {}
  200. elseif ( $thisIsAMailing) // RH: $newWorkRecipients is integer - see class
  201. {
  202. if ( preg_match( dropbox_cnf("mailingZipRegexp"), $dropbox_title))
  203. {
  204. $newWorkRecipients = dropbox_cnf("mailingIdBase");
  205. }
  206. else
  207. {
  208. $error = TRUE;
  209. $errormsg = $dropbox_title . ": " . dropbox_lang("mailingWrongZipfile");
  210. }
  211. }
  212. elseif ( $thisIsJustUpload) // RH: $newWorkRecipients is empty array
  213. {
  214. $newWorkRecipients = array();
  215. }
  216. else
  217. { // creating the array that contains all the users who will receive the file
  218. $newWorkRecipients = array();
  219. foreach ($_POST["recipients"] as $rec)
  220. {
  221. if (strpos($rec, 'user_') === 0) {
  222. $newWorkRecipients[] = substr($rec, strlen('user_') );
  223. }
  224. elseif (strpos($rec, 'group_') === 0 )
  225. {
  226. $userList = GroupManager::get_subscribed_users(substr($rec, strlen('group_') ));
  227. foreach ($userList as $usr)
  228. {
  229. if (! in_array($usr['user_id'], $newWorkRecipients) && $usr['user_id'] != $_user['user_id'])
  230. {
  231. $newWorkRecipients[] = $usr['user_id'];
  232. }
  233. }
  234. }
  235. }
  236. }
  237. //After uploading the file, create the db entries
  238. if ( !$error)
  239. {
  240. @move_uploaded_file( $dropbox_filetmpname, dropbox_cnf("sysPath") . '/' . $dropbox_filename)
  241. or die( dropbox_lang("uploadError")." (code 407)");
  242. new Dropbox_SentWork( $_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $newWorkRecipients);
  243. }
  244. }
  245. }
  246. } //end if(!$error)
  247. /**
  248. * ========================================
  249. * SUBMIT FORM RESULTMESSAGE
  250. * ========================================
  251. */
  252. if ( !$error)
  253. {
  254. $return_message=get_lang('FileUploadSucces');
  255. }
  256. else
  257. {
  258. $return_message=$errormsg;
  259. }
  260. } // end if ( isset( $_POST["submitWork"]))
  261. /**
  262. * ========================================
  263. * // RH: EXAMINE OR SEND MAILING (NEW)
  264. * ========================================
  265. */
  266. if ( isset( $_GET['mailingIndex'])) // examine or send
  267. {
  268. $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor);
  269. if ( isset($_SESSION["sentOrder"]))
  270. {
  271. $dropbox_person->orderSentWork ($_SESSION["sentOrder"]);
  272. }
  273. $i = $_GET['mailingIndex']; $mailing_item = $dropbox_person->sentWork[$i];
  274. $mailing_title = $mailing_item->title;
  275. $mailing_file = dropbox_cnf("sysPath") . '/' . $mailing_item->filename;
  276. $errormsg = '<b>' . $mailing_item->recipients[0]['name'] . ' ('
  277. . "<a href='dropbox_download.php?origin=$origin&id=".urlencode($mailing_item->id)."'>"
  278. . htmlspecialchars($mailing_title,ENT_QUOTES,$charset) . '</a>):</b><br /><br />';
  279. if ( preg_match( dropbox_cnf("mailingZipRegexp"), $mailing_title, $nameParts))
  280. {
  281. $var = api_strtoupper($nameParts[2]); // the variable part of the name
  282. $course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  283. $sel = "SELECT u.user_id, u.lastname, u.firstname, cu.status
  284. FROM `".$_configuration['main_database']."`.`user` u
  285. LEFT JOIN $course_user cu
  286. ON cu.user_id = u.user_id AND cu.course_code = '".$_course['sysCode']."'";
  287. $sel .= " WHERE u.".dropbox_cnf("mailingWhere".$var)." = '";
  288. function getUser($thisRecip)
  289. {
  290. // string result = error message, array result = [user_id, lastname, firstname]
  291. global $var, $sel;
  292. if (isset($students)) {
  293. unset($students);
  294. }
  295. $result = Database::query($sel . $thisRecip . "'",__FILE__,__LINE__);
  296. while ( ($res = Database::fetch_array($result))) {$students[] = $res;}
  297. mysql_free_result($result);
  298. if (count($students) == 1)
  299. {
  300. return($students[0]);
  301. }
  302. elseif (count($students) > 1)
  303. {
  304. return ' <'.dropbox_lang("mailingFileRecipDup", "noDLTT").$var."= $thisRecip>";
  305. }
  306. else
  307. {
  308. return ' <'.dropbox_lang("mailingFileRecipNotFound", "noDLTT").$var."= $thisRecip>";
  309. }
  310. }
  311. $preFix = $nameParts[1]; $postFix = $nameParts[3];
  312. $preLen = api_strlen($preFix); $postLen = api_strlen($postFix);
  313. function findRecipient($thisFile)
  314. {
  315. // string result = error message, array result = [user_id, lastname, firstname, status]
  316. global $nameParts, $preFix, $preLen, $postFix, $postLen;
  317. if ( preg_match(dropbox_cnf("mailingFileRegexp"), $thisFile, $matches))
  318. {
  319. $thisName = $matches[1];
  320. if ( api_substr($thisName, 0, $preLen) == $preFix)
  321. {
  322. if ( $postLen == 0 || api_substr($thisName, -$postLen) == $postFix)
  323. {
  324. $thisRecip = api_substr($thisName, $preLen, api_strlen($thisName) - $preLen - $postLen);
  325. if ( $thisRecip) return getUser($thisRecip);
  326. return ' <'.dropbox_lang("mailingFileNoRecip", "noDLTT").'>';
  327. }
  328. else
  329. {
  330. return ' <'.dropbox_lang("mailingFileNoPostfix", "noDLTT").$postFix.'>';
  331. }
  332. }
  333. else
  334. {
  335. return ' <'.dropbox_lang("mailingFileNoPrefix", "noDLTT").$preFix.'>';
  336. }
  337. }
  338. else
  339. {
  340. return ' <'.dropbox_lang("mailingFileFunny", "noDLTT").'>';
  341. }
  342. }
  343. if (file_exists(api_get_path(INCLUDE_PATH) . "/pclzip/pclzip.lib.php"))
  344. {
  345. require(api_get_path(INCLUDE_PATH) . "/pclzip/pclzip.lib.php");
  346. }
  347. else
  348. {
  349. require(api_get_path(LIBRARY_PATH) . "/pclzip/pclzip.lib.php");
  350. }
  351. $zipFile = new pclZip($mailing_file); $goodFiles = array();
  352. $zipContent = $zipFile->listContent(); $ucaseFiles = array();
  353. if ( $zipContent)
  354. {
  355. foreach( $zipFile->listContent() as $thisContent)
  356. {
  357. $thisFile = substr(strrchr('/' . $thisContent['filename'], '/'), 1);
  358. $thisFileUcase = strtoupper($thisFile);
  359. if ( preg_match("~.(php.*|phtml)$~i", $thisFile) )
  360. {
  361. $error = TRUE; $errormsg .= $thisFile . ': ' . dropbox_lang("mailingZipPhp");
  362. break;
  363. }
  364. elseif ( !$thisContent['folder'])
  365. {
  366. if ( $ucaseFiles[$thisFileUcase])
  367. {
  368. $error = TRUE; $errormsg .= $thisFile . ': ' . dropbox_lang("mailingZipDups");
  369. break;
  370. }
  371. else
  372. {
  373. $goodFiles[$thisFile] = findRecipient($thisFile);
  374. $ucaseFiles[$thisFileUcase] = "yep";
  375. }
  376. }
  377. }
  378. }
  379. else
  380. {
  381. $error = TRUE; $errormsg .= dropbox_lang("mailingZipEmptyOrCorrupt");
  382. }
  383. if ( !$error)
  384. {
  385. $students = array(); // collect all recipients in this course
  386. foreach( $goodFiles as $thisFile => $thisRecip)
  387. {
  388. $errormsg .= htmlspecialchars($thisFile,ENT_QUOTES,$charset) . ': ';
  389. if ( is_string($thisRecip)) // see findRecipient
  390. {
  391. $errormsg .= '<font color="#FF0000">'
  392. . htmlspecialchars($thisRecip,ENT_QUOTES,$charset) . '</font><br>';
  393. }
  394. else
  395. {
  396. if ( isset( $_GET['mailingSend']))
  397. {
  398. $errormsg .= dropbox_lang("mailingFileSentTo");
  399. }
  400. else
  401. {
  402. $errormsg .= dropbox_lang("mailingFileIsFor");
  403. }
  404. $errormsg .= htmlspecialchars(api_get_person_name($thisRecip[2], $thisRecip[1]), ENT_QUOTES, $charset);
  405. if ( is_null($thisRecip[3]))
  406. {
  407. $errormsg .= dropbox_lang("mailingFileNotRegistered");
  408. }
  409. else
  410. {
  411. $students[] = $thisRecip[0];
  412. }
  413. $errormsg .= '<br>';
  414. }
  415. }
  416. // find student course members not among the recipients
  417. $course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  418. $sql = "SELECT u.lastname, u.firstname
  419. FROM $course_user cu
  420. LEFT JOIN `".$_configuration['main_database']."`.`user` u
  421. ON cu.user_id = u.user_id AND cu.course_code = '".$_course['sysCode']."'
  422. WHERE cu.status = 5
  423. AND u.user_id NOT IN ('" . implode("', '" , $students) . "')";
  424. $result = Database::query($sql,__FILE__,__LINE__);
  425. if ( Database::num_rows($result) > 0)
  426. {
  427. $remainingUsers = '';
  428. while ( ($res = Database::fetch_array($result)))
  429. {
  430. $remainingUsers .= ', ' . htmlspecialchars(api_get_person_name($res[1], $res[0]), ENT_QUOTES, $charset);
  431. }
  432. $errormsg .= '<br />' . dropbox_lang("mailingNothingFor") . api_substr($remainingUsers, 1) . '.<br />';
  433. }
  434. if ( isset( $_GET['mailingSend']))
  435. {
  436. chdir(dropbox_cnf("sysPath"));
  437. $zipFile->extract(PCLZIP_OPT_REMOVE_ALL_PATH);
  438. $mailingPseudoId = dropbox_cnf("mailingIdBase") + $mailing_item->id;
  439. foreach( $goodFiles as $thisFile => $thisRecip)
  440. {
  441. if ( is_string($thisRecip)) // remove problem file
  442. {
  443. @unlink(dropbox_cnf("sysPath") . '/' . $thisFile);
  444. }
  445. else
  446. {
  447. $newName = getLoginFromId( $_user['user_id']) . "_" . $thisFile . "_" . uniqid('');
  448. if ( rename(dropbox_cnf("sysPath") . '/' . $thisFile, dropbox_cnf("sysPath") . '/' . $newName))
  449. new Dropbox_SentWork( $mailingPseudoId, $thisFile, $mailing_item->description, $mailing_item->author, $newName, $thisContent['size'], array($thisRecip[0]));
  450. }
  451. }
  452. $sendDT = addslashes(date("Y-m-d H:i:s",time()));
  453. // set filesize to zero on send, to avoid 2nd send (see index.php)
  454. $sql = "UPDATE ".dropbox_cnf("tbl_file")."
  455. SET filesize = '0'
  456. , upload_date = '".$sendDT."', last_upload_date = '".$sendDT."'
  457. WHERE id='".addslashes($mailing_item->id)."'";
  458. $result =Database::query($sql,__FILE__,__LINE__);
  459. }
  460. elseif ( $mailing_item->filesize != 0)
  461. {
  462. $errormsg .= '<br>' . dropbox_lang("mailingNotYetSent") . '<br>';
  463. }
  464. }
  465. }
  466. else
  467. {
  468. $error = TRUE; $errormsg .= dropbox_lang("mailingWrongZipfile");
  469. }
  470. /**
  471. * ========================================
  472. * EXAMINE OR SEND MAILING RESULTMESSAGE
  473. * ========================================
  474. */
  475. if ( $error)
  476. {
  477. ?>
  478. <b><font color="#FF0000"><?php echo $errormsg?></font></b><br><br>
  479. <a href="index.php<?php echo "?origin=$origin"; ?>"><?php echo dropbox_lang("backList")?></a><br>
  480. <?php
  481. }
  482. else
  483. {
  484. ?>
  485. <?php echo $errormsg?><br><br>
  486. <a href="index.php<?php echo "?origin=$origin"; ?>"><?php echo dropbox_lang("backList")?></a><br>
  487. <?php
  488. }
  489. }
  490. /**
  491. * =============================================
  492. * DELETE RECEIVED OR SENT FILES - EDIT FEEDBACK // RH: Feedback
  493. * =============================================
  494. * - DELETE ALL RECEIVED FILES
  495. * - DELETE 1 RECEIVED FILE
  496. * - DELETE ALL SENT FILES
  497. * - DELETE 1 SENT FILE
  498. * - EDIT FEEDBACK // RH: Feedback
  499. */
  500. if ( isset( $_GET['deleteReceived']) || isset( $_GET['deleteSent'])
  501. || isset( $_GET['showFeedback']) || isset( $_GET['editFeedback'])) // RH: Feedback
  502. {
  503. if ( $_GET['mailing']) // RH: Mailing
  504. {
  505. getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '408'); // RH or die
  506. $dropbox_person = new Dropbox_Person( $_GET['mailing'], $is_courseAdmin, $is_courseTutor);
  507. }
  508. else
  509. {
  510. $dropbox_person = new Dropbox_Person( $_user['user_id'], $is_courseAdmin, $is_courseTutor);
  511. }
  512. // RH: these two are needed, I think
  513. if ( isset($_SESSION["sentOrder"]))
  514. {
  515. $dropbox_person->orderSentWork ($_SESSION["sentOrder"]);
  516. }
  517. if ( isset($_SESSION["receivedOrder"]))
  518. {
  519. $dropbox_person->orderReceivedWork ($_SESSION["receivedOrder"]);
  520. }
  521. /*if (! $dropbox_person->isCourseAdmin || ! $dropbox_person->isCourseTutor) {
  522. die(dropbox_lang("generalError")." (code 408)");
  523. }*/
  524. $tellUser = dropbox_lang("fileDeleted"); // RH: Feedback
  525. if ( isset( $_GET['deleteReceived']))
  526. {
  527. if ( $_GET["deleteReceived"] == "all")
  528. {
  529. $dropbox_person->deleteAllReceivedWork( );
  530. }elseif ( is_numeric( $_GET["deleteReceived"]))
  531. {
  532. $dropbox_person->deleteReceivedWork( $_GET['deleteReceived']);
  533. }
  534. else
  535. {
  536. die(dropbox_lang("generalError")." (code 409)");
  537. }
  538. }
  539. elseif ( isset( $_GET['deleteSent'])) // RH: Feedback
  540. {
  541. if ( $_GET["deleteSent"] == "all")
  542. {
  543. $dropbox_person->deleteAllSentWork( );
  544. }elseif ( is_numeric( $_GET["deleteSent"]))
  545. {
  546. $dropbox_person->deleteSentWork( $_GET['deleteSent']);
  547. }
  548. else
  549. {
  550. die(dropbox_lang("generalError")." (code 410)");
  551. }
  552. }
  553. elseif ( isset( $_GET['showFeedback'])) // RH: Feedback
  554. {
  555. $w = new Dropbox_SentWork($id = $_GET['showFeedback']);
  556. if ($w->uploader_id != $_user['user_id'])
  557. getUserOwningThisMailing($w->uploader_id, $_user['user_id'], '411'); // RH or die
  558. foreach( $w -> recipients as $r) if (($fb = $r["feedback"]))
  559. {
  560. $fbarray [$r["feedback_date"].$r["name"]]=
  561. $r["name"] . ' ' . dropbox_lang("sentOn", "noDLTT") .
  562. ' ' . $r["feedback_date"] . ":\n" . $fb;
  563. }
  564. if ($fbarray)
  565. {
  566. krsort($fbarray);
  567. echo '<textarea class="dropbox_feedbacks">',
  568. htmlspecialchars(implode("\n\n", $fbarray),ENT_QUOTES,$charset), '</textarea>', "\n";
  569. }
  570. else
  571. {
  572. echo '<textarea class="dropbox_feedbacks">&nbsp;</textarea>', "\n";
  573. }
  574. $tellUser = dropbox_lang("showFeedback");
  575. }
  576. else // if ( isset( $_GET['editFeedback'])) // RH: Feedback
  577. {
  578. $id = $_GET['editFeedback']; $found = false;
  579. foreach($dropbox_person->receivedWork as $w) {
  580. if ($w->id == $id) {
  581. $found = true; break;
  582. }
  583. }
  584. if (! $found) die(dropbox_lang("generalError")." (code 415)");
  585. echo '<form method="post" action="index.php">', "\n",
  586. '<input type="hidden" name="feedbackid" value="',
  587. $id, '"/>', "\n",
  588. '<textarea name="feedbacktext" class="dropbox_feedbacks">',
  589. htmlspecialchars($w->feedback,ENT_QUOTES,$charset), '</textarea>', "<br>\n",
  590. '<input type="submit" name="feedbacksubmit" value="', dropbox_lang("ok", "noDLTT"), '"/>', "\n",
  591. '</form>', "\n";
  592. $tellUser = dropbox_lang("giveFeedback");
  593. }
  594. /**
  595. * ==============================================
  596. * RESULTMESSAGE FOR DELETE FILE OR EDIT FEEDBACK // RH: Feedback
  597. * ==============================================
  598. */
  599. $return_message=dropbox_lang("backList");
  600. }
  601. ?>