%doc>
-- DHCP tasks --
%doc>
%
<%attr>
title => 'DHCP Tasks'
%attr>
%
%
%#######################################################################
%#
%# 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'
%args>
%
%
%
%#######################################################################
%#
%# 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);
%init>
<%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);
}
}
%perl>