diff options
author | Christian Ruppert <idl0r@gentoo.org> | 2013-10-17 21:12:48 +0200 |
---|---|---|
committer | Christian Ruppert <idl0r@gentoo.org> | 2013-10-17 21:12:48 +0200 |
commit | bf0dc7286033e6cbed8008acb1d7d2a2b37b587f (patch) | |
tree | 62db039d64d003817f69ea91aa827b3160fd77d1 | |
parent | Move m68k, s390, sh to unstable (diff) | |
download | bugzilla-bf0dc7286033e6cbed8008acb1d7d2a2b37b587f.tar.gz bugzilla-bf0dc7286033e6cbed8008acb1d7d2a2b37b587f.tar.bz2 bugzilla-bf0dc7286033e6cbed8008acb1d7d2a2b37b587f.zip |
Update SecureMail and InlineHistory
-rw-r--r-- | extensions/InlineHistory/Extension.pm | 17 | ||||
-rw-r--r-- | extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl | 11 | ||||
-rw-r--r-- | extensions/InlineHistory/web/inline-history.js | 12 | ||||
-rw-r--r-- | extensions/SecureMail/Extension.pm | 34 |
4 files changed, 52 insertions, 22 deletions
diff --git a/extensions/InlineHistory/Extension.pm b/extensions/InlineHistory/Extension.pm index a914d94b5..df7ae9f62 100644 --- a/extensions/InlineHistory/Extension.pm +++ b/extensions/InlineHistory/Extension.pm @@ -18,6 +18,19 @@ our $VERSION = '1.5'; # don't show inline history for bugs with lots of changes use constant MAXIMUM_ACTIVITY_COUNT => 500; +# don't show really long values +use constant MAXIMUM_VALUE_LENGTH => 256; + +sub template_before_create { + my ($self, $args) = @_; + $args->{config}->{FILTERS}->{ih_short_value} = sub { + my ($str) = @_; + return length($str) <= MAXIMUM_VALUE_LENGTH + ? $str + : substr($str, 0, MAXIMUM_VALUE_LENGTH - 3) . '...'; + }; +} + sub template_before_process { my ($self, $args) = @_; my $file = $args->{'file'}; @@ -34,9 +47,7 @@ sub template_before_process { my $bug_id = $bug->id; # build bug activity - my ($activity) = $bug->can('get_activity') - ? $bug->get_activity() - : Bugzilla::Bug::GetBugActivity($bug_id); + my ($activity) = Bugzilla::Bug::GetBugActivity($bug_id); $activity = _add_duplicates($bug_id, $activity); if (scalar @$activity > MAXIMUM_ACTIVITY_COUNT) { diff --git a/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl b/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl index 9abaa760d..079af95f0 100644 --- a/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl +++ b/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl @@ -102,12 +102,17 @@ [% END %] [% END %] + var user_image = ' + [%~ who = operation.who %] + [% Hook.process('user-image', 'bug/comments.html.tmpl') FILTER js %]'; + var item = new Array(7); item[0] = '[% changer_login FILTER js %]'; item[1] = '[% change_date FILTER js %]'; item[2] = html; item[3] = '<div class="bz_comment_head">' + '<span class="bz_comment_user">' + + user_image + '[% user_cache.$changer_id FILTER js %]' + '</span>' + '<span class="bz_comment_time"> ' + item[1] + ' </span>' @@ -132,13 +137,13 @@ [%~%]<a href="[% value FILTER html FILTER js %]" target="_blank" [%~ ' onclick="return inline_history.confirmUnsafeUrl(this.href)"' UNLESS is_safe_url(value) %]> - [%~%][% value FILTER html FILTER js %]</a> + [%~%][% value FILTER ih_short_value FILTER html FILTER js %]</a> [% ELSIF change.fieldname == 'see_also' %] [% FOREACH see_also = value.split(', ') %] [%~%]<a href="[% see_also FILTER html FILTER js %]" target="_blank"> [%~%][% see_also FILTER html FILTER js %]</a> [%- ", " IF NOT loop.last %] - [% END -%] + [% END %] [% ELSIF change.fieldname == 'assigned_to' || change.fieldname == 'reporter' || change.fieldname == 'qa_contact' || @@ -146,7 +151,7 @@ change.fieldname == 'flagtypes.name' %] [% value FILTER email FILTER js %] [% ELSE %] - [% value FILTER html FILTER js %] + [% value FILTER ih_short_value FILTER html FILTER js %] [% END %] [%~ %]'; [% END %] diff --git a/extensions/InlineHistory/web/inline-history.js b/extensions/InlineHistory/web/inline-history.js index 0d38edf7f..95a664a42 100644 --- a/extensions/InlineHistory/web/inline-history.js +++ b/extensions/InlineHistory/web/inline-history.js @@ -126,15 +126,15 @@ var inline_history = { } } - var itemHtml = '<div class="ih_history_item ' + containerClass + '" ' - + 'id="h' + i + '">' - + item[3] + item[2] - + '</div>'; + var itemContainer = document.createElement('div'); + itemContainer.className = 'ih_history_item ' + containerClass; + itemContainer.id = 'h' + i; + itemContainer.innerHTML = item[3] + '<div class="ih_history_change">' + item[2] + '</div>'; if (ih_activity_sort_order == 'oldest_to_newest') { - currentDiv.innerHTML = currentDiv.innerHTML + itemHtml; + currentDiv.appendChild(itemContainer); } else { - currentDiv.innerHTML = itemHtml + currentDiv.innerHTML; + currentDiv.insertBefore(itemContainer, currentDiv.firstChild); } currentDiv.setAttribute("class", "bz_comment ih_history"); if (item[6]) diff --git a/extensions/SecureMail/Extension.pm b/extensions/SecureMail/Extension.pm index 1ea691320..8fd09510d 100644 --- a/extensions/SecureMail/Extension.pm +++ b/extensions/SecureMail/Extension.pm @@ -65,10 +65,24 @@ sub install_update_db { ############################################################################## BEGIN { - *Bugzilla::Group::secure_mail = \&_secure_mail; + *Bugzilla::Group::secure_mail = \&_group_secure_mail; + *Bugzilla::User::public_key = \&_user_public_key; } -sub _secure_mail { return $_[0]->{'secure_mail'}; } +sub _group_secure_mail { return $_[0]->{'secure_mail'}; } + +# We want to lazy-load the public_key. +sub _user_public_key { + my $self = shift; + if (!exists $self->{public_key}) { + ($self->{public_key}) = Bugzilla->dbh->selectrow_array( + "SELECT public_key FROM profiles WHERE userid = ?", + undef, + $self->id + ); + } + return $self->{public_key}; +} # Make sure generic functions know about the additional fields in the user # and group objects. @@ -80,9 +94,6 @@ sub object_columns { if ($class->isa('Bugzilla::Group')) { push(@$columns, 'secure_mail'); } - elsif ($class->isa('Bugzilla::User')) { - push(@$columns, 'public_key'); - } } # Plug appropriate validators so we can check the validity of the two @@ -182,13 +193,13 @@ sub user_preferences { $user->update(); # Send user a test email - if ($user->{'public_key'}) { + if ($user->public_key) { _send_test_email($user); $vars->{'test_email_sent'} = 1; } } - $vars->{'public_key'} = $user->{'public_key'}; + $vars->{'public_key'} = $user->public_key; # Set the 'handled' scalar reference to true so that the caller # knows the panel name is valid and that an extension took care of it. @@ -273,7 +284,10 @@ sub mailer_before_send { } # If the insider group has securemail enabled.. my $insider_group = Bugzilla::Group->new({ name => Bugzilla->params->{'insidergroup'} }); - if ($insider_group->secure_mail && $make_secure == SECURE_NONE) { + if ($insider_group + && $insider_group->secure_mail + && $make_secure == SECURE_NONE) + { my $comment_is_private = Bugzilla->dbh->selectcol_arrayref( "SELECT isprivate FROM longdescs WHERE bug_id=? ORDER BY bug_when", undef, $bug_id); @@ -303,7 +317,7 @@ sub mailer_before_send { # (but, as noted above, the check is the other way around because # we default to secure). if ($user && - !$user->{'public_key'} && + !$user->public_key && !grep($_->secure_mail, @{ $user->groups })) { $make_secure = SECURE_NONE; @@ -319,7 +333,7 @@ sub mailer_before_send { # If finding the user fails for some reason, but we determine we # should be encrypting, we want to make the mail safe. An empty key # does that. - my $public_key = $user ? $user->{'public_key'} : ''; + my $public_key = $user ? $user->public_key : ''; # Check if the new bugmail prefix should be added to the subject. my $add_new = ($email->header('X-Bugzilla-Type') eq 'new' && |