$lt{'ad'}username\@domain,username\@domain, ...
+$lt{'ad'}username:domain,username:domain, ...
$lt{'sb'}:
@@ -819,6 +1055,14 @@ $disbase
$citation
ENDCOMP
+ if (exists($env{'form.ref'})) {
+ $r->print(' ');
+ }
+ if (exists($env{'form.group'})) {
+ $r->print(' ');
+ }
} else { # $broadcast is 'upload'
$r->print(<
@@ -833,14 +1077,14 @@ Subject:
The file format for the uploaded portion of the message is:
-username1\@domain1: text
-username2\@domain2: text
-username3\@domain1: text
+username1:domain1: text
+username2:domain2: text
+username3:domain1: text
The messages will be assembled from all lines with the respective
-username\@domain , and appended to the general message text.
+username:domain , and appended to the general message text.
$dispcrit
@@ -848,7 +1092,13 @@ $dispcrit
ENDUPLOAD
}
if ($broadcast eq 'group') {
- &discourse($r);
+ if ($group eq '') {
+ my $studentsel = &discourse();
+ $r->print($studentsel);
+ }
+ }
+ if ($env{'form.displayedcrit'}) {
+ $r->print(' ');
}
$r->print(''.
&Apache::lonfeedback::generate_preview_button('compemail','message').
@@ -857,6 +1107,20 @@ ENDUPLOAD
# ---------------------------------------------------- Display all face to face
+sub recipient_input_row {
+ my ($dom,%lt) = @_;
+ my $domform = &Apache::loncommon::select_dom_form($dom,'recdomain');
+ my $selectlink=
+ &Apache::loncommon::selectstudent_link('compemail','recuname',
+ 'recdomain');
+ my $output = <<"ENDREC";
+
$lt{'us'}: $selectlink
+$lt{'do'}:
+$domform
+ENDREC
+ return $output;
+}
+
sub retrieve_instructor_comments {
my ($user,$domain)=@_;
my $target=$env{'form.grade_target'};
@@ -871,13 +1135,13 @@ sub retrieve_instructor_comments {
$env{'course.'.$env{'request.course.id'}.'.num'},
'%255b'.$user.'%253a'.$domain.'%255d');
my $result='';
- foreach (sort(keys(%records))) {
- my %content=&Apache::lonmsg::unpackagemsg($records{$_});
+ foreach my $key (sort(keys(%records))) {
+ my %content=&Apache::lonmsg::unpackagemsg($records{$key});
next if ($content{'senderdomain'} eq '');
next if ($content{'subject'} !~ /^Record/);
# &Apache::lonfeedback::newline_to_br(\$content{'message'});
$result.='Recorded by '.
- $content{'sendername'}.'@'.$content{'senderdomain'}."\n";
+ $content{'sendername'}.':'.$content{'senderdomain'}."\n";
$result.=
&Apache::lontexconvert::msgtexconverted($content{'message'})."\n";
}
@@ -899,8 +1163,8 @@ sub disfacetoface {
$env{'course.'.$env{'request.course.id'}.'.num'},
'%255b'.$user.'%253a'.$domain.'%255d');
my $result='';
- foreach (sort keys %records) {
- my %content=&Apache::lonmsg::unpackagemsg($records{$_});
+ foreach my $key (sort(keys(%records))) {
+ my %content=&Apache::lonmsg::unpackagemsg($records{$key});
next if ($content{'senderdomain'} eq '');
&Apache::lonfeedback::newline_to_br(\$content{'message'});
if ($content{'subject'}=~/^Record/) {
@@ -909,7 +1173,7 @@ sub disfacetoface {
$result .=''.&mt('Broadcast Message').' ';
if ($content{'subject'}=~/^Broadcast\./) {
if (defined($content{'coursemsgid'})) {
- my $crsmsgid = &Apache::lonnet::escape($content{'coursemsgid'});
+ my $crsmsgid = &escape($content{'coursemsgid'});
my $broadcast_message = &general_message($crsmsgid);
$content{'message'} = ''.&mt('Subject').': '.$content{'message'}.' '.$broadcast_message;
} else {
@@ -922,7 +1186,7 @@ sub disfacetoface {
} else {
$result.=''.&mt('Critical Message').' ';
if (defined($content{'coursemsgid'})) {
- my $crsmsgid=&Apache::lonnet::escape($content{'coursemsgid'});
+ my $crsmsgid=&escape($content{'coursemsgid'});
my $critical_message = &general_message($crsmsgid);
$content{'message'} = ''.&mt('Subject').': '.$content{'message'}.' '.$critical_message;
} else {
@@ -935,7 +1199,7 @@ sub disfacetoface {
$result.=&mt('By').': '.
&Apache::loncommon::aboutmewrapper(
&Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
-$content{'sendername'}.'@'.
+$content{'sendername'}.':'.
$content{'senderdomain'}.') '.$content{'time'}.
''.
&Apache::lontexconvert::msgtexconverted($content{'message'}).
@@ -943,10 +1207,11 @@ $content{'sendername'}.'@'.
}
# Check to see if there were any messages.
if ($result eq '') {
+ my $lctype = lc(&Apache::loncommon::course_type());
if ($target ne 'tex') {
- $r->print("".&mt("No notes, face-to-face discussion records, critical messages, or broadcast messages in this course.")."
");
+ $r->print("".&mt('No notes, face-to-face discussion records, critical messages, or broadcast messages in this [_1].',$lctype)."
");
} else {
- $r->print('\textbf{'.&mt("No notes, face-to-face discussion records, critical messages or broadcast messages in this course.").'}\\\\');
+ $r->print('\textbf{'.&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this [_1].',$lctype).'}\\\\');
}
} else {
$r->print($result);
@@ -975,6 +1240,9 @@ sub facetoface {
$r->print('Not allowed');
return;
}
+ my $crstype = &Apache::loncommon::course_type();
+ my $leaders = ($crstype eq 'Group') ? 'coordinators and leaders'
+ : 'faculty and staff';
&printheader($r,
'/adm/email?recordftf=query',
"User Notes, Face-to-Face, Critical Messages, Broadcast Messages");
@@ -992,9 +1260,9 @@ sub facetoface {
('stdselect','recuname','recdomain');
my %lt=&Apache::lonlocal::texthash('user' => 'Username',
'dom' => 'Domain',
- 'head' => 'User Notes, Records of Face-To-Face Discussions, Critical Messages, and Broadcast Messages in Course',
+ 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, and Broadcast Messages in $crstype",
'subm' => 'Retrieve discussion and message records',
- 'newr' => 'New Record (record is visible to course faculty and staff)',
+ 'newr' => 'New Record (record is visible to '.lc($crstype).' '.$leaders.')',
'post' => 'Post this Record');
$r->print(<<"ENDTREC");
$lt{'head'}
@@ -1015,13 +1283,9 @@ ENDTREC
($env{'form.recdomain'}) && ($env{'form.recuname'})) {
chomp($env{'form.newrecord'});
if ($env{'form.newrecord'}) {
- my $recordtxt = $env{'form.newrecord'};
- &Apache::lonmsg::user_normal_msg_raw(
- $env{'course.'.$env{'request.course.id'}.'.num'},
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- &mt('Record').
- ' ['.$env{'form.recuname'}.':'.$env{'form.recdomain'}.']',
- $recordtxt);
+ &Apache::lonmsg::store_instructor_comment($env{'form.newrecord'},
+ $env{'form.recuname'},
+ $env{'form.recdomain'});
}
$r->print(''.&Apache::loncommon::plainname($env{'form.recuname'},
$env{'form.recdomain'}).' ');
@@ -1053,10 +1317,12 @@ sub examblock {
$r->print('Not allowed');
return;
}
+ my $usertype = (&Apache::loncommon::course_type() eq 'Group') ? 'members'
+ : 'students';
my %lt=&Apache::lonlocal::texthash(
'comb' => 'Communication Blocking',
'cbds' => 'Communication blocking during scheduled exams',
- 'desc' => 'You can use communication blocking to prevent students enrolled in this course from displaying LON-CAPA messages sent by other students during an online exam. As blocking of communication could potentially interrupt legitimate communication between students who are also both enrolled in a different LON-CAPA course, please be careful that you select the correct start and end times for your scheduled exam when setting or modifying these parameters.',
+ 'desc' => "You can use communication blocking to prevent $usertype enrolled in this course from displaying LON-CAPA messages sent by other $usertype during an online exam. As blocking of communication could potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA course, please be careful that you select the correct start and end times for your scheduled exam when setting or modifying these parameters.",
'mecb' => 'Modify existing communication blocking periods',
'ncbc' => 'No communication blocks currently stored'
);
@@ -1121,35 +1387,35 @@ sub blockstore {
my $addtotal = 0;
my %blocking = ();
$r->print(''.$lt{'head'}.' ');
- foreach (keys %env) {
- if ($_ =~ m/^form\.modify_(\w+)$/) {
+ foreach my $envkey (keys(%env)) {
+ if ($envkey =~ m/^form\.modify_(\w+)$/) {
$adds{$1} = $1;
$removals{$1} = $1;
$modtotal ++;
- } elsif ($_ =~ m/^form\.cancel_(\d+)$/) {
+ } elsif ($envkey =~ m/^form\.cancel_(\d+)$/) {
$cancels{$1} = $1;
unless ( defined($removals{$1}) ) {
$removals{$1} = $1;
$canceltotal ++;
}
- } elsif ($_ =~ m/^form\.add_(\d+)$/) {
+ } elsif ($envkey =~ m/^form\.add_(\d+)$/) {
$adds{$1} = $1;
$addtotal ++;
}
}
- foreach (keys %removals) {
- my $hashkey = $env{'form.key_'.$_};
+ foreach my $key (keys(%removals)) {
+ my $hashkey = $env{'form.key_'.$key};
&Apache::lonnet::del('comm_block',["$hashkey"],
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'}
);
}
- foreach (keys %adds) {
- unless ( defined($cancels{$_}) ) {
- my ($newstart,$newend) = &get_dates_from_form($_);
+ foreach my $key (keys(%adds)) {
+ unless ( defined($cancels{$key}) ) {
+ my ($newstart,$newend) = &get_dates_from_form($key);
my $newkey = $newstart.'____'.$newend;
- $blocking{$newkey} = $env{'user.name'}.'@'.$env{'user.domain'}.':'.$env{'form.title_'.$_};
+ $blocking{$newkey} = $env{'user.name'}.':'.$env{'user.domain'}.':'.$env{'form.title_'.$key};
}
}
if ($addtotal + $modtotal > 0) {
@@ -1192,70 +1458,54 @@ sub get_blockdates {
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'}
);
- $$blockcount = keys %{$records};
-
- foreach (keys %{$records}) {
- if ($_ eq 'error: 2 tie(GDBM) Failed while attempting dump') {
- $$blockcount = 0;
- last;
- }
+ $$blockcount = keys(%{$records});
+
+ if ((keys(%{$records}))[0] =~ /^error: 2 /) {
+ $records = {};
+ $$blockcount = 0;
}
}
sub display_blocker_status {
my ($r,$records,$ltext) = @_;
my $parmcount = 0;
- my @bgcols = ("#eeeeee","#dddddd");
- my $function = &Apache::loncommon::get_users_function();
- my $color = &Apache::loncommon::designparm($function.'.tabbg',
- $env{'user.domain'});
+
my %lt = &Apache::lonlocal::texthash(
'modi' => 'Modify',
'canc' => 'Cancel',
);
+ $r->print(&Apache::loncommon::start_data_table());
$r->print(<<"END");
-
-
-
-
-
-
-
-
- $$ltext{'dura'}
- $$ltext{'setb'}
- $$ltext{'even'}
- $$ltext{'actn'}?
-
+
+ $$ltext{'dura'}
+ $$ltext{'setb'}
+ $$ltext{'even'}
+ $$ltext{'actn'}?
+
END
- foreach (sort keys %{$records}) {
- my $iter = $parmcount%2;
+ foreach my $record (sort(keys(%{$records}))) {
my $onchange = 'onFocus="javascript:window.document.forms['.
"'blockform'].elements['modify_".$parmcount."'].".
'checked=true;"';
- my ($start,$end) = split/____/,$_;
+ my ($start,$end) = split(/____/,$record);
my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
- my ($setter,$title) = split/:/,$$records{$_};
- my ($setuname,$setudom) = split/@/,$setter;
+
+ my ($setuname,$setudom,$title) =
+ &parse_block_record($$records{$record});
+ $title = &HTML::Entities::encode($title,'"<>&');
my $settername = &Apache::loncommon::plainname($setuname,$setudom);
+ $r->print(&Apache::loncommon::start_data_table_row());
$r->print(<<"END");
-
$$ltext{'star'}: $startform $$ltext{'endd'}: $endform
$settername
-
+
$lt{'modi'}? $lt{'canc'}?
-
END
- $parmcount ++;
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $parmcount++;
}
$r->print(<<"END");
-
-
-
-
-
-
@@ -1263,6 +1513,19 @@ END
return $parmcount;
}
+sub parse_block_record {
+ my ($record) = @_;
+ my ($setuname,$setudom,$title);
+ my @data = split(/:/,$record,3);
+ if (scalar(@data) eq 2) {
+ $title = $data[1];
+ ($setuname,$setudom) = split(/@/,$data[0]);
+ } else {
+ ($setuname,$setudom,$title) = @data;
+ }
+ return ($setuname,$setudom,$title);
+}
+
sub display_addblocker_table {
my ($r,$parmcount,$ltext) = @_;
my $start = time;
@@ -1272,9 +1535,6 @@ sub display_addblocker_table {
'checked=true;"';
my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
- my $function = &Apache::loncommon::get_users_function();
- my $color = &Apache::loncommon::designparm($function.'.tabbg',
- $env{'user.domain'});
my %lt = &Apache::lonlocal::texthash(
'addb' => 'Add block',
'exam' => 'e.g., Exam 1',
@@ -1282,133 +1542,106 @@ sub display_addblocker_table {
);
$r->print(<<"END");
$lt{'addn'}
-
END
+ $r->print(&Apache::loncommon::start_data_table());
+ $r->print(<<"END");
+
+ $$ltext{'dura'}
+ $$ltext{'even'} $lt{'exam'}
+ $$ltext{'actn'}?
+
+END
+ $r->print(&Apache::loncommon::start_data_table_row());
+ $r->print(<<"END");
+ $$ltext{'star'}: $startform $$ltext{'endd'}: $endform
+
+ $lt{'addb'}?
+END
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $r->print(&Apache::loncommon::end_data_table());
return;
}
sub blockcheck {
my ($setters,$startblock,$endblock) = @_;
# Retrieve active student roles and active course coordinator/instructor roles
- my @livecses = ();
- my @staffcses = ();
- $$startblock = 0;
- $$endblock = 0;
- foreach (keys %env) {
- if ($_ =~ m-^user\.role\.(st|cc|in)\./(.+)$-) {
- my $role = $1;
- my $cse = $2;
- $cse =~ s|/|_|;
- if ($env{$_} =~ m/^(\d*)\.(\d*)$/) {
- unless (($2 > 0 && $2 < time) || ($1 > time)) {
- if ($role eq 'st') {
- push @livecses, $cse;
- } else {
- unless (grep/^$cse$/,@staffcses) {
- push @staffcses, $cse;
- }
- }
- }
- }
- } elsif ($_ =~ m-user\.role\.cr/(\w+)/(\w+)/([^/]+)\./(.+)$- ) {
- my $rolepriv = $env{'user.role..rolesdef_'.$3};
- }
- }
- # Retrieve blocking times and identity of blocker for active courses for students.
- if (@livecses > 0) {
- foreach my $cse (@livecses) {
- my ($cdom,$crs) = split/_/,$cse;
- if ( (grep/^$cse$/,@staffcses) && ($env{'request.role'} !~ m-^st\./$cdom/$crs$-) ) {
- next;
- } else {
- %{$$setters{$cse}} = ();
- @{$$setters{$cse}{'staff'}} = ();
- @{$$setters{$cse}{'times'}} = ();
- my %records = &Apache::lonnet::dump('comm_block',$cdom,$crs);
- foreach (keys %records) {
- if ($_ =~ m/^(\d+)____(\d+)$/) {
- if ($1 <= time && $2 >= time) {
- my ($staff,$title) = split/:/,$records{$_};
- push @{$$setters{$cse}{'staff'}}, $staff;
- push @{$$setters{$cse}{'times'}}, $_;
- if ( ($$startblock == 0) || ($$startblock > $1) ) {
- $$startblock = $1;
- }
- if ( ($$endblock == 0) || ($$endblock < $2) ) {
- $$endblock = $2;
- }
- }
- }
- }
- }
- }
+ my %live_courses =
+ map { $_ => 1} &Apache::loncommon::findallcourses();
+ # FIXME should really probe for apriv, but ::allowed can only probe the
+ # currently active role
+ my %staff_of =
+ map { $_ => 1} &Apache::loncommon::findallcourses(['cc','in']);
+
+ # Retrieve blocking times and identity of blocker for active courses
+ # for students.
+ return if (!%live_courses);
+
+ foreach my $course (keys(%live_courses)) {
+ my $cdom = $env{'course.'.$course.'.domain'};
+ my $cnum = $env{'course.'.$course.'.num'};
+
+ # if they are a staff member and are currently not playing student
+ next if ( $staff_of{$course}
+ && ($env{'request.role'} !~ m{^st\./$cdom/$cnum}));
+
+ $setters->{$course} = {};
+ $setters->{$course}{'staff'} = [];
+ $setters->{$course}{'times'} = [];
+ my %records = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
+ foreach my $record (keys(%records)) {
+ my ($start,$end) = ($record =~ m/^(\d+)____(\d+)$/);
+ if ($start <= time && $end >= time) {
+ my ($staff_name,$staff_dom,$title) =
+ &parse_block_record($records{$record});
+ push(@{$$setters{$course}{'staff'}}, [$staff_name,$staff_dom]);
+ push(@{$$setters{$course}{'times'}}, [$start,$end]);
+ if ( ($$startblock == 0) || ($$startblock > $1) ) {
+ $$startblock = $1;
+ }
+ if ( ($$endblock == 0) || ($$endblock < $2) ) {
+ $$endblock = $2;
+ }
+ }
+ }
}
}
sub build_block_table {
my ($r,$startblock,$endblock,$setters) = @_;
- my $function = &Apache::loncommon::get_users_function();
- my $color = &Apache::loncommon::designparm($function.'.tabbg',
- $env{'user.domain'});
my %lt = &Apache::lonlocal::texthash(
'cacb' => 'Currently active communication blocks',
- 'cour' => 'Course',
+ 'cour' => 'Course/Group',
'dura' => 'Duration',
'blse' => 'Block set by'
- );
+ );
$r->print(<<"END");
- $lt{'cacb'}:
-
-
-
-
-
-
-
-
- $lt{'cour'}
- $lt{'dura'}
- $lt{'blse'}
-
+ $lt{'cacb'}:
END
- foreach (keys %{$setters}) {
- my %courseinfo=&Apache::lonnet::coursedescription($_);
- for (my $i=0; $i<@{$$setters{$_}{staff}}; $i++) {
- my ($uname,$udom) = split/\@/,$$setters{$_}{staff}[$i];
+ $r->print(&Apache::loncommon::start_data_table());
+ $r->print(<<"END");
+
+ $lt{'cour'}
+ $lt{'dura'}
+ $lt{'blse'}
+
+END
+ foreach my $course (keys(%{$setters})) {
+ my %courseinfo=&Apache::lonnet::coursedescription($course);
+ for (my $i=0; $i<@{$$setters{$course}{staff}}; $i++) {
+ my ($uname,$udom) = @{$$setters{$course}{staff}[$i]};
my $fullname = &Apache::loncommon::plainname($uname,$udom);
- my ($openblock,$closeblock) = split/____/,$$setters{$_}{times}[$i];
+ my ($openblock,$closeblock) = @{$$setters{$course}{times}[$i]};
$openblock = &Apache::lonlocal::locallocaltime($openblock);
$closeblock= &Apache::lonlocal::locallocaltime($closeblock);
- $r->print(''.$courseinfo{'description'}.' '.
+ $r->print(&Apache::loncommon::start_data_table_row().
+ ''.$courseinfo{'description'}.' '.
''.$openblock.' to '.$closeblock.' '.
- ''.$fullname.' ('.$uname.'@'.$udom.
- ') ');
+ ''.$fullname.' ('.$uname.':'.$udom.
+ ') '.
+ &Apache::loncommon::end_data_table_row());
}
}
- $r->print('
');
+ $r->print(&Apache::loncommon::end_data_table());
}
# ----------------------------------------------------------- Display a message
@@ -1421,6 +1654,8 @@ sub displaymessage {
my $startblock = 0;
my $endblock = 0;
my $numblocked = 0;
+ my $crstype = &Apache::loncommon::course_type();
+
# info to generate "next" and "previous" buttons and check if message is blocked
&blockcheck(\%setters,\$startblock,\$endblock);
my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
@@ -1436,7 +1671,7 @@ sub displaymessage {
my $counter=0;
$r->print('');
- my $escmsgid=&Apache::lonnet::escape($msgid);
+ my $escmsgid=&escape($msgid);
foreach (@messages) {
if ($_->[5] eq $escmsgid){
last;
@@ -1446,17 +1681,17 @@ sub displaymessage {
$r->print(' ');
my $number_of_messages = scalar(@messages); #subtract 1 for last index
# start output
- &printheader($r,'/adm/email?display='.&Apache::lonnet::escape($msgid),'Display a Message','',$content{'baseurl'});
+ &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
# Functions
$r->print(''.&mt('Functions').': '.
- ''.&mt('Reply').' '.
- ''.&mt('Forward').' '.
- ''.&mt('Mark Unread').' '.
- ''.&mt('Delete').' '.
''.
$content{'baseurl'}.' ('.&Apache::lonnet::gettitle($content{'baseurl'}).') ':'').
@@ -1555,13 +1790,12 @@ sub header {
my $extra = &Apache::loncommon::studentbrowser_javascript();
if ($baseurl) {
- $extra .= " ";
+ $extra .= " ";
}
$r->print(&Apache::loncommon::start_page('Communication and Messages',
- $extra));
+ $extra));
$r->print(&Apache::lonhtmlcommon::breadcrumbs
- (undef,($title?$title:'Communication and Messages')));
-
+ (($title?$title:'Communication and Messages')));
}
# ---------------------------------------------------------------- Print header
@@ -1580,27 +1814,27 @@ sub storecomment {
my ($r)=@_;
my $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});
my $cleanmsgtxt='';
- foreach (split(/[\n\r]/,$msgtxt)) {
- unless ($_=~/^\s*(\>|\>\;)/) {
- $cleanmsgtxt.=$_."\n";
+ foreach my $line (split(/[\n\r]/,$msgtxt)) {
+ unless ($line=~/^\s*(\>|\>\;)/) {
+ $cleanmsgtxt.=$line."\n";
}
}
- my $key=&Apache::lonnet::escape($env{'form.baseurl'}).'___'.time;
+ my $key=&escape($env{'form.baseurl'}).'___'.time;
&Apache::lonnet::put('nohist_stored_comments',{ $key => $cleanmsgtxt });
}
sub storedcommentlisting {
my ($r)=@_;
my %msgs=&Apache::lonnet::dump('nohist_stored_comments',undef,undef,
- '^'.&Apache::lonnet::escape(&Apache::lonnet::escape($env{'form.showcommentbaseurl'})));
+ '^'.&escape(&escape($env{'form.showcommentbaseurl'})));
$r->print(&Apache::loncommon::start_page('Stored Comment Listing',undef,
{'onlybody' => 1}));
if ((keys %msgs)[0]=~/^error\:/) {
$r->print(&mt('No stored comments yet.'));
} else {
my $found=0;
- foreach (sort keys %msgs) {
- $r->print("\n".$msgs{$_}." ");
+ foreach my $key (sort(keys(%msgs))) {
+ $r->print("\n".$msgs{$key}." ");
$found=1;
}
unless ($found) {
@@ -1617,8 +1851,20 @@ sub sendoffmail {
my $sendstatus='';
my %specialmsg_status;
my $numspecial = 0;
+ my ($cdom,$cnum,$group);
+ if (exists($env{'form.group'})) {
+ $group = $env{'form.group'};
+ }
+ if (exists($env{'request.course.id'})) {
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ }
if ($env{'form.send'}) {
- &printheader($r,'','Messages being sent.');
+ if ($group eq '') {
+ &printheader($r,'','Messages being sent.');
+ } else {
+ $r->print(&groupmail_header('sending',$group));
+ }
$r->rflush();
my %content=();
undef %content;
@@ -1636,36 +1882,56 @@ sub sendoffmail {
%content=&Apache::lonmsg::unpackagemsg($message{$msgid},1);
&statuschange($msgid,'replied',$folder);
}
- my %toaddr=();
- undef %toaddr;
- if ($env{'form.sendmode'} eq 'group') {
- foreach (keys %env) {
- if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
- $toaddr{$1}='';
+
+ my @to =
+ &Apache::loncommon::get_env_multiple('form.selectedusers_forminput');
+ my $mode = $env{'form.sendmode'};
+
+ my %toaddr;
+ if (@to) {
+ foreach my $dest (@to) {
+ my ($user,$domain) = split(/:/, $dest);
+ if (($user ne '') && ($domain ne '')) {
+ my $address = $user.":".$domain; # How the code below expects it.
+ $toaddr{$address} = '';
}
}
+ }
+
+ if ($env{'form.sendmode'} eq 'group') {
+ foreach my $address (keys(%env)) {
+ if ($address=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
+ $toaddr{$1}='';
+ }
+ }
} elsif ($env{'form.sendmode'} eq 'upload') {
- foreach (split(/[\n\r\f]+/,$env{'form.upfile'})) {
- my ($rec,$txt)=split(/\s*\:\s*/,$_);
+ foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
+ my ($rec,$txt) = ($line =~ /^([^:]+:[^:]+):(.*)$/);
if ($txt) {
- $rec=~s/\@/\:/;
+ $rec =~ s/^\s+//;
+ $rec =~ ~s/\s+$//;
$toaddr{$rec}.=$txt."\n";
}
}
} else {
- $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
+ if (($env{'form.recuname'} ne '') && ($env{'form.recdomain'} ne '')) {
+ $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
+ }
}
if ($env{'form.additionalrec'}) {
- foreach (split(/\,/,$env{'form.additionalrec'})) {
- my ($auname,$audom)=split(/\@/,$_);
- $toaddr{$auname.':'.$audom}='';
+ foreach my $rec (split(/\,/,$env{'form.additionalrec'})) {
+ my ($auname,$audom)=split(/:/,$rec);
+ if (($auname ne "") && ($audom ne "")) {
+ $toaddr{$auname.':'.$audom}='';
+ }
}
}
my $savemsg;
my $msgtype;
my %sentmessage;
- my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'});
+ my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'},
+ undef,1);
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
(&Apache::lonnet::allowed('srm',$env{'request.course.id'})
|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
@@ -1677,33 +1943,43 @@ sub sendoffmail {
$savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'});
}
- foreach (keys %toaddr) {
- my ($recuname,$recdomain)=split(/\:/,$_);
+ foreach my $address (sort(keys(%toaddr))) {
+ my ($recuname,$recdomain)=split(/\:/,$address);
my $msgtxt = $savemsg;
- if ($toaddr{$_}) { $msgtxt.=' '.$toaddr{$_}; }
- my $thismsg;
+ if ($toaddr{$address}) { $msgtxt.=' '.$toaddr{$address}; }
+ my @thismsg;
if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
(&Apache::lonnet::allowed('srm',$env{'request.course.id'})
|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
'/'.$env{'request.course.sec'}))) {
- $r->print(&mt('Sending critical message').' '.$recuname.'@'.$recdomain.': ');
- $thismsg=&Apache::lonmsg::user_crit_msg($recuname,$recdomain,$msgsubj,$msgtxt,
- $env{'form.sendbck'},$env{'form.permanent'},
- \$sentmessage{$_});
+ $r->print(&mt('Sending critical message').' '.$recuname.':'.$recdomain.': ');
+ @thismsg=
+ &Apache::lonmsg::user_crit_msg($recuname,$recdomain,
+ $msgsubj,$msgtxt,
+ $env{'form.sendbck'},
+ $env{'form.permanent'},
+ \$sentmessage{$address});
} else {
- $r->print(&mt('Sending').' '.$recuname.'@'.$recdomain.': ');
- $thismsg=&Apache::lonmsg::user_normal_msg($recuname,$recdomain,$msgsubj,$msgtxt,
- $content{'citation'},undef,undef,$env{'form.permanent'},\$sentmessage{$_});
+ $r->print(&mt('Sending').' '.$recuname.':'.$recdomain.': ');
+ @thismsg=
+ &Apache::lonmsg::user_normal_msg($recuname,$recdomain,
+ $msgsubj,$msgtxt,
+ $content{'citation'},
+ undef,undef,
+ $env{'form.permanent'},
+ \$sentmessage{$address});
}
if (($env{'request.course.id'}) && (($msgtype eq 'critical') ||
($env{'form.sendmode'} eq 'group'))) {
- $specialmsg_status{$recuname.':'.$recdomain} = $thismsg;
- if ($thismsg eq 'ok') {
- $numspecial ++;
- }
+ $specialmsg_status{$recuname.':'.$recdomain} =
+ join(' ',@thismsg);
+ foreach my $result (@thismsg) {
+ if ($result eq 'ok') {
+ $numspecial++;
+ }
+ }
}
- $r->print($thismsg.' ');
- $sendstatus.=' '.$thismsg;
+ $sendstatus.=' '.join(' ',@thismsg);
}
if (($env{'request.course.id'}) && (($env{'form.sendmode'} eq 'group')
|| ($msgtype eq 'critical'))) {
@@ -1714,22 +1990,21 @@ sub sendoffmail {
$subj_prefix = 'Broadcast.';
}
my ($specialmsgid,$specialresult);
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $course_str = &Apache::lonnet::escape('['.$cnum.':'.$cdom.']');
+ my $course_str = &escape('['.$cnum.':'.$cdom.']');
if ($numspecial) {
$specialresult = &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix.
' '.$course_str,$savemsg,undef,undef,undef,
undef,undef,\$specialmsgid);
- $specialmsgid = &Apache::lonnet::unescape($specialmsgid);
+ $specialmsgid = &unescape($specialmsgid);
}
if ($specialresult eq 'ok') {
my $record_sent;
- my @recusers = ();
- my @recudoms = ();
- my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
- split(/\:/,&Apache::lonnet::unescape($specialmsgid));
+ my @recusers;
+ my @recudoms;
+ my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
+ split(/\:/,&unescape($specialmsgid));
+
foreach my $recipient (sort(keys(%toaddr))) {
if ($specialmsg_status{$recipient} eq 'ok') {
my $usersubj = $subj_prefix.'['.$recipient.']';
@@ -1741,15 +2016,15 @@ sub sendoffmail {
&Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix.
' ['.$recipient.']',$msgsubj,undef,
undef,undef,undef,$usermsgid,undef,undef,$specialmsgid);
- my ($uname,$udom) = split/:/,$recipient;
+ my ($uname,$udom) = split(/:/,$recipient);
push(@recusers,$uname);
push(@recudoms,$udom);
}
}
if (@recusers) {
my $specialmessage;
- my $sentsubj = $subj_prefix.' ('.$numspecial.' sent) '.
- $msgsubj;
+ my $sentsubj =
+ $subj_prefix.' ('.$numspecial.' sent) '.$msgsubj;
$sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');
my $sentmsgid =
&Apache::lonmsg::buildmsgid($stamp,$sentsubj,$msgname,
@@ -1767,17 +2042,18 @@ sub sendoffmail {
&printheader($r,'','No messages sent.');
}
if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
- $r->print(''.&mt('Completed.').' ');
+ $r->print(''.&mt('Completed.').' ');
if ($env{'form.displayedcrit'}) {
&discrit($r);
+ }
+ if ($group ne '') {
+ $r->print(&groupmail_sent($group,$cdom,$cnum));
} else {
&Apache::loncommunicate::menu($r);
}
} else {
- $r->print(
- ''.&mt('Could not deliver message').' '.
- &mt('Please use the browser "Back" button and correct the recipient addresses')
- );
+ $r->print(''.&mt('Could not deliver message').' '.
+ &mt('Please use the browser "Back" button and correct the recipient addresses '."($sendstatus)").'
');
}
}
@@ -1798,7 +2074,7 @@ sub handler {
['display','replyto','forward','markread','markdel','markunread',
'sendreply','compose','sendmail','critical','recname','recdom',
'recordftf','sortedby','block','folder','startdis','interdis',
- 'showcommentbaseurl','dismode']);
+ 'showcommentbaseurl','dismode','group','subject','text','ref']);
$sqs='&sortedby='.$env{'form.sortedby'};
# ------------------------------------------------------ They checked for email
@@ -1820,7 +2096,7 @@ sub handler {
unless ($folder) {
$folder='';
} else {
- $sqs.='&folder='.&Apache::lonnet::escape($folder);
+ $sqs.='&folder='.&escape($folder);
}
# ------------------------------------------------------------ Get Display Mode
@@ -1828,7 +2104,7 @@ sub handler {
unless ($dismode) {
$dismode='';
} else {
- $sqs.='&dismode='.&Apache::lonnet::escape($dismode);
+ $sqs.='&dismode='.&escape($dismode);
}
# --------------------------------------------------------------------- Display
@@ -1864,19 +2140,23 @@ sub handler {
&compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode);
} elsif ($env{'form.confirm'}) {
&printheader($r,'','Confirmed Receipt');
- foreach (keys %env) {
- if ($_=~/^form\.rec\_(.*)$/) {
+ my $replying = 0;
+ foreach my $envkey (keys(%env)) {
+ if ($envkey=~/^form\.rec\_(.*)$/) {
$r->print(''.&mt('Confirming Receipt').': '.
&Apache::lonmsg::user_crit_received($1).' ');
}
- if ($_=~/^form\.reprec\_(.*)$/) {
+ if ($envkey=~/^form\.reprec\_(.*)$/) {
my $msgid=$1;
$r->print(''.&mt('Confirming Receipt').': '.
&Apache::lonmsg::user_crit_received($msgid).' ');
&compout($r,'','','',$msgid);
+ $replying = 1;
}
}
- &discrit($r);
+ if (!$replying) {
+ &discrit($r);
+ }
} elsif ($env{'form.critical'}) {
&printheader($r,'','Displaying Critical Messages');
&discrit($r);
@@ -1884,32 +2164,67 @@ sub handler {
&compout($r,$env{'form.forward'},undef,undef,undef,$folder);
} elsif ($env{'form.markdel'}) {
&printheader($r,'','Deleted Message');
- &statuschange($env{'form.markdel'},'deleted',$folder);
+ my ($result,$msg) =
+ &statuschange($env{'form.markdel'},'deleted',$folder);
+ if (!$result) {
+ $r->print(''.
+ &mt('Failed to delete the message.').'
'.
+ ''.$msg."
\n");
+ }
&Apache::loncommunicate::menu($r);
&disall($r,($folder?$folder:$dismode));
} elsif ($env{'form.markedmove'}) {
- my $total=0;
- foreach (keys %env) {
- if ($_=~/^form\.delmark_(.*)$/) {
- &movemsg(&Apache::lonnet::unescape($1),$folder,
- $env{'form.movetofolder'});
- $total++;
+ my ($total,$failed,@failed_msg)=(0,0);
+ foreach my $key (keys(%env)) {
+ if ($key=~/^form\.delmark_(.*)$/) {
+ my ($result,$msg) =
+ &movemsg(&unescape($1),$folder,
+ $env{'form.movetofolder'});
+ if ($result) {
+ $total++;
+ } else {
+ $failed++;
+ push(@failed_msg,$msg);
+ }
}
}
&printheader($r,'','Moved Messages');
- $r->print('Moved '.$total.' message(s)');
+ if ($failed) {
+ $r->print('
+ '.&mt('Failed to move [_1] message(s)',$failed).
+ '
');
+ $r->print(''.
+ join("
\n",@failed_msg).
+ "
\n");
+ }
+ $r->print(&mt('Moved [_1] message(s)',$total).'');
&Apache::loncommunicate::menu($r);
&disall($r,($folder?$folder:$dismode));
} elsif ($env{'form.markeddel'}) {
- my $total=0;
- foreach (keys %env) {
- if ($_=~/^form\.delmark_(.*)$/) {
- &statuschange(&Apache::lonnet::unescape($1),'deleted',$folder);
- $total++;
+ my ($total,$failed,@failed_msg)=(0,0);
+ foreach my $key (keys(%env)) {
+ if ($key=~/^form\.delmark_(.*)$/) {
+ my ($result,$msg) =
+ &statuschange(&unescape($1),'deleted',
+ $folder);
+ if ($result) {
+ $total++;
+ } else {
+ $failed++;
+ push(@failed_msg,$msg);
+ }
}
}
&printheader($r,'','Deleted Messages');
- $r->print('Deleted '.$total.' message(s)
');
+ if ($failed) {
+ $r->print('
+ '.&mt('Failed to delete [_1] message(s)',$failed).
+ '
');
+ $r->print(''.
+ join("
\n",@failed_msg).
+ "
\n");
+ }
+ $r->print(&mt('Deleted [_1] message(s)',$total).'');
&Apache::loncommunicate::menu($r);
&disall($r,($folder?$folder:$dismode));
} elsif ($env{'form.markunread'}) {
@@ -1927,15 +2242,17 @@ sub handler {
&sendoffmail($r,$folder);
if ($env{'form.storebasecomment'}) {
&storecomment($r);
- }
+ }
if (($env{'form.rsspost'}) && ($env{'request.course.id'})) {
- &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'},
+ &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'},
$env{'course.'.$env{'request.course.id'}.'.domain'},
'Course_Announcements',
$env{'form.subject'},
$env{'form.message'},'/adm/communicate','public');
}
- &disall($r,($folder?$folder:$dismode));
+ if ((!exists($env{'form.group'})) && (!$env{'form.displayedcrit'})) {
+ &disall($r,($folder?$folder:$dismode));
+ }
} elsif ($env{'form.newfolder'}) {
&printheader($r,'','New Folder');
&makefolder($env{'form.newfolder'});
@@ -1963,9 +2280,3 @@ sub handler {
__END__
-
-
-
-
-
-