[system] / trunk / webwork2 / lib / WeBWorK / ContentGenerator / Instructor / SendMail.pm Repository:
ViewVC logotype

Annotation of /trunk/webwork2/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1369 - (view) (download) (as text)

1 : gage 1368 package WeBWorK::ContentGenerator::Instructor::SendMail;
2 :     use base qw(WeBWorK::ContentGenerator::Instructor);
3 :    
4 :     =head1 NAME
5 :    
6 :     WeBWorK::ContentGenerator::Instructor::SendMail - Entry point for User-specific data editing
7 :    
8 :     =cut
9 :    
10 :     use strict;
11 :     use warnings;
12 :     use CGI qw();
13 :    
14 :     sub initialize {
15 :     my ($self) = @_;
16 :     my $r = $self->{r};
17 :     my $db = $self->{db};
18 :     my $ce = $self->{ce};
19 :     my $authz = $self->{authz};
20 :     my $user = $r->param('user');
21 :    
22 :     unless ($authz->hasPermissions($user, "send_mail")) {
23 :     $self->{submitError} = "You are not authorized to send mail to students.";
24 :     return;
25 :     }
26 : gage 1369 #############################################################################################
27 :     # gather directory data
28 :     #############################################################################################
29 :     my $emailDirectory = $ce->{courseDirs}->{email};
30 :     my $scoringDirectory = $ce->{courseDirs}->{scoring};
31 :     my $templateDirectory = $ce->{courseDirs}->{templates};
32 : gage 1368
33 : gage 1369 my $action = $r->param('action');
34 :     my $openfilename = $r->param('openfilename');
35 :     my $savefilename = $r->param('savefilename');
36 :     #FIXME get these values
37 :     my $default_msg = 'default.msg';
38 :     my $old_default_msg = 'old_default.msg';
39 :     my $defaultFrom = 'FIXME from';
40 :     my $defaultReply = 'FIXME reply';
41 :     #############################################################################################
42 :     # Get directory file name
43 :     #############################################################################################
44 :    
45 :     #make sure message file was submitted and exists
46 :     my $messageFileName;
47 :     if (defined($openfilename) && -e "${emailDirectory}$openfilename") {
48 :     if ( -R "${emailDirectory}$openfilename") {
49 :     $messageFileName = $openfilename;
50 :     } else {
51 :     warn "The file ${emailDirectory}$openfilename is not readable by the webserver.
52 :     Check that it's permissions are set correctly.";
53 :     }
54 :     } else {
55 :     $messageFileName = $default_msg;
56 :     }
57 :    
58 :     $self->{messageFileName}=$messageFileName;
59 :    
60 :     # make sure that the file path is legal (lies below inside the email directory
61 :     if (defined($savefilename) && ($savefilename =~ /^[~.]/ or $savefilename =~ /\.\./ ) ){
62 :     $self->fatal_error("For security reasons, you cannot save a message",
63 :     "in any directory higher than the email directory.",
64 :     "Please specify a file name to save under.");
65 :     }
66 :    
67 :     #############################################################################################
68 :     # if no form is submitted gather data from default message file and return
69 :     #############################################################################################
70 :    
71 :     unless (defined($action) ){
72 :     #############################################################################################
73 :     #get message from given messageFileName
74 :     #############################################################################################
75 :     my ($text, @text);
76 :     my $header = '';
77 :     my ($subject, $from, $replyTo);
78 :     if (-e "$emailDirectory/$messageFileName") {
79 :     open FILE, "$emailDirectory/$messageFileName" || $self->fatal_error("Can't open $emailDirectory/$messageFileName");
80 :     while ($header !~ s/Message:\s*$//m) {
81 :     $header .= <FILE>;
82 :     }
83 :     $text = join( '', <FILE>);
84 :     $text .= "from $emailDirectory/$messageFileName";
85 :     $header =~ /^From:\s(.*)$/m;
86 :     $from = $1 or $from = $defaultFrom; #given email address or default feedback address
87 :     $header =~ /^Reply-To:\s(.*)$/m;
88 :     $replyTo = $1 or $replyTo = $defaultReply;
89 :     $header =~ /^Subject:\s(.*)$/m;
90 :     $subject = $1;
91 :    
92 :     } else {
93 :     $from = $defaultFrom;
94 :     $replyTo = $defaultReply;
95 :     $text = "FIXME file $emailDirectory/$messageFileName doesn't exist";
96 :     $subject = "FIXME default subject";
97 :     }
98 :     #############################################################################################
99 :     # store info for body subroutine
100 :     #############################################################################################
101 :     $self->{openfilename }= $openfilename;
102 :     $self->{savefilename }= $savefilename;
103 :     $self->{from} = $from;
104 :     $self->{replyTo} = $replyTo;
105 :     $self->{subject} = $subject;
106 :     $self->{r_text} = \$text;
107 :     $self->{rows} = (defined($r->param('rows'))) ? $r->param('rows') : $ce->{mail}->{editor_window_rows};
108 :     $self->{columns} = (defined($r->param('columns'))) ? $r->param('columns') : $ce->{mail}->{editor_window_columns};
109 :     $self->{default_msg} = $default_msg;
110 :     $self->{old_default_msg} = $old_default_msg;
111 :    
112 :     return '';
113 :     }
114 :    
115 :    
116 :    
117 :    
118 :    
119 :     #############################################################################################
120 :     # If form is submitted deal with filled out forms
121 :     # and various actions resulting from different buttons
122 :     #############################################################################################
123 :    
124 :     my $from = $r->param('from');
125 :     my $to = $r->param('To');
126 :     my $replyTo = $r->param('replyTo');
127 :     my $subject = $r->param('subject');
128 :     my $body = $r->param('body');
129 :    
130 :    
131 :    
132 :     # script action
133 :     my $script_action = '';
134 :     # user_errors
135 :     # save
136 :     # save as
137 :     # save as default
138 :     # send mail
139 :     # set defaults
140 :    
141 :    
142 :    
143 :     #if Save button was clicked
144 :     if (( $r->param('action') eq 'Save') && defined($r->param('body')) && defined($r->param('savefilename'))) {
145 :    
146 :     my $temp_body = $body;
147 :     $temp_body =~ s/\r\n/\n/g;
148 :     $temp_body = "From: " . $from . "\n" .
149 :     "Reply-To: " . $replyTo . "\n" .
150 :     "Subject: " . $subject . "\n" .
151 :     "Message: \n" . $temp_body;
152 :    
153 :     saveProblem($temp_body, $savefilename);
154 :     $messageFileName = $savefilename;
155 :    
156 :     #if Save As button was clicked
157 :     } elsif (( $r->param('action') eq 'Save as') && defined($r->param('body')) && defined($r->param('savefilename'))) {
158 :    
159 :     $messageFileName = $savefilename;
160 :    
161 :     if ($messageFileName =~ /^[~.]/ || $messageFileName =~ /\.\./) {
162 :     $self->fatal_error("For security reasons, you cannot specify a merge file from a directory higher than the email directory (you can't use ../blah/blah). Please specify a different file or move the needed file to the email directory");
163 :     }
164 :    
165 :    
166 :     my $temp_body = $body;
167 :     $temp_body =~ s/\r\n/\n/g;
168 :     $temp_body = join("",
169 :     "From: $from \nReply-To: $replyTo)\n" ,
170 :     "Subject: $subject\n" ,
171 :     "Message: \n $temp_body");
172 :    
173 :     saveNewProblem($temp_body, $messageFileName);
174 :    
175 :     #if Save As Default button was clicked
176 :     } elsif (( $r->param('action') eq 'Save as Default') && defined($r->param('body'))) {
177 :    
178 :     my $temp_body;
179 :     $temp_body = $r->param('body');
180 :     $temp_body =~ s/\r\n/\n/g;
181 :    
182 :     #get default.msg and back it up in default.old.msg
183 :     open DEFAULT, "$emailDirectory/$default_msg";
184 :     $temp_body = <DEFAULT>;
185 :     close DEFAULT;
186 :    
187 :     if ( -e "$emailDirectory/$old_default_msg") {
188 :     # saveProblem($temp_body, $old_default_msg);
189 :     } else {
190 :     # saveNewProblem($temp_body, $old_default_msg);
191 :     }
192 :    
193 :     #save new default message as default.msg
194 :     $temp_body = $body;
195 :     $temp_body =~ s/\r\n/\n/g;
196 :     $temp_body = join("",
197 :     "From: $from \nReply-To: $replyTo)\n" ,
198 :     "Subject: $subject\n" ,
199 :     "Message: \n $temp_body");
200 :    
201 :     # saveProblem($temp_body, $default_msg);
202 :     $messageFileName = $default_msg;
203 :    
204 :     #if Send Email button was clicked
205 :     } elsif ( $r->param('action') eq 'Send Email' ) {
206 :    
207 :     my @studentID = ();
208 :    
209 :     if ($r->param('To') eq 'classList' && defined($r->param('classList')) && $r->param('classList') ne 'None') {
210 :     # my $classlist = $r->param('classList');
211 :     # my $classListFile = "$templateDirectory$classlist";
212 :     # my @classList = ();
213 :     # #FIXME checkClasslistFile($Global::noOfFieldsInClasslist,$classListFile);
214 :     # open(FILE, "$classListFile") || die "can't open $classListFile";
215 :     # @classList=<FILE>;
216 :     # close(FILE);
217 :     #
218 :     # foreach (@classList) { ## read through classlist and send e-mail
219 :     # ## message to all active students
220 :     # unless ($_ =~ /\S/) {next;} ## skip blank lines
221 :     # chomp;
222 :     # my @classListRecord=&getRecord($_);
223 :     # my ($studentID, $lastName, $firstName, $status, $comment, $section, $recitation, $email_address, $login_name)
224 :     # = @classListRecord;
225 :     # unless (&dropStatus($status)) {
226 :     # push (@studentID, $studentID);
227 :     # $fn{$studentID} = $firstName;
228 :     # $ln{$studentID} = $lastName;
229 :     # $section{$studentID} = $section;
230 :     # $recitation{$studentID} = $recitation;
231 :     # $status{$studentID} = $status;
232 :     # $email{$studentID} = $email_address;
233 :     # $login{$studentID} = $login_name;
234 :     # }
235 : gage 1368 # }
236 : gage 1369 } elsif ($r->param('To') eq 'studentID' && defined($r->param('studentID'))) {
237 :     @studentID = $r->param('studentID');
238 :     my ($studentID, $login_name);
239 :     #
240 :     # foreach $studentID (@studentID) {
241 :     # $login_name = $studentID_LoginName_Hash{$studentID};
242 :     # &attachCLRecord($login_name);
243 :     # $fn{$studentID} = CL_getStudentFirstName($login_name);
244 :     # $ln{$studentID} = CL_getStudentLastName($login_name);
245 :     # $section{$studentID} = CL_getClassSection($login_name);
246 :     # $recitation{$studentID} = CL_getClassRecitation($login_name);
247 :     # $status{$studentID} = CL_getStudentStatus($login_name);
248 :     # $email{$studentID} = CL_getStudentEmailAddress($login_name);
249 :     # $login{$studentID} = $login_name;
250 : gage 1368 # }
251 : gage 1369
252 :     } elsif ($r->param('To') eq 'all_students') {
253 :     @studentID = ();
254 :     my ($studentID, $login_name, $status);
255 :    
256 :     # foreach $login_name (@availableStudents) {
257 :     # &attachCLRecord($login_name);
258 :     # $status = CL_getStudentStatus($login_name);
259 :     # next if &dropStatus($status);
260 :     # $studentID = CL_getStudentID($login_name);
261 :     # push(@studentID,$studentID);
262 :     #
263 :     # $fn{$studentID} = CL_getStudentFirstName($login_name);
264 :     # $ln{$studentID} = CL_getStudentLastName($login_name);
265 :     # $section{$studentID} = CL_getClassSection($login_name);
266 :     # $recitation{$studentID} = CL_getClassRecitation($login_name);
267 :     # $status{$studentID} = CL_getStudentStatus($login_name);
268 :     # $email{$studentID} = CL_getStudentEmailAddress($login_name);
269 :     # $login{$studentID} = $login_name;
270 :     # }
271 :     } else {
272 :     $self->fatal_error('You didn\'t select any recipients. Make sure you select either all student in the course, individual students or a whole classlist.');
273 :     }
274 :    
275 :     my $mergeFile = '';
276 :    
277 :     #the radio button named 'merge' determines whether to take the selected mergefile
278 :     #or one that was typed in. A error message is given if select one and use the other
279 :     $mergeFile = $scoringDirectory . $r->param('mergeFiles')
280 :     if ($r->param('merge') eq 'mergeFiles' && defined($r->param('mergeFiles')) && $r->param('mergeFiles') ne 'None');
281 :    
282 :     $mergeFile = $templateDirectory . $r->param('mergeFile')
283 :     if ($r->param('merge') eq 'mergeFile' && defined($r->param('mergeFile')) && $r->param('mergeFile') !~ m|/$|); #does not end in a /
284 :    
285 :     if ($mergeFile =~ /^[~.]/ || $mergeFile =~ /\.\./) {
286 :     $self->fatal_error("For security reasons, you cannot specify a merge file from a directory higher than the email directory. Please specify a different file or move the needed file to the email directory");
287 :     }
288 :     if ($r->param('body') =~ /(\$COL\[.*?\])/ && !(-e $mergeFile)) {
289 :     $self->fatal_error("In order to use the \$COL[] you must specify a merge file. The file you specified does not exist. Also, make sure you selected the right checkbox.");
290 :     }
291 :    
292 :    
293 :     my %mergeAArray = ();
294 :     # unless ($mergeFile eq '') {%mergeAArray = &delim2aa($mergeFile);}
295 :     #
296 :     $self->fatal_error('You didn\'t enter any message.') if ($r->param('body') eq '');
297 :     #
298 :     # foreach my $studentID (@studentID) {
299 :     # @COL =();
300 :     # $SID = $studentID;
301 :     # $LN = defined $ln{$studentID} ? $ln{$studentID} :'';
302 :     # $FN = defined $fn{$studentID} ? $fn{$studentID} :'';
303 :     # $SECTION = defined $section{$studentID} ? $section{$studentID} :'';
304 :     # $RECITATION = defined $recitation{$studentID} ? $recitation{$studentID} :'';
305 :     # $EMAIL = defined $email{$studentID} ? $email{$studentID} :'';
306 :     # $STATUS =defined $status{$studentID} ? $status{$studentID} :'';
307 :     # $LOGIN = $login{$studentID};
308 :     #
309 :     # next if ($LOGIN =~ /^$practiceUser/); ## skip practice users
310 :     #
311 :     # if ($timeout_attempts >= $max_timeout_attempts) { ## have attemped to connect to smtp server
312 :     # ## the max allowed times. Now just collect
313 :     # ## data on emails not sent and exit
314 :     # ++$emails_not_sent;
315 :     # &log_error(\@exceeded_max_timeout,$FN,$LN,$EMAIL);
316 :     # next;
317 :     # }
318 :     #
319 :     # unless ((defined $mergeAArray{$studentID}) or ($mergeFile eq '')) {
320 :     # if ($cgi->param('no_record')) {
321 :     # ++$emails_not_sent;
322 :     # &log_error(\@no_record,$FN,$LN,$EMAIL);
323 :     # next;
324 :     # }
325 :     # }
326 :    
327 :     # my ($dbString, @dbArray);
328 :     # if (defined $mergeAArray{$SID}) {
329 :     # $dbString = $mergeAArray{$SID}; ## get sid record from merge file
330 :     # @dbArray = &getRecord($dbString);
331 :     # unshift(@dbArray,$SID);
332 :     # unshift(@dbArray,""); ## note COL[1] is the first column
333 :     # @COL= @dbArray; ## put merge fields in COL array
334 :     # $endCol = @COL; ## \endCol-1 gives last field, etc
335 :     # }
336 :     # my $smtp;
337 :     # if ($smtp = Net::SMTP->new($Global::smtpServer, Timeout => $timeout_sec)) {} else {
338 :     # # &internal_error("Couldn't contact SMTP server.");
339 :     # ++$emails_not_sent;
340 :     # &log_error(\@timeout_problem,$FN,$LN,$EMAIL);
341 :     # ++$timeout_attempts;
342 :     # next;
343 :     # }
344 :     #
345 :     # $smtp->mail($smtpSender);
346 :     #
347 :     # if ( $smtp->recipient($EMAIL)) { # this one's okay, keep going
348 :     # if ( $smtp->data("To: $EMAIL\n" . output() ) ) {
349 :     # ++$emails_sent;
350 :     # } else {
351 :     # ++$emails_not_sent;
352 :     # &log_error(\@unknown_problem,$FN,$LN,$EMAIL);
353 :     # next;
354 :     # }
355 :     # # &internal_error("Unknown problem sending message data to SMTP server.");
356 :     # } else { # we have a problem with this address
357 :     # $smtp->reset;
358 :     # #&internal_error("SMTP server doesn't like this address: <$EMAIL>.");
359 :     # ++$emails_not_sent;
360 :     # &log_error(\@bad_email_addresses,$FN,$LN,$EMAIL);
361 :     # }
362 :     # $smtp->quit;
363 : gage 1368 # }
364 : gage 1369 # &success;
365 :     }
366 : gage 1368
367 : gage 1369
368 :    
369 :    
370 :     } #end initialize
371 :    
372 : gage 1368 sub fieldEditHTML {
373 :     my ($self, $fieldName, $value, $properties) = @_;
374 :     my $size = $properties->{size};
375 :     my $type = $properties->{type};
376 :     my $access = $properties->{access};
377 :     my $items = $properties->{items};
378 :     my $synonyms = $properties->{synonyms};
379 :    
380 :    
381 :     if ($access eq "readonly") {
382 :     return $value;
383 :     }
384 :     if ($type eq "number" or $type eq "text") {
385 :     return CGI::input({type=>"text", name=>$fieldName, value=>$value, size=>$size});
386 :     }
387 :     if ($type eq "enumerable") {
388 :     my $matched = undef; # Whether a synonym match has occurred
389 :    
390 :     # Process synonyms for enumerable objects
391 :     foreach my $synonym (keys %$synonyms) {
392 :     if ($synonym ne "*" and $value =~ m/$synonym/) {
393 :     $value = $synonyms->{$synonym};
394 :     $matched = 1;
395 :     }
396 :     }
397 :     if (!$matched and exists $synonyms->{"*"}) {
398 :     $value = $synonyms->{"*"};
399 :     }
400 :     return CGI::popup_menu({
401 :     name => $fieldName,
402 :     values => [keys %$items],
403 :     default => $value,
404 :     labels => $items,
405 :     });
406 :     }
407 :     }
408 :    
409 :     sub title {
410 :     my $self = shift;
411 :     return 'Send mail to ' .$self->{ce}->{courseName};
412 :     }
413 :    
414 :     sub path {
415 :     my $self = shift;
416 :     my $args = $_[-1];
417 :    
418 :     my $ce = $self->{ce};
419 :     my $root = $ce->{webworkURLs}->{root};
420 :     my $courseName = $ce->{courseName};
421 :     return $self->pathMacro($args,
422 :     "Home" => "$root",
423 :     $courseName => "$root/$courseName",
424 :     'instructor' => "$root/$courseName/instructor",
425 :     "Send Mail to: $courseName" => '',
426 :     );
427 :     }
428 :    
429 :     sub body {
430 :     my ($self, $setID) = @_;
431 :     my $r = $self->{r};
432 :     my $authz = $self->{authz};
433 :     my $user = $r->param('user');
434 :     my $db = $self->{db};
435 :     my $ce = $self->{ce};
436 :     my $root = $ce->{webworkURLs}->{root};
437 :     my $courseName = $ce->{courseName};
438 :    
439 :     return CGI::em("You are not authorized to access the Instructor tools.") unless $authz->hasPermissions($user, "access_instructor_tools");
440 :    
441 :     my $userTemplate = $db->newUser;
442 :     my $permissionLevelTemplate = $db->newPermissionLevel;
443 :    
444 :     # This code will require changing if the permission and user tables ever have different keys.
445 :     my @users = $db->listUsers;
446 :    
447 :     # This table can be consulted when display-ready forms of field names are needed.
448 : gage 1369 # my %prettyFieldNames = map {$_ => $_} ($userTemplate->FIELDS(), $permissionLevelTemplate->FIELDS());
449 :     # @prettyFieldNames{qw(
450 :     # user_id
451 :     # first_name
452 :     # last_name
453 :     # email_address
454 :     # student_id
455 :     # status
456 :     # section
457 :     # recitation
458 :     # comment
459 :     # permission
460 :     # )} = (
461 :     # "User ID",
462 :     # "First Name",
463 :     # "Last Name",
464 :     # "E-mail",
465 :     # "Student ID",
466 :     # "Status",
467 :     # "Section",
468 :     # "Recitation",
469 :     # "Comment",
470 :     # "Perm. Level"
471 :     # );
472 : gage 1368
473 : gage 1369 # my %fieldProperties = (
474 :     # user_id => {
475 :     # type => "text",
476 :     # size => 8,
477 :     # access => "readonly",
478 :     # },
479 :     # first_name => {
480 :     # type => "text",
481 :     # size => 10,
482 :     # access => "readwrite",
483 :     # },
484 :     # last_name => {
485 :     # type => "text",
486 :     # size => 10,
487 :     # access => "readwrite",
488 :     # },
489 :     # email_address => {
490 :     # type => "text",
491 :     # size => 20,
492 :     # access => "readwrite",
493 :     # },
494 :     # student_id => {
495 :     # type => "text",
496 :     # size => 11,
497 :     # access => "readwrite",
498 :     # },
499 :     # status => {
500 :     # type => "enumerable",
501 :     # size => 4,
502 :     # access => "readwrite",
503 :     # items => {
504 :     # "C" => "Enrolled",
505 :     # "D" => "Drop",
506 :     # "A" => "Audit",
507 :     # },
508 :     # synonyms => {
509 :     # qr/^[ce]/i => "C",
510 :     # qr/^[dw]/i => "D",
511 :     # qr/^a/i => "A",
512 :     # "*" => "C",
513 :     # }
514 :     # },
515 :     # section => {
516 :     # type => "text",
517 :     # size => 4,
518 :     # access => "readwrite",
519 :     # },
520 :     # recitation => {
521 :     # type => "text",
522 :     # size => 4,
523 :     # access => "readwrite",
524 :     # },
525 :     # comment => {
526 :     # type => "text",
527 :     # size => 20,
528 :     # access => "readwrite",
529 :     # },
530 :     # permission => {
531 :     # type => "number",
532 :     # size => 2,
533 :     # access => "readwrite",
534 :     # }
535 :     # );
536 : gage 1368
537 :    
538 : gage 1369
539 : gage 1368 ##############################################################################################################
540 :    
541 :     # my ($ar_sortedNames, $hr_classlistLabels) = getClasslistFilesAndLabels($course);
542 :     # my @sortedNames = @$ar_sortedNames;
543 :     my %classlistLabels = ();# %$hr_classlistLabels;
544 : gage 1369 unshift(@users, "Yourself");
545 :     $classlistLabels{None} = 'Yourself';
546 :     my $from = $self->{from};
547 :     my $subject = $self->{subject};
548 :     my $replyTo = $self->{replyTo};
549 :     my $columns = $self->{columns};
550 :     my $rows = $self->{rows};
551 :     my $text = defined($self->{r_text}) ? ${ $self->{r_text} }: 'FIXME';
552 :     my $messageFileName = $self->{messageFileName};
553 :    
554 :     CGI::popup_menu(-name=>'classList',
555 :     -values=>\@users,
556 :     -labels=>\%classlistLabels,
557 :     -size => 10,
558 :     -multiple => 1,
559 :     -default=>'Yourself'
560 :     );
561 :     print CGI::start_form({method=>"post", action=>$r->uri()});
562 : gage 1368 #create list of sudents
563 :     # show professors's name and email address
564 :     # show replyTo field and From field
565 :     print CGI::start_table({-border=>'2', -cellpadding=>'4'});
566 : gage 1369 print CGI::Tr({-align=>'left',-valign=>'VCENTER'},
567 :     CGI::td("\n", CGI::p( CGI::b('From: '), CGI::br(), CGI::textfield(-name=>"from", -size=>30, -value=>$from, -override=>1), ),
568 :     "\n", CGI::p( CGI::b('Reply-To: '), CGI::br(), CGI::textfield(-name=>"replyTo", -size=>30, -value=>$replyTo, -override=>1), ),
569 :     "\n", CGI::p( CGI::b('Subject: '), CGI::br(), CGI::textarea(-name=>'subject', -default=>$subject, -rows=>2,-columns=>30, -override=>1), ),
570 : gage 1368 ),
571 : gage 1369 CGI::td({-align=>'left'},
572 :     CGI::radio_group(-name=>'radio', -values=>['all_students','studentID'],
573 :     -labels=>{all_students=>'All active students',studentID => 'Select recipients'},
574 :     -default=>'studentID',
575 :     -linebreak=>1),
576 :     CGI::br(),
577 :     CGI::popup_menu(-name=>'classList',
578 :     -values=>\@users,
579 :     -labels=>\%classlistLabels,
580 :     -size => 10,
581 :     -multiple => 1,
582 :     -default=>'Yourself'
583 :     ),
584 :    
585 :    
586 : gage 1368 ),
587 : gage 1369 CGI::td({align=>'left'},
588 :     CGI::submit(-name=>'preview', -value=>'Preview')," email to ",
589 :     CGI::popup_menu(-name=>'classList',
590 :     -values=>\@users,
591 :     -labels=>\%classlistLabels,
592 :     -default=>'Yourself'
593 :     ),
594 :     CGI::br(),CGI::br(),
595 :     CGI::submit(-name=>'action', -value=>'Revert to original and Resize message window'),CGI::br(),
596 :     " Rows: ", CGI::textfield(-name=>'rows', -size=>3, -value=>$rows),
597 :     " Columns: ", CGI::textfield(-name=>'columns', -size=>3, -value=>$columns),
598 :     CGI::br(),
599 :     "If you resize the message window,",CGI::br(),"you will lose all unsaved changes.",
600 :     CGI::br(),CGI::br(),
601 : gage 1368 #show available macros
602 : gage 1369 CGI::popup_menu(
603 :     -name=>'dummyName',
604 :     -values=>['', '$SID', '$FN', '$LN', '$SECTION', '$RECITATION','$STATUS', '$EMAIL', '$LOGIN', '$COL[3]', '$COL[-1]'],
605 :     -labels=>{''=>'list of insertable macros',
606 :     '$SID'=>'$SID - Student ID',
607 :     '$FN'=>'$FN - First name',
608 :     '$LN'=>'$LN - Last name',
609 :     '$SECTION'=>'$SECTION - Student\'s Section',
610 :     '$RECITATION'=>'$RECITATION',
611 :     '$STATUS'=>'$STATUS - C, Audit, Drop, etc.',
612 :     '$EMAIL'=>'$EMAIL - Email address',
613 :     '$LOGIN'=>'$LOGIN - Login',
614 :     '$COL[3]'=>'$COL[3] - 3rd column in merge file',
615 :     '$COL[-1]'=>'$COL[-1] - Last column'
616 :     }
617 :     ), "\n",
618 : gage 1368 ),
619 :    
620 :     );
621 :     print CGI::end_table();
622 :     #create a textbox with the subject and a textarea with the message
623 :    
624 :     #print actual body of message
625 : gage 1369
626 : gage 1368
627 : gage 1369 print "\n", CGI::p( CGI::textarea(-name=>'body', -default=>$text, -rows=>$rows, -columns=>$columns, -override=>1));
628 : gage 1368 #create all necessary action buttons
629 :     print CGI::p(CGI::submit(-name=>'action', -value=>'Open'), "\n",
630 :     CGI::textfield(-name=>'savefilename', -size => 20, -value=> "$messageFileName", -override=>1), ' ',
631 :     CGI::submit(-name=>'action', -value=>'Save'), " \n",
632 :     CGI::submit(-name=>'action', -value=>'Save as'), " \n",
633 :     CGI::submit(-name=>'action', -value=>'Save as Default'),
634 :     CGI::submit(-name=>'action', -value=>'Send Email'), "\n", CGI::br(),
635 :     'For "Save As" choose a new filename.',
636 :     );
637 :    
638 :     ##############################################################################################################
639 : gage 1369
640 : gage 1368 print $self->hidden_authen_fields();
641 :     print CGI::submit({name=>"save_classlist", value=>"Save Changes to Users"});
642 : gage 1369 print CGI::end_form();
643 : gage 1368 return "";
644 :     }
645 :    
646 : gage 1369 ##############################################################################
647 :     # Utility methods
648 :     ##############################################################################
649 :     sub fatal_error {
650 :     my $self = shift;
651 :     my $msg = join " ", @_;
652 :     # $cgi->start_html('-title' => 'User error'),
653 :     # $cgi->h1('User error'),
654 :     # $cgi->p,
655 :     # $cgi->b(HTML::Entities::encode($msg)),
656 :     # $cgi->p,
657 :     # "Please hit the &quot;<B>Back</B>&quot; button on your browser to ",
658 :     # "try again, or notify ", $cgi->br,
659 :     # "&lt;", $cgi->a({href=>"mailto:$Global::webmaster"}, $Global::webmaster), "&gt; ",
660 :     # "if you believe this message is in error.",
661 :     # $cgi->end_html;
662 :     $self->{submitError}= CGI::b(HTML::Entities::encode($msg)).
663 :     qq{"Please hit the &quot;<B>Back</B>&quot; button on your browser to
664 :     try again, or notify your web master
665 :     if you believe this message is in error.
666 :     };
667 :     return;
668 :     }
669 :    
670 : gage 1368 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9