| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm,v 1.36 2004/09/14 18:55:58 apizer Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm,v 1.38 2004/09/16 19:44:44 apizer Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 29 | #use HTML::Entities; |
29 | #use HTML::Entities; |
| 30 | use Mail::Sender; |
30 | use Mail::Sender; |
| 31 | use WeBWorK::HTML::ScrollingRecordList qw/scrollingRecordList/; |
31 | use WeBWorK::HTML::ScrollingRecordList qw/scrollingRecordList/; |
| 32 | use WeBWorK::Utils::FilterRecords qw/filterRecords/; |
32 | use WeBWorK::Utils::FilterRecords qw/filterRecords/; |
| 33 | |
33 | |
| 34 | my $REFRESH_RESIZE_BUTTON = "Set preview to: "; # handle submit value idiocy |
34 | #my $REFRESH_RESIZE_BUTTON = "Set preview to: "; # handle submit value idiocy |
|
|
35 | my $UPDATE_SETTINGS_BUTTON = "Update settings and refresh page"; # handle submit value idiocy |
| 35 | sub initialize { |
36 | sub initialize { |
| 36 | my ($self) = @_; |
37 | my ($self) = @_; |
| 37 | my $r = $self->r; |
38 | my $r = $self->r; |
| 38 | my $db = $r->db; |
39 | my $db = $r->db; |
| 39 | my $ce = $r->ce; |
40 | my $ce = $r->ce; |
| … | |
… | |
| 77 | $self->{rows} = (defined($r->param('rows'))) ? $r->param('rows') : $ce->{mail}->{editor_window_rows}; |
78 | $self->{rows} = (defined($r->param('rows'))) ? $r->param('rows') : $ce->{mail}->{editor_window_rows}; |
| 78 | $self->{columns} = (defined($r->param('columns'))) ? $r->param('columns') : $ce->{mail}->{editor_window_columns}; |
79 | $self->{columns} = (defined($r->param('columns'))) ? $r->param('columns') : $ce->{mail}->{editor_window_columns}; |
| 79 | $self->{default_msg_file} = $default_msg_file; |
80 | $self->{default_msg_file} = $default_msg_file; |
| 80 | $self->{old_default_msg_file} = $old_default_msg_file; |
81 | $self->{old_default_msg_file} = $old_default_msg_file; |
| 81 | $self->{merge_file} = (defined($r->param('merge_file' ))) ? $r->param('merge_file') : 'None'; |
82 | $self->{merge_file} = (defined($r->param('merge_file' ))) ? $r->param('merge_file') : 'None'; |
| 82 | $self->{preview_user} = (defined($r->param('preview_user'))) ? $r->param('preview_user') : $user; |
83 | #$self->{preview_user} = (defined($r->param('preview_user'))) ? $r->param('preview_user') : $user; |
| 83 | |
84 | # an expermiment -- share the scrolling list for preivew and sendTo actions. |
|
|
85 | my @classList = (defined($r->param('classList'))) ? $r->param('classList') : ($user); |
|
|
86 | $self->{preview_user} = $classList[0] || $user; |
| 84 | |
87 | |
| 85 | ############################################################################################# |
88 | ############################################################################################# |
| 86 | # gather database data |
89 | # gather database data |
| 87 | ############################################################################################# |
90 | ############################################################################################# |
| 88 | # FIXME this might be better done in body? We don't always need all of this data. or do we? |
91 | # FIXME this might be better done in body? We don't always need all of this data. or do we? |
| … | |
… | |
| 301 | ############################################################################################# |
304 | ############################################################################################# |
| 302 | my $to = $r->param('To'); |
305 | my $to = $r->param('To'); |
| 303 | my $script_action = ''; |
306 | my $script_action = ''; |
| 304 | |
307 | |
| 305 | |
308 | |
| 306 | if(not defined($action) or $action eq 'Open' or $action eq $REFRESH_RESIZE_BUTTON or $action eq 'Sort by' |
309 | if(not defined($action) or $action eq 'Open' |
| 307 | or $action eq 'Set merge file to:' ){ |
310 | or $action eq $UPDATE_SETTINGS_BUTTON ){ |
| 308 | |
311 | |
| 309 | return ''; |
312 | return ''; |
| 310 | } |
313 | } |
| 311 | |
314 | |
| 312 | |
315 | |
| … | |
… | |
| 507 | |
510 | |
| 508 | my $userTemplate = $db->newUser; |
511 | my $userTemplate = $db->newUser; |
| 509 | my $permissionLevelTemplate = $db->newPermissionLevel; |
512 | my $permissionLevelTemplate = $db->newPermissionLevel; |
| 510 | |
513 | |
| 511 | # This code will require changing if the permission and user tables ever have different keys. |
514 | # This code will require changing if the permission and user tables ever have different keys. |
| 512 | my @users = @{ $self->{ra_users} }; |
515 | my @users = sort @{ $self->{ra_users} }; |
| 513 | my $ra_user_records = $self->{ra_user_records}; |
516 | my $ra_user_records = $self->{ra_user_records}; |
| 514 | my %classlistLabels = ();# %$hr_classlistLabels; |
517 | my %classlistLabels = ();# %$hr_classlistLabels; |
| 515 | foreach my $ur (@{ $ra_user_records }) { |
518 | foreach my $ur (@{ $ra_user_records }) { |
| 516 | $classlistLabels{$ur->user_id} = $ur->user_id.': '.$ur->last_name. ', '. $ur->first_name.' -- '.$ur->section." / ".$ur->recitation; |
519 | $classlistLabels{$ur->user_id} = $ur->user_id.': '.$ur->last_name. ', '. $ur->first_name.' -- '.$ur->section." / ".$ur->recitation; |
| 517 | } |
520 | } |
| … | |
… | |
| 523 | default_sort => "lnfn", |
526 | default_sort => "lnfn", |
| 524 | default_format => "lnfn_uid", |
527 | default_format => "lnfn_uid", |
| 525 | default_filters => ["all"], |
528 | default_filters => ["all"], |
| 526 | size => 5, |
529 | size => 5, |
| 527 | multiple => 1, |
530 | multiple => 1, |
|
|
531 | refresh_button_name =>'Update settings and refresh page', |
| 528 | }, @{$ra_user_records}); |
532 | }, @{$ra_user_records}); |
| 529 | |
533 | |
| 530 | ############################################################################################################## |
534 | ############################################################################################################## |
| 531 | |
535 | |
| 532 | |
536 | |
| … | |
… | |
| 561 | print CGI::Tr({-align=>'left',-valign=>'top'}, |
565 | print CGI::Tr({-align=>'left',-valign=>'top'}, |
| 562 | ############################################################################################# |
566 | ############################################################################################# |
| 563 | # first column |
567 | # first column |
| 564 | ############################################################################################# |
568 | ############################################################################################# |
| 565 | |
569 | |
| 566 | CGI::td(CGI::strong("Message file: $input_file"),"\n",CGI::br(), |
570 | CGI::td(CGI::strong("Message file: "), $input_file,"\n",CGI::br(), |
| 567 | CGI::submit(-name=>'action', -value=>'Open'), ' ',"\n", |
571 | CGI::submit(-name=>'action', -value=>'Open'), ' ',"\n", |
| 568 | CGI::popup_menu(-name=>'openfilename', |
572 | CGI::popup_menu(-name=>'openfilename', |
| 569 | -values=>\@sorted_messages, |
573 | -values=>\@sorted_messages, |
| 570 | -default=>$input_file |
574 | -default=>$input_file |
|
|
575 | ), |
| 571 | ), "\n",CGI::br(), |
576 | "\n",CGI::br(), |
| 572 | |
577 | CGI::strong("Save file to: "), $output_file, |
| 573 | "Save file to: $output_file","\n",CGI::br(), |
578 | "\n",CGI::br(), |
|
|
579 | CGI::strong('Merge file: '), $merge_file, |
|
|
580 | CGI::br(), |
|
|
581 | CGI::popup_menu(-name=>'merge_file', |
|
|
582 | -values=>\@sorted_merge_files, |
|
|
583 | -default=>$merge_file, |
|
|
584 | ), "\n", |
|
|
585 | "\n", |
|
|
586 | #CGI::hr(), |
|
|
587 | CGI::div({style=>"background-color: #CCCCCC"}, |
| 574 | "\n", 'From:',' ', CGI::textfield(-name=>"from", -size=>30, -value=>$from, -override=>1), |
588 | "\n", 'From:',' ', CGI::textfield(-name=>"from", -size=>30, -value=>$from, -override=>1), |
| 575 | "\n", CGI::br(),'Reply-To: ', CGI::textfield(-name=>"replyTo", -size=>30, -value=>$replyTo, -override=>1), |
589 | "\n", CGI::br(),'Reply-To: ', CGI::textfield(-name=>"replyTo", -size=>30, -value=>$replyTo, -override=>1), |
| 576 | "\n", CGI::br(),'Subject: ', CGI::br(), CGI::textarea(-name=>'subject', -default=>$subject, -rows=>3,-columns=>30, -override=>1), |
590 | "\n", CGI::br(),'Subject: ', CGI::br(), CGI::textarea(-name=>'subject', -default=>$subject, -rows=>3,-columns=>30, -override=>1), |
|
|
591 | ), |
|
|
592 | #CGI::hr(), |
|
|
593 | CGI::submit(-name=>'action', -value=>$UPDATE_SETTINGS_BUTTON), |
|
|
594 | |
| 577 | ), |
595 | ), |
| 578 | ############################################################################################# |
596 | ############################################################################################# |
| 579 | # second column |
597 | # second column |
| 580 | ############################################################################################# |
598 | ############################################################################################# |
| 581 | # CGI::td({-align=>'left',style=>'font-size:smaller'}, |
599 | # CGI::td({-align=>'left',style=>'font-size:smaller'}, |
| … | |
… | |
| 589 | ## Edit by Mark to insert scrolling list |
607 | ## Edit by Mark to insert scrolling list |
| 590 | CGI::td({-style=>"width:33%"},CGI::strong("Send to:"), |
608 | CGI::td({-style=>"width:33%"},CGI::strong("Send to:"), |
| 591 | CGI::radio_group(-name=>'radio', -values=>['all_students','studentID'], |
609 | CGI::radio_group(-name=>'radio', -values=>['all_students','studentID'], |
| 592 | -labels=>{all_students=>'All students in course',studentID => 'Selected students'}, |
610 | -labels=>{all_students=>'All students in course',studentID => 'Selected students'}, |
| 593 | -default=>'studentID', -linebreak=>0), |
611 | -default=>'studentID', -linebreak=>0), |
| 594 | CGI::br(),$scrolling_user_list), |
612 | CGI::br(),$scrolling_user_list, |
|
|
613 | CGI::i("Preview set to: "), $preview_record->last_name, |
|
|
614 | CGI::submit(-name=>'action', -value=>'preview',-label=>'Preview message'),' ', |
|
|
615 | ), |
|
|
616 | |
| 595 | ## Edit here to insert filtering |
617 | ## Edit here to insert filtering |
| 596 | ## be sure to fail GRACEFULLY! |
618 | ## be sure to fail GRACEFULLY! |
| 597 | # |
619 | # |
| 598 | # |
620 | # |
| 599 | # CGI::input({type=>'submit',value=>'Sort by',name=>'action'}),, |
621 | # CGI::input({type=>'submit',value=>'Sort by',name=>'action'}),, |
| … | |
… | |
| 618 | |
640 | |
| 619 | ############################################################################################# |
641 | ############################################################################################# |
| 620 | # third column |
642 | # third column |
| 621 | ############################################################################################# |
643 | ############################################################################################# |
| 622 | CGI::td({align=>'left'}, |
644 | CGI::td({align=>'left'}, |
| 623 | "<b>Merge file:</b> $merge_file", CGI::br(), |
645 | # "<b>Merge file:</b> $merge_file", CGI::br(), |
| 624 | CGI::submit(-name=>'action', -value=>'Set merge file to:'),CGI::br(), |
646 | # CGI::submit(-name=>'action', -value=>'Set merge file to:'),CGI::br(), |
| 625 | CGI::popup_menu(-name=>'merge_file', |
647 | # CGI::popup_menu(-name=>'merge_file', |
| 626 | -values=>\@sorted_merge_files, |
648 | # -values=>\@sorted_merge_files, |
| 627 | -default=>$merge_file, |
649 | # -default=>$merge_file, |
| 628 | ), "\n",CGI::hr(), |
650 | # ), "\n", |
|
|
651 | # CGI::hr(), |
| 629 | CGI::b("Viewing email for: "), "$preview_user",CGI::br(), |
652 | # CGI::b("Viewing email for: "), "$preview_user",CGI::br(), |
| 630 | CGI::submit(-name=>'action', -value=>'resize', -label=>$REFRESH_RESIZE_BUTTON),' ', |
653 | # CGI::submit(-name=>'action', -value=>'resize', -label=>$REFRESH_RESIZE_BUTTON),' ', |
| 631 | CGI::popup_menu(-name=>'preview_user', |
654 | # CGI::popup_menu(-name=>'preview_user', |
| 632 | -values=>\@users, |
655 | # -values=>\@users, |
| 633 | #-labels=>\%classlistLabels, |
656 | # #-labels=>\%classlistLabels, |
| 634 | -default=>$preview_user, |
657 | # -default=>$preview_user, |
| 635 | ), |
658 | # ), |
| 636 | CGI::br(), |
659 | # CGI::br(), |
| 637 | CGI::submit(-name=>'action', -value=>'preview',-label=>'Preview message'),' ', |
660 | # CGI::submit(-name=>'action', -value=>'preview',-label=>'Preview message'),' ', |
| 638 | |
661 | # |
| 639 | CGI::br(), |
662 | # CGI::br(), |
| 640 | |
663 | # |
| 641 | CGI::hr(), |
664 | # CGI::hr(), |
| 642 | " Rows: ", CGI::textfield(-name=>'rows', -size=>3, -value=>$rows), |
665 | " Rows: ", CGI::textfield(-name=>'rows', -size=>3, -value=>$rows), |
| 643 | " Columns: ", CGI::textfield(-name=>'columns', -size=>3, -value=>$columns), |
666 | " Columns: ", CGI::textfield(-name=>'columns', -size=>3, -value=>$columns), |
|
|
667 | CGI::br(), |
| 644 | CGI::br(),CGI::i('Press any action button to update display'),CGI::br(), |
668 | # CGI::i('Press any action button to update display'),CGI::br(), |
| 645 | #show available macros |
669 | #show available macros |
| 646 | CGI::popup_menu( |
670 | CGI::popup_menu( |
| 647 | -name=>'dummyName', |
671 | -name=>'dummyName', |
| 648 | -values=>['', '$SID', '$FN', '$LN', '$SECTION', '$RECITATION','$STATUS', '$EMAIL', '$LOGIN', '$COL[3]', '$COL[-1]'], |
672 | -values=>['', '$SID', '$FN', '$LN', '$SECTION', '$RECITATION','$STATUS', '$EMAIL', '$LOGIN', '$COL[3]', '$COL[-1]'], |
| 649 | -labels=>{''=>'list of insertable macros', |
673 | -labels=>{''=>'list of insertable macros', |