PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 2namespace common\extensions\external_repository_manager\implementation\bitbucket;
 3
 4use common\extensions\external_repository_manager\ExternalRepositoryComponent;
 5use common\libraries\Request;
 6use common\libraries\Translation;
 7
 8class BitbucketExternalRepositoryManagerRevokerComponent extends BitbucketExternalRepositoryManager
 9{
10
11    function run()
12    {
13        $id = Request :: get(self :: PARAM_EXTERNAL_REPOSITORY_ID);
14        $user = Request :: get(self :: PARAM_EXTERNAL_REPOSITORY_USER);
15        $group = Request :: get(self :: PARAM_EXTERNAL_REPOSITORY_GROUP);
16        if ($id || ($id && $user) || ($id && $group))
17        {
18            if (! $user && ! $group)
19            {
20                $success = $this->get_external_repository_manager_connector()->revoke_user_privilege($id);
21                $success = $this->get_external_repository_manager_connector()->revoke_group_privilege($id);
22            }
23            elseif ($user)
24            {
25                $success = $this->get_external_repository_manager_connector()->revoke_user_privilege($id, $user);
26            }
27            elseif ($group)
28            {
29                $success = $this->get_external_repository_manager_connector()->revoke_group_privilege($id, $group);
30            
31            }
32            if ($success)
33            {
34                $parameters = $this->get_parameters();
35                $parameters[self :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = self :: ACTION_VIEW_EXTERNAL_REPOSITORY_PRIVILEGES;
36                $parameters[self :: PARAM_EXTERNAL_REPOSITORY_ID] = $id;
37                $this->redirect(Translation :: get('PrivilegesRevoked'), false, $parameters);
38            }
39            else
40            {
41                $parameters = $this->get_parameters();
42                $parameters[self :: PARAM_EXTERNAL_REPOSITORY_MANAGER_ACTION] = self :: ACTION_VIEW_EXTERNAL_REPOSITORY_PRIVILEGES;
43                $parameters[self :: PARAM_EXTERNAL_REPOSITORY_ID] = $id;
44                $this->redirect(Translation :: get('PrivilegesNotRevoked'), true, $parameters);
45            }
46        }
47    
48    }
49}
50
51?>