mahara.class.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Portfolio;
  3. use Header;
  4. /**
  5. * Interface with a Mahara portfolio.
  6. *
  7. * This class requires that the connect mahara plugin is installed and enabled.
  8. *
  9. * @see https://mahara.org/
  10. * @copyright (c) 2012 University of Geneva
  11. * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html
  12. * @author Laurent Opprecht <laurent@opprecht.info>
  13. */
  14. class Mahara extends Portfolio
  15. {
  16. protected $url = '';
  17. /**
  18. *
  19. * @param string $url The root url
  20. */
  21. function __construct($url)
  22. {
  23. $name = md5($url);
  24. parent::__construct($name, null);
  25. $this->url = $url;
  26. }
  27. function get_url()
  28. {
  29. return $this->url;
  30. }
  31. function get_title(){
  32. $result = parent::get_title();
  33. $result = $result ? $result : 'Mahara';
  34. return $result;
  35. }
  36. /**
  37. *
  38. * @param User $user
  39. * @param Artefact $artefact
  40. * @return bool
  41. */
  42. function send($user, $artefact)
  43. {
  44. $root = $this->get_url();
  45. rtrim($root, '/');
  46. $url = $artefact->get_url();
  47. $url = $root . '/artefact/connect/upload.php?url=' . urlencode($url) . '&extract=true';
  48. Header::location($url);
  49. }
  50. }