';
- $result .= $tmptext;
+ $result .= '';
+ if (ref($statushash) eq 'HASH') {
+ $statushash->{'future'} = 1;
+ }
+
}
return $result;
}
sub disgroup {
- my ($cdom,$cnum,$group,$viewgrps,$editgrps) = @_;
+ my ($cdom,$cnum,$group,$access_status) = @_;
my $result;
# 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.');
+ $result = &mt('Error: you must have a course role selected to be able to send a broadcast
+e-mail to a group in the course.');
return $result;
}
if ($cdom eq '' || $cnum eq '') {
@@ -559,6 +570,10 @@ sub disgroup {
my ($memberinfo,$numitems) =
&Apache::longroup::group_memberlist($cdom,$cnum,$group,{},[]);
my @statustypes = ('active');
+ my $viewgrps = &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.
+ ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
+ my $editgrps = &Apache::lonnet::allowed('mdg',$env{'request.course.id'}.
+ ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
if ($viewgrps || $editgrps) {
push(@statustypes,('future','previous'));
}
@@ -567,7 +582,6 @@ sub disgroup {
'recipients to select.');
return $result;
} else {
- $result = &mt('Select message recipients from the group members listed below.').' ';
my %Sortby = (
active => {},
previous => {},
@@ -577,9 +591,9 @@ sub disgroup {
'name' => 'Name',
'usnm' => 'Username',
'doma' => 'Domain',
- 'active' => 'Active Members',
- 'previous' => 'Former Members',
- 'future' => 'Future Members',
+ 'active' => 'Broadcast to Active Members',
+ 'previous' => 'Broadcast (Bcc) to Former Members',
+ 'future' => 'Broadcast (Bcc) to Future Members',
);
foreach my $user (sort(keys(%{$memberinfo}))) {
my $status = $$memberinfo{$user}{status};
@@ -594,26 +608,34 @@ sub disgroup {
}
}
$result .= &group_check_uncheck();
- $result .= '
'.
- '
';
foreach my $status (@statustypes) {
if (ref($numitems) eq 'HASH') {
if ((defined($$numitems{$status})) && ($$numitems{$status})) {
- $result.='
ENDREC
return $output;
}
@@ -1537,7 +1654,7 @@ sub reply_to_row {
my $radioyes = &mt('Yes');
my $radiono = &mt('No');
my $output = <<"ENDREP";
-
$lt->{'ar'}: $lt->{'rt'}:
+
$lt->{'ar'}: $lt->{'rt'}:
ENDREP
return $output;
}
@@ -1548,33 +1665,56 @@ sub additional_rec_row {
my $bcc = &mt('Bcc:');
my $exmpl = &mt('username:domain,username:domain,...');
my $output = <<"ENDADD";
-
$lt->{'ad'} : ($exmpl)
-
$cc
-
-$bcc
+
+
$lt->{'to'}
+
$cc
+
$bcc
ENDADD
return $output;
}
sub submit_button_row {
- my ($folder,$dismode,$sendtext,$lt) = @_;
- my $output = qq|
+ my ($folder,$dismode,$sendtext,$lt,$is_crsform,$group) = @_;
+ my $pre=&mt("Show Preview and Check Spelling");
+ my $value=&mt('Send');
+ my $prevbutton = '';
+ my $output = qq|
-
-
-
+|;
+ if ($is_crsform) {
+ $output .= ''."\n";
+ if ($group ne '') {
+ $output .= ''."\n";
+ }
+ }
+ $output .= qq|
+
+
+
+
$prevbutton
|;
return $output;
}
sub msg_subject_row {
my ($dissub,$lt,$subj_size,$extra) = @_;
- my $output = '
'.$lt->{'sb'}.': '.$lt->{'sb'}.': '.$extra.
'
';
return $output;
}
+sub generate_preview_form {
+ my $prevbutton = (<
+
+
+
+ENDPREVIEW
+}
+
+# ---------------------------------------------------- Display all face to face
+
sub retrieve_instructor_comments {
my ($user,$domain)=@_;
my $target=$env{'form.grade_target'};
@@ -2096,7 +2236,6 @@ sub displaymessage {
my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
my %content=&Apache::lonmsg::unpackagemsg($message{$msgid});
my $counter=0;
- $r->print('
');
my $escmsgid=&escape($msgid);
foreach (@messages) {
if ($_->[5] eq $escmsgid){
@@ -2104,7 +2243,6 @@ sub displaymessage {
}
$counter++;
}
- $r->print('
');
my $see_anonymous;
my $from_student = 0;
@@ -2183,21 +2321,29 @@ sub displaymessage {
.'');
}
}
- my ($tolist,$cclist);
- my (@recipients,@ccs);
- if (ref($content{'recuser'}) eq 'ARRAY') {
+ my ($tonum,$tolist,$cclist,$bcclist,$groupcclist,%recipients);
+ if ($content{'recipid'}) {
+ $tonum = &retrieve_recips('display',\%content,\%recipients);
+ if (ref($recipients{'cc'}) eq 'ARRAY') {
+ $cclist = join(', ',@{$recipients{'cc'}});
+ }
+ if (ref($recipients{'to'}) eq 'ARRAY') {
+ $tolist = join(', ',@{$recipients{'to'}});
+ }
+ if (ref($recipients{'bcc'}) eq 'ARRAY') {
+ $bcclist = join(', ',@{$recipients{'bcc'}});
+ }
+ }
+ if (!$tolist && ref($content{'recuser'}) eq 'ARRAY') {
+ my @recipients;
for (my $i=0; $i<@{$content{'recuser'}}; $i++) {
$recipients[$i] = &Apache::loncommon::aboutmewrapper(
&Apache::loncommon::plainname($content{'recuser'}[$i],
$content{'recdomain'}[$i]),
$content{'recuser'}[$i],$content{'recdomain'}[$i]).
- ' ('.$content{'recuser'}[$i].' '.&mt('at').' '.$content{'recdomain'}[$i].') ';
+ ' ('.$content{'recuser'}[$i].':'.$content{'recdomain'}[$i].') ';
}
- }
- $tolist = join(', ',@recipients);
- if ($content{'recipid'}) {
- @ccs = &retrieve_cc_recips('display',%content);
- $cclist = join(', ',@ccs);
+ $tolist = join(', ',@recipients);
}
my ($restitle,$baseurl,$refers_to);
if (defined($content{'resource_title'})) {
@@ -2214,6 +2360,14 @@ sub displaymessage {
$r->print(&Apache::loncommon::student_image_tag($content{'senderdomain'},$content{'sendername'}));
}
+ my $broadcast_link;
+ if (($content{'courseid'}) && ($content{'recipid'} &&
+ (ref($recipients{'course_broadcast'}) eq 'ARRAY') ||
+ (ref($recipients{'group_cc_broadcast'}) eq 'ARRAY') ||
+ (ref($recipients{'group_bcc_broadcast'}) eq 'ARRAY'))) {
+ $broadcast_link = &recipients_link($r,\%content,\%recipients);
+ }
+
# Display LON-CAPA Message (Start)
# Subject
$r->print(' '
@@ -2228,11 +2382,48 @@ sub displaymessage {
.$tolist
.&Apache::lonhtmlcommon::row_closure()
);
+ if ($cclist) {
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt('Cc'))
+ .$cclist
+ .&Apache::lonhtmlcommon::row_closure()
+ );
+ }
+ if ($bcclist) {
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt('Bcc'))
+ .$bcclist
+ .&Apache::lonhtmlcommon::row_closure()
+ );
+ }
+ if (($content{'courseid'}) && ($content{'recipid'})) {
+ my %broadcast_types =
+ &Apache::lonlocal::texthash (
+ course_broadcast => 'Broadcast to',
+ group_cc_broadcast => 'Cc to group',
+ group_bcc_broadcast => 'Bcc to group',
+ );
+ foreach my $type (sort(keys(%broadcast_types))) {
+ if (ref($recipients{$type}) eq 'ARRAY') {
+ my $num = @{$recipients{$type}};
+ my $broadcastlist = join(', ',@{$recipients{$type}});
+ if ($broadcastlist && $broadcast_link) {
+ if ($type eq 'group_cc_broadcast') {
+ $groupcclist = $broadcastlist;
+ }
+ $r->print(&Apache::lonhtmlcommon::row_title(
+ $broadcast_types{$type})
+ .&mt('[quant,_1,recipient]',$num)
+ .' ['
+ .&mt('Show').']'
+ .&Apache::lonhtmlcommon::row_closure());
+ }
+ }
+ }
+ }
if ($content{'replytoaddr'}) {
my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
if ($replytoname ne '' && $replytodom ne '') {
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Reply To'))
- .&mt('[_1] at [_2]',$replytoname,$replytodom)
+ .$replytoname.':'.$replytodom
.&Apache::lonhtmlcommon::row_closure()
);
}
@@ -2247,30 +2438,46 @@ sub displaymessage {
if ($content{'noreplies'}) {
$r->print(' ('.&mt('No replies to sender').')'
.&Apache::lonhtmlcommon::row_closure()
- );
+ );
} else {
if ($content{'replytoaddr'}) {
my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
if ($replytoname ne '' && $replytodom ne '') {
$r->print(&Apache::lonhtmlcommon::row_closure()
.&Apache::lonhtmlcommon::row_title(&mt('Reply To'))
- .&mt('[_1] at [_2]',$replytoname,$replytodom)
+ .$replytoname.':'.$replytodom
.&Apache::lonhtmlcommon::row_closure()
);
} else {
$r->print(&Apache::lonhtmlcommon::row_closure());
}
} else {
- $r->print(' ('.&mt('[_1] at [_2]',$content{'sendername'},$content{'senderdomain'}).') '
+ $r->print(' ('.$content{'sendername'}.':'.$content{'senderdomain'}.') '
.&Apache::lonhtmlcommon::row_closure()
);
}
- if ($cclist) {
+ if ($tonum && $tolist) {
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt('To'))
+ .$tolist
+ .&Apache::lonhtmlcommon::row_closure()
+ );
+ }
+ if ($cclist) {
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Cc'))
.$cclist
.&Apache::lonhtmlcommon::row_closure()
);
-
+ }
+ if ($content{'group'} ne '') {
+ if (&check_group_priv($content{'group'})) {
+ $groupcclist = join(', ',@{$recipients{'group_cc_broadcast'}});
+ if ($groupcclist) {
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt('Group Cc'))
+ .$groupcclist
+ .&Apache::lonhtmlcommon::row_closure()
+ );
+ }
+ }
}
}
}
@@ -2356,41 +2563,135 @@ sub displaymessage {
.&displayresource(%content)
);
}
- $r->print(&Apache::lonhtmlcommon::row_closure(1));
+ $r->print(&Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::end_pick_box());
# Display LON-CAPA Message (End)
return;
}
-sub retrieve_cc_recips {
- my ($context,%content) = @_;
- my %reciphash =
- &Apache::lonnet::get('nohist_emailrecip',[$content{'recipid'}],
- $content{'senderdomain'},$content{'sendername'});
- my $recipinfo = $reciphash{$content{'recipid'}};
- my @ccs;
- if (ref($recipinfo) eq 'HASH') {
- if (ref($recipinfo->{'cc'}) eq 'HASH') {
- foreach my $cc (sort(keys(%{$recipinfo->{'cc'}}))) {
- my ($ccname,$ccdom) = split(/:/,$cc);
- if (!(($ccname eq $env{'user.name'}) &&
- ($ccdom eq $env{'user.domain'}))) {
- my $showcc ='';
- if ($context eq 'replying') {
- $showcc = '';
- }
- $showcc .= '';
- push(@ccs,$showcc);
+sub retrieve_recips {
+ my ($context,$content,$recips)= @_;
+ my $tonum = 0;
+ if (ref($content) eq 'HASH') {
+ my %reciphash =
+ &Apache::lonnet::get('nohist_emailrecip',[$content->{'recipid'}],
+ $content->{'senderdomain'},$content->{'sendername'});
+ my $recipinfo = $reciphash{$content->{'recipid'}};
+ if (ref($recipinfo) eq 'HASH') {
+ foreach my $type ('to','cc','course_broadcast','group_cc_broadcast','group_bcc_broadcast') {
+ if (ref($recipinfo->{$type}) eq 'HASH') {
+ if ($type eq 'to') {
+ $tonum = keys(%{$recipinfo->{$type}});
+ }
+ foreach my $user (sort(keys(%{$recipinfo->{$type}}))) {
+ my ($uname,$udom) = split(/:/,$user);
+ next if (($context eq 'replying') && ($uname eq $env{'user.name'})
+ && ($udom eq $env{'user.domain'}));
+ my $showuser ='';
+ if ($context eq 'replying') {
+ if (($type eq 'to') || ($type eq 'cc')) {
+ $showuser = '';
+ if (ref($recips) eq 'HASH') {
+ push(@{$recips->{$type}},$showuser);
+ }
+ }
}
}
}
}
- return @ccs;
+ return $tonum;
+}
+
+sub recipients_link {
+ my ($r,$content,$recipients) = @_;
+ my ($broadcast_link,$show);
+ if ((ref($content) eq 'HASH') && (ref($recipients) eq 'HASH')) {
+ if (ref($recipients->{'course_broadcast'}) eq 'ARRAY') {
+ if (@{$recipients->{'course_broadcast'}} > 0) {
+ $show = 'course';
+ }
+ } elsif (ref($recipients->{'group_cc_broadcast'}) eq 'ARRAY') {
+ if (@{$recipients->{'group_cc_broadcast'}} > 0) {
+ $show = 'group_cc';
+ }
+ } elsif (ref($recipients->{'group_bcc_broadcast'}) eq 'ARRAY') {
+ if (@{$recipients->{'group_bcc_broadcast'}} > 0) {
+ $show = 'group_bcc';
+ }
+ }
+ if ($show) {
+ my ($nothing,$height,$width,$start_page,$end_page,$body);
+ $nothing=&Apache::lonhtmlcommon::javascript_nothing();
+ $height = 400;
+ $width = 600;
+ my $start_page =
+ &Apache::loncommon::start_page('Broadcast List', undef,
+ {only_body => 1,
+ js_ready => 1,});
+ my $end_page = &Apache::loncommon::end_page({js_ready => 1,});
+ my $body = '