- '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 ) ||