web/modules/rhn/RHN/DB.pm | 11 -
web/modules/rhn/RHN/DB/UserGroup.pm | 253 ---------------------------
web/modules/rhn/RHN/UserGroup.pm | 47 -----
web/modules/sniglets/Sniglets/ServerGroup.pm | 1
web/modules/sniglets/Sniglets/Users.pm | 1
5 files changed, 313 deletions(-)
New commits:
commit 9dd29241e6935b82b492eddb3d6bca279406710c
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 11:40:20 2010 +0100
RHN::UserGroup was use'd but not used, removing, which makes RHN::DB::UserGroup
obsolete as well, removing.
diff --git a/web/modules/rhn/RHN/DB/UserGroup.pm b/web/modules/rhn/RHN/DB/UserGroup.pm
deleted file mode 100644
index 7dfeb2a..0000000
--- a/web/modules/rhn/RHN/DB/UserGroup.pm
+++ /dev/null
@@ -1,253 +0,0 @@
-#
-# Copyright (c) 2008 Red Hat, Inc.
-#
-# This software is licensed to you under the GNU General Public License,
-# version 2 (GPLv2). There is NO WARRANTY for this software, express or
-# implied, including the implied warranties of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
-# along with this software; if not, see
-#
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
-#
-# Red Hat trademarks are not licensed under GPLv2. No permission is
-# granted to use or replicate Red Hat trademarks that are incorporated
-# in this software or its documentation.
-#
-
-# See POD at bottom for additional comments
-use strict;
-use DBI;
-
-package RHN::DB::UserGroup;
-
-use Params::Validate qw/:all/;
-Params::Validate::validation_options(strip_leading => "-");
-
-use RHN::DB;
-use Carp;
-use RHN::DB::TableClass;
-use Data::Dumper;
-
-my @ug_fields = qw { id name description max_members group_type org_id };
-my $ug_table = new RHN::DB::TableClass("rhnUserGroup", "UG",
"", @ug_fields);
-
-sub list_group_types {
- my $class = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare("SELECT id, name, label FROM rhnUserGroupType ORDER BY
UPPER(label)");
- $sth->execute;
-
- my @ret;
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
-
- return @ret;
-}
-
-#
-# Create a usergroup object to propagate back to the caller
-#
-sub blank_usergrp {
- my $class = shift;
- my $self = bless { }, $class;
- return $self;
-}
-
-#
-# Retrieve a group given a group id
-#
-sub lookup {
- my $class = shift;
- my %params = validate(@_, {id => 1});
- my $id = $params{id};
-
- my $dbh;
- my $sqlstmt;
- my $sth;
- my $usergrp;
- my @columns;
-
- $dbh = RHN::DB->connect;
- $sqlstmt = $ug_table->select_query("UG.ID = ?");
- $sth = $dbh->prepare($sqlstmt);
- $sth->execute($id);
- @columns = $sth->fetchrow;
- $sth->finish;
-
- if ($columns[0]) {
- $usergrp = $class->blank_usergrp;
- $usergrp->{id} = $columns[0];
- foreach ($ug_table->method_names) {
- $usergrp->$_(shift @columns)
- }
- delete $usergrp->{":modified:"};
- }
- else {
- local $" = ", ";
- die "Error loading usergroup $id (@columns)";
- }
-
- return $usergrp;
-}
-
-sub create {
- my $class = shift;
-
- my $ug = $class->blank_usergrp;
- $ug->{id} = -1;
-
- return $ug;
-}
-
-#
-# Delete a group given a group id
-#
-sub remove {
- my $class = shift;
- my $id = shift;
- my $dbh;
- my $sqlstmt;
- my $sth;
-
- $dbh = RHN::DB->connect;
-
- $sqlstmt = "DELETE FROM " . $ug_table->table_name . " WHERE
id=?";
- $sth = $dbh->prepare($sqlstmt);
- $sth->execute($id);
-
- $dbh->commit;
- $sth->finish;
-}
-
-#
-# build some accessors
-#
-foreach my $field ($ug_table->method_names) {
- my $sub = q {
- sub [[field]] {
- my $self = shift;
- if (@_ and "[[field]]" ne "id") {
- $self->{":modified:"}->{[[field]]} = 1;
- $self->{[[field]]} = shift;
- }
- return $self->{[[field]]};
- }
- };
-
- $sub =~ s/\[\[field\]\]/$field/g;
- eval $sub;
-
- if ($@) {
- warn $@;
- }
-}
-
-#
-# Commit fields iff they have been updated
-#
-sub commit {
- my $self = shift;
- my $mode = 'update';
-
- if ($self->id == -1) {
- my $dbh = RHN::DB->connect;
-
- my $sth = $dbh->prepare("SELECT rhn_user_group_id_seq.nextval FROM
DUAL");
- $sth->execute;
- my ($id) = $sth->fetchrow;
- #warn "id: $id";
- die "No new ugroup id from seq rhn_user_group_id_seq (possible error: " .
$sth->errstr . ")" unless $id;
- $sth->finish;
-
- $self->{":modified:"}->{id} = 1;
- $self->{id} = $id;
- $mode = 'insert';
- }
-
- die "$self->commit called on usergroup without valid id" unless
$self->id;
-
- my @modified = keys %{$self->{":modified:"}};
- my %modified = map { $_ => 1 } @modified;
-
- return unless @modified;
-
- my $dbh = RHN::DB->connect;
-
- my $query;
- if ($mode eq 'update') {
- $query = $ug_table->update_query($ug_table->methods_to_columns(@modified));
- $query .= "UG.ID = ?";
- }
- else {
- $query = $ug_table->insert_query($ug_table->methods_to_columns(@modified));
- }
-
- #warn "ins/upd query: $query";
-
- my $sth = $dbh->prepare($query);
- $sth->execute((map { $self->$_() } grep { $modified{$_} }
$ug_table->method_names), ($mode eq 'update') ? ($self->id) : ());
-
- $dbh->commit;
-
- delete $self->{":modified:"};
-}
-
-sub member_count {
- my $self_or_pkg = shift;
- my $id;
-
- if (ref $self_or_pkg) {
- $id = $self_or_pkg->id;
- }
- else {
- $id = shift;
- }
-
- my $dbh = RHN::DB->connect;
-
- my $sqlstmt = sprintf <<EOT;
-SELECT COUNT(user_id)
- FROM rhnUserGroupMembers UGM
- WHERE UGM.user_group_id = ?
-EOT
-
- my $sth = $dbh->prepare($sqlstmt);
- $sth->execute($id);
-
- my ($count) = $sth->fetchrow;
- $sth->finish;
-
- return $count;
-}
-
-#
-# Return all users in the given group id
-#
-sub users_in_group {
- my $class = shift;
- my $id = shift;
-
- die "Attempt to lookup users in group without a group id" if(!$id);
- my $dbh = RHN::DB->connect;
-
- my $sqlstmt = sprintf <<EOT;
-SELECT U.id, U.login
-FROM rhnUser U, rhnUserGroupMembers M
-WHERE U.id = M.user_id AND M.user_group_id = ?
-ORDER BY U.login_uc
-EOT
-
- my $sth = $dbh->prepare($sqlstmt);
- $sth->execute($id);
-
- my @users;
-
- while (my ($id, $login) = $sth->fetchrow) {
- push @users, [ $id, $login ];
- }
-
- return @users;
-}
-
-1;
diff --git a/web/modules/rhn/RHN/UserGroup.pm b/web/modules/rhn/RHN/UserGroup.pm
deleted file mode 100644
index 4bde83f..0000000
--- a/web/modules/rhn/RHN/UserGroup.pm
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (c) 2008 Red Hat, Inc.
-#
-# This software is licensed to you under the GNU General Public License,
-# version 2 (GPLv2). There is NO WARRANTY for this software, express or
-# implied, including the implied warranties of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
-# along with this software; if not, see
-#
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
-#
-# Red Hat trademarks are not licensed under GPLv2. No permission is
-# granted to use or replicate Red Hat trademarks that are incorporated
-# in this software or its documentation.
-#
-
-package RHN::UserGroup;
-
-use strict;
-use RHN::DB::UserGroup;
-
-our @ISA = qw/RHN::DB::UserGroup/;
-
-sub lookup {
- my $class = shift;
- my $first_arg = $_[0];
-
- die "No argument to $class->lookup"
- unless $first_arg;
-
- if (substr($first_arg,0,1) eq '-') {
- return $class->SUPER::lookup(@_);
- }
- else {
- warn "deprecated use of unparameterized $class->lookup from (" .
join(', ', caller) . ")\n";
- return $class->SUPER::lookup(-id => $first_arg);
- }
-}
-
-1;
diff --git a/web/modules/sniglets/Sniglets/ServerGroup.pm
b/web/modules/sniglets/Sniglets/ServerGroup.pm
index 52abe26..bf1b234 100644
--- a/web/modules/sniglets/Sniglets/ServerGroup.pm
+++ b/web/modules/sniglets/Sniglets/ServerGroup.pm
@@ -19,7 +19,6 @@ package Sniglets::ServerGroup;
use RHN::Server;
use RHN::ServerGroup;
-use RHN::UserGroup;
use RHN::Org;
use RHN::ServerActions;
use RHN::User;
diff --git a/web/modules/sniglets/Sniglets/Users.pm
b/web/modules/sniglets/Sniglets/Users.pm
index f79d5eb..40f4c87 100644
--- a/web/modules/sniglets/Sniglets/Users.pm
+++ b/web/modules/sniglets/Sniglets/Users.pm
@@ -20,7 +20,6 @@ package Sniglets::Users;
use PXT::Utils;
use RHN::User;
-use RHN::UserGroup;
use RHN::Org;
use RHN::Grail;
use PXT::HTML;
commit 6049892a2f1ddd5255896bd0859a7667bb0f9867
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 11:31:05 2010 +0100
lookup_user_group is not called from anywhere, removing.
diff --git a/web/modules/rhn/RHN/UserGroup.pm b/web/modules/rhn/RHN/UserGroup.pm
index 53a6cad..4bde83f 100644
--- a/web/modules/rhn/RHN/UserGroup.pm
+++ b/web/modules/rhn/RHN/UserGroup.pm
@@ -36,12 +36,4 @@ sub lookup {
}
}
-sub lookup_user_group {
- my $class = shift;
-
- warn "deprecated use of $class->lookup_foo from (" . join(', ',
caller) . "). Using $class->lookup instead\n";
-
- return $class->lookup(@_);
-}
-
1;
commit abc75b01f8ae42716f205395d6c274c7d814244e
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 11:26:51 2010 +0100
reset_profiling is not called from anywhere, removing as dead code.
diff --git a/web/modules/rhn/RHN/DB.pm b/web/modules/rhn/RHN/DB.pm
index 1fa978e..cdddc90 100644
--- a/web/modules/rhn/RHN/DB.pm
+++ b/web/modules/rhn/RHN/DB.pm
@@ -352,12 +352,6 @@ sub profile_format {
return @ret;
}
-sub reset_profiling {
- my $self = shift;
-
- $self->{Profile}->{Data} = undef;
-}
-
sub init_db_handle {
my $self = shift;
commit d7176a9bbc37fff3d21ca2f2df476e1ddb397b81
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 11:21:12 2010 +0100
Removal of pxtdb.conf and load_dsn_aliases made clear_aliases unused, removing.
diff --git a/web/modules/rhn/RHN/DB.pm b/web/modules/rhn/RHN/DB.pm
index e30327e..1fa978e 100644
--- a/web/modules/rhn/RHN/DB.pm
+++ b/web/modules/rhn/RHN/DB.pm
@@ -37,11 +37,6 @@ sub add_alias {
$aliases{$dbi_connection_string} = [ @_ ];
}
-sub clear_aliases {
- my $class = shift;
- %aliases = ();
-}
-
sub lookup_alias {
my $class = shift;
my $alias = shift;