diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-08-26 18:11:15 +0800 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-08-26 18:11:15 +0800 |
commit | 74b31566cf5caaf6bf73584e621d56ca99c048d1 (patch) | |
tree | 078a8428e5241d13600482301444684720a77283 /models/user.go | |
parent | f2c263c54facdcbc9375a47535c0389fd7d05875 (diff) | |
download | gitea-74b31566cf5caaf6bf73584e621d56ca99c048d1.tar.gz gitea-74b31566cf5caaf6bf73584e621d56ca99c048d1.zip |
Finsih add/remove repo in organization
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/models/user.go b/models/user.go index e8db1ad157..a74d803972 100644 --- a/models/user.go +++ b/models/user.go @@ -521,21 +521,21 @@ func GetUserByEmail(email string) (*User, error) { } // SearchUserByName returns given number of users whose name contains keyword. -func SearchUserByName(key string, limit int) (us []*User, err error) { +func SearchUserByName(opt SearchOption) (us []*User, err error) { // Prevent SQL inject. - key = strings.TrimSpace(key) - if len(key) == 0 { + opt.Keyword = strings.TrimSpace(opt.Keyword) + if len(opt.Keyword) == 0 { return us, nil } - key = strings.Split(key, " ")[0] - if len(key) == 0 { + opt.Keyword = strings.Split(opt.Keyword, " ")[0] + if len(opt.Keyword) == 0 { return us, nil } - key = strings.ToLower(key) + opt.Keyword = strings.ToLower(opt.Keyword) - us = make([]*User, 0, limit) - err = x.Limit(limit).Where("type=0").And("lower_name like '%" + key + "%'").Find(&us) + us = make([]*User, 0, opt.Limit) + err = x.Limit(opt.Limit).Where("type=0").And("lower_name like '%" + opt.Keyword + "%'").Find(&us) return us, err } |