5 =head1 NAME $RCSfile: processalert.cgi,v $
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Oct 25 11:10:47 PDT 2008
27 $Date: 2011/02/14 14:51:54 $
33 Usage processalert.cgi: [-u|sage] [-ve|rbose] [-d|ebug]
34 action=[Add|Delete|Edit|Post] alert=<alertname>
37 -u|sage: Displays usage
39 -d|ebug: Output debug messages
41 action: Specifies to add, delete, edit or post an alert
42 alert: Name of alert to delete or edit
46 This script adds, deletes, edits or posts an alert
55 use CGI qw (:standard :cgi-lib *table start_Tr end_Tr);
56 use CGI::Carp 'fatalsToBrowser';
58 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
65 my $VERSION = '$Revision: 1.3 $';
66 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
72 usage => sub { Usage },
73 verbose => sub { set_verbose },
74 debug => sub { set_debug },
75 ) or Usage 'Invalid parameter';
78 verbose "$FindBin::Script v$VERSION";
80 $clearadm = Clearadm->new;
88 unless ($opts{'delete.x'} or $opts{'edit.x'} or $opts{action}) {
89 displayError 'Action not defined!';
93 unless ($opts{action} eq 'Add') {
94 unless ($opts{name}) {
95 displayError 'Alert not defined!';
102 if ($opts{action} eq 'Add') {
103 display h1 {class => 'center'}, 'Add Alert';
105 } elsif ($opts{'delete.x'}) {
106 ($err, $msg) = $clearadm->DeleteAlert ($opts{name});
108 if ($msg !~ /Records deleted/) {
109 displayError "Unable to delete alert $opts{name}\n$msg";
111 display h1 {class => 'center'}, $title;
112 display h3 {class => 'center'}, "Alert '$opts{name}' deleted";
116 } elsif ($opts{'edit.x'}) {
117 display h1 {class => 'center'}, 'Edit Alert: ', $opts{name};
118 editAlert ($opts{name});
119 } elsif ($opts{action} eq 'Post') {
120 delete $opts{action};
122 my %system = $clearadm->GetAlert ($opts{name});
124 if (%system or $opts{oldname}) {
125 my $name = delete $opts{oldname};
127 $name ||= $opts{name};
129 ($err, $msg) = $clearadm->UpdateAlert ($name, %opts);
132 displayError "$msg (Status: $err)";
134 display h1 {class => 'center'}, $title;
135 display h3 {class => 'center'}, "Alert '$opts{name}' updated";
140 ($err, $msg) = $clearadm->AddAlert (%opts);
143 displayError "$msg (Status: $err)";
146 display h1 {class => 'center'}, $title;
147 display h3 {class => 'center'}, "Alert '$opts{name}' added";
153 displayError "Unknown action - $opts{action}";
160 =head1 CONFIGURATION AND ENVIRONMENT
162 DEBUG: If set then $debug is set to this level.
164 VERBOSE: If set then $verbose is set to this level.
166 TRACE: If set then $trace is set to this level.
174 L<CGI::Carp|CGI::Carp>
178 L<Getopt::Long|Getopt::Long>
180 =head2 ClearSCM Perl Modules
194 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
195 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
196 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
197 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
202 =head1 BUGS AND LIMITATIONS
204 There are no known bugs in this script
206 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
208 =head1 LICENSE AND COPYRIGHT
210 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.