dropboxlink.class.php 1.6 KB

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