[LON-CAPA-cvs] cvs: loncom /interface lonmsgdisplay.pm
raeburn
raeburn@source.lon-capa.org
Tue, 16 Dec 2008 22:57:31 -0000
raeburn Tue Dec 16 22:57:31 2008 EDT
Modified files:
/loncom/interface lonmsgdisplay.pm
Log:
- Use LC_error and LC_warning to wrap messages generated in &disgroup().
- Pass $r (request object) as first arg to &disgroup().
- Return from &disgroup is $hasfloat ('' or 1)
- 1 if <div>s to be used for 2 column display.
- Removed surplus </a> from inside <th></th> in &disgroup.
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.104 loncom/interface/lonmsgdisplay.pm:1.105
--- loncom/interface/lonmsgdisplay.pm:1.104 Sun Dec 14 02:45:48 2008
+++ loncom/interface/lonmsgdisplay.pm Tue Dec 16 22:57:31 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.104 2008/12/14 02:45:48 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.105 2008/12/16 22:57:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -555,16 +555,16 @@
}
sub disgroup {
- my ($cdom,$cnum,$group,$access_status) = @_;
- my $result;
+ my ($r,$cdom,$cnum,$group,$access_status) = @_;
+ my $hasfloat;
# Needs to be in a course
if (!($env{'request.course.fn'})) {
- $result = &mt('Error: you must have a course role selected to be able to send a broadcast message to a group in the course.');
- return $result;
+ $r->print('<span class="LC_error">'.&mt('Error: you must have a course role selected to be able to send a broadcast message to a group in the course.').'</span>');
+ return;
}
if ($cdom eq '' || $cnum eq '') {
- $result = &mt('Error: could not determine domain or number of course');
- return $result;
+ $r->print('<span class="LC_error">'.&mt('Error: could not determine domain or number of course').'</span>');
+ return;
}
my ($memberinfo,$numitems) =
&Apache::longroup::group_memberlist($cdom,$cnum,$group,{},[]);
@@ -577,10 +577,13 @@
push(@statustypes,('future','previous'));
}
if (keys(%{$memberinfo}) == 0) {
- $result = &mt('As this group has no members, there are no '.
- 'recipients to select.');
- return $result;
+ $r->print('<span class="LC_warning">'.
+ &mt('As this group has no members, there are no recipients to select').
+ '</span>');
+ return;
} else {
+ $hasfloat = 1;
+ $r->print('<div class="LC_left_float">');
my %Sortby = (
active => {},
previous => {},
@@ -606,7 +609,7 @@
push(@{$Sortby{$status}{$$memberinfo{$user}{fullname}}},$user);
}
}
- $result .= &group_check_uncheck();
+ $r->print(&group_check_uncheck());
foreach my $status (@statustypes) {
if (ref($numitems) eq 'HASH') {
if ((defined($$numitems{$status})) && ($$numitems{$status})) {
@@ -614,46 +617,46 @@
if (ref($access_status) eq 'HASH') {
$access_status->{$status} = $$numitems{$status};
}
- $result.='<fieldset><legend><b>'.$lt{$status}.
- '</b></legend><form name="'.$formname.'">'.
- '<span class="LC_nobreak">'.
- '<input type="button" value="'.&mt('Check All').'" '.
- 'onclick="javascript:toggleAll('."this.form,'check'".')" />'.
- ' '.
- '<input type="button" value="'.&mt('Uncheck All').'" '.
- 'onclick="javascript:toggleAll('."this.form,'uncheck'".')" />'.
- '</span>';
+ $r->print('<fieldset><legend><b>'.$lt{$status}.
+ '</b></legend><form name="'.$formname.'">'.
+ '<span class="LC_nobreak">'.
+ '<input type="button" value="'.&mt('Check All').'" '.
+ 'onclick="javascript:toggleAll('."this.form,'check'".')" />'.
+ ' '.
+ '<input type="button" value="'.&mt('Uncheck All').'" '.
+ 'onclick="javascript:toggleAll('."this.form,'uncheck'".')" />'.
+ '</span>');
if ($status eq 'active') {
- $result .= ' <select name="groupmail">'.
- '<option value="bcc" selected="selected">'.&mt('Bcc').'</option>'.
- '<option value="cc">'.&mt('Cc').'</option>'.
- '</select>';
+ $r->print((' 'x3).'<select name="groupmail">'.
+ '<option value="bcc" selected="selected">'.&mt('Bcc').'</option>'.
+ '<option value="cc">'.&mt('Cc').'</option>'.
+ '</select>');
}
- $result .= '<br />'.&Apache::loncommon::start_data_table().
+ $r->print('<br />'.&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
- "<th>$lt{'name'}</a></th>".
- "<th>$lt{'usnm'}</a></th>".
- "<th>$lt{'doma'}</a></th>".
- &Apache::loncommon::end_data_table_header_row();
+ "<th>$lt{'name'}</th>".
+ "<th>$lt{'usnm'}</th>".
+ "<th>$lt{'doma'}</th>".
+ &Apache::loncommon::end_data_table_header_row());
foreach my $key (sort(keys(%{$Sortby{$status}}))) {
foreach my $user (@{$Sortby{$status}{$key}}) {
- $result .=
- &Apache::loncommon::start_data_table_row().
- '<td><input type="checkbox" '.
+ $r->print(&Apache::loncommon::start_data_table_row().
+ '<td><span class="LC_nobreak"><input type="checkbox" '.
'name="selectedusers_forminput" value="'.
$user.':'.$status.'" />'.
- $$memberinfo{$user}{'fullname'}.'</td>'.
+ $$memberinfo{$user}{'fullname'}.'</span></td>'.
'<td>'.$$memberinfo{$user}{'uname'}.'</td>'.
'<td>'.$$memberinfo{$user}{'udom'}.'</td>'.
- &Apache::loncommon::end_data_table_row();
+ &Apache::loncommon::end_data_table_row());
}
}
- $result .= &Apache::loncommon::end_data_table().'</form></fieldset><br />';
+ $r->print(&Apache::loncommon::end_data_table().'</form>'.
+ '</fieldset><br /></div>');
}
}
}
}
- return $result;
+ return $hasfloat;
}
sub group_check_uncheck {
@@ -1322,10 +1325,7 @@
} else {
$can_grp_broadcast = &check_group_priv($group);
if ($can_grp_broadcast) {
- $r->print('<div class="LC_left_float">'.
- &disgroup($cdom,$cnum,$group,\%access_status).
- '</div>');
- $hasfloat = 1;
+ $hasfloat = &disgroup($r,$cdom,$cnum,$group,\%access_status);
}
}
if ($hasfloat) {