rel-eng/packages/spacewalk-web | 2 web/modules/rhn/RHN/DB/ChannelEditor.pm | 58 +++++++++++++++++++++++++ web/modules/sniglets/Sniglets/ChannelEditor.pm | 51 +++++++++++++-------- web/spacewalk-web.spec | 6 ++ 4 files changed, 95 insertions(+), 22 deletions(-)
New commits: commit d633fc581799a5ec1950cbc398d07edc6d81e61a Author: Stephen Herr sherr@redhat.com Date: Thu Apr 12 11:18:45 2012 -0400
Automatic commit of package [spacewalk-web] release [1.8.9-1].
diff --git a/rel-eng/packages/spacewalk-web b/rel-eng/packages/spacewalk-web index c1b7181..a29e1ae 100644 --- a/rel-eng/packages/spacewalk-web +++ b/rel-eng/packages/spacewalk-web @@ -1 +1 @@ -1.8.8-1 web/ +1.8.9-1 web/ diff --git a/web/spacewalk-web.spec b/web/spacewalk-web.spec index 9115ee2..e55d6a4 100644 --- a/web/spacewalk-web.spec +++ b/web/spacewalk-web.spec @@ -2,7 +2,7 @@ Name: spacewalk-web Summary: Spacewalk Web site - Perl modules Group: Applications/Internet License: GPLv2 -Version: 1.8.8 +Version: 1.8.9 Release: 1%{?dist} URL: https://fedorahosted.org/spacewalk/ Source0: https://fedorahosted.org/releases/s/p/spacewalk/%%7Bname%7D-%%7Bversion%7D.t... @@ -254,6 +254,10 @@ rm -rf $RPM_BUILD_ROOT
# $Id$ %changelog +* Thu Apr 12 2012 Stephen Herr sherr@redhat.com 1.8.9-1 +- 812031 - Update perl channel-select-dropdowns to use the same hierarchical + sort as java pages (sherr@redhat.com) + * Thu Apr 05 2012 Jan Pazdziora 1.8.8-1 - Fix naming of cloned errata to replace only the first 2 chars (tlestach@redhat.com)
commit 893bc22592af1a354037335f9bc2559f09d1056a Author: Stephen Herr sherr@redhat.com Date: Thu Apr 12 11:18:32 2012 -0400
812031 - Update perl channel-select-dropdowns to use the same hierarchical sort as java pages
diff --git a/web/modules/rhn/RHN/DB/ChannelEditor.pm b/web/modules/rhn/RHN/DB/ChannelEditor.pm index 223c799..564e75e 100644 --- a/web/modules/rhn/RHN/DB/ChannelEditor.pm +++ b/web/modules/rhn/RHN/DB/ChannelEditor.pm @@ -146,6 +146,64 @@ EOQ return @channels; }
+sub base_channels_visible_to_org { + my $self = shift; + my $org_id = shift; + + my $dbh = RHN::DB->connect; + + my $query; + my $sth; + + $query = <<EOQ; +SELECT NAME, ID + FROM rhnChannel + WHERE (org_id = :org_id OR org_id is NULL) + AND parent_channel is NULL + ORDER BY name +EOQ + + $sth = $dbh->prepare($query); + $sth->execute_h(org_id => $org_id); + + my @channels; + + while (my $row = $sth->fetchrow_hashref) { + push @channels, $row; + } + + return @channels; +} + +sub child_channels_visible_to_org_from_base { + my $self = shift; + my $org_id = shift; + my $base_channel_id = shift; + + my $dbh = RHN::DB->connect; + + my $query; + my $sth; + + $query = <<EOQ; +SELECT NAME, ID + FROM rhnChannel + WHERE (org_id = :org_id OR org_id is NULL) + AND parent_channel = :parent_channel + ORDER BY name +EOQ + + $sth = $dbh->prepare($query); + $sth->execute_h(org_id => $org_id, parent_channel => $base_channel_id); + + my @channels; + + while (my $row = $sth->fetchrow_hashref) { + push @channels, $row; + } + + return @channels; +}
sub channels_visible_to_org { my $self = shift; diff --git a/web/modules/sniglets/Sniglets/ChannelEditor.pm b/web/modules/sniglets/Sniglets/ChannelEditor.pm index 912c194..8b0e9b7 100644 --- a/web/modules/sniglets/Sniglets/ChannelEditor.pm +++ b/web/modules/sniglets/Sniglets/ChannelEditor.pm @@ -350,11 +350,31 @@ sub clone_channel_form { return $html; }
+sub populate_channel_list { + my $org_id = shift; + + my @channel_list = (); + my @base_channel_list = RHN::ChannelEditor->base_channels_visible_to_org($org_id); + foreach my $base (@base_channel_list) { + push (@channel_list, { NAME => $base->{NAME}, + ID => $base->{ID}, + DEPTH => 1}); + my @child_channel_list = RHN::ChannelEditor->child_channels_visible_to_org_from_base($org_id, $base->{ID}); + foreach my $child (@child_channel_list) { + push (@channel_list, { NAME => $child->{NAME}, + ID => $child->{ID}, + DEPTH => 2}); + } + } + + return @channel_list +} + sub build_clone_channel_details_form { my $pxt = shift; my %attr = @_;
- my @channel_list = RHN::ChannelEditor->channels_visible_to_org_with_parent($pxt->user->org_id); + my @channel_list = populate_channel_list($pxt->user->org_id);
my $ds = new RHN::DataSource::Channel(-mode => 'user_subscribe_perms'); my $subscribable = $ds->execute_query(-u_id => $pxt->user->id, -org_id => $pxt->user->org_id); @@ -373,17 +393,7 @@ sub build_clone_channel_details_form { my $channel_selectbox = new RHN::Form::Widget::Select(name => 'Clone From', label => 'clone_from');
- my @my_channels = grep {$_->{CHANNEL_ORG_ID} and $_->{CHANNEL_ORG_ID} == $pxt->user->org_id} @channel_list; -## my @other_channels = grep { not ($_->{CHANNEL_ORG_ID} and $_->{CHANNEL_ORG_ID} == $pxt->user->org_id) } @channel_list; - ##bugzilla - my @other_channels = grep { not ($_->{CHANNEL_ORG_ID}) } @channel_list; - - my @options = ( { NAME => 'My Channels', ID => 'my_channels', DEPTH => 1, OPTGROUP => 1 }, - @my_channels, - { NAME => 'Other Channels', ID => 'other_channels', DEPTH => 1, OPTGROUP => 1 }, - @other_channels); - - foreach my $opt (@options) { + foreach my $opt (@channel_list) { $channel_selectbox->add_option( {value => $opt->{ID}, label => ( $opt->{DEPTH} == 1 ? $opt->{NAME} @@ -649,16 +659,17 @@ sub channel_select_options { @rh_channels); } elsif ($mode eq 'compare_channels') { - my @org_channels = RHN::Channel->channels_owned_by_org($pxt->user->org_id); - my @rh_channels = RHN::Channel->channels_owned_by_org('NULL'); + my @additional_channels_hash = populate_channel_list($pxt->user->org_id); + my @additional_channels = (); + foreach my $tmp_channel (@additional_channels_hash) { + push (@additional_channels, [$tmp_channel->{DEPTH} == 1 ? + $tmp_channel->{NAME} : '  ' . $tmp_channel->{NAME}, + 'channel_' . $tmp_channel->{ID}]); + }
- @org_channels = grep { $perm_map{$_->[1]} } @org_channels; - @rh_channels = grep { $perm_map{$_->[1]} } @rh_channels; + @additional_channels = grep { $perm_map{$_->[1]} } @additional_channels;
- push @channel_list, ([ 'My Channels', 'my_channels', 'optgroup' ], - @org_channels, - [ 'Red Hat Channels', 'redhat_channels', 'optgroup' ], - @rh_channels); + push @channel_list, (@additional_channels); } elsif ($mode eq 'errata_manager') { @channel_list = ([ 'All managed packages', 'any_channel' ]);