GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 89babd...5ed7d9 )
by
unknown
79:45 queued 23:58
created

SystemEvent_UGROUP_MODIFY   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6
Metric Value
wmc 15
lcom 1
cbo 6
dl 0
loc 105
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A verbalizeParameters() 0 6 1
B process() 0 24 4
A processSVNAccessFile() 0 11 4
B processUgroupBinding() 0 21 5
A getUgroupBinding() 0 6 1
1
<?php
2
/**
3
 *  Copyright (c) Enalean, 2016. All Rights Reserved.
4
 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5
 *
6
 * This file is a part of Tuleap.
7
 *
8
 * Tuleap is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * Tuleap is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
/**
23
* System Event classes
24
*
25
* UGROUP_MODIFY = one static ugroup of the project has been modified
26
*/
27
class SystemEvent_UGROUP_MODIFY extends SystemEvent {
28
    /**
29
     * Verbalize the parameters so they are readable and much user friendly in
30
     * notifications
31
     *
32
     * @param bool $with_link true if you want links to entities. The returned 
33
     * string will be html instead of plain/text
34
     *
35
     * @return string
36
     */
37
    public function verbalizeParameters($with_link) {
38
        $txt = '';
39
        list($group_id, $ugroup_id) = $this->getParametersAsArray();
40
        $txt .= 'project: '. $this->verbalizeProjectId($group_id, $with_link) .', ugroup: #'. $ugroup_id;
41
        return $txt;
42
    }
43
    
44
    /** 
45
     * Process stored event
46
     *
47
     * @return Boolean
48
     */
49
    function process() {
50
        $ugroup_name = null;
51
        $ugroup_old_name = null;
52
        // Check parameters
53
        if (count($this->getParametersAsArray()) == 4) {
54
            list($group_id, $ugroup_id, $ugroup_name, $ugroup_old_name) = $this->getParametersAsArray();
55
        } else {
56
            list($group_id, $ugroup_id) = $this->getParametersAsArray();
57
        }
58
        // Remove ugroup binding to this user group
59
        if (!$this->processUgroupBinding($ugroup_id, $group_id)) {
60
            $this->error("Could not process binding to this user group ($ugroup_id)");
61
            return false;
62
        }
63
64
        $is_svn_access_successfuly_updated = $this->processSVNAccessFile($group_id, $ugroup_name, $ugroup_old_name);
65
        if (! $is_svn_access_successfuly_updated) {
66
            $this->error("Could not update SVN access file ($group_id)");
67
            return false;
68
        }
69
70
        $this->done();
71
        return true;
72
    }
73
74
    /**
75
     * @return bool
76
     */
77
    private function processSVNAccessFile($project_id, $ugroup_name, $ugroup_old_name) {
78
        if ($project = $this->getProject($project_id)) {
79
            if ($project->usesSVN()) {
80
                $backendSVN = $this->getBackend('SVN');
81
                if (! $backendSVN->updateSVNAccess($project_id, $ugroup_name, $ugroup_old_name)) {
82
                    return false;
83
                }
84
            }
85
        }
86
        return true;
87
    }
88
89
    /**
90
     * Remove all user group bound to a deleted given ugroup
91
     *
92
     * @param Integer $ugroup_id Id of the deleted user group
93
     * @param Integer $group_id  Id of the project
94
     *
95
     * @return Boolean
96
     */
97
    protected function processUgroupBinding($ugroup_id, $group_id) {
98
        $ugroupBinding                = $this->getUgroupBinding();
99
        $ugroups_successfully_updated = true;
100
        if (!$ugroupBinding->checkUGroupValidity($group_id, $ugroup_id)) {
101
            //The user group is removed, we remove all its binding traces
102
            $ugroups_successfully_updated = $ugroupBinding->removeAllUGroupsBinding($ugroup_id);
103
        } else {
104
            if (count($this->getParametersAsArray()) == 2) {
105
                //The user group has been updated (user added / user removed), we update all its bound user groups
106
                $ugroups_successfully_updated = $ugroupBinding->updateBindedUGroups($ugroup_id);
107
            }
108
        }
109
110
        $binded_ugroups = $ugroupBinding->getUGroupsByBindingSource($ugroup_id);
111
        foreach ($binded_ugroups as $binded_ugroup_id => $binded_ugroup) {
112
            $ugroups_successfully_updated = $this->processSVNAccessFile($binded_ugroup['group_id'], null, null) &&
113
                $ugroups_successfully_updated;
114
        }
115
116
        return $ugroups_successfully_updated;
117
    }
118
119
    /**
120
     * Obtain instance of UGroupBinding
121
     *
122
     * @return UGroupBinding
123
     */
124
    public function getUgroupBinding() {
125
        $ugroupUserDao = new UGroupUserDao();
126
        $ugroupManager = new UGroupManager(new UGroupDao());
127
        $uGroupBinding = new UGroupBinding($ugroupUserDao, $ugroupManager);
128
        return $uGroupBinding;
129
    }
130
131
}
132