--- loncom/interface/lonmsgdisplay.pm 2010/08/07 19:23:51 1.154
+++ loncom/interface/lonmsgdisplay.pm 2019/08/06 17:53:56 1.181.2.2
@@ -1,7 +1,7 @@
-# $textareaclass The LearningOnline Network with CAPA
+# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.154 2010/08/07 19:23:51 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.181.2.2 2019/08/06 17:53:56 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;
@@ -110,7 +112,7 @@ use Apache::lonfeedback;
use Apache::lonrss();
use Apache::lonselstudent();
use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
# Querystring component with sorting type
my $sqs='';
@@ -120,21 +122,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 +186,16 @@ function folder_choice(targetform,caller
if (targetform.folderaction.options[targetform.folderaction.selectedIndex].value == 'rename') {
for (var i=0; i
+
'."\n".
''.
''.
@@ -261,8 +270,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 +387,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 +552,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 +573,7 @@ sub discourse {
$result .= '
';
if (ref($statushash) eq 'HASH') {
$statushash->{'previous'} = 1;
@@ -587,7 +596,7 @@ sub discourse {
$result .= '';
if (ref($statushash) eq 'HASH') {
$statushash->{'future'} = 1;
@@ -662,7 +671,7 @@ sub disgroup {
}
$r->print(''."\n"
+ );
my $postedstartdis=$startdis+1;
$r->print('');
if ($numblocked > 0) {
@@ -1443,9 +1493,12 @@ function courseRecipients() {
document.compemail.groupmail.value = document.$formname.groupmail[document.$formname.groupmail.selectedIndex].value;
|;
}
+ #typeof(...forminput.length) returns 'undefined' if only one entry exists
$broadcast_js .= qq|
if (typeof(document.$formname.selectedusers_forminput.length)=="undefined") {
- document.compemail.courserecips.value += '_&&&_'+document.$formname.selectedusers_forminput.value;
+ if (document.$formname.selectedusers_forminput.checked) {
+ document.compemail.courserecips.value += '_&&&_'+document.$formname.selectedusers_forminput.value;
+ }
} else {
for (var i=0; i ');
+ &mt("The subject in each forwarded message will be [_1]'Forwarding:'[_2] followed by the original subject.",'','').''.
&mt('Unless you choose otherwise:').'
-'.&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.','
@@ -1865,7 +1918,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.'.')."
','',''));
$r->print(<
'.&mt('Subject').': '.$content{'subject'}.'
'.
$content{'message'};
}
} else {
@@ -1927,15 +1979,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 {
@@ -2365,7 +2106,6 @@ sub displaymessage {
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");
$r->print("
".$blocktext);
return;
@@ -2402,7 +2142,6 @@ sub displaymessage {
my $number_of_messages = scalar(@messages); #subtract 1 for last index
# start output
&printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
- my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
# Prepare available functions
my @functionlist;
@@ -2420,19 +2159,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;
@@ -2441,12 +2183,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'));
@@ -2469,7 +2212,7 @@ sub displaymessage {
}
}
-# Print functionlist and actionlist in page header
+# Print functionlist, navigationlist, and actionlist in page header
my $functions='