dropboxlink.class.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Gradebook link to dropbox item.
  5. *
  6. * @author Bert Steppé
  7. *
  8. * @package chamilo.gradebook
  9. */
  10. class DropboxLink extends EvalLink
  11. {
  12. private $dropbox_table = null;
  13. /**
  14. * Constructor.
  15. */
  16. public function __construct()
  17. {
  18. parent::__construct();
  19. $this->set_type(LINK_DROPBOX);
  20. }
  21. /**
  22. * Returns the URL of a document
  23. * This function is loaded when using a gradebook as a tab (gradebook = -1) see issue #2705.
  24. */
  25. public function get_view_url($stud_id)
  26. {
  27. // find a file uploaded by the given student,
  28. // with the same title as the evaluation name
  29. $eval = $this->get_evaluation();
  30. $sql = 'SELECT filename FROM '.$this->get_dropbox_table().'
  31. WHERE
  32. c_id = '.$this->course_id.' AND
  33. uploader_id = '.intval($stud_id)." AND
  34. title = '".Database::escape_string($eval->get_name())."'";
  35. $result = Database::query($sql);
  36. if ($fileurl = Database::fetch_row($result)) {
  37. return null;
  38. } else {
  39. return null;
  40. }
  41. }
  42. public function get_type_name()
  43. {
  44. return get_lang('LMSDropbox');
  45. }
  46. public function is_allowed_to_change_name()
  47. {
  48. return false;
  49. }
  50. public function get_icon_name()
  51. {
  52. return 'dropbox';
  53. }
  54. /**
  55. * Lazy load function to get the dropbox database table.
  56. */
  57. private function get_dropbox_table()
  58. {
  59. $this->dropbox_table = Database::get_course_table(TABLE_DROPBOX_FILE);
  60. return $this->dropbox_table;
  61. }
  62. }