version 1.9, 2005/12/09 00:08:35
|
version 1.14, 2006/03/16 20:27:26
|
Line 56 sub handler {
|
Line 56 sub handler {
|
my $origin = $env{'form.origin'}; |
my $origin = $env{'form.origin'}; |
|
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
my %ltext=&Apache::lonlocal::texthash( |
|
'note' => 'Notification E-mail', |
|
); |
|
my $function = &Apache::loncommon::get_users_function(); |
my $function = &Apache::loncommon::get_users_function(); |
my $loadcode; |
|
my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); |
my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); |
if ((defined($env{'form.origin'})) && ($command eq 'compose' || $command eq 'pick_target' || $command eq 'pick_display')) { |
|
unless ($env{'form.origin'} eq '') { |
|
$loadcode = 'javascript:setFormElements(document.'.$env{'form.command'}.')'; |
|
if (($command eq 'pick_target') && ( |
|
($origin eq 'compose') || ($origin eq 'process'))) { |
|
if ($env{'form.coursepick'} eq 'category') { |
|
$loadcode .= ';javascript:setCourseCat(document.'.$env{'form.command'}.')'; |
|
} |
|
} |
|
} |
|
} |
|
my $loaditems = ' onLoad="'.$loadcode.'" '; |
|
my $bodytag = &Apache::loncommon::bodytag('Broadcast e-mail to users',$function,$loaditems); |
|
my $html=&Apache::lonxml::xmlbegin(); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>'/adm/notify', |
({href=>'/adm/notify', |
text=>"Broadcast E-mail"}); |
text=>"Broadcast E-mail"}); |
if ($command eq 'process') { |
if ($command eq 'process') { |
&print_request_receipt($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); |
&print_request_receipt($r,$command,$cdom,$tablecolor); |
} elsif ($command eq 'compose') { |
} elsif ($command eq 'compose') { |
&print_composition_form($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); |
&print_composition_form($r,$command,$cdom,$tablecolor); |
} elsif ($command eq 'pick_target') { |
} elsif ($command eq 'pick_target') { |
&print_selection_form($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); |
&print_selection_form($r,$command,$cdom,$tablecolor); |
} elsif ($command eq 'pick_display') { |
} elsif ($command eq 'pick_display') { |
&print_display_option_form($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); |
&print_display_option_form($r,$command,$cdom,$tablecolor); |
} elsif ($command eq 'display') { |
} elsif ($command eq 'display') { |
&print_display($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); |
&print_display($r,$command,$cdom,$tablecolor); |
} else { |
} else { |
&print_front_page($r,'front',$cdom,$tablecolor,$bodytag,$html,\%ltext); |
&print_front_page($r,'front',$cdom,$tablecolor); |
} |
} |
return OK; |
return OK; |
} |
} |
|
|
|
sub add_script { |
|
my ($js) = @_; |
|
return '<script type="text/javascript">'."\n".$js."\n".'</script>'; |
|
} |
|
|
|
sub start_page { |
|
my ($jscript,$bread_title,$formname) = @_; |
|
|
|
my $html = &Apache::lonxml::xmlbegin(); |
|
|
|
my $head = &Apache::loncommon::head('Notification E-mail',$jscript); |
|
|
|
my $loadcode; |
|
if ((defined($env{'form.origin'})) |
|
&& ($env{'form.command'} eq 'compose' |
|
|| $env{'form.command'} eq 'pick_target' |
|
|| $env{'form.command'} eq 'pick_display')) { |
|
if ($env{'form.origin'} ne '') { |
|
$loadcode = 'javascript:setFormElements(document.'.$env{'form.command'}.')'; |
|
if (($env{'form.command'} eq 'pick_target') |
|
&& (($env{'form.origin'} eq 'compose') |
|
|| ($env{'form.origin'} eq 'process'))) { |
|
if ($env{'form.coursepick'} eq 'category') { |
|
$loadcode .= ';javascript:setCourseCat(document.'.$env{'form.command'}.')'; |
|
} |
|
} |
|
} |
|
} |
|
|
|
$loadcode = ' onLoad="'.$loadcode.'" '; |
|
my $bodytag = |
|
&Apache::loncommon::bodytag('Broadcast e-mail to users', undef, |
|
$loadcode); |
|
|
|
my $breadcrumbs = |
|
&Apache::lonhtmlcommon::breadcrumbs(undef,$bread_title, |
|
'Broadcast_system_email'); |
|
my $output = <<"ENDONE"; |
|
$html |
|
$head |
|
$bodytag |
|
$breadcrumbs |
|
<br /> |
|
<form name="$formname" method="POST"> |
|
ENDONE |
|
|
|
return $output; |
|
} |
|
|
|
sub end_page { |
|
return '</form>'.&Apache::loncommon::end_page(); |
|
} |
|
|
sub print_front_page { |
sub print_front_page { |
my ($r,$formname,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; |
my ($r,$formname,$cdom,$tablecolor) = @_; |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Broadcast e-mail to Domain','Broadcast_system_email'); |
|
my $jscript = qq| |
my $jscript = qq| |
function next_page(caller) { |
function next_page(caller) { |
if (caller == 'view') { |
if (caller == 'view') { |
Line 110 function next_page(caller) {
|
Line 146 function next_page(caller) {
|
document.front.submit() |
document.front.submit() |
} |
} |
|; |
|; |
my %lt=&Apache::lonlocal::texthash( |
|
'note' => 'Notification E-mail', |
my $output = &start_page(&add_script($jscript), |
); |
'Broadcast e-mail to Domain', $formname); |
my $output = <<"ENDONE"; |
|
$html |
$output .= '<input type="hidden" name="command" />'; |
<head> |
|
<title>LON-CAPA $lt{'note'}</title> |
|
<script type"text/javascript"> |
|
$jscript |
|
</script> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<br /> |
|
ENDONE |
|
$output .= '<form name="'.$formname.'" method="post">'. |
|
'<input type="hidden" name="command" />'; |
|
$output .= &Apache::lonhtmlcommon::start_pick_box(); |
$output .= &Apache::lonhtmlcommon::start_pick_box(); |
$output .= '<table cellspacing="8" cellpadding="8">'. |
$output .= '<table cellspacing="8" cellpadding="8">'. |
'<tr><td><a href="javascript:next_page('."'new'".')">'. |
'<tr><td><a href="javascript:next_page('."'new'".')">'. |
Line 135 ENDONE
|
Line 159 ENDONE
|
'Display e-mail sent by Domain Coordinators in this domain'. |
'Display e-mail sent by Domain Coordinators in this domain'. |
'</a></td></tr></table>'; |
'</a></td></tr></table>'; |
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
$output .= qq( |
$output .= &end_page(); |
</form> |
|
</body> |
|
</html>); |
|
$r->print($output); |
$r->print($output); |
return; |
return; |
} |
} |
|
|
sub print_display_option_form { |
sub print_display_option_form { |
my ($r,$formname,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; |
my ($r,$formname,$cdom,$tablecolor) = @_; |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb({text=>"Display options"}); |
({text=>"Display options"}); |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Broadcast e-mail display options','Broadcast_system_email'); |
|
my $table_width = ''; |
my $table_width = ''; |
my $col_width = '200'; |
my $col_width = '200'; |
my $cmd = 'display'; |
my $cmd = 'display'; |
my $submit_text = 'Display e-mail'; |
my $submit_text = 'Display e-mail'; |
my @roles = ('dc'); |
my @roles = ('dc'); |
my $now = time; |
my $now = time; |
my %lt=&Apache::lonlocal::texthash( |
|
'note' => 'Notification E-mail', |
|
); |
|
my $startdateform = &Apache::lonhtmlcommon::date_setter($formname, |
my $startdateform = &Apache::lonhtmlcommon::date_setter($formname, |
'startdate', |
'startdate', |
$now); |
$now); |
Line 180 sub print_display_option_form {
|
Line 198 sub print_display_option_form {
|
sender => 'checkbox', |
sender => 'checkbox', |
); |
); |
my $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements); |
my $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements); |
my $output = <<"ENDONE"; |
|
$html |
my $output = &start_page(&add_script($jscript), |
<head> |
'Broadcast e-mail display options', $formname); |
<title>LON-CAPA $lt{'note'}</title> |
|
<script type"text/javascript"> |
|
$jscript |
|
</script> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<br /> |
|
<form method="post" name="$formname"> |
|
ENDONE |
|
$output .= &Apache::lonhtmlcommon::start_pick_box($table_width); |
$output .= &Apache::lonhtmlcommon::start_pick_box($table_width); |
$output .= &Apache::lonhtmlcommon::row_title($col_width,$tablecolor,&mt('Date range')); |
$output .= &Apache::lonhtmlcommon::row_title($col_width,$tablecolor,&mt('Date range')); |
$output .= '<td><table><tr><td>Earliest to display: </td><td>'. |
$output .= '<td><table><tr><td>Earliest to display: </td><td>'. |
Line 218 ENDONE
|
Line 227 ENDONE
|
$output .= &Apache::lonhtmlcommon::row_closure(); |
$output .= &Apache::lonhtmlcommon::row_closure(); |
$output .= &Apache::lonhtmlcommon::submit_row($col_width,$tablecolor,&mt('Submit'),$cmd,$submit_text); |
$output .= &Apache::lonhtmlcommon::submit_row($col_width,$tablecolor,&mt('Submit'),$cmd,$submit_text); |
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
$output .= qq( |
$output .= qq(<input type="hidden" name="sortby" value="date" />\n). |
<input type="hidden" name="sortby" value="date" /> |
&end_page(); |
</form> |
|
</body> |
|
</html>); |
|
$r->print($output); |
$r->print($output); |
return; |
return; |
} |
} |
|
|
sub print_display { |
sub print_display { |
my ($r,$formname,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; |
my ($r,$formname,$cdom,$tablecolor) = @_; |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:goBack('pick_display')", |
({href=>"javascript:goBack('pick_display')", |
text=>"Display options"}, |
text=>"Display options"}, |
{text=>"E-mail display"}); |
{text=>"E-mail display"}); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Display Broadcast e-mail','Broadcast_system_email'); |
|
my $table_width = ''; |
my $table_width = ''; |
my $col_width = '200'; |
my $col_width = '200'; |
my $rowColor1 = "#ffffff"; |
my $rowColor1 = "#ffffff"; |
Line 259 function goBack(target) {
|
Line 264 function goBack(target) {
|
} |
} |
|
|
ENDSCRIPT |
ENDSCRIPT |
my $output = <<"ENDONE"; |
|
$html |
my $output = &start_page(&add_script($jscript), |
<head> |
'Display Broadcast e-mail', $formname); |
<title>LON-CAPA $$ltext{'note'}</title> |
|
<script type"text/javascript"> |
|
$jscript |
|
</script> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<br /> |
|
<form method="post" name="$formname"> |
|
ENDONE |
|
|
|
foreach my $msgid (keys(%sentmail)) { |
foreach my $msgid (keys(%sentmail)) { |
my %content = &unpackagemail($sentmail{$msgid}); |
my %content = &Apache::lonmsg::unpackagemsg($sentmail{$msgid}); |
$msgcount ++; |
$msgcount ++; |
%{$dcmail{$msgid}} = (); |
%{$dcmail{$msgid}} = (); |
foreach my $item (keys(%content)) { |
foreach my $item (keys(%content)) { |
if ($item eq 'recipients') { |
if ($item eq 'recipient') { |
foreach my $user (keys(%{$content{recipients}})) { |
foreach my $user (keys(%{$content{recipient}})) { |
$dcmail{$msgid}{recipients}{$user} = $content{recipients}{$user}; |
$dcmail{$msgid}{recipient}{$user} = $content{recipient}{$user}; |
} |
} |
} else { |
} else { |
$dcmail{$msgid}{$item} = $content{$item}; |
$dcmail{$msgid}{$item} = $content{$item}; |
Line 306 ENDONE
|
Line 301 ENDONE
|
$rowColor = $rowColor2; |
$rowColor = $rowColor2; |
} |
} |
my $recipients = ''; |
my $recipients = ''; |
my ($date,$subj,$sname,$sdom,$cdom) = split(/:/,$msgid,5); |
my ($date,$subj,$sname,$sdom) = |
|
&Apache::lonmsg::unpackmsgid($msgid,undef,1); |
|
$subj = &Apache::lonnet::escape($subj); |
$date = &Apache::lonlocal::locallocaltime($date); |
$date = &Apache::lonlocal::locallocaltime($date); |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipients}}))) { |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipient}}))) { |
$recipients .= $dcmail{$msgid}{recipients}{$user}.', '; |
$recipients .= $dcmail{$msgid}{recipient}{$user}.', '; |
} |
} |
$recipients =~ s/,\s$//; |
$recipients =~ s/,\s$//; |
$output .= '<tr bgcolor="'.$rowColor.'"><td><small>'.$date.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{subject}).'</small></td><td><small>'.$sname.':'.$sdom.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{message}).'</small></td><td><small>'.$recipients.'</small></td></tr>'."\n"; |
$output .= '<tr bgcolor="'.$rowColor.'"><td><small>'.$date.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{subject}).'</small></td><td><small>'.$sname.':'.$sdom.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{message}).'</small></td><td><small>'.$recipients.'</small></td></tr>'."\n"; |
Line 317 ENDONE
|
Line 314 ENDONE
|
} |
} |
} else { |
} else { |
foreach my $msgid (sort(keys(%dcmail))) { |
foreach my $msgid (sort(keys(%dcmail))) { |
my ($date,$subj,$sname,$sdom,$cdom) = split(/:/,$msgid,5); |
my ($date,$subj,$sname,$sdom) = |
|
&Apache::lonmsg::unpackmsgid($msgid,undef,1); |
|
$subj = &Apache::lonnet::escape($subj); |
if ($env{'form.sortby'} eq 'subject') { |
if ($env{'form.sortby'} eq 'subject') { |
push @{$Sortby{$dcmail{$msgid}{subject}}},$msgid; |
push @{$Sortby{$dcmail{$msgid}{subject}}},$msgid; |
} elsif ($env{'form.sortby'} eq 'message') { |
} elsif ($env{'form.sortby'} eq 'message') { |
push @{$Sortby{$dcmail{$msgid}{message}}},$msgid; |
push @{$Sortby{$dcmail{$msgid}{message}}},$msgid; |
} elsif ($env{'form.sortby'} eq 'recipients') { |
} elsif ($env{'form.sortby'} eq 'recipients') { |
my $recipients =''; |
my $recipients =''; |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipients}}))) { |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipient}}))) { |
$recipients .= $dcmail{$msgid}{recipients}{$user}.', '; |
$recipients .= $dcmail{$msgid}{recipient}{$user}.', '; |
} |
} |
$recipients =~ s/,\s$//; |
$recipients =~ s/,\s$//; |
push @{$Sortby{$recipients}},$msgid; |
push @{$Sortby{$recipients}},$msgid; |
Line 346 ENDONE
|
Line 345 ENDONE
|
if ($env{'form.sortby'} eq 'recipients') { |
if ($env{'form.sortby'} eq 'recipients') { |
$recipients = $key; |
$recipients = $key; |
} else { |
} else { |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipients}}))) { |
foreach my $user (sort(keys(%{$dcmail{$msgid}{recipient}}))) { |
$recipients .= $dcmail{$msgid}{recipients}{$user}.', '; |
$recipients .= $dcmail{$msgid}{recipient}{$user}.', '; |
} |
} |
$recipients =~ s/,\s$//; |
$recipients =~ s/,\s$//; |
} |
} |
|
my ($date,$subj,$sname,$sdom) = |
my ($date,$subj,$sname,$sdom,$cdom) = split(/:/,$msgid,5); |
&Apache::lonmsg::unpackmsgid($msgid,undef,1); |
|
$subj = &Apache::lonnet::escape($subj); |
$date = &Apache::lonlocal::locallocaltime($date); |
$date = &Apache::lonlocal::locallocaltime($date); |
$output .= '<tr bgcolor="'.$rowColor.'"><td><small>'.$date.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{subject}).'</small></td><td><small>'.$sname.':'.$sdom.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{message}).'</small></td><td><small>'.$recipients.'</small></td></tr>'."\n"; |
$output .= '<tr bgcolor="'.$rowColor.'"><td><small>'.$date.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{subject}).'</small></td><td><small>'.$sname.':'.$sdom.'</small></td><td><small>'.&cr_to_br($dcmail{$msgid}{message}).'</small></td><td><small>'.$recipients.'</small></td></tr>'."\n"; |
$rowNum ++; |
$rowNum ++; |
Line 374 ENDONE
|
Line 374 ENDONE
|
$output .= qq(<input type="hidden" name="origin" value="$formname" />\n); |
$output .= qq(<input type="hidden" name="origin" value="$formname" />\n); |
$output .= qq(<input type="hidden" name="command" />\n); |
$output .= qq(<input type="hidden" name="command" />\n); |
$output .= qq(<input type="hidden" name="sortby" value="$curr_sortby" />\n); |
$output .= qq(<input type="hidden" name="sortby" value="$curr_sortby" />\n); |
$output .= qq( |
$output .= &end_page(); |
</form> |
|
</body> |
|
</html>); |
|
$r->print($output); |
$r->print($output); |
return; |
return; |
} |
} |
|
|
sub print_selection_form { |
sub print_selection_form { |
my ($r,$formname,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; |
my ($r,$formname,$cdom,$tablecolor) = @_; |
my %coursecodes = (); |
my %coursecodes = (); |
my %codes = (); |
my %codes = (); |
my @codetitles = (); |
my @codetitles = (); |
Line 399 sub print_selection_form {
|
Line 396 sub print_selection_form {
|
my $table_width = '100%'; |
my $table_width = '100%'; |
my $col_width = '200'; |
my $col_width = '200'; |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'note' => 'Notification E-mail', |
|
'buil' => 'Building valid e-mail address from username, if missing from preferences:', |
'buil' => 'Building valid e-mail address from username, if missing from preferences:', |
'kerb' => 'Kerberos: enter default for each realm used in the domain, with comma separation of entries', |
'kerb' => 'Kerberos: enter default for each realm used in the domain, with comma separation of entries', |
'infs' => 'Internal, Filesystem and Local authentication: enter single default.', |
'infs' => 'Internal, Filesystem and Local authentication: enter single default.', |
Line 418 sub print_selection_form {
|
Line 414 sub print_selection_form {
|
} |
} |
} |
} |
|
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Choose e-mail audience','Broadcast_system_email'); |
|
my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($cdom); |
my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($cdom); |
|
|
my %elements = ( |
my %elements = ( |
Line 469 function setCourseCat(formname) {
|
Line 463 function setCourseCat(formname) {
|
} |
} |
|; |
|; |
} |
} |
my $output = <<"ENDONE"; |
|
$html |
|
<head> |
my $output = &start_page(&add_script($jscript).$cb_jscript, |
<title>LON-CAPA $lt{'note'}</title> |
'Choose e-mail audience', $formname); |
<script type"text/javascript"> |
|
$jscript |
$output .= &Apache::lonhtmlcommon::start_pick_box($table_width); |
</script> |
my @roles = ('ow','cc','in','ta','ep','st','cr'); |
$cb_jscript |
my %longtypes = (); |
</head> |
my %authtypes = (); |
$bodytag |
&form_elements(\%longtypes,\%authtypes); |
$breadcrumbs |
my $descrip = $lt{'buil'}.' |
<br /> |
|
<form method="post" name="$formname"> |
|
ENDONE |
|
$output .= &Apache::lonhtmlcommon::start_pick_box($table_width); |
|
my @roles = ('ow','cc','in','ta','ep','st','cr'); |
|
my %longtypes = (); |
|
my %authtypes = (); |
|
&form_elements(\%longtypes,\%authtypes); |
|
my $descrip = $lt{'buil'}.' |
|
<ul> |
<ul> |
<li>'.$lt{'kerb'}.'<br />(e.g., MSU.EDU=msu.edu, MSUE.EDU=msue.msu.edu).</li> |
<li>'.$lt{'kerb'}.'<br />(e.g., MSU.EDU=msu.edu, MSUE.EDU=msue.msu.edu).</li> |
<li>'.$lt{'infs'}.'</li> |
<li>'.$lt{'infs'}.'</li> |
</ul>'."\n"; |
</ul>'."\n"; |
my $submit_text = $lt{'comp'}; |
my $submit_text = $lt{'comp'}; |
my $cmd = 'compose'; |
my $cmd = 'compose'; |
$output .= &Apache::lonhtmlcommon::role_select_row(\@roles,$col_width,$tablecolor,'Roles'); |
$output .= &Apache::lonhtmlcommon::role_select_row(\@roles,$col_width,$tablecolor,'Roles'); |
$output .= &Apache::lonhtmlcommon::course_select_row($col_width,$tablecolor,'Courses',$formname,$totcodes,\@codetitles,\%idlist,\%idlist_titles); |
$output .= &Apache::lonhtmlcommon::course_select_row($col_width,$tablecolor,'Courses',$formname,$totcodes,\@codetitles,\%idlist,\%idlist_titles); |
$output .= &Apache::lonhtmlcommon::status_select_row(\%longtypes,$col_width,$tablecolor,&mt('Access status')); |
$output .= &Apache::lonhtmlcommon::status_select_row(\%longtypes,$col_width,$tablecolor,&mt('Access status')); |
$output .= &Apache::lonhtmlcommon::email_default_row(\%authtypes,$col_width,$tablecolor,&mt('Username -> Email conversion'),$descrip); |
$output .= &Apache::lonhtmlcommon::email_default_row(\%authtypes,$col_width,$tablecolor,&mt('Username -> Email conversion'),$descrip); |
$output .= &Apache::lonhtmlcommon::submit_row($col_width,$tablecolor,&mt('Submit'),$cmd,$submit_text); |
$output .= &Apache::lonhtmlcommon::submit_row($col_width,$tablecolor,&mt('Submit'),$cmd,$submit_text); |
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
$output .= qq( |
$output .= &end_page(); |
</form> |
|
</body> |
|
</html>); |
|
$r->print($output); |
$r->print($output); |
return; |
return; |
} |
} |
|
|
sub print_composition_form { |
sub print_composition_form { |
my ($r,$formname,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; |
my ($r,$formname,$cdom,$tablecolor) = @_; |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:goBack('pick_target')", |
({href=>"javascript:goBack('pick_target')", |
text=>"Select Audience"}, |
text=>"Select Audience"}, |
Line 522 function goBack(target) {
|
Line 504 function goBack(target) {
|
document.$formname.submit(); |
document.$formname.submit(); |
} |
} |
|; |
|; |
my $breadcrumbs = (&Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Broadcast e-mail to users','Broadcast_system_email')); |
|
|
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'note' => 'Notification E-mail', |
|
'nore' => 'No recipients identified', |
'nore' => 'No recipients identified', |
'emad' => 'e-mail address', |
'emad' => 'e-mail address', |
); |
); |
Line 538 function goBack(target) {
|
Line 517 function goBack(target) {
|
); |
); |
$jscript .= &Apache::lonhtmlcommon::set_form_elements(\%elements); |
$jscript .= &Apache::lonhtmlcommon::set_form_elements(\%elements); |
|
|
$r->print(<<ENDONE); |
$r->print(&start_page(&add_script($jscript), |
$html |
'Broadcast e-mail to users', $formname)); |
<head> |
|
<title>LON-CAPA $lt{'note'}</title> |
|
<script type="text/javascript"> |
|
$jscript |
|
</script> |
|
</head> |
|
$bodytag $breadcrumbs |
|
<br /> |
|
ENDONE |
|
my $coursefilter = $env{'form.coursepick'}; |
my $coursefilter = $env{'form.coursepick'}; |
my %courses = (); |
my %courses = (); |
if ($coursefilter eq 'all') { |
if ($coursefilter eq 'all') { |
Line 641 ENDONE
|
Line 612 ENDONE
|
} |
} |
} |
} |
} |
} |
my $output = '<form name="'.$formname.'" method="post">'."\n"; |
my $output; |
|
|
if ($totalrecip > 0) { |
if ($totalrecip > 0) { |
$output .= &Apache::lonhtmlcommon::start_pick_box($table_width); |
$output .= &Apache::lonhtmlcommon::start_pick_box($table_width); |
Line 688 ENDONE
|
Line 659 ENDONE
|
} |
} |
$output .= '<input type="hidden" name="origin" value="'.$formname.'" />'."\n"; |
$output .= '<input type="hidden" name="origin" value="'.$formname.'" />'."\n"; |
$output .= &Apache::lonhtmlcommon::echo_form_input(['command','origin','subject','message','recipient','sender'],); |
$output .= &Apache::lonhtmlcommon::echo_form_input(['command','origin','subject','message','recipient','sender'],); |
$output .= '</form></body></html>'; |
$output .= &end_page(); |
$r->print($output); |
$r->print($output); |
return; |
return; |
} |
} |
|
|
|
|
sub print_request_receipt { |
sub print_request_receipt { |
my ($r,$formname,$dom,$tablecolor,$bodytag,$html,$ltext) =@_; |
my ($r,$formname,$dom,$tablecolor) =@_; |
my @recipients = &Apache::loncommon::get_env_multiple('form.recipient'); |
my @recipients = &Apache::loncommon::get_env_multiple('form.recipient'); |
my $subject = $env{'form.subject'}; |
my $subject = $env{'form.subject'}; |
my $message = $env{'form.message'}; |
my $message = $env{'form.message'}; |
Line 706 function goBack(target) {
|
Line 677 function goBack(target) {
|
document.$formname.submit(); |
document.$formname.submit(); |
} |
} |
ENDSCRIPT |
ENDSCRIPT |
|
|
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:goBack('pick_target')", |
({href=>"javascript:goBack('pick_target')", |
text=>"Select audience"}); |
text=>"Select audience"}); |
Line 715 ENDSCRIPT
|
Line 687 ENDSCRIPT
|
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/notify?command=process", |
({href=>"/adm/notify?command=process", |
text=>"Outcome"}); |
text=>"Outcome"}); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'E-mail Delivery','Broadcast_system_email'); |
|
my $output = <<ENDONE; |
my $output = &start_page(&add_script($jscript), 'E-mail Delivery', |
$html |
$formname); |
<head> |
|
<title>LON-CAPA Notification E-mail</title> |
|
<script type="text/javascript"> |
|
$jscript |
|
</script> |
|
</head> |
|
$bodytag |
|
$breadcrumbs |
|
<br /> |
|
<form name="$formname" method="post"> |
|
ENDONE |
|
$output .= &Apache::lonhtmlcommon::start_pick_box(); |
$output .= &Apache::lonhtmlcommon::start_pick_box(); |
my @deliveries = (); |
my @deliveries = (); |
&broadcast_email(\@recipients,$subject,$from,$message,\@deliveries); |
&broadcast_email(\@recipients,$subject,$from,$message,\@deliveries); |
Line 758 ENDONE
|
Line 720 ENDONE
|
</table> |
</table> |
</td> |
</td> |
</tr>'; |
</tr>'; |
&store_mail($subject,$message,$dom,\@deliveries); |
|
} else { |
} else { |
$output .= 'No mail sent - no recipients identified'; |
$output .= 'No mail sent - no recipients identified'; |
} |
} |
Line 767 ENDONE
|
Line 728 ENDONE
|
$output .= '<input type="hidden" name="command" />'."\n". |
$output .= '<input type="hidden" name="command" />'."\n". |
'<input type="hidden" name="origin" value="'.$formname.'" />'."\n"; |
'<input type="hidden" name="origin" value="'.$formname.'" />'."\n"; |
$output .= &Apache::lonhtmlcommon::echo_form_input(['command','origin']); |
$output .= &Apache::lonhtmlcommon::echo_form_input(['command','origin']); |
$output .= ' |
$output .= &end_page(); |
</form> |
|
</body> |
|
</html>'; |
|
$r->print($output); |
$r->print($output); |
return; |
return; |
} |
} |
|
|
sub broadcast_email { |
sub broadcast_email { |
my ($recipients,$subject,$from,$message,$deliveries,$ltext)=@_; |
my ($recipients,$subject,$from,$message,$deliveries)=@_; |
# Should implement staggered delivery for large numbers of recipients?. |
# Should implement staggered delivery for large numbers of recipients?. |
foreach my $user (@{$recipients}) { |
foreach my $user (@{$recipients}) { |
my $msg = new Mail::Send; |
my $msg = new Mail::Send; |
Line 823 sub get_user_info {
|
Line 781 sub get_user_info {
|
} |
} |
|
|
sub form_elements { |
sub form_elements { |
my ($longtypes,$authtypes,$ltext) = @_; |
my ($longtypes,$authtypes) = @_; |
%{$longtypes} = ( |
%{$longtypes} = ( |
active => 'Currently has access', |
active => 'Currently has access', |
previous => 'Previously had access', |
previous => 'Previously had access', |
Line 840 sub form_elements {
|
Line 798 sub form_elements {
|
} |
} |
|
|
sub store_mail { |
sub store_mail { |
my ($subject,$message,$domain,$recipients,$attachmenturl,$ltext) = @_; |
my ($subject,$message,$domain,$recipients,$attachmenturl) = @_; |
my $msgid; |
my $msgid; |
($msgid,$message) = &packagemail($subject,$message,$domain,$recipients, |
($msgid,$message) = &Apache::lonmsg::packagemsg($subject,$message,undef,undef, |
$attachmenturl); |
$attachmenturl,$recipients,undef,undef,'dcmail'); |
|
|
# Store in dc email db files on primary library server for domain. |
# Store in dc email db files on primary library server for domain. |
my $server = $Apache::lonnet::domain_primary{$domain}; |
my $server = $Apache::lonnet::domain_primary{$domain}; |
if (defined($server)) { |
if (defined($server)) { |
Line 858 sub store_mail {
|
Line 817 sub store_mail {
|
} |
} |
} |
} |
|
|
sub packagemail { |
|
my ($subject,$message,$dom,$recipients,$attachmenturl) = @_; |
|
my %record = (); |
|
my $partsubj=$subject; |
|
$partsubj=&Apache::lonnet::escape($partsubj); |
|
$message =&HTML::Entities::encode($message,'<>&"'); |
|
$subject =&HTML::Entities::encode($subject,'<>&"'); |
|
#remove machine specification |
|
$attachmenturl =~ s|^http://[^/]+/|/|; |
|
$attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"'); |
|
my $now=time; |
|
my $msgid= &Apache::lonnet::escape($now).':'.$partsubj.':'. |
|
&Apache::lonnet::escape($env{'user.name'}).':'. |
|
&Apache::lonnet::escape($env{'user.domain'}).':'. |
|
&Apache::lonnet::escape($dom).':'.$$; |
|
my $result='<sendername>'.$env{'user.name'}.'</sendername>'. |
|
'<senderdomain>'.$env{'user.domain'}.'</senderdomain>'. |
|
'<time>'.&Apache::lonlocal::locallocaltime($now).'</time>'. |
|
'<servername>'.$ENV{'SERVER_NAME'}.'</servername>'. |
|
'<host>'.$ENV{'HTTP_HOST'}.'</host>'. |
|
'<client>'.$ENV{'REMOTE_ADDR'}.'</client>'. |
|
'<msgid>'.$msgid.'</msgid>'. |
|
'<dcdomain>'.$dom.'</dcdomain>'. |
|
'<subject>'.$subject.'</subject>'. |
|
'<message>'.$message.'</message>'."\n"; |
|
if (defined($attachmenturl)) { |
|
$result.= '<attachmenturl>'.$attachmenturl.'</attachmenturl>'; |
|
} |
|
foreach my $recip (@{$recipients}) { |
|
my ($username,$email) = split(/:/,$recip); |
|
$username = &Apache::lonnet::unescape($username); |
|
$email = &Apache::lonnet::unescape($email); |
|
$username = &HTML::Entities::encode($username,'<>&"'); |
|
$email = &HTML::Entities::encode($email,'<>&"'); |
|
$result .= '<recipient username="'.$username.'">'. |
|
$email.'</recipient>'; |
|
} |
|
return ($msgid,$result); |
|
} |
|
|
|
sub unpackagemail { |
|
my ($message,$notoken,$ltext)=@_; |
|
my $parser=HTML::TokeParser->new(\$message); |
|
my $token; |
|
my %content=(); |
|
%{$content{recipients}} = (); |
|
while ($token=$parser->get_token()) { |
|
if ($token->[0] eq 'S') { |
|
my $entry=$token->[1]; |
|
my $value=$parser->get_text('/'.$entry); |
|
my ($username,$email); |
|
if ($entry eq 'recipient') { |
|
$username = $token->[2]{'username'}; |
|
$username = &HTML::Entities::decode($username,'<>&"'); |
|
$content{recipients}{$username} = |
|
&HTML::Entities::decode($value,'<>&"'); |
|
} elsif ($entry eq 'subject' || $entry eq 'message') { |
|
$content{$entry}=&HTML::Entities::decode($value,'<>&"'); |
|
} else { |
|
$content{$entry}=$value; |
|
} |
|
} |
|
} |
|
if ($content{'attachmenturl'}) { |
|
my ($fname)=($content{'attachmenturl'}=~m|/([^/]+)$|); |
|
if ($notoken) { |
|
$content{'message'}.='<p>'.&mt('Attachment').': <tt>'.$fname.'</tt>'; } else { |
|
&Apache::lonnet::allowuploaded('/adm/notify', |
|
$content{'attachmenturl'}); |
|
$content{'message'}.='<p>'.&mt('Attachment'). |
|
': <a href="'.$content{'attachmenturl'}.'"><tt>'. |
|
$fname.'</tt></a>'; |
|
} |
|
} |
|
return %content; |
|
} |
|
|
|
sub cr_to_br { |
sub cr_to_br { |
my $incoming = shift; |
my $incoming = shift; |
$incoming =~ s/\n/\<br \/\>/g; |
$incoming =~ s/\n/\<br \/\>/g; |