<%doc> -- DHCP tasks -- % <%attr> title => 'DHCP Tasks' % % %####################################################################### %# %# Args section %# %####################################################################### <%args> $user => $ui->get_current_user($r) $action => undef $search => undef $scope_id => undef $scope_name => undef $scope_type => undef $scope_container => undef $scope_version => undef $submit => undef $show_tasks => undef $showheader => 1 $view => 'search' % % % %####################################################################### %# %# INIT section %# %####################################################################### % <%init> my $DEBUG = 0; print '%ARGS is
', Dumper(%ARGS), '

' if $DEBUG; $show_tasks = $show_tasks || $user->getAttribute("SHOW_TASKS"); if ( $show_tasks eq "" ) { $user->setAttribute($r, "SHOW_TASKS", "show"); $show_tasks = "show"; } *print_showtaskslink = $m->comp('SELF:.sub_print_showtaskslink'); my $hideheader = 'style="display:none"' if ( !$showheader ); my @global_scopes = DhcpScope->search(type=>'global'); my @containers = DhcpScope->get_containers(); my $manager = $ui->get_permission_manager($r);
>
DHCP Tasks
% if ( $manager && $manager->can($user, 'access_admin_section', 'dhcp_tasks:new') ){ % if ( $view eq 'search' ){ [new] % }elsif ( $view eq 'new' ){ [search] % } % } % print_showtaskslink($show_tasks);
">
% if ( $view eq 'search' ){
Find

% }elsif ( $view eq 'new' ){ % unless ( $manager && $manager->can($user, 'access_admin_section', 'dhcp_tasks.html:new') ){ % $m->comp('/generic/error.mhtml', error => "You do not have permission to add new scopes here"); % }
Add New Scope

(required unless global)

(Only for global)

% }
<%perl> if ( $scope_id ){ $m->comp("scope.html", id=>$scope_id); } ####################################################################################### # Search # ####################################################################################### elsif ( $action eq "search" ) { if (!(defined $search)) { $m->comp('/generic/error.mhtml', error=>"You need to specify a scope name"); } my @scopes = DhcpScope->search_like(name=>$search); print '
'; print '
DHCP Scopes
'; print '
'; if ( @scopes ){ my $with_edit = ($manager && $manager->can($user, 'access_admin_section', 'dhcp_tasks:edit'))? 1 : 0; $m->comp('/generic/sortresults.mhtml', object=>\@scopes, withedit=>$with_edit); }else{ print "No matches"; } print '
'; print '
'; } ####################################################################################### # New zone # ####################################################################################### elsif ( $action eq "new" ) { if (!(defined $scope_name)) { $m->comp('/generic/error.mhtml', error=>"You need to specify a scope name"); } my $scope; eval { $scope = DhcpScope->insert({name => $scope_name, type => $scope_type, container => $scope_container, version => $scope_version, }); }; if ( my $e = $@ ){ $m->comp("/generic/error.mhtml", error=>$e); }else{ $m->comp("scope.html", id=>$scope->id); } }