From 529ec19487d625e011fd899da3d88af63c9668ca Mon Sep 17 00:00:00 2001 From: Christopher Burger Date: Tue, 2 Oct 2018 14:38:38 -0400 Subject: Revert "RT# 39340 - removed min_selfservice dir and merged into ng_selfservice" This reverts commit f4ad9107585d16317bb15bf3223fe8b8eeeeb82c. --- FS/FS/ClientAPI/MyAccount.pm | 122 ++++++------------------------------------- FS/FS/ClientAPI_XMLRPC.pm | 1 - 2 files changed, 17 insertions(+), 106 deletions(-) (limited to 'FS') diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 5bccad199..3390687ae 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -86,8 +86,6 @@ sub skin_info { my($context, $session, $custnum) = _custoragent_session_custnum($p); #return { 'error' => $session } if $context eq 'error'; - my $domain = $session->{'domain'}; - my $agentnum = ''; if ( $context eq 'customer' ) { @@ -121,8 +119,6 @@ sub skin_info { warn "$me populating skin info cache for agentnum $agentnum\n" if $DEBUG > 1; - my $menu = $conf->config("ng_selfservice-menu", $agentnum ); - $skin_info_cache_agent = { 'agentnum' => $agentnum, ( map { $_ => scalar( $conf->config($_, $agentnum) ) } @@ -146,93 +142,7 @@ sub skin_info { ( map { $_ => join("\n", $conf->config("selfservice-$_", $agentnum ) ) } qw( head body_header body_footer company_address ) ), 'money_char' => $conf->config("money_char") || '$', - 'menu' => _menu($domain,$menu), - }; - - _cache->set("skin_info_cache_agent$agentnum", $skin_info_cache_agent); - - } - - #{ %$skin_info_cache_agent }; - $skin_info_cache_agent; - -} - -## checks if page is in menu listing, if not sends to main with error. -sub check_access { - my $p = shift; - my $error; - - return if $p->{'page'} eq "index.php"; - return if $p->{'page'} eq "ip_login.php"; - - return if substr($p->{'page'}, 0, length("process_")) eq "process_"; - - my $conf = new FS::Conf; - - my($context, $session, $custnum) = _custoragent_session_custnum($p); - - my $domain = ref($session) ? $session->{'domain'} : ''; - - my $agentnum = ''; - if ( $context eq 'customer' && $custnum ) { - - my $sth = dbh->prepare('SELECT agentnum FROM cust_main WHERE custnum = ?') - or die dbh->errstr; - - $sth->execute($custnum) or die $sth->errstr; - - $agentnum = $sth->fetchrow_arrayref->[0] - or die "no agentnum for custnum $custnum"; - - #} elsif ( $context eq 'agent' ) { - } elsif ( defined($p->{'agentnum'}) and $p->{'agentnum'} =~ /^(\d+)$/ ) { - $agentnum = $1; - } - $p->{'agentnum'} = $agentnum; - - my $menu = $conf->config("ng_selfservice-menu", $agentnum ); - - my $allowed_pages = _menu($domain,$menu); - - my %allowed; - my @lines = split /\n/, $allowed_pages; - foreach my $line (@lines) { - chomp; # remove newlines - $line =~ s/^\s+//; # remove leading whitespace - next unless length($line); - my (@pages) = split(/ /, $line, 2); - $allowed{$pages[0]} = $pages[1]; - } - - $error = "You do not have access to the page ".$allowed{$p->{page}} unless $allowed{$p->{page}}; - - return { 'error' => $error, }; - -} - -sub _menu { - my $p = shift; - my $m = shift; - - my $menu; - - if ($p eq 'ip_mac') { - $menu = 'main.php Home - - payment.php Payments - payment_cc.php Credit Card Payment - payment_ach.php Electronic Check Payment - payment_paypal.php PayPal Payment - payment_webpay.php Webpay Payments - - docs.php FAQs - - logout.php Logout - '; - } - else { - $menu = join("\n", $m ) || + 'menu' => join("\n", $conf->config("ng_selfservice-menu", $agentnum ) ) || 'main.php Home services.php Services @@ -261,9 +171,16 @@ sub _menu { docs.php FAQs logout.php Logout - '; - } - return $menu; + ', + }; + + _cache->set("skin_info_cache_agent$agentnum", $skin_info_cache_agent); + + } + + #{ %$skin_info_cache_agent }; + $skin_info_cache_agent; + } sub get_mac_address { @@ -281,11 +198,12 @@ sub get_mac_address { foreach my $part_export (@part_export) { push @sessions, ( @{ $part_export->usage_sessions( { 'ip' => $p->{'ip'}, - 'session_status' => 'open', } ) } ); } - return { 'mac_address' => $sessions[0]->{'callingstationid'}, }; + my $mac = $sessions[0]->{'callingstationid'}; + + return { 'mac_address' => $mac, }; } sub login_info { @@ -295,8 +213,8 @@ sub login_info { my %info = ( %{ skin_info($p) }, - 'phone_login' => $conf->exists('selfservice_server-phone_login'), - 'single_domain' => scalar($conf->config('selfservice_server-single_domain')), + 'phone_login' => $conf->exists('selfservice_server-phone_login'), + 'single_domain'=> scalar($conf->config('selfservice_server-single_domain')), 'banner_url' => scalar($conf->config('selfservice-login_banner_url')), 'banner_image_md5' => md5_hex($conf->config_binary('selfservice-login_banner_image')), @@ -343,20 +261,14 @@ sub login { } elsif ( $p->{'domain'} eq 'ip_mac' ) { - return { error => 'MAC address empty '.$p->{'username'} } - unless $p->{'username'}; - my $mac_address = $p->{'username'}; - $mac_address =~ s/[\:\,\-\. ]//g; - $mac_address =~ tr/[a-z]/[A-Z/; + $mac_address =~ s/\://g; my $svc_broadband = qsearchs( 'svc_broadband', { 'mac_addr' => $mac_address } ); return { error => 'MAC address not found '.$p->{'username'} } unless $svc_broadband; $svc_x = $svc_broadband; - $session->{'domain'} = $p->{'domain'}; - } elsif ( $p->{email} && (my $contact = FS::contact->by_selfservice_email($p->{email})) ) diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm index 464bd6374..76992af8d 100644 --- a/FS/FS/ClientAPI_XMLRPC.pm +++ b/FS/FS/ClientAPI_XMLRPC.pm @@ -223,7 +223,6 @@ sub ss2clientapi { 'quotation_remove_pkg' => 'MyAccount/quotation/quotation_remove_pkg', 'quotation_order' => 'MyAccount/quotation/quotation_order', 'get_mac_address' => 'MyAccount/get_mac_address', - 'check_access' => 'MyAccount/check_access', 'freesideinc_service' => 'Freeside/freesideinc_service', }; -- cgit v1.2.1