2 ################################################################################
4 # File: $RCSfile: list.cgi,v $
5 # Revision: $Revision: 1.1 $
6 # Description: Manage lists
7 # Author: Andrew@DeFaria.com
8 # Created: Mon Jan 16 20:25:32 PST 2006
9 # Modified: $Date: 2013/06/12 14:05:47 $
12 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
14 ################################################################################
19 $0 = $FindBin::Script;
21 use lib $FindBin::Bin;
27 use CGI qw (:standard *table start_div end_div);
28 use CGI::Carp "fatalsToBrowser";
30 my $next = param ("next");
31 my $lines = param ("lines");
32 my $type = param ("type");
33 my $message = param ("message");
34 my $Type = ucfirst $type;
39 my $table_name = "list";
44 if (defined $message) {
45 print div {-align => "center"},
46 font {-class => "error"}, $message;
51 -action => "processaction.cgi",
55 # Print some hidden fields to pass along
57 hidden (-name => "type",
59 hidden (-name => "next",
62 my $current = $next + 1;
64 print div {-align => "center"}, b (
65 "(" . $current . "-" . $last . " of " . $total . ")");
66 print start_div {-class => "toolbar",
68 my $prev_button = $prev >= 0 ?
69 a ({-href => "list.cgi?type=$type;next=$prev"},
70 "<img src=/maps/images/previous.gif border=0 alt=Previous align=middle>") : "";
71 my $next_button = ($next + $lines) < $total ?
72 a {-href => "list.cgi?type=$type;next=" . ($next + $lines)},
73 "<img src=/maps/images/next.gif border=0 alt=Next align=middle>" : "";
75 submit ({-name => "action",
76 -value => "Add New Entry",
77 -onClick => "return NoneChecked (document.list);"}),
78 submit ({-name => "action",
79 -value => "Delete Marked",
80 -onClick => "return CheckAtLeast1Checked (document.list) && AreYouSure ('Are you sure you want to delete these entries?');"}),
81 submit ({-name => "action",
82 -value => "Modify Marked",
83 -onClick => "return CheckAtLeast1Checked (document.list);"}),
84 submit ({-name => "action",
85 -value => "Reset Marks",
86 -onClick => "return ClearAll (document.list);"}),
89 print start_table {-align => "center",
96 th {-class => "tableleftend"}, "Seq",
97 th {-class => "tableheader"}, "Mark",
98 th {-class => "tableheader"}, "Username",
99 th {-class => "tableheader"}, "@",
100 th {-class => "tableheader"}, "Domain",
101 th {-class => "tablerightend"}, "Comments"
104 my @list = ReturnList $type, $next, $lines;
110 $record{pattern} = " " if !defined $record{pattern};
111 $record{domain} = " " if !defined $record{domain};
112 $record{comment} = " " if !defined $record{comment};
114 my $leftclass = ($i eq $lines || $record{sequence} eq $total) ?
115 "tablebottomleft" : "tableleftdata";
116 my $dataclass = ($i eq $lines || $record{sequence} eq $total) ?
117 "tablebottomdata" : "tabledata";
118 my $rightclass = ($i eq $lines || $record{sequence} eq $total) ?
119 "tablebottomright" : "tablerightdata";
123 td {-class => $leftclass,
124 -align => "center"}, $record{sequence},
125 td {-class => $dataclass,
127 checkbox ({-name => "action$record{sequence}",
129 td {-class => $dataclass,
130 -align => "right"}, $record{pattern},
131 td {-class => $dataclass,
132 -align => "center"}, "\@",
133 td {-class => $dataclass,
134 -align => "left"}, $record{domain},
135 td {-class => $rightclass,
136 -align => "left"}, $record{comment}
142 print div ({-align => "center"},
143 a ({-href => "/maps/bin/exportlist.cgi?type=$type"},
144 submit ({-name => "export",
145 -value => "Export list"})),
146 a ({-href => "/maps/bin/importlist.cgi?type=$type"},
147 submit ({-name => "import",
148 -value => "Import List"})));
152 my @scripts = ("ListActions.js");
165 NavigationBar $userid;
167 if (!defined $lines) {
168 my %options = GetUserOptions $userid;
169 $lines = $options{"Page"};
172 $total = MAPSDB::count "list", "userid = \"$userid\" and type = \"$type\"";;
174 $next = !defined $next ? 0 : $next;
175 $last = $next + $lines < $total ? $next + $lines : $total;
177 if (($next - $lines) > 0) {
178 $prev = $next - $lines;
180 $prev = $next eq 0 ? -1 : 0;