<%doc> -- Device tasks for regular users -- Show drop-down box with devices for which user has permissions <%attr> title => 'Device Tasks for End Users' % % %####################################################################### %# %# Args section %# %####################################################################### <%args> $editints => undef $id => undef $user => $ui->get_current_user($r) $submit => undef $show_device => undef $show_tasks => undef $ifsort => "number" $showheader => 1 % % % %####################################################################### %# %# 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 ); $ARGS{show_tasks} = $show_tasks;
>
My devices
% print_showtaskslink($show_tasks);
"> <%perl> my @devs; my $ao = $ui->get_allowed_objects($r, $user); if ( exists $ao->{Device} ){ foreach my $id ( keys %{$ao->{Device}} ){ if ( my $dev = Device->retrieve($id) ){ push @devs, $dev; }else{ delete $ao->{Device}->{$id}; } } }

% if ( @devs ){

% }else{ No devices available for this user. % }
<%perl> if ( $show_device || $id ){ if($id){ $m->comp('user_device.html', id=>$id, ifsort=>$ifsort, editints=>$editints ); } else{ $m->comp('user_device.html', id=>$show_device, ifsort=>$ifsort ); } }