/php/component/revoker.class.php

https://bitbucket.org/chamilo/chamilo-ext-repo-bitbucket-dev/ · PHP · 51 lines · 45 code · 6 blank · 0 comment · 8 complexity · c9dc54536e7fe78afccba6230e17a529 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 BitbucketExternalRepositoryManagerRevokerComponent 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. $group = Request :: get(self :: PARAM_EXTERNAL_REPOSITORY_GROUP);
  13. if ($id || ($id && $user) || ($id && $group))
  14. {
  15. if (! $user && ! $group)
  16. {
  17. $success = $this->get_external_repository_manager_connector()->revoke_user_privilege($id);
  18. $success = $this->get_external_repository_manager_connector()->revoke_group_privilege($id);
  19. }
  20. elseif ($user)
  21. {
  22. $success = $this->get_external_repository_manager_connector()->revoke_user_privilege($id, $user);
  23. }
  24. elseif ($group)
  25. {
  26. $success = $this->get_external_repository_manager_connector()->revoke_group_privilege($id, $group);
  27. }
  28. if ($success)
  29. {
  30. $parameters = $this->get_parameters();
  31. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = self :: ACTION_VIEW_EXTERNAL_REPOSITORY_PRIVILEGES;
  32. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_ID] = $id;
  33. $this->redirect(Translation :: get('PrivilegesRevoked'), false, $parameters);
  34. }
  35. else
  36. {
  37. $parameters = $this->get_parameters();
  38. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = self :: ACTION_VIEW_EXTERNAL_REPOSITORY_PRIVILEGES;
  39. $parameters[self :: PARAM_EXTERNAL_REPOSITORY_ID] = $id;
  40. $this->redirect(Translation :: get('PrivilegesNotRevoked'), true, $parameters);
  41. }
  42. }
  43. }
  44. }
  45. ?>