/php/component/granter.class.php

https://bitbucket.org/chamilo/chamilo-ext-repo-bitbucket-dev/ · PHP · 44 lines · 38 code · 6 blank · 0 comment · 5 complexity · 1ee764b520d3b34432b284381512ac94 MD5 · raw file

  1. <?php
  2. namespace common\extensions\external_repository_manager\implementation\bitbucket;
  3. use common\extensions\external_repository_manager\ExternalRepositoryComponent;
  4. use common\libraries\Request;
  5. use common\libraries\Translation;
  6. class BitbucketExternalRepositoryManagerGranterComponent extends BitbucketExternalRepositoryManager
  7. {
  8. function run()
  9. {
  10. $id = Request :: get(self :: PARAM_EXTERNAL_REPOSITORY_ID);
  11. $user = Request :: get(self :: PARAM_EXTERNAL_REPOSITORY_USER);
  12. $privilege = Request :: get(self :: PARAM_EXTERNAL_REPOSITORY_PRIVILEGE);
  13. if ($id || ($id && $user && $privilege))
  14. {
  15. $success = $this->get_external_repository_manager_connector()->grant_user_privilege($id, $user, $privilege);
  16. if ($success)
  17. {
  18. $parameters = $this->get_parameters();
  19. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = self :: ACTION_VIEW_EXTERNAL_REPOSITORY_PRIVILEGES;
  20. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_ID] = $id;
  21. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_USER] = $user;
  22. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_PRIVILEGE] = $privilege;
  23. $this->redirect(Translation :: get('PrivilegesGranted'), false, $parameters);
  24. }
  25. else
  26. {
  27. $parameters = $this->get_parameters();
  28. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = self :: ACTION_VIEW_EXTERNAL_REPOSITORY_PRIVILEGES;
  29. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_ID] = $id;
  30. $this->redirect(Translation :: get('PrivilegesNotGranted'), true, $parameters);
  31. }
  32. }
  33. else
  34. {
  35. }
  36. }
  37. }
  38. ?>