dropboxlink.class.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /**
  9. * Class
  10. * @package chamilo.gradebook
  11. */
  12. class DropboxLink extends EvalLink
  13. {
  14. // INTERNAL VARIABLES
  15. private $dropbox_table = null;
  16. // CONSTRUCTORS
  17. function __construct() {
  18. parent::__construct();
  19. $this->set_type(LINK_DROPBOX);
  20. }
  21. /**
  22. *
  23. * Returns the URL of a document
  24. * This funcion is loaded when using a gradebook as a tab (gradebook = -1) see issue #2705
  25. */
  26. public function get_view_url ($stud_id) {
  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 c_id = '.$this->course_id.' AND uploader_id = '.intval($stud_id)
  32. ." AND title = '".Database::escape_string($eval->get_name())."'";
  33. $result = Database::query($sql);
  34. if ($fileurl = Database::fetch_row($result)) {
  35. $course_info = Database :: get_course_info($this->get_course_code());
  36. return null;
  37. } else {
  38. return null;
  39. }
  40. }
  41. public function get_type_name() {
  42. return get_lang('DokeosDropbox');
  43. }
  44. public function is_allowed_to_change_name() {
  45. return false;
  46. }
  47. // INTERNAL FUNCTIONS
  48. /**
  49. * Lazy load function to get the dropbox database table
  50. */
  51. private function get_dropbox_table () {
  52. $this->dropbox_table = Database :: get_course_table(TABLE_DROPBOX_FILE);
  53. return $this->dropbox_table;
  54. }
  55. public function get_icon_name() {
  56. return 'dropbox';
  57. }
  58. }