dropbox_class.inc.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Dropbox module for Chamilo
  5. * Classes for the dropbox module.
  6. *
  7. * 3 classes have been defined:
  8. * - Dropbox_Work:
  9. * . id
  10. * . uploader_id => who sent it
  11. * . filename => name of file stored on the server
  12. * . filesize
  13. * . title => name of file returned to user. This is the original name of the file
  14. * except when the original name contained spaces. In that case the spaces
  15. * will be replaced by _
  16. * . description
  17. * . author
  18. * . upload_date => date when file was first sent
  19. * . last_upload_date => date when file was last sent
  20. * . isOldWork => has the work already been uploaded before
  21. *
  22. * . feedback_date => date of most recent feedback
  23. * . feedback => feedback text (or HTML?)
  24. *
  25. * - Dropbox_SentWork extends Dropbox_Work
  26. * . recipients => array of ["id"]["name"] lists the recipients of the work
  27. *
  28. * - Dropbox_Person:
  29. * . userId
  30. * . receivedWork => array of Dropbox_Work objects
  31. * . sentWork => array of Dropbox_SentWork objects
  32. * . isCourseTutor
  33. * . isCourseAdmin
  34. * . _orderBy => private property used for determining the field by which the works have to be ordered
  35. *
  36. * @version 1.30
  37. * @copyright 2004
  38. * @author Jan Bols <jan@ivpv.UGent.be>
  39. * with contributions by René Haentjens <rene.haentjens@UGent.be>
  40. * @package chamilo.dropbox
  41. */
  42. class Dropbox_Work
  43. {
  44. public $id;
  45. public $uploader_id;
  46. public $filename;
  47. public $filesize;
  48. public $title;
  49. public $description;
  50. public $author;
  51. public $upload_date;
  52. public $last_upload_date;
  53. public $isOldWork;
  54. public $feedback_date;
  55. public $feedback;
  56. /**
  57. * Constructor calls private functions to create a new work or retreive an existing work from DB
  58. * depending on the number of parameters
  59. *
  60. * @param unknown_type $arg1
  61. * @param unknown_type $arg2
  62. * @param unknown_type $arg3
  63. * @param unknown_type $arg4
  64. * @param unknown_type $arg5
  65. * @param unknown_type $arg6
  66. * @return Dropbox_Work
  67. */
  68. public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null)
  69. {
  70. if (func_num_args() > 1) {
  71. $this->_createNewWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  72. } else {
  73. $this->_createExistingWork($arg1);
  74. }
  75. }
  76. /**
  77. * private function creating a new work object
  78. *
  79. * @param int $uploader_id
  80. * @param string $title
  81. * @param string $description
  82. * @param string $author
  83. * @param string $filename
  84. * @param int $filesize
  85. *
  86. * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
  87. * As a consequence this parameter can be removed
  88. */
  89. public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
  90. {
  91. // Fill in the properties
  92. $this->uploader_id = intval($uploader_id);
  93. $this->filename = $filename;
  94. $this->filesize = $filesize;
  95. $this->title = $title;
  96. $this->description = $description;
  97. $this->author = $author;
  98. $this->last_upload_date = api_get_utc_datetime();
  99. $course_id = api_get_course_int_id();
  100. // Check if object exists already. If it does, the old object is used
  101. // with updated information (authors, description, upload_date)
  102. $this->isOldWork = false;
  103. $sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
  104. WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
  105. $result = Database::query($sql);
  106. $res = Database::fetch_array($result);
  107. if ($res) {
  108. $this->isOldWork = true;
  109. }
  110. // Insert or update the dropbox_file table and set the id property
  111. if ($this->isOldWork) {
  112. $this->id = $res['id'];
  113. $this->upload_date = $res['upload_date'];
  114. $params = [
  115. 'filesize' => $this->filesize,
  116. 'title' => $this->title,
  117. 'description' => $this->description,
  118. 'author' => $this->author,
  119. 'last_upload_date' => $this->last_upload_date,
  120. 'session_id' => api_get_session_id()
  121. ];
  122. Database::update(
  123. Database::get_course_table(TABLE_DROPBOX_FILE),
  124. $params,
  125. ['c_id = ? AND id = ?' => [$course_id, $this->id]]
  126. );
  127. } else {
  128. $this->upload_date = $this->last_upload_date;
  129. $params = [
  130. 'c_id' => $course_id,
  131. 'uploader_id' => $this->uploader_id,
  132. 'filename' => $this->filename,
  133. 'filesize' => $this->filesize,
  134. 'title' => $this->title,
  135. 'description' => $this->description,
  136. 'author' => $this->author,
  137. 'upload_date' => $this->upload_date,
  138. 'last_upload_date' => $this->last_upload_date,
  139. 'session_id' => api_get_session_id(),
  140. 'cat_id' => 0
  141. ];
  142. $this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
  143. if ($this->id) {
  144. $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
  145. Database::query($sql);
  146. }
  147. }
  148. $sql = "SELECT count(file_id) as count
  149. FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
  150. WHERE c_id = $course_id AND file_id = ".intval($this->id)." AND user_id = ".$this->uploader_id;
  151. $result = Database::query($sql);
  152. $row = Database::fetch_array($result);
  153. if ($row['count'] == 0) {
  154. // Insert entries into person table
  155. $sql = "INSERT INTO ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." (c_id, file_id, user_id)
  156. VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
  157. Database::query($sql);
  158. }
  159. }
  160. /**
  161. * private function creating existing object by retreiving info from db
  162. *
  163. * @param int $id
  164. */
  165. public function _createExistingWork($id)
  166. {
  167. $course_id = api_get_course_int_id();
  168. $action = isset($_GET['action']) ? $_GET['action'] : null;
  169. // Do some sanity checks
  170. $id = intval($id);
  171. // Get the data from DB
  172. $sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
  173. FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
  174. WHERE c_id = $course_id AND id = ".$id."";
  175. $result = Database::query($sql);
  176. $res = Database::fetch_array($result, 'ASSOC');
  177. // Check if uploader is still in Chamilo system
  178. $uploader_id = stripslashes($res['uploader_id']);
  179. $userInfo = api_get_user_info($uploader_id);
  180. if (!$userInfo) {
  181. //deleted user
  182. $this->uploader_id = -1;
  183. } else {
  184. $this->uploader_id = $uploader_id;
  185. }
  186. // Fill in properties
  187. $this->id = $id;
  188. $this->filename = stripslashes($res['filename']);
  189. $this->filesize = stripslashes($res['filesize']);
  190. $this->title = stripslashes($res['title']);
  191. $this->description = stripslashes($res['description']);
  192. $this->author = stripslashes($res['author']);
  193. $this->upload_date = stripslashes($res['upload_date']);
  194. $this->last_upload_date = stripslashes($res['last_upload_date']);
  195. $this->category = $res['cat_id'];
  196. // Getting the feedback on the work.
  197. if ($action == 'viewfeedback' AND $this->id == $_GET['id']) {
  198. $feedback2 = array();
  199. $sql = "SELECT * FROM ". Database::get_course_table(TABLE_DROPBOX_FEEDBACK) ."
  200. WHERE c_id = $course_id AND file_id='".$id."'
  201. ORDER BY feedback_id ASC";
  202. $result = Database::query($sql);
  203. while ($row_feedback = Database::fetch_array($result)) {
  204. $row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']);
  205. $feedback2[] = $row_feedback;
  206. }
  207. $this->feedback2= $feedback2;
  208. }
  209. }
  210. }
  211. class Dropbox_SentWork extends Dropbox_Work
  212. {
  213. public $recipients; //array of ['id']['name'] arrays
  214. /**
  215. * Constructor calls private functions to create a new work or retreive an existing work from DB
  216. * depending on the number of parameters
  217. *
  218. * @param unknown_type $arg1
  219. * @param unknown_type $arg2
  220. * @param unknown_type $arg3
  221. * @param unknown_type $arg4
  222. * @param unknown_type $arg5
  223. * @param unknown_type $arg6
  224. * @param unknown_type $arg7
  225. * @return Dropbox_SentWork
  226. */
  227. public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
  228. {
  229. if (func_num_args() > 1) {
  230. $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
  231. } else {
  232. $this->_createExistingSentWork($arg1);
  233. }
  234. }
  235. /**
  236. * private function creating a new SentWork object
  237. *
  238. * @param int $uploader_id
  239. * @param string $title
  240. * @param string $description
  241. * @param string $author
  242. * @param string $filename
  243. * @param int $filesize
  244. * @param array $recipient_ids
  245. */
  246. public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
  247. {
  248. $dropbox_cnf = getDropboxConf();
  249. $_course = api_get_course_info();
  250. // Call constructor of Dropbox_Work object
  251. parent::__construct(
  252. $uploader_id,
  253. $title,
  254. $description,
  255. $author,
  256. $filename,
  257. $filesize
  258. );
  259. $course_id = api_get_course_int_id();
  260. // Do sanity checks on recipient_ids array & property fillin
  261. // The sanity check for ex-coursemembers is already done in base constructor
  262. $uploader_id = (int) $uploader_id;
  263. $justSubmit = false;
  264. if (is_int($recipient_ids)) {
  265. $justSubmit = true;
  266. $recipient_ids = array($recipient_ids + $this->id);
  267. } elseif (count($recipient_ids) == 0) {
  268. $justSubmit = true;
  269. $recipient_ids = array($uploader_id);
  270. }
  271. if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
  272. die(get_lang('GeneralError').' (code 209)');
  273. }
  274. foreach ($recipient_ids as $rec) {
  275. if (empty($rec)) {
  276. continue;
  277. }
  278. //if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
  279. //this check is done when validating submitted data
  280. $this->recipients[] = array('id' => $rec);
  281. }
  282. $table_post = Database::get_course_table(TABLE_DROPBOX_POST);
  283. $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON);
  284. $session_id = api_get_session_id();
  285. $user = api_get_user_id();
  286. $now = api_get_utc_datetime();
  287. $mailId = get_mail_id_base();
  288. // Insert data in dropbox_post and dropbox_person table for each recipient
  289. foreach ($this->recipients as $rec) {
  290. $file_id = (int)$this->id;
  291. $user_id = (int)$rec['id'];
  292. $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
  293. VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
  294. Database::query($sql);
  295. // If work already exists no error is generated
  296. /**
  297. * Poster is already added when work is created - not so good to split logic
  298. */
  299. if ($user_id != $user) {
  300. // Insert entries into person table
  301. $sql = "INSERT INTO $table_person (c_id, file_id, user_id)
  302. VALUES ($course_id, $file_id, $user_id)";
  303. // Do not add recipient in person table if mailing zip or just upload.
  304. if (!$justSubmit) {
  305. Database::query($sql); // If work already exists no error is generated
  306. }
  307. }
  308. // Update item_property table for each recipient
  309. if (($ownerid = $this->uploader_id) > $mailId) {
  310. $ownerid = getUserOwningThisMailing($ownerid);
  311. }
  312. if (($recipid = $rec["id"]) > $mailId) {
  313. $recipid = $ownerid; // mailing file recipient = mailing id, not a person
  314. }
  315. api_item_property_update(
  316. $_course,
  317. TOOL_DROPBOX,
  318. $this->id,
  319. 'DropboxFileAdded',
  320. $ownerid,
  321. null,
  322. $recipid
  323. );
  324. }
  325. }
  326. /**
  327. * private function creating existing object by retreiving info from db
  328. *
  329. * @param unknown_type $id
  330. */
  331. public function _createExistingSentWork($id)
  332. {
  333. $id = intval($id);
  334. $course_id = api_get_course_int_id();
  335. // Call constructor of Dropbox_Work object
  336. parent::__construct($id);
  337. // Fill in recipients array
  338. $this->recipients = array();
  339. $sql = "SELECT dest_user_id, feedback_date, feedback
  340. FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
  341. WHERE c_id = $course_id AND file_id = ".intval($id)."";
  342. $result = Database::query($sql);
  343. while ($res = Database::fetch_array($result, 'ASSOC')) {
  344. // Check for deleted users
  345. $dest_user_id = $res['dest_user_id'];
  346. $user_info = api_get_user_info($dest_user_id);
  347. //$this->category = $res['cat_id'];
  348. if (!$user_info) {
  349. $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
  350. } else {
  351. $this->recipients[] = array(
  352. 'id' => $dest_user_id,
  353. 'name' => $user_info['complete_name'],
  354. 'user_id' => $dest_user_id,
  355. 'feedback_date' => $res['feedback_date'],
  356. 'feedback' => $res['feedback']
  357. );
  358. }
  359. }
  360. }
  361. }
  362. class Dropbox_Person
  363. {
  364. // The receivedWork and the sentWork arrays are sorted.
  365. public $receivedWork; // an array of Dropbox_Work objects
  366. public $sentWork; // an array of Dropbox_SentWork objects
  367. public $userId = 0;
  368. public $isCourseAdmin = false;
  369. public $isCourseTutor = false;
  370. public $_orderBy = ''; // private property that determines by which field
  371. /**
  372. * Constructor for recreating the Dropbox_Person object
  373. *
  374. * @param int $userId
  375. * @param bool $isCourseAdmin
  376. * @param bool $isCourseTutor
  377. * @return Dropbox_Person
  378. */
  379. public function __construct($userId, $isCourseAdmin, $isCourseTutor)
  380. {
  381. $course_id = api_get_course_int_id();
  382. // Fill in properties
  383. $this->userId = $userId;
  384. $this->isCourseAdmin = $isCourseAdmin;
  385. $this->isCourseTutor = $isCourseTutor;
  386. $this->receivedWork = array();
  387. $this->sentWork = array();
  388. // Note: perhaps include an ex coursemember check to delete old files
  389. $session_id = api_get_session_id();
  390. $condition_session = api_get_session_condition($session_id);
  391. $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
  392. $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
  393. $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
  394. // Find all entries where this person is the recipient
  395. $sql = "SELECT DISTINCT r.file_id, r.cat_id
  396. FROM $post_tbl r
  397. INNER JOIN $person_tbl p
  398. ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
  399. WHERE
  400. p.user_id = ".intval($this->userId)." AND
  401. r.dest_user_id = ".intval($this->userId)." $condition_session ";
  402. $result = Database::query($sql);
  403. while ($res = Database::fetch_array($result)) {
  404. $temp = new Dropbox_Work($res['file_id']);
  405. $temp->category = $res['cat_id'];
  406. $this->receivedWork[] = $temp;
  407. }
  408. // Find all entries where this person is the sender/uploader
  409. $sql = "SELECT DISTINCT f.id
  410. FROM $file_tbl f
  411. INNER JOIN $person_tbl p
  412. ON (f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
  413. WHERE
  414. f.uploader_id = ".intval($this->userId)." AND
  415. p.user_id = ".intval($this->userId)."
  416. $condition_session
  417. ";
  418. $result = Database::query($sql);
  419. while ($res = Database::fetch_array($result)) {
  420. $this->sentWork[] = new Dropbox_SentWork($res['id']);
  421. }
  422. }
  423. /**
  424. * Deletes all the received work of this person
  425. */
  426. public function deleteAllReceivedWork()
  427. {
  428. $course_id = api_get_course_int_id();
  429. // Delete entries in person table concerning received works
  430. foreach ($this->receivedWork as $w) {
  431. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
  432. WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
  433. Database::query($sql);
  434. }
  435. // Check for unused files
  436. removeUnusedFiles();
  437. }
  438. /**
  439. * Deletes all the received categories and work of this person
  440. * @param integer $id
  441. */
  442. public function deleteReceivedWorkFolder($id)
  443. {
  444. $course_id = api_get_course_int_id();
  445. $id = intval($id);
  446. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
  447. WHERE c_id = $course_id AND cat_id = '".$id."' ";
  448. if (!Database::query($sql)) return false;
  449. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
  450. WHERE c_id = $course_id AND cat_id = '".$id."' ";
  451. if (!Database::query($sql)) return false;
  452. $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
  453. WHERE c_id = $course_id AND cat_id = '".$id."' ";
  454. if (!Database::query($sql)) return false;
  455. return true;
  456. }
  457. /**
  458. * Deletes a received dropbox file of this person with id=$id
  459. *
  460. * @param integer $id
  461. */
  462. public function deleteReceivedWork($id)
  463. {
  464. $course_id = api_get_course_int_id();
  465. $id = intval($id);
  466. // index check
  467. $found = false;
  468. foreach ($this->receivedWork as $w) {
  469. if ($w->id == $id) {
  470. $found = true;
  471. break;
  472. }
  473. }
  474. if (!$found) {
  475. if (!$this->deleteReceivedWorkFolder($id)) {
  476. die(get_lang('GeneralError').' (code 216)');
  477. }
  478. }
  479. // Delete entries in person table concerning received works
  480. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
  481. WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
  482. Database::query($sql);
  483. removeUnusedFiles(); // Check for unused files
  484. }
  485. /**
  486. * Deletes all the sent dropbox files of this person
  487. */
  488. public function deleteAllSentWork()
  489. {
  490. $course_id = api_get_course_int_id();
  491. //delete entries in person table concerning sent works
  492. foreach ($this->sentWork as $w) {
  493. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
  494. WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
  495. Database::query($sql);
  496. removeMoreIfMailing($w->id);
  497. }
  498. removeUnusedFiles(); // Check for unused files
  499. }
  500. /**
  501. * Deletes a sent dropbox file of this person with id=$id
  502. *
  503. * @param unknown_type $id
  504. */
  505. public function deleteSentWork($id)
  506. {
  507. $course_id = api_get_course_int_id();
  508. $id = intval($id);
  509. // index check
  510. $found = false;
  511. foreach ($this->sentWork as $w) {
  512. if ($w->id == $id) {
  513. $found = true;
  514. break;
  515. }
  516. }
  517. if (!$found) {
  518. if (!$this->deleteReceivedWorkFolder($id)) {
  519. die(get_lang('GeneralError').' (code 219)');
  520. }
  521. }
  522. //$file_id = $this->sentWork[$index]->id;
  523. // Delete entries in person table concerning sent works
  524. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
  525. WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
  526. Database::query($sql);
  527. removeMoreIfMailing($id);
  528. removeUnusedFiles(); // Check for unused files
  529. }
  530. /**
  531. * Updates feedback for received work of this person with id=$id
  532. *
  533. * @param string $id
  534. * @param string $text
  535. */
  536. public function updateFeedback($id, $text)
  537. {
  538. $course_id = api_get_course_int_id();
  539. $_course = api_get_course_info();
  540. $dropbox_cnf = getDropboxConf();
  541. $id = intval($id);
  542. // index check
  543. $found = false;
  544. $wi = -1;
  545. foreach ($this->receivedWork as $w) {
  546. $wi++;
  547. if ($w->id == $id){
  548. $found = true;
  549. break;
  550. } // foreach (... as $wi -> $w) gives error 221! (no idea why...)
  551. }
  552. if (!$found) {
  553. return false;
  554. }
  555. $feedback_date = api_get_utc_datetime();
  556. $this->receivedWork[$wi]->feedback_date = $feedback_date;
  557. $this->receivedWork[$wi]->feedback = $text;
  558. $params = [
  559. 'feedback_date' => $feedback_date,
  560. 'feedback' => $text,
  561. ];
  562. Database::update(
  563. Database::get_course_table(TABLE_DROPBOX_POST),
  564. $params,
  565. [
  566. 'c_id = ? AND dest_user_id = ? AND file_id = ?' => [
  567. $course_id,
  568. $this->userId,
  569. $id,
  570. ],
  571. ]
  572. );
  573. // Update item_property table
  574. $mailId = get_mail_id_base();
  575. if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) {
  576. $ownerid = getUserOwningThisMailing($ownerid);
  577. }
  578. api_item_property_update(
  579. $_course,
  580. TOOL_DROPBOX,
  581. $this->receivedWork[$wi]->id,
  582. 'DropboxFileUpdated',
  583. $this->userId,
  584. null,
  585. $ownerid
  586. );
  587. }
  588. /**
  589. * Filter the received work
  590. * @param string $type
  591. * @param string $value
  592. */
  593. public function filter_received_work($type, $value)
  594. {
  595. $dropbox_cnf = getDropboxConf();
  596. $new_received_work = array();
  597. $mailId = get_mail_id_base();
  598. foreach ($this->receivedWork as $work) {
  599. switch ($type) {
  600. case 'uploader_id':
  601. if ($work->uploader_id == $value ||
  602. ($work->uploader_id > $mailId &&
  603. getUserOwningThisMailing($work->uploader_id) == $value)
  604. ) {
  605. $new_received_work[] = $work;
  606. }
  607. break;
  608. default:
  609. $new_received_work[] = $work;
  610. break;
  611. }
  612. }
  613. $this->receivedWork = $new_received_work;
  614. }
  615. }