summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/InlineHistory/Config.pm28
-rw-r--r--extensions/InlineHistory/Extension.pm93
-rw-r--r--extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl62
-rw-r--r--extensions/InlineHistory/template/en/default/hook/bug/comments-comment_banner.html.tmpl28
-rw-r--r--extensions/InlineHistory/template/en/default/hook/bug/show-header-end.html.tmpl33
-rw-r--r--extensions/InlineHistory/template/en/default/hook/global/setting-descs-settings.none.tmpl30
-rw-r--r--extensions/InlineHistory/web/inline-history.js30
-rw-r--r--extensions/InlineHistory/web/style.css29
-rw-r--r--extensions/Splinter/Extension.pm3
9 files changed, 102 insertions, 234 deletions
diff --git a/extensions/InlineHistory/Config.pm b/extensions/InlineHistory/Config.pm
index dd4002856..3834bd81d 100644
--- a/extensions/InlineHistory/Config.pm
+++ b/extensions/InlineHistory/Config.pm
@@ -1,27 +1,9 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with the
-# License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
-# the specific language governing rights and limitations under the License.
-#
-# The Original Code is the InlineHistory Bugzilla Extension;
-# Derived from the Bugzilla Tweaks Addon.
-#
-# The Initial Developer of the Original Code is the Mozilla Foundation.
-# Portions created by the Initial Developer are Copyright (C) 2011 the Initial
-# Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Johnathan Nightingale <johnath@mozilla.com>
-# Ehsan Akhgari <ehsan@mozilla.com>
-# Byron Jones <glob@mozilla.com>
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-# ***** END LICENSE BLOCK *****
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
package Bugzilla::Extension::InlineHistory;
use strict;
diff --git a/extensions/InlineHistory/Extension.pm b/extensions/InlineHistory/Extension.pm
index da1e3f274..61a263f61 100644
--- a/extensions/InlineHistory/Extension.pm
+++ b/extensions/InlineHistory/Extension.pm
@@ -1,27 +1,9 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with the
-# License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
-# the specific language governing rights and limitations under the License.
-#
-# The Original Code is the InlineHistory Bugzilla Extension;
-# Derived from the Bugzilla Tweaks Addon.
-#
-# The Initial Developer of the Original Code is the Mozilla Foundation.
-# Portions created by the Initial Developer are Copyright (C) 2011 the Initial
-# Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Johnathan Nightingale <johnath@mozilla.com>
-# Ehsan Akhgari <ehsan@mozilla.com>
-# Byron Jones <glob@mozilla.com>
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-# ***** END LICENSE BLOCK *****
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
package Bugzilla::Extension::InlineHistory;
use strict;
@@ -31,7 +13,7 @@ use Bugzilla::User::Setting;
use Bugzilla::Constants;
use Bugzilla::Attachment;
-our $VERSION = '1.4';
+our $VERSION = '1.5';
# don't show inline history for bugs with lots of changes
use constant MAXIMUM_ACTIVITY_COUNT => 500;
@@ -40,25 +22,16 @@ sub template_before_process {
my ($self, $args) = @_;
my $file = $args->{'file'};
my $vars = $args->{'vars'};
- my $user = Bugzilla->user;
- my $dbh = Bugzilla->dbh;
- return unless $user && $user->id && $user->settings;
- return unless $user->settings->{'inline_history'}->{'value'} eq 'on';
+ return if $file ne 'bug/edit.html.tmpl';
- # in the header we just need to set the var, to ensure the css and
- # javascript get included
- if ($file eq 'bug/show-header.html.tmpl') {
- $vars->{'ih_activity'} = 1;
- return;
- } elsif ($file ne 'bug/edit.html.tmpl') {
- return;
- }
+ my $user = Bugzilla->user;
+ my $dbh = Bugzilla->dbh;
+ return unless $user->id && $user->settings->{'inline_history'}->{'value'} eq 'on';
# note: bug/edit.html.tmpl doesn't support multiple bugs
- my $bug_id = exists $vars->{'bugs'}
- ? $vars->{'bugs'}[0]->id
- : $vars->{'bug'}->id;
+ my $bug = exists $vars->{'bugs'} ? $vars->{'bugs'}[0] : $vars->{'bug'};
+ my $bug_id = $bug->id;
# build bug activity
my ($activity) = Bugzilla::Bug::GetBugActivity($bug_id);
@@ -71,24 +44,32 @@ sub template_before_process {
return;
}
- Bugzilla->request_cache->{ih_user_cache} ||= {};
- my $user_cache = Bugzilla->request_cache->{ih_user_cache};
+ # prime caches with objects already loaded
+ my %user_cache;
+ foreach my $comment (@{$bug->comments}) {
+ $user_cache{$comment->{author}->login} = $comment->{author};
+ }
+
+ my %attachment_cache;
+ foreach my $attachment (@{$bug->attachments}) {
+ $attachment_cache{$attachment->id} = $attachment;
+ }
+
+ # build a list of bugs we need to check visibility of, so we can check with a single query
+ my %visible_bug_ids;
# augment and tweak
foreach my $operation (@$activity) {
# make operation.who an object
- if (!$user_cache->{$operation->{who}}) {
- $user_cache->{$operation->{who}}
- = Bugzilla::User->new({ name => $operation->{who} });
- }
- $operation->{who} = $user_cache->{$operation->{who}};
+ $user_cache{$operation->{who}} ||= Bugzilla::User->new({ name => $operation->{who} });
+ $operation->{who} = $user_cache{$operation->{who}};
for (my $i = 0; $i < scalar(@{$operation->{changes}}); $i++) {
my $change = $operation->{changes}->[$i];
# make an attachment object
if ($change->{attachid}) {
- $change->{attach} = Bugzilla::Attachment->new($change->{attachid});
+ $change->{attach} = $attachment_cache{$change->{attachid}};
}
# empty resolutions are displayed as --- by default
@@ -110,10 +91,20 @@ sub template_before_process {
}
# identify buglist changes
- $change->{buglist} =
- $change->{fieldname} eq 'blocked' ||
+ if ($change->{fieldname} eq 'blocked' ||
$change->{fieldname} eq 'dependson' ||
- $change->{fieldname} eq 'dupe';
+ $change->{fieldname} eq 'dupe'
+ ) {
+ $change->{buglist} = 1;
+ foreach my $what (qw(removed added)) {
+ my @buglist = split(/[\s,]+/, $change->{$what});
+ foreach my $id (@buglist) {
+ if ($id && $id =~ /^\d+$/) {
+ $visible_bug_ids{$id} = 1;
+ }
+ }
+ }
+ }
# split multiple flag changes (must be processed last)
if ($change->{fieldname} eq 'flagtypes.name') {
@@ -149,6 +140,8 @@ sub template_before_process {
}
}
+ $user->visible_bugs([keys %visible_bug_ids]);
+
$vars->{'ih_activity'} = $activity;
}
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 c8111bf75..5ecf2f0d8 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
@@ -1,32 +1,12 @@
-[%# ***** BEGIN LICENSE BLOCK *****
- # Version: MPL 1.1
- #
- # The contents of this file are subject to the Mozilla Public License Version
- # 1.1 (the "License"); you may not use this file except in compliance with
- # the License. You may obtain a copy of the License at
- # http://www.mozilla.org/MPL/
- #
- # Software distributed under the License is distributed on an "AS IS" basis,
- # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- # for the specific language governing rights and limitations under the
- # License.
- #
- # The Original Code is the InlineHistory Bugzilla Extension;
- # Derived from the Bugzilla Tweaks Addon.
- #
- # The Initial Developer of the Original Code is the Mozilla Foundation.
- # Portions created by the Initial Developer are Copyright (C) 2011 the
- # Initial Developer. All Rights Reserved.
- #
- # Contributor(s):
- # Johnathan Nightingale <johnath@mozilla.com>
- # Ehsan Akhgari <ehsan@mozilla.com>
- # Byron Jones <glob@mozilla.com>
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
- # ***** END LICENSE BLOCK *****
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
#%]
-[% IF ih_activity %]
+[% RETURN UNLESS ih_activity %]
[%# this div exists to allow bugzilla-tweaks to detect when we're active %]
<div id="inline-history-ext"></div>
@@ -38,15 +18,20 @@
var html = '';
[% has_cc = 0 %]
[% has_flag = 0 %]
+ [% changer_identity = "" %]
+ [% changer_login = operation.who.login %]
+ [% change_date = operation.when FILTER time %]
+
[% FOREACH change = operation.changes %]
[%# track flag changes %]
[% IF change.fieldname == 'flagtypes.name' && change.added != '' %]
+ [% changer_identity = operation.who.identity UNLESS changer_identity %]
var item = new Array(5);
- item[0] = '[% operation.who.login FILTER js %]';
- item[1] = '[% operation.when FILTER time FILTER js %]';
+ item[0] = '[% changer_login FILTER js %]';
+ item[1] = '[% change_date FILTER js %]';
item[2] = '[% change.attachid FILTER js %]';
item[3] = '[% change.added FILTER js %]';
- item[4] = '[% operation.who.identity FILTER js %]';
+ item[4] = '[% changer_identity FILTER js %]';
ih_activity_flags.push(item);
[% has_flag = 1 %]
[% END %]
@@ -109,13 +94,21 @@
html += '</span>';
[% END %]
[% END %]
+
+ [% changer_id = operation.who.id %]
+ [% UNLESS user_cache.$changer_id %]
+ [% user_cache.$changer_id = BLOCK %]
+ [% INCLUDE global/user.html.tmpl who = comment.author %]
+ [% END %]
+ [% END %]
+
var item = new Array(7);
- item[0] = '[% operation.who.login FILTER js %]';
- item[1] = '[% operation.when FILTER time FILTER js %]';
+ 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">'
- + '[% INCLUDE global/user.html.tmpl who = operation.who FILTER js %]'
+ + '[% user_cache.$changer_id FILTER js %]'
+ '</span>'
+ '<span class="bz_comment_time"> ' + item[1] + ' </span>'
+ '</div>';
@@ -126,7 +119,6 @@
[% END %]
inline_history.init();
</script>
-[% END %]
[% BLOCK add_change %]
html += '[%~%]
@@ -149,9 +141,9 @@
change.fieldname == 'qa_contact' ||
change.fieldname == 'cc' ||
change.fieldname == 'flagtypes.name' %]
- [% display_value(change.fieldname, value) FILTER email FILTER js %]
+ [% value FILTER email FILTER js %]
[% ELSE %]
- [% display_value(change.fieldname, value) FILTER html FILTER js %]
+ [% value FILTER html FILTER js %]
[% END %]
[%~ %]';
[% END %]
diff --git a/extensions/InlineHistory/template/en/default/hook/bug/comments-comment_banner.html.tmpl b/extensions/InlineHistory/template/en/default/hook/bug/comments-comment_banner.html.tmpl
index 73f428508..133005f4f 100644
--- a/extensions/InlineHistory/template/en/default/hook/bug/comments-comment_banner.html.tmpl
+++ b/extensions/InlineHistory/template/en/default/hook/bug/comments-comment_banner.html.tmpl
@@ -1,27 +1,9 @@
-[%# ***** BEGIN LICENSE BLOCK *****
- # Version: MPL 1.1
- #
- # The contents of this file are subject to the Mozilla Public License Version
- # 1.1 (the "License"); you may not use this file except in compliance with
- # the License. You may obtain a copy of the License at
- # http://www.mozilla.org/MPL/
- #
- # Software distributed under the License is distributed on an "AS IS" basis,
- # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- # for the specific language governing rights and limitations under the
- # License.
- #
- # The Original Code is the InlineHistory Bugzilla Extension;
- # Derived from the Bugzilla Tweaks Addon.
- #
- # The Initial Developer of the Original Code is the Mozilla Foundation.
- # Portions created by the Initial Developer are Copyright (C) 2011 the
- # Initial Developer. All Rights Reserved.
- #
- # Contributor(s):
- # Byron Jones <glob@mozilla.com>
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
- # ***** END LICENSE BLOCK *****
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
#%]
[% IF ih_activity_max %]
diff --git a/extensions/InlineHistory/template/en/default/hook/bug/show-header-end.html.tmpl b/extensions/InlineHistory/template/en/default/hook/bug/show-header-end.html.tmpl
index 221175105..7e54b8380 100644
--- a/extensions/InlineHistory/template/en/default/hook/bug/show-header-end.html.tmpl
+++ b/extensions/InlineHistory/template/en/default/hook/bug/show-header-end.html.tmpl
@@ -1,33 +1,12 @@
-[%# ***** BEGIN LICENSE BLOCK *****
- # Version: MPL 1.1
- #
- # The contents of this file are subject to the Mozilla Public License Version
- # 1.1 (the "License"); you may not use this file except in compliance with
- # the License. You may obtain a copy of the License at
- # http://www.mozilla.org/MPL/
- #
- # Software distributed under the License is distributed on an "AS IS" basis,
- # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- # for the specific language governing rights and limitations under the
- # License.
- #
- # The Original Code is the InlineHistory Bugzilla Extension;
- # Derived from the Bugzilla Tweaks Addon.
- #
- # The Initial Developer of the Original Code is the Mozilla Foundation.
- # Portions created by the Initial Developer are Copyright (C) 2011 the
- # Initial Developer. All Rights Reserved.
- #
- # Contributor(s):
- # Johnathan Nightingale <johnath@mozilla.com>
- # Ehsan Akhgari <ehsan@mozilla.com>
- # Byron Jones <glob@mozilla.com>
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
- # ***** END LICENSE BLOCK *****
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
#%]
-[% IF ih_activity %]
+[% IF user.id && user.settings.inline_history.value == "on" %]
[% style_urls.push('extensions/InlineHistory/web/style.css') %]
[% javascript_urls.push('extensions/InlineHistory/web/inline-history.js') %]
[% END %]
-
diff --git a/extensions/InlineHistory/template/en/default/hook/global/setting-descs-settings.none.tmpl b/extensions/InlineHistory/template/en/default/hook/global/setting-descs-settings.none.tmpl
index 852dac22f..e1ff4c0f6 100644
--- a/extensions/InlineHistory/template/en/default/hook/global/setting-descs-settings.none.tmpl
+++ b/extensions/InlineHistory/template/en/default/hook/global/setting-descs-settings.none.tmpl
@@ -1,29 +1,9 @@
-[%# ***** BEGIN LICENSE BLOCK *****
- # Version: MPL 1.1
- #
- # The contents of this file are subject to the Mozilla Public License Version
- # 1.1 (the "License"); you may not use this file except in compliance with
- # the License. You may obtain a copy of the License at
- # http://www.mozilla.org/MPL/
- #
- # Software distributed under the License is distributed on an "AS IS" basis,
- # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- # for the specific language governing rights and limitations under the
- # License.
- #
- # The Original Code is the InlineHistory Bugzilla Extension;
- # Derived from the Bugzilla Tweaks Addon.
- #
- # The Initial Developer of the Original Code is the Mozilla Foundation.
- # Portions created by the Initial Developer are Copyright (C) 2011 the
- # Initial Developer. All Rights Reserved.
- #
- # Contributor(s):
- # Johnathan Nightingale <johnath@mozilla.com>
- # Ehsan Akhgari <ehsan@mozilla.com>
- # Byron Jones <glob@mozilla.com>
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
- # ***** END LICENSE BLOCK *****
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
#%]
[%
diff --git a/extensions/InlineHistory/web/inline-history.js b/extensions/InlineHistory/web/inline-history.js
index 94a1bc124..c4930e15b 100644
--- a/extensions/InlineHistory/web/inline-history.js
+++ b/extensions/InlineHistory/web/inline-history.js
@@ -1,29 +1,9 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- *
- * The Original Code is the InlineHistory Bugzilla Extension;
- * Derived from the Bugzilla Tweaks Addon.
- * Derived from the Bugzilla Tweaks Addon.
- *
- * The Initial Developer of the Original Code is the Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2011 the Initial
- * Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Johnathan Nightingale <johnath@mozilla.com>
- * Ehsan Akhgari <ehsan@mozilla.com>
- * Byron Jones <glob@mozilla.com>
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
*
- * ***** END LICENSE BLOCK *****
- */
+ * This Source Code Form is "Incompatible With Secondary Licenses", as
+ * defined by the Mozilla Public License, v. 2.0. */
var inline_history = {
_ccDivs: null,
diff --git a/extensions/InlineHistory/web/style.css b/extensions/InlineHistory/web/style.css
index bca3a197b..af76eba82 100644
--- a/extensions/InlineHistory/web/style.css
+++ b/extensions/InlineHistory/web/style.css
@@ -1,28 +1,9 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- *
- * The Original Code is the InlineHistory Bugzilla Extension;
- * Derived from the Bugzilla Tweaks Addon.
- *
- * The Initial Developer of the Original Code is the Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2011 the Initial
- * Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Johnathan Nightingale <johnath@mozilla.com>
- * Ehsan Akhgari <ehsan@mozilla.com>
- * Byron Jones <glob@mozilla.com>
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
*
- * ***** END LICENSE BLOCK *****
- */
+ * This Source Code Form is "Incompatible With Secondary Licenses", as
+ * defined by the Mozilla Public License, v. 2.0. */
.ih_history {
background: none !important;
diff --git a/extensions/Splinter/Extension.pm b/extensions/Splinter/Extension.pm
index 75c0dbb0c..9c8be4beb 100644
--- a/extensions/Splinter/Extension.pm
+++ b/extensions/Splinter/Extension.pm
@@ -20,9 +20,7 @@ our $VERSION = '0.1';
sub page_before_template {
my ($self, $args) = @_;
-
my ($vars, $page) = @$args{qw(vars page_id)};
- my $input = Bugzilla->input_params;
if ($page eq 'splinter.html') {
# Login is required for performing a review
@@ -34,6 +32,7 @@ sub page_before_template {
# If both are give they will be checked later to make
# sure they are connected.
+ my $input = Bugzilla->input_params;
if ($input->{'bug'}) {
$vars->{'bug_id'} = $input->{'bug'};
$vars->{'attach_id'} = $input->{'attachment'};