<%doc> Contact Lists % <%attr> title => 'Contact Lists' % % %####################################################################### %# %# Args section %# %####################################################################### <%args> $search => undef $search_clist => undef $user => $ui->get_current_user($r); $submit_list => undef $submit_insert => undef $show_tasks => undef $showheader => 1 $_action => undef $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 @list; my $manager = $ui->get_permission_manager($r); my $id;
>
Contacts Tasks
% if ( $manager && $manager->can($user, 'access_admin_section', 'clists.html:new') ){ % if ( $view eq 'search' ){ [new] % }elsif ( $view eq 'new' ){ [search] % } % } % print_showtaskslink($show_tasks);
">
% if ( $view eq 'search' ){
Search

% }elsif ( $view eq 'new' ){
Add a New Contact List

% print $ui->form_field(table=>"ContactList", column=>"name", edit=>1, htmlExtra=>'class="txt"', returnValOnly=>1, no_help=>1);

% print $ui->form_field(table=>"ContactList", column=>"info", edit=>1, returnValOnly=>1, no_help=>1);

(*) Field is required

% }
<%perl> ####################################################################################### # Search # ####################################################################################### # Remove trailing and leading spaces if ( $submit_list && $search_clist ){ $search = $ui->rem_lt_sp($search_clist); @list = ContactList->search_like(name=>$search); }elsif ( $submit_list ) { $m->comp('/generic/no_search_criteria.html'); } ####################################################################################### # Add List ####################################################################################### if ( $submit_insert ){ my %ret; eval { %ret = $ui->form_to_db(%ARGS); print 'form_to_db returned:
', Dumper(%ret), '

' if $DEBUG; }; if ( my $e = $@ ) { $m->comp('/generic/error.mhtml', error=>$e); } if ( %ret ){ $id = (keys %{$ret{'ContactList'}{id}})[0]; $_action = "VIEW"; } } % if ( $search ){ % if ( scalar @list > 1 ){
Query <% $search %> returned: <% scalar(@list) %> matches
<& /generic/sortresults.mhtml, object=>\@list, page=>'view.html', withedit=>0 &>
% }elsif ( scalar @list == 1 ){ % my $viewid = $list[0]->id; % $m->comp('/generic/contactlist.html', table=>'ContactList', id=>$viewid); % }else{ % $m->comp('/generic/no_search_results.html', search=>$search); % } % } % if ( $_action eq "VIEW" && $id ){ % $m->comp('/generic/view.html', table=>"ContactList", id=>$id); % }