5 =head1 NAME $RCSfile: processnotification.cgi,v $
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Oct 25 11:10:47 PDT 2008
27 $Date: 2011/02/14 14:53:07 $
33 Usage processnotification.cgi: [-u|sage] [-ve|rbose] [-d|ebug]
34 action=[Add|Delete|Edit|Post]
35 notification=<notificationname>
38 -u|sage: Displays usage
40 -d|ebug: Output debug messages
42 action: Specifies to add, delete, edit or post an alert
43 notification: Name of notification to delete or edit
47 This script adds, deletes, edits or posts a notification
56 use CGI qw (:standard :cgi-lib *table start_Tr end_Tr);
57 use CGI::Carp 'fatalsToBrowser';
59 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
66 my $VERSION = '$Revision: 1.3 $';
67 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
73 usage => sub { Usage },
74 verbose => sub { set_verbose },
75 debug => sub { set_debug },
76 ) or Usage 'Invalid parameter';
79 verbose "$FindBin::Script v$VERSION";
81 $clearadm = Clearadm->new;
85 my $title = 'Notifications';
89 unless ($opts{'delete.x'} or $opts{'edit.x'} or $opts{action}) {
90 displayError 'Action not defined!';
94 unless ($opts{action} eq 'Add') {
95 unless ($opts{name}) {
96 displayError 'Notification not defined!';
103 if ($opts{action} eq 'Add') {
104 display h1 {class => 'center'}, 'Add Notification';
106 } elsif ($opts{'delete.x'}) {
107 ($err, $msg) = $clearadm->DeleteNotification ($opts{name});
109 if ($msg !~ /Records deleted/) {
110 displayError "Unable to delete notification $opts{name}\n$msg";
112 display h1 {class => 'center'}, $title;
113 display h3 {class => 'center'}, "Notification '$opts{name}' deleted";
117 } elsif ($opts{'edit.x'}) {
118 display h1 {class => 'center'}, 'Edit Notification: ', $opts{name};
119 editNotification ($opts{name});
120 } elsif ($opts{action} eq 'Post') {
121 delete $opts{action};
123 my %notification = $clearadm->GetNotification ($opts{name});
125 # System and Filesystem are links to tables of the same name. If specified
126 # they need to match up to an existing system or they can be null. If we
127 # have this as an edited field and the user puts nothing in them then we
128 # get '', which won't work. So change '' -> undef.
130 # TODO: Should think about making these dropdowns instead (However that would
131 # require AJAX to update filesystem when system changes). For now let's do
133 # $opts{system} = undef
134 # if $opts{system} eq '';
135 # $opts{filesystem} = undef
136 # if $opts{filesystem} eq '';
138 if (%notification or $opts{oldname}) {
139 my $name = delete $opts{oldname};
141 $name ||= $opts{name};
143 ($err, $msg) = $clearadm->UpdateNotification ($name, %opts);
146 displayError "$msg (Status: $err)";
148 display h1 {class => 'center'}, $title;
149 display h3 {class => 'center'}, "Notification '$opts{name}' updated";
154 ($err, $msg) = $clearadm->AddNotification (%opts);
157 displayError "$msg (Status: $err)";
160 display h1 {class => 'center'}, $title;
161 display h3 {class => 'center'}, "Notification '$opts{name}' added";
167 displayError "Unknown action - $opts{action}";
174 =head1 CONFIGURATION AND ENVIRONMENT
176 DEBUG: If set then $debug is set to this level.
178 VERBOSE: If set then $verbose is set to this level.
180 TRACE: If set then $trace is set to this level.
188 L<CGI::Carp|CGI::Carp>
192 L<Getopt::Long|Getopt::Long>
194 =head2 ClearSCM Perl Modules
208 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
209 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
210 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
211 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
216 =head1 BUGS AND LIMITATIONS
218 There are no known bugs in this script
220 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
222 =head1 LICENSE AND COPYRIGHT
224 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.