[LON-CAPA-cvs] cvs: loncom /interface lonnotify.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 07 Jul 2006 13:43:21 -0000
This is a MIME encoded message
--albertel1152279801
Content-Type: text/plain
albertel Fri Jul 7 09:43:21 2006 EDT
Modified files:
/loncom/interface lonnotify.pm
Log:
- make use of new sematics for pick_box
--albertel1152279801
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060707094321.txt"
Index: loncom/interface/lonnotify.pm
diff -u loncom/interface/lonnotify.pm:1.19 loncom/interface/lonnotify.pm:1.20
--- loncom/interface/lonnotify.pm:1.19 Tue May 30 08:46:09 2006
+++ loncom/interface/lonnotify.pm Fri Jul 7 09:43:20 2006
@@ -59,24 +59,21 @@
&Apache::lonhtmlcommon::clear_breadcrumbs();
- my $function = &Apache::loncommon::get_users_function();
- my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg');
-
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/notify',
text=>"Broadcast E-mail"});
if ($command eq 'process') {
- &print_request_receipt($r,$command,$cdom,$tablecolor);
+ &print_request_receipt($r,$command,$cdom);
} elsif ($command eq 'compose') {
- &print_composition_form($r,$command,$cdom,$tablecolor);
+ &print_composition_form($r,$command,$cdom);
} elsif ($command eq 'pick_target') {
- &print_selection_form($r,$command,$cdom,$tablecolor);
+ &print_selection_form($r,$command,$cdom);
} elsif ($command eq 'pick_display') {
- &print_display_option_form($r,$command,$cdom,$tablecolor);
+ &print_display_option_form($r,$command,$cdom);
} elsif ($command eq 'display') {
- &print_display($r,$command,$cdom,$tablecolor);
+ &print_display($r,$command,$cdom);
} else {
- &print_front_page($r,'front',$cdom,$tablecolor);
+ &print_front_page($r,'front',$cdom);
}
return OK;
}
@@ -128,7 +125,7 @@
}
sub print_front_page {
- my ($r,$formname,$cdom,$tablecolor) = @_;
+ my ($r,$formname,$cdom) = @_;
my $jscript = qq|
function next_page(caller) {
@@ -146,14 +143,12 @@
'Broadcast e-mail to Domain', $formname);
$output .= '<input type="hidden" name="command" />';
- $output .= &Apache::lonhtmlcommon::start_pick_box();
- $output .= '<table cellspacing="8" cellpadding="8">'.
+ $output .= '<table class="LC_notify_front_page">'.
'<tr><td><a href="javascript:next_page('."'new'".')">'.
'Send a new e-mail message to selected users from this domain</a></td></tr><tr>'.
'<td><a href="javascript:next_page('."'view'".')">'.
'Display e-mail sent by Domain Coordinators in this domain'.
'</a></td></tr></table>';
- $output .= &Apache::lonhtmlcommon::end_pick_box();
$output .= &end_page();
$r->print($output);
@@ -161,11 +156,9 @@
}
sub print_display_option_form {
- my ($r,$formname,$cdom,$tablecolor) = @_;
+ my ($r,$formname,$cdom) = @_;
&Apache::lonhtmlcommon::add_breadcrumb({text=>"Display options"});
- my $table_width = '';
- my $col_width = '200';
my $cmd = 'display';
my $submit_text = 'Display e-mail';
my @roles = ('dc');
@@ -197,16 +190,15 @@
my $output = &start_page(&add_script($jscript),
'Broadcast e-mail display options', $formname);
- $output .= &Apache::lonhtmlcommon::start_pick_box($table_width);
- $output .= &Apache::lonhtmlcommon::row_title($col_width,$tablecolor,&mt('Date range'));
- $output .= '<td><table><tr><td>Earliest to display: </td><td>'.
+ $output .= &Apache::lonhtmlcommon::start_pick_box();
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Date range'));
+ $output .= '<table><tr><td>'.&mt('Earliest to display:').' </td><td>'.
$startdateform.'</td></tr>';
- $output .= '<tr><td>Latest to display: </td><td>'.$enddateform.
- '</td></tr></table></td>';
+ $output .= '<tr><td>'.&mt('Latest to display:').' </td><td>'.$enddateform.
+ '</td></tr></table>';
$output .= &Apache::lonhtmlcommon::row_closure();
- $output .= &Apache::lonhtmlcommon::row_title($col_width,$tablecolor,&mt('Choose sender(s)'));
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Choose sender(s)'));
my %personnel = &Apache::lonnet::get_domain_roles($cdom,\@roles);
- $output .= '<td>';
my @domcc = ();
foreach my $server (keys %personnel) {
foreach my $user (sort(keys %{$personnel{$server}})) {
@@ -218,9 +210,8 @@
}
}
}
- $output .= '</td>';
$output .= &Apache::lonhtmlcommon::row_closure();
- $output .= &Apache::lonhtmlcommon::submit_row($col_width,$tablecolor,&mt('Submit'),$cmd,$submit_text);
+ $output .= &Apache::lonhtmlcommon::submit_row(&mt('Submit'),$cmd,$submit_text);
$output .= &Apache::lonhtmlcommon::end_pick_box();
$output .= qq(<input type="hidden" name="sortby" value="date" />\n).
&end_page();
@@ -229,17 +220,12 @@
}
sub print_display {
- my ($r,$formname,$cdom,$tablecolor) = @_;
+ my ($r,$formname,$cdom) = @_;
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:goBack('pick_display')",
text=>"Display options"},
{text=>"E-mail display"});
- my $table_width = '';
- my $col_width = '200';
- my $rowColor1 = "#ffffff";
- my $rowColor2 = "#eeeeee";
- my $rowColor;
my $msgcount = 0;
my $start = &Apache::lonhtmlcommon::get_date_from_form('startdate');
my $end = &Apache::lonhtmlcommon::get_date_from_form('enddate');
@@ -277,24 +263,19 @@
}
}
}
- $output .= &Apache::lonhtmlcommon::start_pick_box();
+ $output .= &Apache::loncommon::start_data_table();
if ($msgcount > 0) {
my $rowNum = 0;
- $output .= '<tr><td><table cellpadding="4" cellspacing="2" width="100%">
- <tr bgcolor="'.$tablecolor.'" align="center">
- <td><b><a href="javascript:changeSort('."'date'".')">Date</a></b></td>
- <td><b><a href="javascript:changeSort('."'subject'".')">Subject</a></b></td>
- <td><b><a href="javascript:changeSort('."'sender'".')">Sender</a></b></td>
- <td><b><a href="javascript:changeSort('."'message'".')">Message</a></b></td>
- <td><b><a href="javascript:changeSort('."'recipients'".')">Recipients</a></b></td>
- </tr>';
+ $output .= &Apache::loncommon::start_data_table_header_row().
+ '<th><a href="javascript:changeSort(\'date\')">Date</a></th>'.
+ '<th><a href="javascript:changeSort(\'subject\')">Subject</a></th>'.
+ '<th><a href="javascript:changeSort(\'sender\')">Sender</a></th>'.
+ '<th><a href="javascript:changeSort(\'message\')">Message</a></th>'.
+ '<th><a href="javascript:changeSort(\'recipients\')">Recipients</a></th>'.
+ &Apache::loncommon::end_data_table_header_row();
+
if (($env{'form.sortby'} eq 'date') || ($env{'form.sortby'} eq '') || (!defined($env{'form.sortby'})) || (($env{'form.sortby'} eq 'sender') && (@senders <= 1))) {
foreach my $msgid (sort(keys(%dcmail))) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
- }
my $recipients = '';
my ($date,undef,$sname,$sdom) =
&Apache::lonmsg::unpackmsgid($msgid,undef,1);
@@ -303,8 +284,12 @@
$recipients .= $dcmail{$msgid}{recipient}{$user}.', ';
}
$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";
- $rowNum ++;
+ $output .= &Apache::loncommon::start_data_table_row().
+ '<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>'."\n".
+ &Apache::loncommon::end_data_table_row();
}
} else {
foreach my $msgid (sort(keys(%dcmail))) {
@@ -329,11 +314,6 @@
}
foreach my $key (sort(keys(%Sortby))) {
foreach my $msgid (@{$Sortby{$key}}) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
- }
my $recipients = '';
if ($env{'form.sortby'} eq 'recipients') {
$recipients = $key;
@@ -346,16 +326,22 @@
my ($date,undef,$sname,$sdom) =
&Apache::lonmsg::unpackmsgid($msgid,undef,1);
$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";
- $rowNum ++;
+ $output .= &Apache::loncommon::start_data_table_row().
+ '<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>'."\n".
+ &Apache::loncommon::end_data_table_row();
}
}
}
- $output .= '</table></td></tr>';
} else {
- $output .= '<tr bgcolor="#ffffff"><td> </td><td><br><center><i><b><small> No mail sent matching supplied criteria </small><br><br></b></i></td><td> </td></tr>';
+ $output .= &Apache::loncommon::start_data_table_empty_row().
+ '<td>No mail sent matching supplied criteria</td>'.
+ &Apache::loncommon::end_data_table_empty_row();
}
- $output .= &Apache::lonhtmlcommon::end_pick_box();
+ $output .= &Apache::loncommon::end_data_table();
$output .= &Apache::lonhtmlcommon::echo_form_input(['sortby','command','origin']);
my $curr_sortby;
if (defined($env{'form.sortby'})) {
@@ -372,7 +358,7 @@
}
sub print_selection_form {
- my ($r,$formname,$cdom,$tablecolor) = @_;
+ my ($r,$formname,$cdom) = @_;
my %coursecodes = ();
my %codes = ();
my @codetitles = ();
@@ -385,8 +371,6 @@
my $totcodes = 0;
my $format_reply;
my $jscript = '';
- my $table_width = '100%';
- my $col_width = '200';
my %lt=&Apache::lonlocal::texthash(
'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',
@@ -460,7 +444,7 @@
my $output = &start_page(&add_script($jscript).$cb_jscript,
'Choose e-mail audience', $formname);
- $output .= &Apache::lonhtmlcommon::start_pick_box($table_width);
+ $output .= &Apache::lonhtmlcommon::start_pick_box();
my @roles = ('ow','cc','in','ta','ep','st','cr');
my %longtypes = ();
my %authtypes = ();
@@ -472,11 +456,11 @@
</ul>'."\n";
my $submit_text = $lt{'comp'};
my $cmd = 'compose';
- $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::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::submit_row($col_width,$tablecolor,&mt('Submit'),$cmd,$submit_text);
+ $output .= &Apache::lonhtmlcommon::role_select_row(\@roles,'Roles');
+ $output .= &Apache::lonhtmlcommon::course_select_row('Courses',$formname,$totcodes,\@codetitles,\%idlist,\%idlist_titles);
+ $output .= &Apache::lonhtmlcommon::status_select_row(\%longtypes,&mt('Access status'));
+ $output .= &Apache::lonhtmlcommon::email_default_row(\%authtypes,&mt('Username -> Email conversion'),$descrip);
+ $output .= &Apache::lonhtmlcommon::submit_row(&mt('Submit'),$cmd,$submit_text);
$output .= &Apache::lonhtmlcommon::end_pick_box();
$output .= &end_page();
$r->print($output);
@@ -484,7 +468,7 @@
}
sub print_composition_form {
- my ($r,$formname,$cdom,$tablecolor) = @_;
+ my ($r,$formname,$cdom) = @_;
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:goBack('pick_target')",
text=>"Select Audience"},
@@ -547,8 +531,6 @@
my %longtypes = ();
my %authtypes = ();
my %email_defaults = ();
- my $table_width = '100%';
- my $col_width = '200';
&form_elements(\%longtypes,\%authtypes);
foreach my $auth (keys(%authtypes)) {
@@ -607,30 +589,35 @@
my $output;
if ($totalrecip > 0) {
- $output .= &Apache::lonhtmlcommon::start_pick_box($table_width);
- $output .= &Apache::lonhtmlcommon::row_title($col_width,$tablecolor,&mt('Subject'));
- $output .= ' <td><input type="text" name="subject" size="30" /></td>';
+ $output .= &Apache::lonhtmlcommon::start_pick_box();
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Subject'));
+ $output .= '<input type="text" name="subject" size="30" />';
$output .= &Apache::lonhtmlcommon::row_closure();
- $output .= &Apache::lonhtmlcommon::row_title($col_width,$tablecolor,&mt('Message'));
- $output .= ' <td><textarea name="message" id="message"
- cols="60" rows="10" wrap="hard"></textarea></td>';
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Message'));
+ $output .= ' <textarea name="message" id="message"
+ cols="60" rows="10" wrap="hard"></textarea>';
$output .= &Apache::lonhtmlcommon::row_closure();
- $output .= &Apache::lonhtmlcommon::row_title($col_width,$tablecolor,&mt('Recipients'));
- $output .= '<td><input type="button" value="check all"
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Recipients'));
+ $output .= '<input type="button" value="check all"
onclick="javascript:checkAll(document.compose.recipient)" />
<input type="button" value="uncheck all"
onclick="javascript:uncheckAll(document.compose.recipient)" />
- <br /><table border="0">';
+ <br />';
+ $output .= &Apache::loncommon::start_data_table();
if (keys(%recipients) > 0) {
- $output .= '<tr><td> </td><td><small><b>username:domain</b></small></td><td> </td><td><small><b>'.$lt{'emad'}.'</b></small></td></tr>';
+ $output .= &Apache::loncommon::start_data_table_header_row();
+ $output .= '<th> <th>username:domain</th><th> </th><th>'.$lt{'emad'}.'</th>';
+ $output .= &Apache::loncommon::end_data_table_header_row();
}
foreach my $username (sort(keys(%recipients))) {
+ $output .= &Apache::loncommon::start_data_table_row();
if ($recipients{$username} =~ /\@/) {
my $value=&escape($username).':'.&escape($recipients{$username});
- $output .= '<tr><td><input type="checkbox" name="recipient" value="'.$value.'" /></td><td>'.$username.'</td><td> </td><td>'.$recipients{$username}.'</td></tr>';
+ $output .= '<td><input type="checkbox" name="recipient" value="'.$value.'" /></td><td>'.$username.'</td><td> </td><td>'.$recipients{$username}.'</td>';
}
+ $output .= &Apache::loncommon::end_data_table_row();
}
- $output .= '</table>';
+ $output .= &Apache::loncommon::end_data_table();
if (@unmatched) {
$output .= '<br /><br />'.&mt('Could not determine e-mail addresses for the following users:').'<ul>';
foreach my $username (sort @unmatched) {
@@ -638,12 +625,11 @@
}
$output .= '</ul>';
}
- $output .= '</td>';
$output .= &Apache::lonhtmlcommon::row_closure();
- $output .= &Apache::lonhtmlcommon::row_title($col_width,$tablecolor,&mt('Sender e-mail address'));
- $output .= '<td><input type="text" name="sender" value="'.$sender.'" /></td>';
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Sender e-mail address'));
+ $output .= '<input type="text" name="sender" value="'.$sender.'" />';
$output .= &Apache::lonhtmlcommon::row_closure();
- $output .= &Apache::lonhtmlcommon::submit_row($col_width,$tablecolor,&mt('Submit'),'process',&mt('Send Message'));
+ $output .= &Apache::lonhtmlcommon::submit_row(&mt('Submit'),'process',&mt('Send Message'));
$output .= &Apache::lonhtmlcommon::end_pick_box();
} else {
$output .= $lt{'nore'}."\n".
@@ -658,7 +644,7 @@
sub print_request_receipt {
- my ($r,$formname,$dom,$tablecolor) =@_;
+ my ($r,$formname,$dom) =@_;
my @recipients = &Apache::loncommon::get_env_multiple('form.recipient');
my $subject = $env{'form.subject'};
my $message = $env{'form.message'};
@@ -684,38 +670,33 @@
my $output = &start_page(&add_script($jscript), 'E-mail Delivery',
$formname);
- $output .= &Apache::lonhtmlcommon::start_pick_box();
+
my @deliveries = ();
&broadcast_email(\@recipients,$subject,$from,$message,\@deliveries);
if (@deliveries > 0) {
+ $output .= &Apache::loncommon::start_data_table();
&store_mail($subject,$message,$dom,\@deliveries);
- $output .= '<tr>
- <td>
- <table cellpadding="4" cellspacing="2" width="100%">
- <tr bgcolor="'.$tablecolor.'" align="center">
- <td><b>Status</b></td>
- <td><b>Subject</b></td>
- <td><b>Message</b></td>
- <td><b>Recipients</b></td>
- </tr>
- <tr bgcolor="#eeeeee">
- <td valign="middle">Sent</td>
- <td valign="middle">'.&cr_to_br($subject).'</td>
- <td valign="middle">'.&cr_to_br($message).'</td>
- <td>';
+ $output .= &Apache::loncommon::start_data_table_header_row().
+ '<th>'.&mt('Status').'</th>'.
+ '<th>'.&mt('Subject').'</th>'.
+ '<th>'.&mt('Message').'</th>'.
+ '<th>'.&mt('Recipents').'</th>'.
+ &Apache::loncommon::end_data_table_header_row();
+ $output .= &Apache::loncommon::start_data_table_row().
+ '<td valign="middle">'.&mt('Sent').'</td>'.
+ '<td valign="middle">'.&cr_to_br($subject).'</td>'.
+ '<td valign="middle">'.&cr_to_br($message).'</td>'.
+ '<td>';
foreach my $person (@deliveries) {
my ($username,$email) = split(/:/,$person);
$output .= &unescape($email).' ('.&unescape($username).')<br />'."\n";
}
- $output .= '</td>
- </tr>
- </table>
- </td>
- </tr>';
+ $output .= '</td>'.
+ &Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table();
} else {
$output .= 'No mail sent - no recipients identified';
}
- $output .= &Apache::lonhtmlcommon::end_pick_box();
$output .= '<br /><a href="/adm/notify">Send another message?</a>'."\n";
$output .= '<input type="hidden" name="command" />'."\n".
'<input type="hidden" name="origin" value="'.$formname.'" />'."\n";
--albertel1152279801--