dropbox_class.inc.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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. $dropbox_cnf = getDropboxConf();
  92. // Fill in the properties
  93. $this->uploader_id = intval($uploader_id);
  94. $this->filename = $filename;
  95. $this->filesize = $filesize;
  96. $this->title = $title;
  97. $this->description = $description;
  98. $this->author = $author;
  99. $this->last_upload_date = api_get_utc_datetime();
  100. $course_id = api_get_course_int_id();
  101. // Check if object exists already. If it does, the old object is used
  102. // with updated information (authors, description, upload_date)
  103. $this->isOldWork = false;
  104. $sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
  105. WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
  106. $result = Database::query($sql);
  107. $res = Database::fetch_array($result);
  108. if ($res) {
  109. $this->isOldWork = true;
  110. }
  111. // Insert or update the dropbox_file table and set the id property
  112. if ($this->isOldWork) {
  113. $this->id = $res['id'];
  114. $this->upload_date = $res['upload_date'];
  115. $params = [
  116. 'filesize' => $this->filesize,
  117. 'title' => $this->title,
  118. 'description' => $this->description,
  119. 'author' => $this->author,
  120. 'last_upload_date' => $this->last_upload_date,
  121. 'session_id' => api_get_session_id()
  122. ];
  123. Database::update(
  124. $dropbox_cnf['tbl_file'],
  125. $params,
  126. ['c_id = ? AND id = ?' => [$course_id, $this->id]]
  127. );
  128. } else {
  129. $this->upload_date = $this->last_upload_date;
  130. $params = [
  131. 'c_id' => $course_id,
  132. 'uploader_id' => $this->uploader_id,
  133. 'filename' => $this->filename,
  134. 'filesize' => $this->filesize,
  135. 'title' => $this->title,
  136. 'description' => $this->description,
  137. 'author' => $this->author,
  138. 'upload_date' => $this->upload_date,
  139. 'last_upload_date' => $this->last_upload_date,
  140. 'session_id' => api_get_session_id(),
  141. 'cat_id' => 0
  142. ];
  143. $this->id = Database::insert($dropbox_cnf['tbl_file'], $params);
  144. if ($this->id) {
  145. $sql = "UPDATE ".$dropbox_cnf['tbl_file']." SET id = iid WHERE iid = {$this->id}";
  146. Database::query($sql);
  147. }
  148. }
  149. $sql = "SELECT count(file_id) as count
  150. FROM ".$dropbox_cnf['tbl_person']."
  151. WHERE c_id = $course_id AND file_id = ".intval($this->id)." AND user_id = ".$this->uploader_id;
  152. $result = Database::query($sql);
  153. $row = Database::fetch_array($result);
  154. if ($row['count'] == 0) {
  155. // Insert entries into person table
  156. $sql = "INSERT INTO ".$dropbox_cnf['tbl_person']." (c_id, file_id, user_id)
  157. VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
  158. Database::query($sql);
  159. }
  160. }
  161. /**
  162. * private function creating existing object by retreiving info from db
  163. *
  164. * @param int $id
  165. */
  166. public function _createExistingWork($id)
  167. {
  168. $course_id = api_get_course_int_id();
  169. $dropbox_cnf = getDropboxConf();
  170. $action = isset($_GET['action']) ? $_GET['action'] : null;
  171. // Do some sanity checks
  172. $id = intval($id);
  173. // Get the data from DB
  174. $sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
  175. FROM ".$dropbox_cnf['tbl_file']."
  176. WHERE c_id = $course_id AND id = ".$id."";
  177. $result = Database::query($sql);
  178. $res = Database::fetch_array($result, 'ASSOC');
  179. // Check if uploader is still in Chamilo system
  180. $uploader_id = stripslashes($res['uploader_id']);
  181. $userInfo = api_get_user_info($uploader_id);
  182. if (!$userInfo) {
  183. //deleted user
  184. $this->uploader_id = -1;
  185. } else {
  186. $this->uploader_id = $uploader_id;
  187. }
  188. // Fill in properties
  189. $this->id = $id;
  190. $this->filename = stripslashes($res['filename']);
  191. $this->filesize = stripslashes($res['filesize']);
  192. $this->title = stripslashes($res['title']);
  193. $this->description = stripslashes($res['description']);
  194. $this->author = stripslashes($res['author']);
  195. $this->upload_date = stripslashes($res['upload_date']);
  196. $this->last_upload_date = stripslashes($res['last_upload_date']);
  197. $this->category = $res['cat_id'];
  198. // Getting the feedback on the work.
  199. if ($action == 'viewfeedback' AND $this->id == $_GET['id']) {
  200. $feedback2 = array();
  201. $sql = "SELECT * FROM ".$dropbox_cnf['tbl_feedback']."
  202. WHERE c_id = $course_id AND file_id='".$id."'
  203. ORDER BY feedback_id ASC";
  204. $result = Database::query($sql);
  205. while ($row_feedback = Database::fetch_array($result)) {
  206. $row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']);
  207. $feedback2[] = $row_feedback;
  208. }
  209. $this->feedback2= $feedback2;
  210. }
  211. }
  212. }
  213. class Dropbox_SentWork extends Dropbox_Work
  214. {
  215. public $recipients; //array of ['id']['name'] arrays
  216. /**
  217. * Constructor calls private functions to create a new work or retreive an existing work from DB
  218. * depending on the number of parameters
  219. *
  220. * @param unknown_type $arg1
  221. * @param unknown_type $arg2
  222. * @param unknown_type $arg3
  223. * @param unknown_type $arg4
  224. * @param unknown_type $arg5
  225. * @param unknown_type $arg6
  226. * @param unknown_type $arg7
  227. * @return Dropbox_SentWork
  228. */
  229. public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
  230. {
  231. if (func_num_args() > 1) {
  232. $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
  233. } else {
  234. $this->_createExistingSentWork($arg1);
  235. }
  236. }
  237. /**
  238. * private function creating a new SentWork object
  239. *
  240. * @param int $uploader_id
  241. * @param string $title
  242. * @param string $description
  243. * @param string $author
  244. * @param string $filename
  245. * @param int $filesize
  246. * @param array $recipient_ids
  247. */
  248. public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
  249. {
  250. $dropbox_cnf = getDropboxConf();
  251. $_course = api_get_course_info();
  252. // Call constructor of Dropbox_Work object
  253. parent::__construct(
  254. $uploader_id,
  255. $title,
  256. $description,
  257. $author,
  258. $filename,
  259. $filesize
  260. );
  261. $course_id = api_get_course_int_id();
  262. // Do sanity checks on recipient_ids array & property fillin
  263. // The sanity check for ex-coursemembers is already done in base constructor
  264. $uploader_id = (int) $uploader_id;
  265. $justSubmit = false;
  266. if (is_int($recipient_ids)) {
  267. $justSubmit = true;
  268. $recipient_ids = array($recipient_ids + $this->id);
  269. } elseif (count($recipient_ids) == 0) {
  270. $justSubmit = true;
  271. $recipient_ids = array($uploader_id);
  272. }
  273. if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
  274. die(get_lang('GeneralError').' (code 209)');
  275. }
  276. foreach ($recipient_ids as $rec) {
  277. if (empty($rec)) {
  278. continue;
  279. }
  280. //this check is done when validating submitted data
  281. $this->recipients[] = array('id' => $rec);
  282. }
  283. $table_post = $dropbox_cnf['tbl_post'];
  284. $table_person = $dropbox_cnf['tbl_person'];
  285. $session_id = api_get_session_id();
  286. $user = api_get_user_id();
  287. $now = api_get_utc_datetime();
  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) > $dropbox_cnf['mailingIdBase']) {
  310. $ownerid = getUserOwningThisMailing($ownerid);
  311. }
  312. if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
  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. $dropbox_cnf = getDropboxConf();
  334. $id = intval($id);
  335. $course_id = api_get_course_int_id();
  336. // Call constructor of Dropbox_Work object
  337. parent::__construct($id);
  338. // Fill in recipients array
  339. $this->recipients = array();
  340. $sql = "SELECT dest_user_id, feedback_date, feedback
  341. FROM ".$dropbox_cnf['tbl_post']."
  342. WHERE c_id = $course_id AND file_id = ".intval($id)."";
  343. $result = Database::query($sql);
  344. while ($res = Database::fetch_array($result, 'ASSOC')) {
  345. // Check for deleted users
  346. $dest_user_id = $res['dest_user_id'];
  347. $user_info = api_get_user_info($dest_user_id);
  348. //$this->category = $res['cat_id'];
  349. if (!$user_info) {
  350. $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
  351. } else {
  352. $this->recipients[] = array(
  353. 'id' => $dest_user_id,
  354. 'name' => $user_info['complete_name'],
  355. 'user_id' => $dest_user_id,
  356. 'feedback_date' => $res['feedback_date'],
  357. 'feedback' => $res['feedback']
  358. );
  359. }
  360. }
  361. }
  362. }
  363. class Dropbox_Person
  364. {
  365. // The receivedWork and the sentWork arrays are sorted.
  366. public $receivedWork; // an array of Dropbox_Work objects
  367. public $sentWork; // an array of Dropbox_SentWork objects
  368. public $userId = 0;
  369. public $isCourseAdmin = false;
  370. public $isCourseTutor = false;
  371. public $_orderBy = ''; // private property that determines by which field
  372. /**
  373. * Constructor for recreating the Dropbox_Person object
  374. *
  375. * @param int $userId
  376. * @param bool $isCourseAdmin
  377. * @param bool $isCourseTutor
  378. * @return Dropbox_Person
  379. */
  380. public function __construct($userId, $isCourseAdmin, $isCourseTutor)
  381. {
  382. $course_id = api_get_course_int_id();
  383. // Fill in properties
  384. $this->userId = $userId;
  385. $this->isCourseAdmin = $isCourseAdmin;
  386. $this->isCourseTutor = $isCourseTutor;
  387. $this->receivedWork = array();
  388. $this->sentWork = array();
  389. // Note: perhaps include an ex coursemember check to delete old files
  390. $session_id = api_get_session_id();
  391. $condition_session = api_get_session_condition($session_id);
  392. $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
  393. $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
  394. $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
  395. // Find all entries where this person is the recipient
  396. $sql = "SELECT DISTINCT r.file_id, r.cat_id
  397. FROM $post_tbl r
  398. INNER JOIN $person_tbl p
  399. ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
  400. WHERE
  401. p.user_id = ".intval($this->userId)." AND
  402. r.dest_user_id = ".intval($this->userId)." $condition_session ";
  403. $result = Database::query($sql);
  404. while ($res = Database::fetch_array($result)) {
  405. $temp = new Dropbox_Work($res['file_id']);
  406. $temp->category = $res['cat_id'];
  407. $this->receivedWork[] = $temp;
  408. }
  409. // Find all entries where this person is the sender/uploader
  410. $sql = "SELECT DISTINCT f.id
  411. FROM $file_tbl f
  412. INNER JOIN $person_tbl p
  413. ON (f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
  414. WHERE
  415. f.uploader_id = ".intval($this->userId)." AND
  416. p.user_id = ".intval($this->userId)."
  417. $condition_session
  418. ";
  419. $result = Database::query($sql);
  420. while ($res = Database::fetch_array($result)) {
  421. $this->sentWork[] = new Dropbox_SentWork($res['id']);
  422. }
  423. }
  424. /**
  425. * Deletes all the received work of this person
  426. */
  427. public function deleteAllReceivedWork()
  428. {
  429. $course_id = api_get_course_int_id();
  430. $dropbox_cnf = getDropboxConf();
  431. // Delete entries in person table concerning received works
  432. foreach ($this->receivedWork as $w) {
  433. $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
  434. WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
  435. Database::query($sql);
  436. }
  437. // Check for unused files
  438. removeUnusedFiles();
  439. }
  440. /**
  441. * Deletes all the received categories and work of this person
  442. * @param integer $id
  443. */
  444. public function deleteReceivedWorkFolder($id)
  445. {
  446. $dropbox_cnf = getDropboxConf();
  447. $course_id = api_get_course_int_id();
  448. $id = intval($id);
  449. $sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
  450. WHERE c_id = $course_id AND cat_id = '".$id."' ";
  451. if (!Database::query($sql)) return false;
  452. $sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
  453. WHERE c_id = $course_id AND cat_id = '".$id."' ";
  454. if (!Database::query($sql)) return false;
  455. $sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
  456. WHERE c_id = $course_id AND cat_id = '".$id."' ";
  457. if (!Database::query($sql)) return false;
  458. return true;
  459. }
  460. /**
  461. * Deletes a received dropbox file of this person with id=$id
  462. *
  463. * @param integer $id
  464. */
  465. public function deleteReceivedWork($id)
  466. {
  467. $course_id = api_get_course_int_id();
  468. $dropbox_cnf = getDropboxConf();
  469. $id = intval($id);
  470. // index check
  471. $found = false;
  472. foreach ($this->receivedWork as $w) {
  473. if ($w->id == $id) {
  474. $found = true;
  475. break;
  476. }
  477. }
  478. if (!$found) {
  479. if (!$this->deleteReceivedWorkFolder($id)) {
  480. die(get_lang('GeneralError').' (code 216)');
  481. }
  482. }
  483. // Delete entries in person table concerning received works
  484. $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
  485. WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
  486. Database::query($sql);
  487. removeUnusedFiles(); // Check for unused files
  488. }
  489. /**
  490. * Deletes all the sent dropbox files of this person
  491. */
  492. public function deleteAllSentWork()
  493. {
  494. $course_id = api_get_course_int_id();
  495. $dropbox_cnf = getDropboxConf();
  496. //delete entries in person table concerning sent works
  497. foreach ($this->sentWork as $w) {
  498. $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
  499. WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
  500. Database::query($sql);
  501. removeMoreIfMailing($w->id);
  502. }
  503. removeUnusedFiles(); // Check for unused files
  504. }
  505. /**
  506. * Deletes a sent dropbox file of this person with id=$id
  507. *
  508. * @param unknown_type $id
  509. */
  510. public function deleteSentWork($id)
  511. {
  512. $course_id = api_get_course_int_id();
  513. $dropbox_cnf = getDropboxConf();
  514. $id = intval($id);
  515. // index check
  516. $found = false;
  517. foreach ($this->sentWork as $w) {
  518. if ($w->id == $id) {
  519. $found = true;
  520. break;
  521. }
  522. }
  523. if (!$found) {
  524. if (!$this->deleteReceivedWorkFolder($id)) {
  525. die(get_lang('GeneralError').' (code 219)');
  526. }
  527. }
  528. //$file_id = $this->sentWork[$index]->id;
  529. // Delete entries in person table concerning sent works
  530. $sql = "DELETE FROM ".$dropbox_cnf['tbl_person']."
  531. WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
  532. Database::query($sql);
  533. removeMoreIfMailing($id);
  534. removeUnusedFiles(); // Check for unused files
  535. }
  536. /**
  537. * Updates feedback for received work of this person with id=$id
  538. *
  539. * @param string $id
  540. * @param string $text
  541. */
  542. public function updateFeedback($id, $text)
  543. {
  544. $course_id = api_get_course_int_id();
  545. $_course = api_get_course_info();
  546. $dropbox_cnf = getDropboxConf();
  547. $id = intval($id);
  548. // index check
  549. $found = false;
  550. $wi = -1;
  551. foreach ($this->receivedWork as $w) {
  552. $wi++;
  553. if ($w->id == $id){
  554. $found = true;
  555. break;
  556. } // foreach (... as $wi -> $w) gives error 221! (no idea why...)
  557. }
  558. if (!$found) {
  559. return false;
  560. }
  561. $feedback_date = api_get_utc_datetime();
  562. $this->receivedWork[$wi]->feedback_date = $feedback_date;
  563. $this->receivedWork[$wi]->feedback = $text;
  564. $params = [
  565. 'feedback_date' => $feedback_date,
  566. 'feedback' => $text,
  567. ];
  568. Database::update(
  569. $dropbox_cnf['tbl_post'],
  570. $params,
  571. [
  572. 'c_id = ? AND dest_user_id = ? AND file_id = ?' => [
  573. $course_id,
  574. $this->userId,
  575. $id,
  576. ],
  577. ]
  578. );
  579. // Update item_property table
  580. if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $dropbox_cnf['mailingIdBase']) {
  581. $ownerid = getUserOwningThisMailing($ownerid);
  582. }
  583. api_item_property_update(
  584. $_course,
  585. TOOL_DROPBOX,
  586. $this->receivedWork[$wi]->id,
  587. 'DropboxFileUpdated',
  588. $this->userId,
  589. null,
  590. $ownerid
  591. );
  592. }
  593. /**
  594. * Filter the received work
  595. * @param string $type
  596. * @param string $value
  597. */
  598. public function filter_received_work($type, $value)
  599. {
  600. $dropbox_cnf = getDropboxConf();
  601. $new_received_work = array();
  602. foreach ($this->receivedWork as $work) {
  603. switch ($type) {
  604. case 'uploader_id':
  605. if ($work->uploader_id == $value ||
  606. ($work->uploader_id > $dropbox_cnf['mailingIdBase'] &&
  607. getUserOwningThisMailing($work->uploader_id) == $value)
  608. ) {
  609. $new_received_work[] = $work;
  610. }
  611. break;
  612. default:
  613. $new_received_work[] = $work;
  614. break;
  615. }
  616. }
  617. $this->receivedWork = $new_received_work;
  618. }
  619. }