]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 332149: Ability to have symbols placed next to user names based on group membersh...
authorlpsolit%gmail.com <>
Wed, 8 Aug 2007 18:58:19 +0000 (18:58 +0000)
committerlpsolit%gmail.com <>
Wed, 8 Aug 2007 18:58:19 +0000 (18:58 +0000)
Bugzilla/Bug.pm
Bugzilla/BugMail.pm
Bugzilla/DB/Schema.pm
Bugzilla/Group.pm
Bugzilla/Install/DB.pm
Bugzilla/User.pm
editgroups.cgi

index 5f37e9ff4bb37c718dc574ad6fcd89c370361049..0a2770a65cf5998c2695ab1915d58feb7a50b0e2 100755 (executable)
@@ -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;
index acc12556d1825fd78fd6b776c069ecb1788cf89d..0d5d3fd78725d62a2f77451c0abf93e42bbde8af 100644 (file)
@@ -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";
         }
index 35e786c51b4459a00d843f0a210cb5a1f964ba0e..f8c1588e46be07d481165ff6d5445f081709a8c1 100644 (file)
@@ -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'},
index 9e5a601c7c5c990e931ac5e3fd5df4d6bb049e73..6bdacbe6dd104ff9c103aad5514512d71882d978 100644 (file)
@@ -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);
index 99b405736bbb53ee130f36a8b7ea25b899f5b3d9..5106fd525df7c6d4854e0c6319c39c9e5e5cc8bf 100644 (file)
@@ -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 #
     ################################################################
index f73dd06dfbfb07908f4bb479345c3564eb8bd3b6..cf8de0274ce0588815ec231f6563a2d46c10951c 100644 (file)
@@ -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.
index 5e2a3baf66df7b4ce2f848b1f738a4b195939168..b9503426b58385bf86876a31e43bb7944c14fb78 100755 (executable)
@@ -244,12 +244,18 @@ if ($action eq 'new') {
     my $desc = CheckGroupDesc($cgi->param('desc'));
     my $regexp = CheckGroupRegexp($cgi->param('regexp'));
     my $isactive = $cgi->param('isactive') ? 1 : 0;
+    # This is an admin page. The URL is considered safe.
+    my $icon_url;
+    if ($cgi->param('icon_url')) {
+        $icon_url = clean_text($cgi->param('icon_url'));
+        trick_taint($icon_url);
+    }
 
     # Add the new group
     $dbh->do('INSERT INTO groups
-              (name, description, isbuggroup, userregexp, isactive)
-              VALUES (?, ?, 1, ?, ?)',
-              undef, ($name, $desc, $regexp, $isactive));
+              (name, description, isbuggroup, userregexp, isactive, icon_url)
+              VALUES (?, ?, 1, ?, ?, ?)',
+              undef, ($name, $desc, $regexp, $isactive, $icon_url));
 
     my $gid = $dbh->bz_last_key('groups', 'id');
     my $admin = Bugzilla::Group->new({name => 'admin'})->id();
@@ -565,6 +571,10 @@ sub doGroupChanges {
         }
     }
 
+    if (defined $cgi->param('icon_url')) {
+        $group->set_icon_url($cgi->param('icon_url'));
+    }
+
     my $changes = $group->update();
 
     my $sth_insert = $dbh->prepare('INSERT INTO group_group_map