2 # Show installed packages, and flag those for which an update is needed
4 require './package-updates-lib.pl';
5 &ui_print_header(undef, $module_info{'desc'}, "", undef, 1, 1);
6 &error_setup($text{'index_err'});
12 # See if any security updates exist
13 $in{'mode'} ||= 'updates';
14 @avail = &list_for_mode($in{'mode'}, 0);
15 ($sec) = grep { $_->{'security'} } @avail;
17 # Show mode selector (all, updates only, updates and new)
19 foreach $m ('current', 'updates', 'new',
20 $sec ? ( 'security' ) : ( )) {
21 $mmsg = $text{'index_mode_'.$m};
22 if ($in{'mode'} eq $m) {
23 push(@mlinks, "<b>$mmsg</b>");
26 push(@mlinks, "<a href='index.cgi?mode=$m&all=".
27 &urlize($in{'all'})."&search=".
28 &urlize($in{'search'})."'>$mmsg</a>");
31 push(@grid, $text{'index_mode'}, &ui_links_row(\@mlinks));
34 push(@grid, $text{'index_search'}, &ui_textbox("search", $in{'search'}, 30)." ".
35 &ui_submit($text{'index_searchok'})." ".
36 &ui_submit($text{'index_clear'}, 'clear'));
38 print &ui_form_start("index.cgi");
39 print &ui_hidden("mode", $in{'mode'});
40 print &ui_grid_table(\@grid, 2),"<p>\n";
43 # Work out what packages to show
44 @current = &list_current(1);
47 %current = map { $_->{'name'}."/".$_->{'system'}, $_ } @current;
48 %avail = map { $_->{'name'}."/".$_->{'system'}, $_ } @avail;
52 foreach $p (sort { $a->{'name'} cmp $b->{'name'} } (@current, @avail)) {
53 next if ($done{$p->{'name'},$p->{'system'}}++); # May be in both lists
56 $c = $current{$p->{'name'}."/".$p->{'system'}};
57 $a = $avail{$p->{'name'}."/".$p->{'system'}};
59 if ($a && $c && &compare_versions($a, $c) > 0) {
60 # An update is available
61 $msg = "<b><font color=#00aa00>".
62 &text('index_new', $a->{'version'})."</font></b>";
64 next if ($in{'mode'} eq 'security' && !$a->{'security'});
65 next if ($in{'mode'} ne 'updates' &&
66 $in{'mode'} ne 'current' &&
67 $in{'mode'} ne 'security');
70 # Could be installed, but isn't currently
71 next if (!&installation_candiate($a));
72 $msg = "<font color=#00aa00>$text{'index_caninstall'}</font>";
74 next if ($in{'mode'} ne 'new');
76 elsif (!$a->{'version'} && $c->{'updateonly'}) {
77 # No update exists, and we don't care unless there is one
80 elsif (!$a->{'version'}) {
82 $msg = "<font color=#ffaa00><b>".
83 &text('index_noupdate', $c->{'version'})."</b></font>";
85 next if ($in{'mode'} ne 'current');
89 $msg = &text('index_ok', $c->{'version'});
91 next if ($in{'mode'} ne 'current');
93 $source = ucfirst($a->{'source'});
94 if ($a->{'security'}) {
95 $source = "<font color=#ff0000>$source</font>";
98 # If searching, limit to search
101 $found = $p->{'desc'} =~ /\Q$re\E/i ||
102 $p->{'name'} =~ /\Q$re\E/i ||
103 $p->{'version'} =~ /\Q$re\E/i;
109 { 'type' => 'checkbox', 'name' => 'u',
110 'value' => $p->{'update'}."/".$p->{'system'},
111 'checked' => $need },
112 "<a href='view.cgi?mode=$in{'mode'}&name=".
113 &urlize($p->{'name'})."&system=".
114 &urlize($p->{'system'})."&search=".
115 &urlize($in{'search'})."'>$p->{'name'}</a>",
118 $source ? ( $source ) : $anysource ? ( "") : ( ),
120 $anysource++ if ($source);
123 # Show the packages, if any
125 print &text('index_count', scalar(@rows)),"<br>\n";
127 print &ui_form_columns_table(
129 [ [ "ok", $in{'mode'} eq 'new' ? $text{'index_install'}
130 : $text{'index_update'} ],
132 [ "refresh", $text{'index_refresh'} ] ],
135 [ [ "mode", $in{'mode'} ],
136 [ "search", $in{'search'} ] ],
137 [ "", $text{'index_name'}, $text{'index_desc'}, $text{'index_status'},
138 $anysource ? ( $text{'index_source'} ) : ( ), ],
144 $text{'index_none_'.$in{'mode'}},
148 print &ui_form_start("update.cgi");
149 print &ui_hidden("mode", $in{'mode'});
150 print &ui_hidden("search", $in{'search'});
151 print &ui_form_end([ [ "refresh", $text{'index_refresh'} ] ]);
154 # Show scheduled report form
156 print &ui_form_start("save_sched.cgi");
157 print &ui_hidden("mode", $in{'mode'});
158 print &ui_hidden("search", $in{'search'});
159 print &ui_table_start($text{'index_header'}, undef, 2);
161 $job = &find_cron_job();
163 $sched = $job->{'hours'} eq '*' ? 'h' :
164 $job->{'days'} eq '*' && $job->{'weekdays'} eq '*' ? 'd' :
165 $job->{'days'} eq '*' && $job->{'months'} eq '*' ? 'w' :
173 print &ui_table_row($text{'index_sched'},
174 &ui_radio("sched_def", $job ? 0 : 1,
175 [ [ 1, $text{'index_sched1'} ],
176 [ 0, $text{'index_sched0'} ] ])."\n".
177 &ui_select("sched", $sched,
178 [ [ 'h', $text{'index_schedh'} ],
179 [ 'd', $text{'index_schedd'} ],
180 [ 'w', $text{'index_schedw'} ] ]));
183 print &ui_table_row($text{'index_email'},
184 &ui_textbox("email", $config{'sched_email'}, 40));
186 # Install or just notify?
187 print &ui_table_row($text{'index_action'},
188 &ui_radio("action", int($config{'sched_action'}),
189 [ [ 0, $text{'index_action0'} ],
190 [ 1, $text{'index_action1'} ],
191 [ 2, $text{'index_action2'} ] ]));
193 print &ui_table_end();
194 print &ui_form_end([ [ "save", $text{'save'} ] ]);
196 &ui_print_footer("/", $text{'index'});