dropbox_class.inc.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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. //this check is done when validating submitted data
  279. $this->recipients[] = array('id' => $rec);
  280. }
  281. $table_post = Database::get_course_table(TABLE_DROPBOX_POST);
  282. $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON);
  283. $session_id = api_get_session_id();
  284. $user = api_get_user_id();
  285. $now = api_get_utc_datetime();
  286. $mailId = get_mail_id_base();
  287. // Insert data in dropbox_post and dropbox_person table for each recipient
  288. foreach ($this->recipients as $rec) {
  289. $file_id = (int)$this->id;
  290. $user_id = (int)$rec['id'];
  291. $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
  292. VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
  293. Database::query($sql);
  294. // If work already exists no error is generated
  295. /**
  296. * Poster is already added when work is created - not so good to split logic
  297. */
  298. if ($user_id != $user) {
  299. // Insert entries into person table
  300. $sql = "INSERT INTO $table_person (c_id, file_id, user_id)
  301. VALUES ($course_id, $file_id, $user_id)";
  302. // Do not add recipient in person table if mailing zip or just upload.
  303. if (!$justSubmit) {
  304. Database::query($sql); // If work already exists no error is generated
  305. }
  306. }
  307. // Update item_property table for each recipient
  308. if (($ownerid = $this->uploader_id) > $mailId) {
  309. $ownerid = getUserOwningThisMailing($ownerid);
  310. }
  311. if (($recipid = $rec["id"]) > $mailId) {
  312. $recipid = $ownerid; // mailing file recipient = mailing id, not a person
  313. }
  314. api_item_property_update(
  315. $_course,
  316. TOOL_DROPBOX,
  317. $this->id,
  318. 'DropboxFileAdded',
  319. $ownerid,
  320. null,
  321. $recipid
  322. );
  323. }
  324. }
  325. /**
  326. * private function creating existing object by retreiving info from db
  327. *
  328. * @param unknown_type $id
  329. */
  330. public function _createExistingSentWork($id)
  331. {
  332. $id = intval($id);
  333. $course_id = api_get_course_int_id();
  334. // Call constructor of Dropbox_Work object
  335. parent::__construct($id);
  336. // Fill in recipients array
  337. $this->recipients = array();
  338. $sql = "SELECT dest_user_id, feedback_date, feedback
  339. FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
  340. WHERE c_id = $course_id AND file_id = ".intval($id)."";
  341. $result = Database::query($sql);
  342. while ($res = Database::fetch_array($result, 'ASSOC')) {
  343. // Check for deleted users
  344. $dest_user_id = $res['dest_user_id'];
  345. $user_info = api_get_user_info($dest_user_id);
  346. //$this->category = $res['cat_id'];
  347. if (!$user_info) {
  348. $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
  349. } else {
  350. $this->recipients[] = array(
  351. 'id' => $dest_user_id,
  352. 'name' => $user_info['complete_name'],
  353. 'user_id' => $dest_user_id,
  354. 'feedback_date' => $res['feedback_date'],
  355. 'feedback' => $res['feedback']
  356. );
  357. }
  358. }
  359. }
  360. }
  361. class Dropbox_Person
  362. {
  363. // The receivedWork and the sentWork arrays are sorted.
  364. public $receivedWork; // an array of Dropbox_Work objects
  365. public $sentWork; // an array of Dropbox_SentWork objects
  366. public $userId = 0;
  367. public $isCourseAdmin = false;
  368. public $isCourseTutor = false;
  369. public $_orderBy = ''; // private property that determines by which field
  370. /**
  371. * Constructor for recreating the Dropbox_Person object
  372. *
  373. * @param int $userId
  374. * @param bool $isCourseAdmin
  375. * @param bool $isCourseTutor
  376. * @return Dropbox_Person
  377. */
  378. public function __construct($userId, $isCourseAdmin, $isCourseTutor)
  379. {
  380. $course_id = api_get_course_int_id();
  381. // Fill in properties
  382. $this->userId = $userId;
  383. $this->isCourseAdmin = $isCourseAdmin;
  384. $this->isCourseTutor = $isCourseTutor;
  385. $this->receivedWork = array();
  386. $this->sentWork = array();
  387. // Note: perhaps include an ex coursemember check to delete old files
  388. $session_id = api_get_session_id();
  389. $condition_session = api_get_session_condition($session_id);
  390. $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
  391. $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
  392. $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
  393. // Find all entries where this person is the recipient
  394. $sql = "SELECT DISTINCT r.file_id, r.cat_id
  395. FROM $post_tbl r
  396. INNER JOIN $person_tbl p
  397. ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
  398. WHERE
  399. p.user_id = ".intval($this->userId)." AND
  400. r.dest_user_id = ".intval($this->userId)." $condition_session ";
  401. $result = Database::query($sql);
  402. while ($res = Database::fetch_array($result)) {
  403. $temp = new Dropbox_Work($res['file_id']);
  404. $temp->category = $res['cat_id'];
  405. $this->receivedWork[] = $temp;
  406. }
  407. // Find all entries where this person is the sender/uploader
  408. $sql = "SELECT DISTINCT f.id
  409. FROM $file_tbl f
  410. INNER JOIN $person_tbl p
  411. ON (f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
  412. WHERE
  413. f.uploader_id = ".intval($this->userId)." AND
  414. p.user_id = ".intval($this->userId)."
  415. $condition_session
  416. ";
  417. $result = Database::query($sql);
  418. while ($res = Database::fetch_array($result)) {
  419. $this->sentWork[] = new Dropbox_SentWork($res['id']);
  420. }
  421. }
  422. /**
  423. * Deletes all the received work of this person
  424. */
  425. public function deleteAllReceivedWork()
  426. {
  427. $course_id = api_get_course_int_id();
  428. // Delete entries in person table concerning received works
  429. foreach ($this->receivedWork as $w) {
  430. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
  431. WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
  432. Database::query($sql);
  433. }
  434. // Check for unused files
  435. removeUnusedFiles();
  436. }
  437. /**
  438. * Deletes all the received categories and work of this person
  439. * @param integer $id
  440. */
  441. public function deleteReceivedWorkFolder($id)
  442. {
  443. $course_id = api_get_course_int_id();
  444. $id = intval($id);
  445. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
  446. WHERE c_id = $course_id AND cat_id = '".$id."' ";
  447. if (!Database::query($sql)) return false;
  448. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
  449. WHERE c_id = $course_id AND cat_id = '".$id."' ";
  450. if (!Database::query($sql)) return false;
  451. $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
  452. WHERE c_id = $course_id AND cat_id = '".$id."' ";
  453. if (!Database::query($sql)) return false;
  454. return true;
  455. }
  456. /**
  457. * Deletes a received dropbox file of this person with id=$id
  458. *
  459. * @param integer $id
  460. */
  461. public function deleteReceivedWork($id)
  462. {
  463. $course_id = api_get_course_int_id();
  464. $id = intval($id);
  465. // index check
  466. $found = false;
  467. foreach ($this->receivedWork as $w) {
  468. if ($w->id == $id) {
  469. $found = true;
  470. break;
  471. }
  472. }
  473. if (!$found) {
  474. if (!$this->deleteReceivedWorkFolder($id)) {
  475. die(get_lang('GeneralError').' (code 216)');
  476. }
  477. }
  478. // Delete entries in person table concerning received works
  479. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
  480. WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
  481. Database::query($sql);
  482. removeUnusedFiles(); // Check for unused files
  483. }
  484. /**
  485. * Deletes all the sent dropbox files of this person
  486. */
  487. public function deleteAllSentWork()
  488. {
  489. $course_id = api_get_course_int_id();
  490. //delete entries in person table concerning sent works
  491. foreach ($this->sentWork as $w) {
  492. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
  493. WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
  494. Database::query($sql);
  495. removeMoreIfMailing($w->id);
  496. }
  497. removeUnusedFiles(); // Check for unused files
  498. }
  499. /**
  500. * Deletes a sent dropbox file of this person with id=$id
  501. *
  502. * @param unknown_type $id
  503. */
  504. public function deleteSentWork($id)
  505. {
  506. $course_id = api_get_course_int_id();
  507. $id = intval($id);
  508. // index check
  509. $found = false;
  510. foreach ($this->sentWork as $w) {
  511. if ($w->id == $id) {
  512. $found = true;
  513. break;
  514. }
  515. }
  516. if (!$found) {
  517. if (!$this->deleteReceivedWorkFolder($id)) {
  518. die(get_lang('GeneralError').' (code 219)');
  519. }
  520. }
  521. //$file_id = $this->sentWork[$index]->id;
  522. // Delete entries in person table concerning sent works
  523. $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
  524. WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
  525. Database::query($sql);
  526. removeMoreIfMailing($id);
  527. removeUnusedFiles(); // Check for unused files
  528. }
  529. /**
  530. * Updates feedback for received work of this person with id=$id
  531. *
  532. * @param string $id
  533. * @param string $text
  534. */
  535. public function updateFeedback($id, $text)
  536. {
  537. $course_id = api_get_course_int_id();
  538. $_course = api_get_course_info();
  539. $dropbox_cnf = getDropboxConf();
  540. $id = intval($id);
  541. // index check
  542. $found = false;
  543. $wi = -1;
  544. foreach ($this->receivedWork as $w) {
  545. $wi++;
  546. if ($w->id == $id){
  547. $found = true;
  548. break;
  549. } // foreach (... as $wi -> $w) gives error 221! (no idea why...)
  550. }
  551. if (!$found) {
  552. return false;
  553. }
  554. $feedback_date = api_get_utc_datetime();
  555. $this->receivedWork[$wi]->feedback_date = $feedback_date;
  556. $this->receivedWork[$wi]->feedback = $text;
  557. $params = [
  558. 'feedback_date' => $feedback_date,
  559. 'feedback' => $text,
  560. ];
  561. Database::update(
  562. Database::get_course_table(TABLE_DROPBOX_POST),
  563. $params,
  564. [
  565. 'c_id = ? AND dest_user_id = ? AND file_id = ?' => [
  566. $course_id,
  567. $this->userId,
  568. $id,
  569. ],
  570. ]
  571. );
  572. // Update item_property table
  573. $mailId = get_mail_id_base();
  574. if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) {
  575. $ownerid = getUserOwningThisMailing($ownerid);
  576. }
  577. api_item_property_update(
  578. $_course,
  579. TOOL_DROPBOX,
  580. $this->receivedWork[$wi]->id,
  581. 'DropboxFileUpdated',
  582. $this->userId,
  583. null,
  584. $ownerid
  585. );
  586. }
  587. /**
  588. * Filter the received work
  589. * @param string $type
  590. * @param string $value
  591. */
  592. public function filter_received_work($type, $value)
  593. {
  594. $dropbox_cnf = getDropboxConf();
  595. $new_received_work = array();
  596. $mailId = get_mail_id_base();
  597. foreach ($this->receivedWork as $work) {
  598. switch ($type) {
  599. case 'uploader_id':
  600. if ($work->uploader_id == $value ||
  601. ($work->uploader_id > $mailId &&
  602. getUserOwningThisMailing($work->uploader_id) == $value)
  603. ) {
  604. $new_received_work[] = $work;
  605. }
  606. break;
  607. default:
  608. $new_received_work[] = $work;
  609. break;
  610. }
  611. }
  612. $this->receivedWork = $new_received_work;
  613. }
  614. }