diff options
author | mkanat%bugzilla.org <> | 2008-10-18 23:15:19 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2008-10-18 23:15:19 +0200 |
commit | d9e6f2408d2d6d0a1a827a54d719bd5d6fb35743 (patch) | |
tree | 9cd0d018867c18ea3cec2029aa4d5a78ef530607 /Bugzilla | |
parent | a261aae25d79d1eb642bf2f9e786dcc793a4f105 (diff) | |
download | bugzilla-d9e6f2408d2d6d0a1a827a54d719bd5d6fb35743.tar.gz bugzilla-d9e6f2408d2d6d0a1a827a54d719bd5d6fb35743.tar.xz |
Bug 460581: editgroups should be using Bugzilla::Group->create to make groups
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Group.pm | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm index d9f49c074..455276c99 100644 --- a/Bugzilla/Group.pm +++ b/Bugzilla/Group.pm @@ -198,7 +198,30 @@ sub is_active_bug_group { sub _rederive_regexp { my ($self) = @_; - RederiveRegexp($self->user_regexp, $self->id); + + my $dbh = Bugzilla->dbh; + my $sth = $dbh->prepare("SELECT userid, login_name, group_id + FROM profiles + LEFT JOIN user_group_map + ON user_group_map.user_id = profiles.userid + AND group_id = ? + AND grant_type = ? + AND isbless = 0"); + my $sthadd = $dbh->prepare("INSERT INTO user_group_map + (user_id, group_id, grant_type, isbless) + VALUES (?, ?, ?, 0)"); + my $sthdel = $dbh->prepare("DELETE FROM user_group_map + WHERE user_id = ? AND group_id = ? + AND grant_type = ? and isbless = 0"); + $sth->execute($self->id, GRANT_REGEXP); + my $regexp = $self->user_regexp; + while (my ($uid, $login, $present) = $sth->fetchrow_array) { + if ($regexp ne '' and $login =~ /$regexp/i) { + $sthadd->execute($uid, $self->id, GRANT_REGEXP) unless $present; + } else { + $sthdel->execute($uid, $self->id, GRANT_REGEXP) if $present; + } + } } sub members_non_inherited { @@ -266,35 +289,6 @@ sub ValidateGroupName { return $ret; } -# This sub is not perldoc'ed because we expect it to go away and -# just become the _rederive_regexp private method. -sub RederiveRegexp { - my ($regexp, $gid) = @_; - my $dbh = Bugzilla->dbh; - my $sth = $dbh->prepare("SELECT userid, login_name, group_id - FROM profiles - LEFT JOIN user_group_map - ON user_group_map.user_id = profiles.userid - AND group_id = ? - AND grant_type = ? - AND isbless = 0"); - my $sthadd = $dbh->prepare("INSERT INTO user_group_map - (user_id, group_id, grant_type, isbless) - VALUES (?, ?, ?, 0)"); - my $sthdel = $dbh->prepare("DELETE FROM user_group_map - WHERE user_id = ? AND group_id = ? - AND grant_type = ? and isbless = 0"); - $sth->execute($gid, GRANT_REGEXP); - while (my ($uid, $login, $present) = $sth->fetchrow_array()) { - if (($regexp =~ /\S+/) && ($login =~ m/$regexp/i)) - { - $sthadd->execute($uid, $gid, GRANT_REGEXP) unless $present; - } else { - $sthdel->execute($uid, $gid, GRANT_REGEXP) if $present; - } - } -} - ############################### ### Validators ### ############################### |