/php/component/uploader.class.php

https://bitbucket.org/chamilo/chamilo-ext-repo-box-dev/ · PHP · 55 lines · 48 code · 7 blank · 0 comment · 3 complexity · 2183c74386b87d5b15c28a1b52cc315c MD5 · raw file

  1. <?php
  2. namespace common\extensions\external_repository_manager\implementation\box;
  3. use common\libraries\Path;
  4. use common\libraries\Redirect;
  5. use common\libraries\Request;
  6. use common\libraries\application;
  7. use common\libraries\Translation;
  8. use common\extensions\external_repository_manager\ExternalRepositoryManager;
  9. require_once dirname(__FILE__) . '/../forms/box_external_repository_manager_form.class.php';
  10. class BoxExternalRepositoryManagerUploaderComponent extends BoxExternalRepositoryManager
  11. {
  12. function run()
  13. {
  14. $form = new BoxExternalRepositoryManagerForm(BoxExternalRepositoryManagerForm :: TYPE_CREATE, $this->get_url(), $this);
  15. if ($form->validate())
  16. {
  17. $id = $form->upload_file();
  18. if ($id)
  19. {
  20. $parameters = $this->get_parameters();
  21. $parameters[ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = ExternalRepositoryManager :: ACTION_VIEW_EXTERNAL_REPOSITORY;
  22. $parameters[ExternalRepositoryManager :: PARAM_EXTERNAL_REPOSITORY_ID] = $id;
  23. if ($this->is_stand_alone())
  24. {
  25. Redirect :: web_link(Path :: get(WEB_PATH) . 'common/launcher/index.php', $parameters);
  26. }
  27. else
  28. {
  29. Redirect :: web_link(Path :: get(WEB_PATH) . 'index.php', $parameters);
  30. }
  31. }
  32. else
  33. {
  34. Request :: set_get(Application :: PARAM_ERROR_MESSAGE, Translation :: get('BoxUploadProblem'));
  35. $this->display_header();
  36. $form->display();
  37. $this->display_footer();
  38. }
  39. }
  40. else
  41. {
  42. $this->display_header();
  43. $form->display();
  44. $this->display_footer();
  45. }
  46. }
  47. }
  48. ?>