-
-my @processed_menu;
-foreach my $submenu (@menu) {
-
- my @links;
- my $first = 1;
- foreach my $entry ( @$submenu ) {
- # if the menu head was skipped, skip the whole menu
- last if (!$first and !@links);
- $first = 0;
-
- my $a = entry2link($entry, $cust_main, $opt{show});
- push @links, $a if length($a);
-
- } # foreach $entry
-
- if (@links) {
- push @processed_menu, \@links;
- }
-
-}
-
-sub entry2link {
- my( $entry, $cust_main, $show ) = @_;
-
- # check conditions
- if ( $entry->{acl} ) {
- return ''
- unless $FS::CurrentUser::CurrentUser->access_right( $entry->{acl} );
- }
- if ( $entry->{confexists} ) {
- if ( $entry->{confexists} =~ /^!(.*)/ ) {
- # confexists => !foo, a negative condition
- return '' if FS::Conf->new->exists( $1 );
- } else {
- return '' unless FS::Conf->new->exists( $entry->{confexists} );
- }
- }
- if ( $entry->{condition} ) {
- return '' unless &{ $entry->{condition} }($cust_main);
- }
-
- my $label = emt($entry->{label});
-
- if ( $entry->{submenu} ) {
-
- my $a = '<a href="javascript:void(0);">'. $label.
- '<span class="arrow"></span>'.
- '</a><ul class="customer_subsubmenu">';
- foreach my $submenu (@{ $entry->{submenu} }) {
- $a .= '<li>'. entry2link($submenu, $cust_main, $show), '</li>';
- }
-
- return $a. '</ul>';
-
- }
-
- my $target = $entry->{content}
- || $entry->{popup}
- || $entry->{url};
-
- if ( ref($target) eq 'CODE' ) {
- $target = &$target($cust_main);
- }
-
- return $target if $entry->{content}; #the coderef specified the whole thing
-
- if ( $entry->{show} ) {
-
- # the menu head: always a link back to this page
- $cgi->param('show', $entry->{show});
-
- #$target = $cgi->self_url;
- #XXX support installs outside /freeside in 4.x
- $target = '/freeside/view/cust_main.cgi?'.
- 'show='. $entry->{show}.
- ';custnum='. $cust_main->custnum;
-
- $cgi->param('show', $show);
-
- my $a = qq[ <A HREF="$target"];
- $a .= ' class="current_show"' if $show eq $entry->{show};
- return $a. qq[>$label</A> ];
-
- } elsif ( $entry->{popup} ) {
-
- $target =~ s/\$custnum/$custnum/g;
- $target = $p.$target;
-
- return include('/elements/popup_link.html',
- action => $target,
- width => 616,
- height => 410,
- %$entry,
- label => $label,
- );
-
- } elsif ( $entry->{url} ) {
-
- $target =~ s/\$custnum/$custnum/g;
- $target = $p.$target;
-
- return qq[ <A HREF="$target">$label</A> ];
-
- } else {
- die "bad entry ". join(',',%$entry). " in menu: no url, popup or content";
- }
-
-}
-