web/modules/rhn/RHN/DB/Org.pm | 499 -----------------------------------------
web/modules/rhn/RHN/DB/User.pm | 121 ---------
2 files changed, 620 deletions(-)
New commits:
commit 83d401ad4eb1a8f92ea2ec129eefc45253e26e36
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:19:16 2010 +0100
Removal of create_new_user and banish made create_new_org unused, removing.
diff --git a/web/modules/rhn/RHN/DB/Org.pm b/web/modules/rhn/RHN/DB/Org.pm
index 756e49f..7f017ae 100644
--- a/web/modules/rhn/RHN/DB/Org.pm
+++ b/web/modules/rhn/RHN/DB/Org.pm
@@ -306,42 +306,6 @@ EOQ
return @result;
}
-sub create_new_org {
- my $class = shift;
- my %params = @_;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOQ);
-BEGIN
- CREATE_NEW_ORG(name_in => :org_name, password_in => :org_password,
- oracle_customer_number_in => :oracle_customer_number,
- oracle_customer_id_in => :oracle_customer_id,
- customer_type_in => :customer_type,
- org_id_out => :org_id, org_admin_group_out => :org_admin_group,
- org_app_group_out => :org_app_group,
- creation_location => 'rhn');
-END;
-EOQ
-
- $sth->bind_param(":org_name" => $params{"-org_name"});
- $sth->bind_param(":org_password" =>
$params{"-org_password"});
-
- $sth->bind_param(":${_}" => $params{"-$_"})
- foreach qw/oracle_customer_number oracle_customer_id customer_type/;
-
- my ($org_id, $org_admin_group, $org_app_group);
- $sth->bind_param_inout(':org_id' => \$org_id, 4096);
- $sth->bind_param_inout(':org_admin_group' => \$org_admin_group, 4096);
- $sth->bind_param_inout(':org_app_group' => \$org_app_group, 4096);
- $sth->execute;
-
- if ($params{-commit}) {
- $dbh->commit;
- }
-
- return ($org_id, $org_admin_group, $org_app_group);
-}
-
sub entitlement_counts {
my $self = shift;
my $entitlement = shift;
commit e75e940b96150699ab32dfc36a1bcafb0ba1d604
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:18:19 2010 +0100
banish not used anywhere, removing.
diff --git a/web/modules/rhn/RHN/DB/User.pm b/web/modules/rhn/RHN/DB/User.pm
index db148f3..d45c4b9 100644
--- a/web/modules/rhn/RHN/DB/User.pm
+++ b/web/modules/rhn/RHN/DB/User.pm
@@ -1759,23 +1759,6 @@ sub has_incomplete_info {
return 0;
}
-sub banish {
- my $self = shift;
-
- my ($org_id) = RHN::Org->create_new_org(-org_name => "Rejection Org for
" . $self->login,
- -org_password => PXT::Utils->random_password(16),
- -customer_type => 'P');
-
- $self->remove_from_group('org_applicant');
-
- $self->org_id($org_id);
- delete $self->{__orgobj__};
- $self->set_password(PXT::Utils->random_password(16));
- $self->login(substr($self->id . '-' . $self->login, 0, 63));
-
- $self->commit;
-}
-
sub approve {
my $self = shift;
commit 696baaf25196850b6a3291ee70b415667577689b
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:16:56 2010 +0100
create_new_user not used in Perl stack, removing.
diff --git a/web/modules/rhn/RHN/DB/User.pm b/web/modules/rhn/RHN/DB/User.pm
index bf76172..db148f3 100644
--- a/web/modules/rhn/RHN/DB/User.pm
+++ b/web/modules/rhn/RHN/DB/User.pm
@@ -322,110 +322,6 @@ sub _blank_user {
return $self;
}
-sub create_new_user {
- my $class = shift;
- my %params = @_;
-
- my $dbh = RHN::DB->connect;
- my $commit_org = 0;
-
- # type 'S' (a placeholder for the first satellite user)
- if (exists $params{-customer_type} and $params{-customer_type} eq 'S') {
-
- # check to be sure we really are running in satellite mode
- die "Attempt to create satellite user when not running a satellite" unless
- PXT::Config->get('satellite');
-
- # check to be sure the one and only org for this satellite was created
- my $sth = $dbh->prepare('SELECT id FROM web_customer');
- $sth->execute;
- my ($org_id) = $sth->fetchrow;
- if (not defined $org_id) {
- die "Attempt to create satellite user when no orgs exist";
- }
-
- if ($sth->fetchrow) {
- die "Attempt to create satellite user when more than one org exists";
- }
-
- $sth->finish;
-
- # check to be sure there are no other users on this satellite
- $sth = $dbh->prepare('SELECT id FROM web_contact');
- $sth->execute;
- my ($existing_user) = $sth->fetchrow;
- $sth->finish;
-
- if ($existing_user) {
- die "Attempt to create satellite user when a user already exists";
- }
-
- $params{-customer_type} = 'P';
- $params{-org_id} = $org_id;
- }
-
- if (not $params{-org_id} or $params{-org_id} < 1) {
- @params{'-org_id', '-org_admin_group', '-org_app_group'} =
- RHN::Org->create_new_org(-org_name => $params{-org_name} ||
"$params{-first_names} $params{-last_name}",
- -org_password => $params{-org_password} ||
PXT::Utils->random_password(16),
- -oracle_customer_number => $params{-oracle_customer_number},
- -oracle_customer_id => $params{-oracle_customer_id},
- -customer_type => $params{-customer_type} || 'P',
- -commit => 0);
- $commit_org = 1;
- }
-
-
- if (PXT::Config->get('encrypted_passwords')) {
- my $salt = '$1$' . PXT::Utils->generate_salt(8);
-
- $params{-password} = crypt($params{-password}, $salt);
- }
-
- my $sth = $dbh->prepare(<<EOQ);
-BEGIN
- :user_id := CREATE_NEW_USER(org_id_in => :org_id, login_in => :login, password_in
=> :password,
- oracle_contact_id_in => :oracle_contact_id, prefix_in
=> :prefix,
- first_names_in => :first_names, last_name_in =>
:last_name, genqual_in => :genqual,
- parent_company_in => :parent_company, company_in =>
:company, title_in => :title,
- phone_in => :phone, fax_in => :fax, email_in =>
:email, pin_in => :pin,
- first_names_ol_in => :first_names_ol, last_name_ol_in
=> :last_name_ol,
- address1_in => :address1, address2_in => :address2,
address3_in => :address3,
- city_in => :city, state_in => :state, zip_in =>
:zip, country_in => :country,
- alt_first_names_in => :alt_first_names, alt_last_name_in
=> :alt_last_name,
- contact_call_in => :contact_call,
- contact_mail_in => :contact_mail,
- contact_email_in => :contact_email,
- contact_fax_in => :contact_fax);
-END;
-EOQ
-
-# warn "Param dump for new user: " . Data::Dumper->Dump([\%params]);
- foreach (qw/org_id login password oracle_contact_id prefix/,
- qw/first_names last_name genqual parent_company company title phone/,
- qw/fax email pin first_names_ol last_name_ol contact_call/,
- qw/contact_mail contact_email contact_fax address1 address2 address3/,
- qw/city state zip country alt_first_names alt_last_name/) {
- $sth->bind_param(":${_}" => $params{"-$_"});
- }
-
- my $user_id;
- $sth->bind_param_inout(':user_id' => \$user_id, 4096);
- $sth->execute;
-
- my $ret = RHN::User->lookup(-id => $user_id);
- $dbh->commit;
-
- if ($commit_org) {
- my $org = RHN::Org->lookup(-id => $params{-org_id});
- $org->oai_customer_sync();
- }
-
- $ret->oai_contact_sync();
-
- return $ret;
-}
-
sub create {
my $class = shift;
commit 9ca64d80bd5bc57e53f573c51bd3257d983ce347
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 17:15:05 2010 +0100
Removing bunch of unused methods from RHN::DB::Org:
satellite_org
create_org
random_org_admin
servers_in_org
usergroups_in_org
servergroups_in_org
user_count
user_group_id
user_applicant_group
user_applet_overview
owns_servers
support_user_overview
orders_for_org
products_for_org
pending_users
find_responsible_user
entitlement_history
rename_customer
monitoring_slot_name
quota_data
available_cert_channels
diff --git a/web/modules/rhn/RHN/DB/Org.pm b/web/modules/rhn/RHN/DB/Org.pm
index a776387..756e49f 100644
--- a/web/modules/rhn/RHN/DB/Org.pm
+++ b/web/modules/rhn/RHN/DB/Org.pm
@@ -38,28 +38,6 @@ my @skip_cert_channels = qw/%%-beta%% %%-staging%% rhn-satellite%%/;
my $o = new RHN::DB::TableClass("web_customer", "O", "",
@org_fields);
-# loads the org for a satellite, dies if called in non-satellite context
-sub satellite_org {
- my $class = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth;
-
- $sth = $dbh->prepare("SELECT is_satellite() FROM DUAL");
- $sth->execute();
- my ($is_satellite)= $sth->fetchrow;
- $sth->finish;
-
- die 'not a satellite!' unless $is_satellite;
-
- $sth = $dbh->prepare("SELECT id FROM web_customer");
- $sth->execute;
- my ($org_id) = $sth->fetchrow;
- $sth->finish;
-
- return $class->lookup(-id => $org_id);
-}
-
sub lookup {
my $class = shift;
my %params = validate(@_, { id => 0, customer_number => 0, customer_name => 0
});
@@ -160,15 +138,6 @@ sub blank_org {
return $self;
}
-sub create_org {
- my $class = shift;
-
- my $org = $class->blank_org;
- $org->{__id__} = -1;
-
- return $org;
-}
-
# build some accessors
foreach my $field ($o->method_names) {
my $sub = q {
@@ -237,36 +206,6 @@ sub commit {
delete $self->{":modified:"};
}
-sub random_org_admin {
- my $self_or_class = shift;
- my $oid;
-
- if (ref $self_or_class) {
- $oid = $self_or_class->id;
- }
- else {
- $oid = shift;
- }
-
- my $dbh = RHN::DB->connect;
- my $query = <<EOSQL;
-SELECT UGM.user_id
- FROM rhnUserGroupMembers UGM,
- rhnUserGroup UG
- WHERE UG.id = UGM.user_group_id
- AND UG.org_id = ?
- AND UG.group_type = (SELECT id FROM rhnUserGroupType WHERE label =
'org_admin')
-EOSQL
-
- my $sth = $dbh->prepare($query);
- $sth->execute($oid);
-
- my ($id) = $sth->fetchrow;
- $sth->finish;
-
- return $id;
-}
-
sub users_in_org {
my $class = shift;
my $org_id = shift;
@@ -291,102 +230,6 @@ EOSQL
return @ret;
}
-# calling convention:
-# RHN::DB::Org->servers_in_org(org_id, [upper, lower], columns to display)
-# TODO: make servergroups_in_org, users_in_org, usergroups_in_org act like
servers_in_org
-
-sub servers_in_org {
- my $class = shift;
- my $org_id = shift;
- my $bounds = shift;
- my @columns = @_;
-
- if (not ref $bounds or ref $bounds ne 'ARRAY') {
- unshift @columns, $bounds;
- $bounds = [ 1, 1_000_000 ];
- }
-
- @columns = ('S.ID') unless @columns;
-
- my $dbh = RHN::DB->connect;
- my $query = sprintf <<EOSQL, join(", ", map { "S.$_" }
@columns);
-SELECT %s
-FROM rhnServer S
-WHERE S.org_id = ?
-ORDER BY UPPER(S.name), S.id
-EOSQL
-
- my $sth = $dbh->prepare($query);
- $sth->execute($org_id);
-
- my @ret;
-
- my $i = 1;
- while (my @row = $sth->fetchrow) {
- if ($i >= $bounds->[0] and $i <= $bounds->[1]) {
- push @ret, [ @row ];
- } else {
- last;
- }
- $i++;
- }
- $sth->finish;
-
- return @ret;
-}
-
-sub usergroups_in_org {
- my $class = shift;
- my $org_id = shift;
- my @columns = @_;
-
- my $dbh = RHN::DB->connect;
- my $query = sprintf <<EOSQL, join(", ", map { "UG.$_" }
@columns);
-SELECT %s
-FROM rhnUserGroup UG
-WHERE UG.org_id = ?
-EOSQL
-
-# warn "q: $query";
-
- my $sth = $dbh->prepare($query);
- $sth->execute($org_id);
-
- my @ret;
-
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
-
- return @ret;
-}
-
-sub servergroups_in_org {
- my $class = shift;
- my $org_id = shift;
- my @columns = @_ ? @_ : ("ID");
-
- my $dbh = RHN::DB->connect;
- my $query = sprintf <<EOSQL, join(", ", map { "SG.$_" }
@columns);
-SELECT %s
-FROM rhnServerGroup SG
-WHERE SG.org_id = ?
- AND SG.group_type is NULL
-EOSQL
-
- my $sth = $dbh->prepare($query);
- $sth->execute($org_id);
-
- my @ret;
-
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
-
- return @ret;
-}
-
-
sub users_in_org_overview {
my $class = shift;
my %params = @_;
@@ -463,45 +306,6 @@ EOQ
return @result;
}
-sub user_count {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare('SELECT COUNT(id) FROM web_contact WHERE org_id =
?');
- $sth->execute($self->id);
- my ($count) = $sth->fetchrow;
- $sth->finish;
-
- return $count;
-}
-
-sub user_group_id {
- my $self = shift;
- my $label = shift;
-
- die "No label" unless $label;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare('SELECT UG.id FROM rhnUserGroupType UGT, rhnUserGroup UG
WHERE UG.org_id = ? AND UG.group_type = UGT.id AND UGT.label = ?');
- $sth->execute($self->id, $label);
- my ($id) = $sth->fetchrow;
- $sth->finish;
-
- return $id;
-}
-
-sub user_applicant_group {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare('SELECT UG.id FROM rhnUserGroupType UGT, rhnUserGroup UG
WHERE UG.org_id = ? AND UG.group_type = UGT.id AND UGT.label = ?');
- $sth->execute($self->id, 'org_applicant');
- my ($id) = $sth->fetchrow;
- $sth->finish;
-
- return $id;
-}
-
sub create_new_org {
my $class = shift;
my %params = @_;
@@ -538,30 +342,6 @@ EOQ
return ($org_id, $org_admin_group, $org_app_group);
}
-sub user_applet_overview {
- my $class = shift;
- my $user_id = shift;
-
- my $dbh = RHN::DB->connect;
-
- my $sth = $dbh->prepare("SELECT COUNT(server_id) FROM rhnUserServerPerms WHERE
user_id = ?");
- $sth->execute($user_id);
- my ($count) = $sth->fetchrow;
- $sth->finish;
-
- $sth = $dbh->prepare(<<EOSQL);
-SELECT security_count, bug_count, enhancement_count
- FROM rhnUserAppletOverview
- WHERE user_id = ?
-EOSQL
- $sth->execute($user_id);
-
- my ($sec, $bug, $enh) = $sth->fetchrow;
- $sth->finish;
-
- return ($count, $sec, $bug, $enh);
-}
-
sub entitlement_counts {
my $self = shift;
my $entitlement = shift;
@@ -642,25 +422,6 @@ EOS
return $tot;
}
-sub owns_servers {
- my $self = shift;
- my @server_ids = @_;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare("SELECT org_id FROM rhnServer WHERE id = ?");
-
- foreach my $server (@server_ids) {
- $sth->execute($server);
- my ($org_id) = $sth->fetchrow;
- $sth->finish;
-
- return 0 if not defined $org_id;
- return 0 if $org_id != $self->id;
- }
-
- return 1;
-}
-
sub owns_server_groups {
my $self = shift;
my @sg_ids = @_;
@@ -738,107 +499,6 @@ EOQ
return 0;
}
-sub support_user_overview {
- my $class = shift;
- my %params = @_;
-
- my $org_id;
-
- if (exists $params{-org_id}) {
- $org_id = $params{-org_id};
- }
- elsif (exists $params{-custnum}) {
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare('SELECT id FROM web_customer WHERE
oracle_customer_number = ?');
-
- $sth->execute($params{-custnum});
- ($org_id) = $sth->fetchrow;
- $sth->finish;
- }
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare('SELECT id, login FROM web_contact WHERE org_id =
?');
-
- $sth->execute($org_id);
-
- my @ret;
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
-
- return @ret;
-}
-
-sub orders_for_org {
- my $class = shift;
- my $oid = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOS);
-SELECT CUSTOMER_NUMBER, WEB_ORDER_NUMBER, LINE_ID, PRODUCT_ITEM_CODE, PRODUCT_NAME,
QUANTITY
- FROM user_orders
- WHERE customer_number = (SELECT oracle_customer_id FROM web_customer cu WHERE cu.id =
?)
-EOS
-
- $sth->execute($oid);
-
- my @ret;
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
-
- return @ret;
-}
-
-sub products_for_org {
- my $class = shift;
- my $oid = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOS);
-SELECT REGISTRATION_USER_ID, REG_NUMBER, SERVICE_TAG, PRODUCT_DESCRIPTION,
PRODUCT_ITEM_CODE,
- PRODUCT_START_DATE, PRODUCT_END_DATE, PRODUCT_ACTIVE_FLAG, PRODUCT_QUANTITY,
- SERVICE_DESCRIPTION, SERVICE_ITEM_CODE, SERVICE_START_DATE, SERVICE_END_DATE,
- SERVICE_ACTIVE_FLAG
- FROM user_products
- WHERE org_id = ?
-EOS
-
- $sth->execute($oid);
-
- my @ret;
- while (my @row = $sth->fetchrow) {
- push @ret, [ @row ];
- }
-
- return @ret;
-}
-
-sub pending_users {
- my $class = shift;
- my $org_id = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOS);
-SELECT wc.id, wc.login, wupi.first_names, wupi.last_name, wupi.title, wupi.email
- FROM web_user_personal_info wupi,
- web_contact wc,
- rhnUserGroupMembers UGM
- WHERE UGM.user_group_id = (SELECT id
- FROM rhnUserGroup
- WHERE org_id = ?
- AND group_type = (SELECT id FROM rhnUserGroupType WHERE
label = 'org_applicant'))
- AND UGM.user_id = wc.id
- AND wupi.web_user_id = wc.id
-EOS
-
- $sth->execute($org_id);
-
- my @ret = $sth->fullfetch;
-
- return @ret;
-}
-
sub org_admins {
my $self = shift;
@@ -864,20 +524,6 @@ EOS
return @ret;
}
-# find a user who is responsible (org admin; current policy is org
-# admin with lowest id)
-sub find_responsible_user {
- my $self = shift;
-
- my @ret = $self->org_admins;
- if (@ret) {
- return RHN::User->lookup(-id => $ret[0]);
- }
- else {
- return undef;
- }
-}
-
sub entitled_satellite_families {
my $self = shift;
@@ -909,50 +555,6 @@ EOS
return $ret;
}
-sub entitlement_history {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOS);
-SELECT wce.customer_id,
- wce.active_flag,
- TO_CHAR(wce.start_date_active, 'YYYY-MM-DD'),
- TO_CHAR(wce.end_date_active, 'YYYY-MM-DD'),
- wce.product_name,
- wce.service_name,
- wce.product_item_code,
- wce.service_item_code,
- wce.group_label,
- wce.quantity,
- wce.customer_product_id,
- wce.paid
- FROM web_customer_entitlements wce
- WHERE wce.customer_id = ?
-EOS
-
- $sth->execute($self->id);
-
- my @ret = $sth->fullfetch;
-
- return @ret;
-}
-
-sub rename_customer {
- my $self = shift;
- my $name = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare("UPDATE web_customer SET name = ? WHERE id = ?");
- $sth->execute($name, $self->id);
-
- $sth = $dbh->prepare("UPDATE web_user_personal_info SET company = ? WHERE
web_user_id IN (SELECT id FROM web_contact WHERE org_id = ?)");
- $sth->execute($name, $self->id);
-
- $self->name($name);
-
- $self->oai_customer_sync();
-}
-
sub oai_customer_sync {
my $self = shift;
@@ -1106,12 +708,6 @@ sub provisioning_slot_name {
return $self->slot_name('provisioning_entitled');
}
-sub monitoring_slot_name {
- my $self = shift;
-
- return $self->slot_name('monitoring_entitled');
-}
-
sub nonlinux_slot_name {
my $self = shift;
@@ -1306,29 +902,6 @@ sub channel_entitlements {
return $channels;
}
-sub quota_data {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $sth = $dbh->prepare(<<EOQ);
-SELECT OQ.total, OQ.bonus, OQ.used
- FROM rhnOrgQuota OQ
- WHERE OQ.org_id = :org_id
-EOQ
-
- $sth->execute_h(org_id => $self->id);
- my $data = $sth->fetchrow_hashref;
-
- $sth->finish;
-
- return unless (ref $data eq 'HASH');
-
- $data->{LIMIT} = $data->{TOTAL} + $data->{BONUS};
- $data->{AVAILABLE} = $data->{LIMIT} - $data->{USED};
-
- return $data;
-}
-
sub validate_cert {
my $self = shift;
@@ -1359,42 +932,6 @@ EOQ
}
-sub available_cert_channels {
- my $self = shift;
-
- my $dbh = RHN::DB->connect;
- my $stmt = <<EOQ;
-SELECT
- cf.id id,
- cf.name name,
- cf.label label
-FROM rhnChannelFamily cf
-WHERE 1=1
- and cf.org_id is null
-EOQ
-
- foreach my $skip_clause (@skip_cert_channels) {
- $stmt .= " and cf.label not like '$skip_clause'";
- }
- $stmt .= " order by cf.label";
-
- my $sth = $dbh->prepare($stmt);
-
- $sth->execute_h();
-
- my @result;
-
- while ( my (@data) = $sth->fetchrow ) {
- push ( @result, \@data );
- }
-
- $sth->finish;
-
- return @result;
-
-}
-
-
# Get options defined for this Org's list of monitoring Scouts
sub get_scout_options {
my $self = shift;