version 1.43, 2006/11/29 05:54:34
|
version 1.45, 2006/11/29 19:31:47
|
Line 649 sub disnew {
|
Line 649 sub disnew {
|
my @msgids = sort(&Apache::lonnet::getkeys('nohist_email')); |
my @msgids = sort(&Apache::lonnet::getkeys('nohist_email')); |
my @newmsgs; |
my @newmsgs; |
my %setters = (); |
my %setters = (); |
my $startblock = 0; |
|
my $endblock = 0; |
|
my %blocked = (); |
my %blocked = (); |
my $numblocked = 0; |
my $numblocked = 0; |
# Check for blocking of display because of scheduled online exams. |
# Check for blocking of display because of scheduled online exams. |
&blockcheck(\%setters,\$startblock,\$endblock); |
my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com'); |
my %status_cache = |
my %status_cache = |
&Apache::lonnet::get('email_status',\@msgids); |
&Apache::lonnet::get('email_status',\@msgids); |
my %descriptions; |
my %descriptions; |
Line 706 ENDLINK
|
Line 704 ENDLINK
|
if ($numblocked > 0) { |
if ($numblocked > 0) { |
my $beginblock = &Apache::lonlocal::locallocaltime($startblock); |
my $beginblock = &Apache::lonlocal::locallocaltime($startblock); |
my $finishblock = &Apache::lonlocal::locallocaltime($endblock); |
my $finishblock = &Apache::lonlocal::locallocaltime($endblock); |
if ($numblocked == 1) { |
$r->print('<h3>'.&mt('You have [quant,_1,blocked unread message,blocked unread messages].',$numblocked).'</h3>'."\n". |
$r->print("<h3>".&mt('You have').' '.$numblocked.' '.&mt('blocked unread message').".</h3>"); |
&mt('[quant,_1,message is,messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock).'<br />'."\n". |
$r->print(&mt('This message is not viewable because').' '); |
&Apache::loncommon::build_block_table($startblock,$endblock, |
} else { |
\%setters)); |
$r->print("<h3>".&mt('You have').' '.$numblocked.' '.&mt('blocked unread messages').".</h3>"); |
|
$r->print(&mt('These').' '.$numblocked.' '.&mt('messages are not viewable because ')); |
|
} |
|
$r->print( |
|
&mt('display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams').'.'); |
|
&build_block_table($r,$startblock,$endblock,\%setters); |
|
} |
} |
} |
} |
|
|
Line 740 sub disfolder {
|
Line 732 sub disfolder {
|
my ($r,$folder)=@_; |
my ($r,$folder)=@_; |
my %blocked = (); |
my %blocked = (); |
my %setters = (); |
my %setters = (); |
my $startblock; |
|
my $endblock; |
|
my $numblocked = 0; |
my $numblocked = 0; |
&blockcheck(\%setters,\$startblock,\$endblock); |
my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com'); |
$r->print(<<ENDDISHEADER); |
$r->print(<<ENDDISHEADER); |
<script type="text/javascript"> |
<script type="text/javascript"> |
function checkall() { |
function checkall() { |
Line 886 ENDDISHEADER
|
Line 876 ENDDISHEADER
|
my $beginblock = &Apache::lonlocal::locallocaltime($startblock); |
my $beginblock = &Apache::lonlocal::locallocaltime($startblock); |
my $finishblock = &Apache::lonlocal::locallocaltime($endblock); |
my $finishblock = &Apache::lonlocal::locallocaltime($endblock); |
$r->print('<br /><br />'. |
$r->print('<br /><br />'. |
$numblocked.' '.&mt('message(s) is/are not viewable because display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams.')); |
&mt('[_1,quant,message is, messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock)); |
&build_block_table($r,$startblock,$endblock,\%setters); |
$r->print(&Apache::loncommon::build_block_table($startblock,$endblock, |
|
\%setters)); |
} |
} |
} |
} |
|
|
Line 1311 ENDBFORM
|
Line 1302 ENDBFORM
|
sub examblock { |
sub examblock { |
my ($r,$action) = @_; |
my ($r,$action) = @_; |
unless ($env{'request.course.id'}) { return;} |
unless ($env{'request.course.id'}) { return;} |
if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'}) |
if (!&Apache::lonnet::allowed('dcm',$env{'request.course.id'}) |
&& ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}. |
&& ! &Apache::lonnet::allowed('dcm',$env{'request.course.id'}. |
'/'.$env{'request.course.sec'})) { |
'/'.$env{'request.course.sec'})) { |
$r->print('Not allowed'); |
$r->print('Not allowed'); |
return; |
return; |
Line 1331 sub examblock {
|
Line 1322 sub examblock {
|
'dura' => 'Duration', |
'dura' => 'Duration', |
'setb' => 'Set by', |
'setb' => 'Set by', |
'even' => 'Event', |
'even' => 'Event', |
|
'blck' => 'Blocked?', |
'actn' => 'Action', |
'actn' => 'Action', |
'star' => 'Start', |
'star' => 'Start', |
'endd' => 'End' |
'endd' => 'End' |
Line 1388 sub blockstore {
|
Line 1380 sub blockstore {
|
my %blocking = (); |
my %blocking = (); |
$r->print('<h3>'.$lt{'head'}.'</h3>'); |
$r->print('<h3>'.$lt{'head'}.'</h3>'); |
foreach my $envkey (keys(%env)) { |
foreach my $envkey (keys(%env)) { |
if ($envkey =~ m/^form\.modify_(\w+)$/) { |
if ($envkey =~ m/^form\.modify_(\d+)$/) { |
$adds{$1} = $1; |
$adds{$1} = $1; |
$removals{$1} = $1; |
$removals{$1} = $1; |
$modtotal ++; |
$modtotal ++; |
Line 1401 sub blockstore {
|
Line 1393 sub blockstore {
|
} elsif ($envkey =~ m/^form\.add_(\d+)$/) { |
} elsif ($envkey =~ m/^form\.add_(\d+)$/) { |
$adds{$1} = $1; |
$adds{$1} = $1; |
$addtotal ++; |
$addtotal ++; |
} |
} |
} |
} |
|
|
foreach my $key (keys(%removals)) { |
foreach my $key (keys(%removals)) { |
Line 1415 sub blockstore {
|
Line 1407 sub blockstore {
|
unless ( defined($cancels{$key}) ) { |
unless ( defined($cancels{$key}) ) { |
my ($newstart,$newend) = &get_dates_from_form($key); |
my ($newstart,$newend) = &get_dates_from_form($key); |
my $newkey = $newstart.'____'.$newend; |
my $newkey = $newstart.'____'.$newend; |
$blocking{$newkey} = $env{'user.name'}.':'.$env{'user.domain'}.':'.$env{'form.title_'.$key}; |
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) { |
if ($addtotal + $modtotal > 0) { |
Line 1466 sub get_blockdates {
|
Line 1463 sub get_blockdates {
|
} |
} |
} |
} |
|
|
|
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 { |
sub display_blocker_status { |
my ($r,$records,$ltext) = @_; |
my ($r,$records,$ltext) = @_; |
my $parmcount = 0; |
my $parmcount = 0; |
Line 1474 sub display_blocker_status {
|
Line 1485 sub display_blocker_status {
|
'modi' => 'Modify', |
'modi' => 'Modify', |
'canc' => 'Cancel', |
'canc' => 'Cancel', |
); |
); |
|
my ($typeorder,$types) = &blocktype_text(); |
$r->print(&Apache::loncommon::start_data_table()); |
$r->print(&Apache::loncommon::start_data_table()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<tr> |
<tr> |
<th>$$ltext{'dura'}</th> |
<th>$ltext->{'dura'}</th> |
<th>$$ltext{'setb'}</th> |
<th>$ltext->{'setb'}</th> |
<th>$$ltext{'even'}</th> |
<th>$ltext->{'even'}</th> |
<th>$$ltext{'actn'}?</th> |
<th>$ltext->{'blck'}</th> |
|
<th>$ltext->{'actn'}?</th> |
</tr> |
</tr> |
END |
END |
foreach my $record (sort(keys(%{$records}))) { |
foreach my $record (sort(keys(%{$records}))) { |
Line 1491 END
|
Line 1504 END
|
my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange); |
my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange); |
my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange); |
my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange); |
|
|
my ($setuname,$setudom,$title) = |
my ($setuname,$setudom,$title,$blocks) = |
&parse_block_record($$records{$record}); |
&Apache::loncommon::parse_block_record($$records{$record}); |
$title = &HTML::Entities::encode($title,'"<>&'); |
$title = &HTML::Entities::encode($title,'"<>&'); |
my $settername = &Apache::loncommon::plainname($setuname,$setudom); |
my $settername = |
|
&Apache::loncommon::aboutmewrapper( |
|
&Apache::loncommon::plainname($setuname,$setudom), |
|
$setuname,$setudom); |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<td>$$ltext{'star'}: $startform<br/>$$ltext{'endd'}: $endform</td> |
<td>$ltext->{'star'}: $startform<br/>$ltext->{'endd'}: $endform</td> |
<td>$settername</td> |
<td>$settername</td> |
<td><input type="text" name="title_$parmcount" size="15" value="$title" /><input type="hidden" name="key_$parmcount" value="$record" /></td> |
<td><input type="text" name="title_$parmcount" size="15" value="$title" /><input type="hidden" name="key_$parmcount" value="$record" /></td> |
|
<td> |
|
END |
|
foreach my $block (@{$typeorder}) { |
|
my $blockstatus = ''; |
|
if ($blocks->{$block} eq 'on') { |
|
$blockstatus = 'checked="true"'; |
|
} |
|
$r->print('<label><input type="checkbox" name="'.$block.'_'.$parmcount.'" '.$blockstatus.' value="1" />'.$types->{$block}.'</label><br />'); |
|
} |
|
$r->print(<<"END"); |
|
</td> |
<td><label>$lt{'modi'}? <input type="checkbox" name="modify_$parmcount" /></label><br /><label>$lt{'canc'}? <input type="checkbox" name="cancel_$parmcount" /></label> |
<td><label>$lt{'modi'}? <input type="checkbox" name="modify_$parmcount" /></label><br /><label>$lt{'canc'}? <input type="checkbox" name="cancel_$parmcount" /></label> |
END |
END |
$r->print(&Apache::loncommon::end_data_table_row()); |
$r->print(&Apache::loncommon::end_data_table_row()); |
Line 1513 END
|
Line 1540 END
|
return $parmcount; |
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 { |
sub display_addblocker_table { |
my ($r,$parmcount,$ltext) = @_; |
my ($r,$parmcount,$ltext) = @_; |
my $start = time; |
my $start = time; |
Line 1540 sub display_addblocker_table {
|
Line 1554 sub display_addblocker_table {
|
'exam' => 'e.g., Exam 1', |
'exam' => 'e.g., Exam 1', |
'addn' => 'Add new communication blocking periods' |
'addn' => 'Add new communication blocking periods' |
); |
); |
|
my ($typeorder,$types) = &blocktype_text(); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<h4>$lt{'addn'}</h4> |
<h4>$lt{'addn'}</h4> |
END |
END |
$r->print(&Apache::loncommon::start_data_table()); |
$r->print(&Apache::loncommon::start_data_table()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<tr> |
<tr> |
<th>$$ltext{'dura'}</th> |
<th>$ltext->{'dura'}</th> |
<th>$$ltext{'even'} $lt{'exam'}</th> |
<th>$ltext->{'even'} $lt{'exam'}</th> |
<th>$$ltext{'actn'}?</th> |
<th>$ltext->{'blck'}</th> |
|
<th>$ltext->{'actn'}?</th> |
</tr> |
</tr> |
END |
END |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<td>$$ltext{'star'}: $startform<br />$$ltext{'endd'}: $endform</td> |
<td>$ltext->{'star'}: $startform<br />$ltext->{'endd'}: $endform</td> |
<td><input type="text" name="title_$parmcount" size="15" value="" /></td> |
<td><input type="text" name="title_$parmcount" size="15" value="" /></td> |
|
<td> |
|
END |
|
foreach my $block (@{$typeorder}) { |
|
$r->print('<label><input type="checkbox" name="'.$block.'_'.$parmcount.'" value="1" />'.$types->{$block}.'</label><br />'); |
|
} |
|
$r->print(<<"END"); |
|
</td> |
<td><label>$lt{'addb'}? <input type="checkbox" name="add_$parmcount" value="1" /></label></td> |
<td><label>$lt{'addb'}? <input type="checkbox" name="add_$parmcount" value="1" /></label></td> |
END |
END |
$r->print(&Apache::loncommon::end_data_table_row()); |
$r->print(&Apache::loncommon::end_data_table_row()); |
Line 1562 END
|
Line 1585 END
|
return; |
return; |
} |
} |
|
|
sub blockcheck { |
sub blocktype_text { |
my ($setters,$startblock,$endblock) = @_; |
my %types = &Apache::lonlocal::texthash( |
# Retrieve active student roles and active course coordinator/instructor roles |
'com' => 'Messaging', |
my %live_courses = |
'chat' => 'Chat', |
map { $_ => 1} &Apache::loncommon::findallcourses(); |
'boards' => 'Discussion', |
# FIXME should really probe for apriv, but ::allowed can only probe the |
'port' => 'Portfolio', |
# currently active role |
'groups' => 'Groups', |
my %staff_of = |
'blogs' => 'Blogs', |
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 %lt = &Apache::lonlocal::texthash( |
|
'cacb' => 'Currently active communication blocks', |
|
'cour' => 'Course/Group', |
|
'dura' => 'Duration', |
|
'blse' => 'Block set by' |
|
); |
); |
$r->print(<<"END"); |
my $typeorder = ['com','chat','boards','port','groups','blogs']; |
<br /><br />$lt{'cacb'}:<br /><br /> |
return ($typeorder,\%types); |
END |
|
$r->print(&Apache::loncommon::start_data_table()); |
|
$r->print(<<"END"); |
|
<tr> |
|
<th>$lt{'cour'}</th> |
|
<th>$lt{'dura'}</th> |
|
<th>$lt{'blse'}</th> |
|
</tr> |
|
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) = @{$$setters{$course}{times}[$i]}; |
|
$openblock = &Apache::lonlocal::locallocaltime($openblock); |
|
$closeblock= &Apache::lonlocal::locallocaltime($closeblock); |
|
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<td>'.$courseinfo{'description'}.'</td>'. |
|
'<td>'.$openblock.' to '.$closeblock.'</td>'. |
|
'<td>'.$fullname.' ('.$uname.':'.$udom. |
|
')</td>'. |
|
&Apache::loncommon::end_data_table_row()); |
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_data_table()); |
|
} |
} |
|
|
# ----------------------------------------------------------- Display a message |
# ----------------------------------------------------------- Display a message |
Line 1651 sub displaymessage {
|
Line 1605 sub displaymessage {
|
my $suffix=&Apache::lonmsg::foldersuffix($folder); |
my $suffix=&Apache::lonmsg::foldersuffix($folder); |
my %blocked = (); |
my %blocked = (); |
my %setters = (); |
my %setters = (); |
my $startblock = 0; |
|
my $endblock = 0; |
|
my $numblocked = 0; |
my $numblocked = 0; |
my $crstype = &Apache::loncommon::course_type(); |
my $crstype = &Apache::loncommon::course_type(); |
|
|
# info to generate "next" and "previous" buttons and check if message is blocked |
# info to generate "next" and "previous" buttons and check if message is blocked |
&blockcheck(\%setters,\$startblock,\$endblock); |
my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com'); |
my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder); |
my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder); |
if ( $blocked{$msgid} eq 'ON' ) { |
if ( $blocked{$msgid} eq 'ON' ) { |
&printheader($r,'/adm/email',&mt('Display a Message')); |
&printheader($r,'/adm/email',&mt('Display a Message')); |
Line 1909 sub sendoffmail {
|
Line 1861 sub sendoffmail {
|
my ($rec,$txt) = ($line =~ /^([^:]+:[^:]+):(.*)$/); |
my ($rec,$txt) = ($line =~ /^([^:]+:[^:]+):(.*)$/); |
if ($txt) { |
if ($txt) { |
$rec =~ s/^\s+//; |
$rec =~ s/^\s+//; |
$rec =~ ~s/\s+$//; |
$rec =~ s/\s+$//; |
$toaddr{$rec}.=$txt."\n"; |
$toaddr{$rec}.=$txt."\n"; |
} |
} |
} |
} |
Line 2262 sub handler {
|
Line 2214 sub handler {
|
&storedcommentlisting($r); |
&storedcommentlisting($r); |
} else { |
} else { |
&printheader($r,'','Display All Messages'); |
&printheader($r,'','Display All Messages'); |
&Apache::loncommunicate::menu($r); |
&Apache::loncommunicate::menu($r); |
&disall($r,($folder?$folder:$dismode)); |
&disall($r,($folder?$folder:$dismode)); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |