summaryrefslogtreecommitdiffstats
path: root/models/org.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/org.go')
-rw-r--r--models/org.go60
1 files changed, 31 insertions, 29 deletions
diff --git a/models/org.go b/models/org.go
index 6844445591..020284d8d2 100644
--- a/models/org.go
+++ b/models/org.go
@@ -9,8 +9,8 @@ import (
"fmt"
"os"
"strings"
- "strconv"
+ "github.com/Unknwon/com"
"github.com/go-xorm/xorm"
)
@@ -1054,54 +1054,56 @@ func RemoveOrgRepo(orgID, repoID int64) error {
// that the user with the given userID has access to.
func (org *User) GetUserRepositories(userID int64) (err error) {
teams := make([]*Team, 0, 10)
- if err := x.Cols("`team`.id").
- Where("`team_user`.org_id=?", org.Id).
- And("`team_user`.uid=?", userID).
- Join("INNER", "`team_user`", "`team_user`.team_id=`team`.id").
- Find(&teams); err != nil {
- return fmt.Errorf("getUserRepositories: get teams: %v", err)
+ if err = x.Cols("`team`.id").
+ Where("`team_user`.org_id=?", org.Id).
+ And("`team_user`.uid=?", userID).
+ Join("INNER", "`team_user`", "`team_user`.team_id=`team`.id").
+ Find(&teams); err != nil {
+ return fmt.Errorf("GetUserRepositories: get teams: %v", err)
}
- var teamIDs []string
- for _, team := range teams {
- teamIDs = append(teamIDs, strconv.FormatInt(team.ID, 10))
+ teamIDs := make([]string, len(teams))
+ for i := range teams {
+ teamIDs[i] = com.ToStr(teams[i].ID)
}
if len(teamIDs) == 0 {
// user has no team but "IN ()" is invalid SQL
- teamIDs = append(teamIDs, "-1") // there is no repo with id=-1
+ teamIDs = append(teamIDs, "-1") // there is no repo with id=-1
}
// Due to a bug in xorm using IN() together with OR() is impossible.
// As a workaround, we have to build the IN statement on our own, until this is fixed.
// https://github.com/go-xorm/xorm/issues/342
- if err := x.Cols("`repository`.*").
- Join("INNER", "`team_repo`", "`team_repo`.repo_id=`repository`.id").
- Where("`repository`.owner_id=?", org.Id).
- And("`repository`.is_private=?", false).
- Or("`team_repo`.team_id=(?)", strings.Join(teamIDs, ",")).
- GroupBy("`repository`.id").
- Find(&org.Repos); err != nil {
- return fmt.Errorf("getUserRepositories: get repositories: %v", err)
+ if err = x.Cols("`repository`.*").
+ Join("INNER", "`team_repo`", "`team_repo`.repo_id=`repository`.id").
+ Where("`repository`.owner_id=?", org.Id).
+ And("`repository`.is_private=?", false).
+ Or("`team_repo`.team_id=(?)", strings.Join(teamIDs, ",")).
+ GroupBy("`repository`.id").
+ Find(&org.Repos); err != nil {
+ return fmt.Errorf("GetUserRepositories: get repositories: %v", err)
}
+ // FIXME: should I change this value inside method,
+ // or only in location of caller where it's really needed?
org.NumRepos = len(org.Repos)
-
- return
+ return nil
}
// GetTeams returns all teams that belong to organization,
// and that the user has joined.
-func (org *User) GetUserTeams(userID int64) (err error) {
+func (org *User) GetUserTeams(userID int64) error {
if err := x.Cols("`team`.*").
- Where("`team_user`.org_id=?", org.Id).
- And("`team_user`.uid=?", userID).
- Join("INNER", "`team_user`", "`team_user`.team_id=`team`.id").
- Find(&org.Teams); err != nil {
- return fmt.Errorf("getUserTeams: %v", err)
+ Where("`team_user`.org_id=?", org.Id).
+ And("`team_user`.uid=?", userID).
+ Join("INNER", "`team_user`", "`team_user`.team_id=`team`.id").
+ Find(&org.Teams); err != nil {
+ return fmt.Errorf("GetUserTeams: %v", err)
}
+ // FIXME: should I change this value inside method,
+ // or only in location of caller where it's really needed?
org.NumTeams = len(org.Teams)
-
- return
+ return nil
}
/40394/stable30'>backport/40394/stable30 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/core/l10n/ro.php
blob: 033290b34f92026160201c744d834dc9b0ded4e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127