diff options
author | lpsolit%gmail.com <> | 2007-08-08 20:58:19 +0200 |
---|---|---|
committer | lpsolit%gmail.com <> | 2007-08-08 20:58:19 +0200 |
commit | 152f61366bd9b268cd838307c1e58399003ef2c7 (patch) | |
tree | 92fb18a7f824cb450db3df0fdea8407cc05d7f29 /Bugzilla | |
parent | 8d9074a59f0bfa4b79256e5524a447397e3490de (diff) | |
download | bugzilla-152f61366bd9b268cd838307c1e58399003ef2c7.tar.gz bugzilla-152f61366bd9b268cd838307c1e58399003ef2c7.tar.xz |
Bug 332149: Ability to have symbols placed next to user names based on group membership - Patch by Frédéric Buclin <LpSolit@gmail.com> r=myk a=LpSolit
Diffstat (limited to 'Bugzilla')
-rwxr-xr-x | Bugzilla/Bug.pm | 6 | ||||
-rw-r--r-- | Bugzilla/BugMail.pm | 7 | ||||
-rw-r--r-- | Bugzilla/DB/Schema.pm | 1 | ||||
-rw-r--r-- | Bugzilla/Group.pm | 8 | ||||
-rw-r--r-- | Bugzilla/Install/DB.pm | 3 | ||||
-rw-r--r-- | Bugzilla/User.pm | 23 |
6 files changed, 41 insertions, 7 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 5f37e9ff4..0a2770a65 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -2251,8 +2251,7 @@ sub GetComments { my @comments; my @args = ($id); - my $query = 'SELECT longdescs.comment_id AS id, profiles.realname AS name, - profiles.login_name AS email, ' . + my $query = 'SELECT longdescs.comment_id AS id, profiles.userid, ' . $dbh->sql_date_format('longdescs.bug_when', '%Y.%m.%d %H:%i:%s') . ' AS time, longdescs.thetext AS body, longdescs.work_time, isprivate, already_wrapped, type, extra_data @@ -2271,8 +2270,7 @@ sub GetComments { while (my $comment_ref = $sth->fetchrow_hashref()) { my %comment = %$comment_ref; - - $comment{'email'} .= Bugzilla->params->{'emailsuffix'}; + $comment{'author'} = new Bugzilla::User($comment{'userid'}); # If raw data is requested, do not format 'special' comments. $comment{'body'} = format_comment(\%comment) unless $raw; diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index acc12556d..0d5d3fd78 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -703,11 +703,12 @@ sub prepare_comments { my $result = ""; foreach my $comment (@$raw_comments) { if ($count) { + my $author = $comment->{'author'}; $result .= "\n\n--- Comment #$count from "; - if ($comment->{'name'}) { - $result .= $comment->{'name'} . " <" . $comment->{'email'} . ">"; + if ($author->name) { + $result .= $author->name . " <" . $author->email . ">"; } else { - $result .= $comment->{'email'}; + $result .= $author->email; } $result .= " " . format_time($comment->{'time'}) . " ---\n"; } diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index 35e786c51..f8c1588e4 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -873,6 +873,7 @@ use constant ABSTRACT_SCHEMA => { DEFAULT => "''"}, isactive => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'}, + icon_url => {TYPE => 'TINYTEXT'}, ], INDEXES => [ groups_name_idx => {FIELDS => ['name'], TYPE => 'UNIQUE'}, diff --git a/Bugzilla/Group.pm b/Bugzilla/Group.pm index 9e5a601c7..6bdacbe6d 100644 --- a/Bugzilla/Group.pm +++ b/Bugzilla/Group.pm @@ -43,6 +43,7 @@ use constant DB_COLUMNS => qw( groups.isbuggroup groups.userregexp groups.isactive + groups.icon_url ); use constant DB_TABLE => 'groups'; @@ -55,6 +56,7 @@ use constant VALIDATORS => { userregexp => \&_check_user_regexp, isactive => \&_check_is_active, isbuggroup => \&_check_is_bug_group, + icon_url => \&_check_icon_url, }; use constant REQUIRED_CREATE_FIELDS => qw(name description isbuggroup); @@ -64,6 +66,7 @@ use constant UPDATE_COLUMNS => qw( description userregexp isactive + icon_url ); # Parameters that are lists of groups. @@ -78,6 +81,7 @@ sub description { return $_[0]->{'description'}; } sub is_bug_group { return $_[0]->{'isbuggroup'}; } sub user_regexp { return $_[0]->{'userregexp'}; } sub is_active { return $_[0]->{'isactive'}; } +sub icon_url { return $_[0]->{'icon_url'}; } sub members_direct { my ($self) = @_; @@ -134,6 +138,7 @@ sub set_description { $_[0]->set('description', $_[1]); } sub set_is_active { $_[0]->set('isactive', $_[1]); } sub set_name { $_[0]->set('name', $_[1]); } sub set_user_regexp { $_[0]->set('userregexp', $_[1]); } +sub set_icon_url { $_[0]->set('icon_url', $_[1]); } sub update { my $self = shift; @@ -324,6 +329,8 @@ sub _check_is_bug_group { return $_[1] ? 1 : 0; } +sub _check_icon_url { return $_[1] ? clean_text($_[1]) : undef; } + 1; __END__ @@ -344,6 +351,7 @@ Bugzilla::Group - Bugzilla group class. my $description = $group->description; my $user_reg_exp = $group->user_reg_exp; my $is_active = $group->is_active; + my $icon_url = $group->icon_url; my $is_active_bug_group = $group->is_active_bug_group; my $group_id = Bugzilla::Group::ValidateGroupName('admin', @users); diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 99b405736..5106fd525 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -510,6 +510,9 @@ sub update_table_definitions { # 2007-05-17 LpSolit@gmail.com - Bug 344965 _initialize_workflow($old_params); + # 2007-07-11 LpSolit@gmail.com - Bug 332149 + $dbh->bz_add_column('groups', 'icon_url', {TYPE => 'TINYTEXT'}); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index f73dd06df..cf8de0274 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -800,6 +800,24 @@ sub can_set_flag { || $self->in_group_id($flag_type->grant_group->id)) ? 1 : 0; } +sub direct_group_membership { + my $self = shift; + my $dbh = Bugzilla->dbh; + + if (!$self->{'direct_group_membership'}) { + my $gid = $dbh->selectcol_arrayref('SELECT id + FROM groups + INNER JOIN user_group_map + ON groups.id = user_group_map.group_id + WHERE user_id = ? + AND isbless = 0', + undef, $self->id); + $self->{'direct_group_membership'} = Bugzilla::Group->new_from_list($gid); + } + return $self->{'direct_group_membership'}; +} + + # visible_groups_inherited returns a reference to a list of all the groups # whose members are visible to this user. sub visible_groups_inherited { @@ -2026,6 +2044,11 @@ is in any of the groups input to flatten_group_membership by querying the user_group_map for any user with DIRECT or REGEXP membership IN() the list of groups returned. +=item C<direct_group_membership> + +Returns a reference to an array of group objects. Groups the user belong to +by group inheritance are excluded from the list. + =item C<visible_groups_inherited> Returns a list of all groups whose members should be visible to this user. |