summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/WebService/Product.pm2
-rw-r--r--extensions/BMO/Extension.pm40
-rw-r--r--extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl47
-rw-r--r--extensions/GuidedBugEntry/Extension.pm4
-rw-r--r--extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl9
-rw-r--r--extensions/GuidedBugEntry/web/js/guided.js10
6 files changed, 79 insertions, 33 deletions
diff --git a/Bugzilla/WebService/Product.pm b/Bugzilla/WebService/Product.pm
index b7484327f..bccaa8347 100644
--- a/Bugzilla/WebService/Product.pm
+++ b/Bugzilla/WebService/Product.pm
@@ -205,6 +205,8 @@ sub _product_to_hash {
# BMO - add default hw/os
$field_data->{default_platform} = $self->type('string', $product->default_platform);
$field_data->{default_op_sys} = $self->type('string', $product->default_op_sys);
+ # BMO - add default security group
+ $field_data->{default_security_group} = $self->type('string', $product->default_security_group);
return filter($params, $field_data);
}
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index 5515f56db..2e2a9c168 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -158,6 +158,17 @@ sub template_before_process {
$vars->{attachment} = Bugzilla::Attachment->new({ id => $attachid, cache => 1 })
if $attachid;
}
+
+ if ($file =~ /^admin\/products\/(create|edit)\./) {
+ my $product = $vars->{product};
+ my $security_groups = Bugzilla::Group->match({ isbuggroup => 1, isactive => 1 });
+ # If set group is not active currently, we add it into the list
+ if (!grep($_->name eq $product->default_security_group, @$security_groups)) {
+ push(@$security_groups, $product->default_security_group_obj);
+ @$security_groups = sort { $a->name cmp $b->name } @$security_groups;
+ }
+ $vars->{security_groups} = $security_groups;
+ }
}
sub page_before_template {
@@ -678,13 +689,21 @@ sub quicksearch_map {
sub object_columns {
my ($self, $args) = @_;
return unless $args->{class}->isa('Bugzilla::Product');
- push @{ $args->{columns} }, qw( default_platform_id default_op_sys_id );
+ push @{ $args->{columns} }, qw(
+ default_platform_id
+ default_op_sys_id
+ security_group_id
+ );
}
sub object_update_columns {
my ($self, $args) = @_;
return unless $args->{object}->isa('Bugzilla::Product');
- push @{ $args->{columns} }, qw( default_platform_id default_op_sys_id );
+ push @{ $args->{columns} }, qw(
+ default_platform_id
+ default_op_sys_id
+ security_group_id
+ );
}
sub object_before_create {
@@ -693,7 +712,7 @@ sub object_before_create {
my $cgi = Bugzilla->cgi;
my $params = $args->{params};
- foreach my $field (qw( default_platform_id default_op_sys_id )) {
+ foreach my $field (qw( default_platform_id default_op_sys_id security_group_id )) {
$params->{$field} = $cgi->param($field);
}
}
@@ -705,7 +724,7 @@ sub object_end_of_set_all {
my $cgi = Bugzilla->cgi;
my $params = $args->{params};
- foreach my $field (qw( default_platform_id default_op_sys_id )) {
+ foreach my $field (qw( default_platform_id default_op_sys_id security_group_id )) {
my $value = $cgi->param($field);
detaint_natural($value);
$object->set($field, $value);
@@ -1989,16 +2008,15 @@ sub _group_always_settable {
}
sub _default_security_group {
- my ($self) = @_;
- return exists $product_sec_groups{$self->name}
- ? $product_sec_groups{$self->name}
- : $product_sec_groups{_default};
+ return $_[0]->default_security_group_obj->name;
}
sub _default_security_group_obj {
- my ($self) = @_;
- return unless my $group_name = $self->default_security_group;
- return Bugzilla::Group->new({ name => $group_name, cache => 1 })
+ my $group_id = $_[0]->{security_group_id};
+ if (!$group_id) {
+ return Bugzilla::Group->new({ name => Bugzilla->params->{insidergroup}, cache => 1 });
+ }
+ return Bugzilla::Group->new({ id => $group_id, cache => 1 });
}
# called from the verify version, component, and group page.
diff --git a/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl b/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl
index 7093bcfc6..f91e4052b 100644
--- a/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl
+++ b/extensions/BMO/template/en/default/hook/admin/products/edit-common-rows.html.tmpl
@@ -6,8 +6,53 @@
# defined by the Mozilla Public License, v. 2.0.
#%]
+[%
+ group_correct_visibility = {};
+ FOREACH g = product.group_controls.values;
+ IF (g.membercontrol == constants.CONTROLMAPSHOWN)
+ && (g.othercontrol == constants.CONTROLMAPSHOWN);
+ group_correct_visibility.${g.name} = 1;
+ ELSE;
+ group_correct_visibility.${g.name} = 0;
+ END;
+ END;
+%]
+
+<tr>
+ <th align="right">Default Security Group:</th>
+ <td>
+ <select required name="security_group_id" id="security_group_id">
+ <option value=""></option>
+ [% FOREACH g IN security_groups %]
+ <option value="[% g.id FILTER html %]"
+ data-group-correct-visibility="[% group_correct_visibility.${g.name} FILTER none %]"
+ [% " selected" IF product.default_security_group_obj.id == g.id %]>
+ [% g.name FILTER html %]
+ </option>
+ [% END %]
+ </select>
+ <span id="security_group_warning" style="color:red; display:none;">
+ The chosen security group needs to be set to SHOWN/SHOWN for this product
+ </span>
+ <script type="text/javascript">
+ var toggleGroupWarning = function() {
+ var correct_shown = $('#security_group_id option:selected')
+ .data('group-correct-visibility');
+ if (correct_shown) {
+ $('#security_group_warning').hide();
+ }
+ else {
+ $('#security_group_warning').show();
+ }
+ };
+ $('#security_group_id').change(toggleGroupWarning);
+ $(document).ready(toggleGroupWarning);
+ </script>
+ </td>
+</tr>
+
<tr>
- <th align="right">Default Platform</th>
+ <th align="right">Default Platform:</th>
<td>
[% INCLUDE default_select
field_name = 'default_platform_id'
diff --git a/extensions/GuidedBugEntry/Extension.pm b/extensions/GuidedBugEntry/Extension.pm
index e36d0a2e4..93cab9787 100644
--- a/extensions/GuidedBugEntry/Extension.pm
+++ b/extensions/GuidedBugEntry/Extension.pm
@@ -107,10 +107,6 @@ sub page_before_template {
return unless $page eq 'guided_products.js';
- # import data from the BMO ext
-
- $vars->{'product_sec_groups'} = \%product_sec_groups;
-
my %bug_formats;
foreach my $product (keys %create_bug_formats) {
if (my $format = Bugzilla::Extension::BMO::forced_format($product)) {
diff --git a/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl b/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl
index b58df8298..a57f0b581 100644
--- a/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl
+++ b/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl
@@ -15,12 +15,3 @@
products['[% product.key FILTER js %]'].format = '[% product.value FILTER js %]';
[% END %]
[% END %]
-
-[% IF product_sec_groups %]
- [% FOREACH product = product_sec_groups %]
- if (!products['[% product.key FILTER js %]']) [% ~%]
- products['[% product.key FILTER js %]'] = {};
- products['[% product.key FILTER js %]'].secgroup = '[% product.value FILTER js %]';
- [% END %]
-[% END %]
-
diff --git a/extensions/GuidedBugEntry/web/js/guided.js b/extensions/GuidedBugEntry/web/js/guided.js
index 0ff438782..339a6fc65 100644
--- a/extensions/GuidedBugEntry/web/js/guided.js
+++ b/extensions/GuidedBugEntry/web/js/guided.js
@@ -189,13 +189,6 @@ var product = {
return;
}
- // use the correct security group
- if (products[productName] && products[productName].secgroup) {
- Dom.get('groups').value = products[productName].secgroup;
- } else {
- Dom.get('groups').value = products['_default'].secgroup;
- }
-
// show support message
if (products[productName] && products[productName].support) {
Dom.get("product_support_message").innerHTML = products[productName].support;
@@ -824,9 +817,10 @@ var bugForm = {
}
bugForm.onVersionChange(elVersions.value);
- // set default hw/os
+ // set default hw/os/group
Dom.get('rep_platform').value = product.details.default_platform;
Dom.get('op_sys').value = product.details.default_op_sys;
+ Dom.get('groups').value = product.details.default_security_group;
},
onComponentChange: function(componentName) {