--- loncom/interface/lonmsgdisplay.pm 2011/05/03 10:37:14 1.156
+++ loncom/interface/lonmsgdisplay.pm 2023/09/15 22:32:46 1.200
@@ -1,7 +1,7 @@
-# $textareaclass The LearningOnline Network with CAPA
+# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.156 2011/05/03 10:37:14 bisitz Exp $
+# $Id: lonmsgdisplay.pm,v 1.200 2023/09/15 22:32:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -102,6 +102,8 @@ use HTML::TokeParser();
use Apache::Constants qw(:common);
use Apache::loncommon();
use Apache::lonhtmlcommon();
+use Apache::longroup;
+use Apache::lonnavmaps;
use Apache::lontexconvert();
use HTML::Entities();
use Apache::lonlocal;
@@ -109,8 +111,9 @@ use Apache::loncommunicate;
use Apache::lonfeedback;
use Apache::lonrss();
use Apache::lonselstudent();
+use Apache::lonenc();
use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
# Querystring component with sorting type
my $sqs='';
@@ -120,21 +123,23 @@ my $startdis='';
sub folderlist {
my ($folder,$msgstatus) = @_;
- my %lt = &Apache::lonlocal::texthash(
+ my %html_lt = &Apache::lonlocal::texthash(
actn => 'Action',
fold => 'Folder',
show => 'Show',
status => 'Message Status',
go => 'Go',
+
+ );
+ &html_escape(\%html_lt);
+ my %js_lt = &Apache::lonlocal::texthash(
nnff => 'New Name for Folder',
newn => 'New Name',
- thfm => 'The folder may not be renamed',
- fmnb => 'folder may not be renamed as it is a folder provided by the system.',
- asth => 'as this name is already in use for a system-provided or user-defined folder.',
- the => 'The',
- tnfm => 'The new folder may not be named',
+ fmnb => 'Folder may not be renamed as it is a folder provided by the system.',
+ asth => 'Requested name already in use for a system-provided or user-defined folder.',
);
+ &js_escape(\%js_lt);
# set se lastvisit for the new mail check in the toplevel menu
&Apache::lonnet::appenv({'user.mailcheck.lastvisit'=>time});
@@ -182,16 +187,16 @@ function folder_choice(targetform,caller
if (targetform.folderaction.options[targetform.folderaction.selectedIndex].value == 'rename') {
for (var i=0; i
+
'."\n".
''.
''.
@@ -261,8 +271,8 @@ sub get_permanent_folders {
my %permfolders =
&Apache::lonlocal::texthash('' => 'INBOX',
'trash' => 'TRASH',
- 'critical' => 'Critical',
- 'sent' => 'Sent Messages',
+ 'critical' => 'CRITICAL',
+ 'sent' => 'SENT MESSAGES',
);
return %permfolders;
}
@@ -378,7 +388,7 @@ sub deletefolder {
my ($folder)=@_;
my %permfolders = &get_permanent_folders();
if (defined($permfolders{$folder})) {
- return &mt('The folder "[_1]" may not be deleted.',$folder);
+ return &mt('The folder "[_1]" may not be deleted.',$permfolders{$folder});
}
my %userfolders = &Apache::lonmsg::get_user_folders();
if (!defined($userfolders{$folder})) {
@@ -543,7 +553,7 @@ sub discourse {
$result .= '
-
'.$lt{'fold'}.'
'."\n".
+ '.$html_lt{'fold'}.'
-
'."\n".
&Apache::loncommon::select_form($folder,'folder',\%formhash).'
'.$lt{'show'}.'
'."\n".
+ '.$html_lt{'show'}.'
-
'."\n".
&Apache::loncommon::select_form($env{'form.interdis'},'interdis',
\%show).'
'.$lt{'status'}.'
'."\n".
+ '.$html_lt{'status'}.'
-
'."\n".
&Apache::loncommon::select_form($msgstatus,'msgstatus',\%statushash).'
'.$lt{'actn'}.'
'."\n".'
+
+ '.$html_lt{'actn'}.'
-
'."\n".'
'.
&Apache::loncommon::select_form('view','folderaction',\%actions).
- '
'.&mt('New Folder').'
'."\n".'
+
+ '.&mt('New Folder').'
'."\n".'
-
';
if (ref($statushash) eq 'HASH') {
$statushash->{'active'} = 1;
@@ -564,7 +574,7 @@ sub discourse {
$result .= '
';
if (ref($statushash) eq 'HASH') {
$statushash->{'previous'} = 1;
@@ -587,7 +597,7 @@ sub discourse {
$result .= '';
if (ref($statushash) eq 'HASH') {
$statushash->{'future'} = 1;
@@ -662,7 +672,7 @@ sub disgroup {
}
$r->print('
-'.&mt('The messages will be assembled from all lines with the respective'."\n".'username:domain, and appended to the general message text.'));
+'.&mt('The messages will be assembled from all lines with the respective [_1][_2]username:domain[_3], and appended to the general message text.','
@@ -1871,7 +1955,7 @@ sub disfacetoface {
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'},
'%255b'.$user.'%253a'.$domain.'%255d');
- my $result=' ".&mt('No notes, face-to-face discussion records, critical messages, or broadcast messages in this [_1].',$lctype)." ".&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this '.$lctype.'.')." '.&mt('Attachment not included - exceeded permitted length').' '.&mt('Attachment not included - exceeded permitted length').'
','',''));
$r->print(<
'.&mt('Subject').': '.$content{'subject'}.'
'.
$content{'message'};
}
} else {
@@ -1925,7 +2008,7 @@ sub disfacetoface {
&Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
$content{'sendername'}.':'.
$content{'senderdomain'}.') '.$content{'time'}.
- ''.
+ '
'.
&Apache::lontexconvert::msgtexconverted($content{'message'}).
'
';
}
@@ -1933,15 +2016,15 @@ $content{'sendername'}.':'.
if ($result eq '') {
my $lctype = &mt(lc(&Apache::loncommon::course_type()));
if ($target ne 'tex') {
- $r->print("'
+ .'
'
);
&disfacetoface($r,$env{'form.recuname'},$env{'form.recdomain'});
$r->print(<'.$lt{'cbds'}.'
');
-
- if ($action eq 'store') {
- &blockstore($r);
- }
-
- $r->print($lt{'desc'}.'
-
-$end_page
-END
- return;
-}
-
-sub blockstore {
- my $r = shift;
- my %lt=&Apache::lonlocal::texthash(
- 'tfcm' => 'The following changes were made',
- 'ncwm' => 'No changes were made.'
- );
- my %adds = ();
- my %removals = ();
- my %cancels = ();
- my $modtotal = 0;
- my $canceltotal = 0;
- my $addtotal = 0;
- my %blocking = ();
- $r->print(''.$lt{'head'}.'
');
- foreach my $envkey (keys(%env)) {
- if ($envkey =~ m/^form\.modify_(\d+)$/) {
- $adds{$1} = $1;
- $removals{$1} = $1;
- $modtotal ++;
- } elsif ($envkey =~ m/^form\.cancel_(\d+)$/) {
- $cancels{$1} = $1;
- unless ( defined($removals{$1}) ) {
- $removals{$1} = $1;
- $canceltotal ++;
- }
- } elsif ($envkey =~ m/^form\.add_(\d+)$/) {
- $adds{$1} = $1;
- $addtotal ++;
- }
- }
-
- 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 my $key (keys(%adds)) {
- unless ( defined($cancels{$key}) ) {
- my ($newstart,$newend) = &get_dates_from_form($key);
- my $newkey = $newstart.'____'.$newend;
- my $blocktypes = &get_block_choices($key);
- $blocking{$newkey} = {
- setter => $env{'user.name'}.':'.$env{'user.domain'},
- event => &escape($env{'form.title_'.$key}),
- blocks => $blocktypes,
- };
- }
- }
- if ($addtotal + $modtotal > 0) {
- &Apache::lonnet::put('comm_block',\%blocking,
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'}
- );
- }
- my $chgestotal = $canceltotal + $modtotal + $addtotal;
- if ($chgestotal > 0) {
- $r->print($lt{'tfcm'}.'');
- if ($canceltotal > 0) {
- $r->print('
');
- } else {
- $r->print($lt{'ncwm'});
- }
- $r->print('
');
- return;
-}
-
-sub get_dates_from_form {
- my $item = shift;
- my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate_'.$item);
- my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate_'.$item);
- return ($startdate,$enddate);
-}
-
-sub get_blockdates {
- my ($records,$blockcount) = @_;
- $$blockcount = 0;
- %{$records} = &Apache::lonnet::dump('comm_block',
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'}
- );
- $$blockcount = keys(%{$records});
-
- if ((keys(%{$records}))[0] =~ /^error: 2 /) {
- $records = {};
- $$blockcount = 0;
- }
-}
-
-sub get_block_choices {
- my $item = shift;
- my $blocklist;
- my ($typeorder,$types) = &blocktype_text();
- foreach my $type (@{$typeorder}) {
- if ($env{'form.'.$type.'_'.$item}) {
- $blocklist->{$type} = 'on';
- } else {
- $blocklist->{$type} = 'off';
- }
- }
- return $blocklist;
-}
-
-sub display_blocker_status {
- my ($r,$records,$ltext) = @_;
- my $parmcount = 0;
-
- my %lt = &Apache::lonlocal::texthash(
- 'modi' => 'Modify',
- 'canc' => 'Cancel',
- );
- my ($typeorder,$types) = &blocktype_text();
- $r->print(&Apache::loncommon::start_data_table());
- $r->print(<<"END");
-
-
-END
- foreach my $record (sort(keys(%{$records}))) {
- my $onchange = 'onFocus="javascript:window.document.forms['.
- "'blockform'].elements['modify_".$parmcount."'].".
- 'checked=true;"';
- 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 ($setuname,$setudom,$title,$blocks) =
- &Apache::loncommon::parse_block_record($$records{$record});
- $title = &HTML::Entities::encode($title,'"<>&');
- my $settername =
- &Apache::loncommon::aboutmewrapper(
- &Apache::loncommon::plainname($setuname,$setudom),
- $setuname,$setudom);
- $r->print(&Apache::loncommon::start_data_table_row());
- $r->print(<<"END");
- $ltext->{'dura'}
- $ltext->{'setb'}
- $ltext->{'even'}
- $ltext->{'blck'}
- $ltext->{'actn'}
- $ltext->{'star'}: $startform
-
$ltext->{'endd'}: $endform$settername
-
-
-END
- foreach my $block (@{$typeorder}) {
- my $blockstatus = '';
- if ($blocks->{$block} eq 'on') {
- $blockstatus = 'checked="checked"';
- }
- $r->print('
-
');
- }
- $r->print(<<"END");
-
-
-END
- $r->print(&Apache::loncommon::end_data_table_row());
- $parmcount++;
- }
- $r->print(<<"END");
-
-
-
-END
- return $parmcount;
-}
-
-sub display_addblocker_table {
- my ($r,$parmcount,$ltext) = @_;
- my $start = time;
- my $end = $start + (60 * 60 * 2); #Default is an exam of 2 hours duration.
- my $onchange = 'onFocus="javascript:window.document.forms['.
- "'blockform'].elements['add_".$parmcount."'].".
- '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 %lt = &Apache::lonlocal::texthash(
- 'addb' => 'Add block',
- 'exam' => 'e.g., Exam 1',
- 'addn' => 'Add new communication blocking periods'
- );
- my ($typeorder,$types) = &blocktype_text();
- $r->print(<<"END");
-$lt{'addn'}
-END
- $r->print(&Apache::loncommon::start_data_table());
- $r->print(<<"END");
-
-
-END
- $r->print(&Apache::loncommon::start_data_table_row());
- $r->print(<<"END");
- $ltext->{'dura'}
- $ltext->{'even'} $lt{'exam'}
- $ltext->{'blck'}
- $ltext->{'actn'}
- $ltext->{'star'}: $startform
-
$ltext->{'endd'}: $endform
-
-END
- foreach my $block (@{$typeorder}) {
- $r->print('
-
');
- }
- $r->print(<<"END");
-
-END
- $r->print(&Apache::loncommon::end_data_table_row());
- $r->print(&Apache::loncommon::end_data_table());
- return;
-}
-
-sub blocktype_text {
- my %types = &Apache::lonlocal::texthash(
- 'com' => 'Messaging',
- 'chat' => 'Chat Room',
- 'boards' => 'Discussion',
- 'port' => 'Portfolio',
- 'groups' => 'Groups',
- 'blogs' => 'Blogs',
- );
- my $typeorder = ['com','chat','boards','port','groups','blogs'];
- return ($typeorder,\%types);
-}
-
# ----------------------------------------------------------- Display a message
sub displaymessage {
@@ -2364,15 +2136,16 @@ sub displaymessage {
my %setters = ();
my $numblocked = 0;
my $crstype = &Apache::loncommon::course_type();
+ my $clientip = &Apache::lonnet::get_requestor_ip($r);
# info to generate "next" and "previous" buttons and check if message is blocked
- my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
- my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus);
+ my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =
+ &Apache::loncommon::blockcheck(\%setters,'com',$clientip);
+ my @messages=&sortedmessages(\%blocked,$startblock,$endblock,$by_ip,\$numblocked,$folder,$msgstatus);
if ( $blocked{$msgid} eq 'ON' ) {
&printheader($r,'/adm/email',&mt('Display a Message'));
#$r->print(&mt('You attempted to display a message that is currently blocked because you are enrolled in one or more courses for which there is an ongoing online exam.'));
- #&build_block_table($r,$startblock,$endblock,\%setters);
- my($blocked, $blocktext) = &Apache::loncommon::blocking_status("com");
+ my($blocked, $blocktext) = &Apache::loncommon::blocking_status("com",$clientip);
$r->print("
".$blocktext);
return;
}
@@ -2406,9 +2179,28 @@ sub displaymessage {
my $number_of_messages = scalar(@messages); #subtract 1 for last index
+ my $head_extra;
+
+# if student's view of resource will be included
+# get tag(s) for css file(s) in use, and pass to &header to include
+# in call to loncommon::start_page()
+
+ if (($env{'request.course.id'} eq $content{'courseid'}) &&
+ (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {
+ my $symb;
+ if (defined($content{'symb'})) {
+ $symb = $content{'symb'};
+ } elsif (defined($content{'baseurl'})) {
+ $symb=&Apache::lonnet::symbread($content{'baseurl'});
+ }
+ if ($symb) {
+ $head_extra = &Apache::loncommon::css_links($symb);
+ }
+ }
+
# start output
- &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
- my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
+ &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',
+ $content{'baseurl'},$head_extra);
# Prepare available functions
my @functionlist;
@@ -2426,19 +2218,22 @@ sub displaymessage {
push(@functionlist,''
.&mt('Delete')
.'');
- push(@functionlist,''
- .&mt('Back to Folder Display')
- .'');
+
+# Prepare available navigation
+ my @navigationlist;
if ($counter > 0){
- push(@functionlist,''
+ push(@navigationlist,''
.&mt('Previous')
.'');
}
if ($counter < $number_of_messages - 1){
- push(@functionlist,''
+ push(@navigationlist,''
.&mt('Next')
.'');
}
+ push(@navigationlist,''
+ .&mt('Back to Folder Display')
+ .'');
# Prepare available actions
my $symb;
@@ -2447,12 +2242,13 @@ sub displaymessage {
} elsif (defined($content{'baseurl'})) {
$symb=&Apache::lonnet::symbread($content{'baseurl'});
}
- my @actionlist;
+ my @actionlist;
if ($env{'user.adv'}) {
- if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
+ if (($env{'request.course.id'}) && ($from_student) &&
+ (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
push(@actionlist,&Apache::loncommon::track_student_link(
- &mt('View recent activity')
+ 'View recent activity'
,$content{'sendername'}
,$content{'senderdomain'}
,'check'));
@@ -2475,7 +2271,7 @@ sub displaymessage {
}
}
-# Print functionlist and actionlist in page header
+# Print functionlist, navigationlist, and actionlist in page header
my $functions=''
+ .'
'
.&Apache::lontexconvert::msgtexconverted($content{'message'},1)
.'
'
);
@@ -2891,12 +2707,20 @@ sub displayresource {
&& (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {
my $symb;
if (defined($content{'symb'})) {
- $symb = $content{'symb'};
- } else {
- $symb=&Apache::lonnet::symbread($content{'baseurl'});
+ $symb = &Apache::lonenc::check_decrypt($content{'symb'});
+ } elsif (defined($content{'baseurl'})) {
+ $symb =
+ &Apache::lonnet::symbread(&Apache::lonenc::check_decrypt($content{'baseurl'}));
}
# Could not get a symb, give up
unless ($symb) { return $content{'citation'}; }
+ if ($symb =~ /ext\.tool$/) {
+ return ''.&mt('Current transactions for student (if applicable)').'
'.
+ &Apache::loncommon::get_previous_attempt($symb,
+ $content{'sendername'},
+ $content{'senderdomain'},
+ $content{'courseid'});
+ }
# Have a symb, can render
return ''.&mt('Current attempts of student (if applicable)').'
'.
&Apache::loncommon::get_previous_attempt($symb,
@@ -2922,11 +2746,16 @@ sub displayresource {
# ================================================================== The Header
sub header {
- my ($r,$title,$baseurl)=@_;
+ my ($r,$title,$baseurl,$head_extra)=@_;
my $extra = &Apache::loncommon::studentbrowser_javascript();
if ($baseurl) {
$extra .= "
');
+ }
+ if (ref($disallowed{'cc'}) eq 'HASH') {
+ $r->print(&mt("The following CCs were excluded because the user's domain does not accept messages from server's domain:").'
');
+ }
+ if (ref($disallowed{'bcc'}) eq 'HASH') {
+ $r->print(&mt("The following BCCs were excluded because the user's domain does not accept messages from server's domain:").'
');
+ }
+ }
} else {
&printheader($r,'','Messages cancelled.');
return 'cancelled';
@@ -3331,16 +3268,29 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['display','replyto','forward','markread','markdel','markunread',
'sendreply','compose','sendmail','critical','recname','recdom',
- 'recordftf','sortedby','block','folder','startdis','interdis',
+ 'recordftf','sortedby','folder','startdis','interdis',
'showcommentbaseurl','dismode','group','subject','text','ref',
- 'msgstatus']);
+ 'msgstatus','btoken']);
$sqs='&sortedby='.$env{'form.sortedby'};
-# ------------------------------------------------------ They checked for email
- unless ($env{'form.block'}) {
- &Apache::lonnet::put('email_status',{'recnewemail'=>0});
+# ----------- Check if access was from balancer to server with existing session
+
+ if ($env{'form.btoken'}) {
+ my %info = &Apache::lonnet::tmpget($env{'form.btoken'});
+ &Apache::lonnet::tmpdel($env{'form.btoken'});
+ delete($env{'form.btoken'});
+ unless ($env{'form.display'}) {
+ if (($info{'display'}) && ($info{'mailrecip'})) {
+ if (&unescape($info{'mailrecip'}) eq $env{'user.name'}.':'.$env{'user.domain'}) {
+ $env{'form.display'} = &unescape($info{'display'});
+ }
+ }
+ }
}
+# ------------------------------------------------------ They checked for email
+ &Apache::lonnet::put('email_status',{'recnewemail'=>0});
+
# ----------------------------------------------------------------- Breadcrumbs
&Apache::lonhtmlcommon::clear_breadcrumbs();
@@ -3542,8 +3492,6 @@ sub handler {
&compout($r,'','',$env{'form.compose'});
} elsif ($env{'form.recordftf'}) {
&facetoface($r,$env{'form.recordftf'});
- } elsif ($env{'form.block'}) {
- &examblock($r,$env{'form.block'});
} elsif ($env{'form.sendmail'}) {
if ($env{'form.multiforward'}) {
&printheader($r,'','Messages being sent.');
@@ -3594,8 +3542,12 @@ sub handler {
my $count = keys(%forwardfail);
my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Could not forward [quant,_1,message].',$count),1);
foreach my $key (keys(%forwardfail)) {
- $message .= '
'.&mt('Could not deliver forwarded message.').' '.
- &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.')';
+ $message .= '
'.&mt('Could not deliver forwarded message.').' ';
+ if ($forwardfail{$key} eq 'blocked') {
+ $message .= &mt('Sending messages is blocked from your IP address');
+ } else {
+ $message .= &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.')';
+ }
}
$message = &Apache::loncommon::confirmwrapper($message);
$r->print($message);