# The LearningOnline Network with CAPA
# displays the blocking status table
#
# $Id: lonblockingstatus.pm,v 1.5 2009/07/27 12:12:48 kalberla Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
#
package Apache::lonblockingstatus;
use strict;
use Apache::Constants qw(:common);
use Apache::loncommon();
use Apache::lonnet;
use GDBM_File;
use POSIX qw(strftime mktime);
use Apache::lonmenu();
use Apache::lonenc();
use Apache::lonlocal;
use Apache::lonnet();
use HTML::Entities;
use Apache::lonhtmlcommon();
use Apache::loncoursedata();
use Apache::lontexconvert();
use Apache::lonclonecourse();
use LONCAPA qw(:DEFAULT :match);
use DateTime::TimeZone;
use DateTime::Locale::Catalog;
sub handler {
my $r = shift;
Apache::loncommon::no_cache($r);
Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
$r->print(
Apache::loncommon::start_page(
'Communication Blocking Status Information',
undef, {'only_body' => 1, }));
Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['activity']);
my $blocktext = get_blocking_table($env{'form.activity'});
$r->print($blocktext);
$r->print(Apache::loncommon::end_page());
return OK;
}
sub get_blocking_table{
my ($activity,$uname,$udom) = @_;
my %setters;
my ($blocked,$output,$ownitem,$is_course);
my ($startblock,$endblock)=&Apache::loncommon::blockcheck(\%setters,$activity,$uname,$udom);
if ($startblock && $endblock) {
$blocked = 1;
my $category;
if ($activity eq 'boards') {
$category = 'Discussion posts in this course';
} elsif ($activity eq 'chat') {
$category = 'Chat';
} elsif ($activity eq 'msgdisplay') {
$category = 'This message';
} elsif ($activity eq 'blogs') {
$category = 'Blogs';
} elsif ($activity eq 'port') {
if (defined($uname) && defined($udom)) {
if ($uname eq $env{'user.name'} &&
$udom eq $env{'user.domain'}) {
$ownitem = 1;
}
}
$is_course = &Apache::lonnet::is_course($udom,$uname);
if ($ownitem) {
$category = 'Your portfolio files';
} elsif ($is_course) {
my $coursedesc;
foreach my $course (keys(%setters)) {
my %courseinfo =
&Apache::lonnet::coursedescription($course);
$coursedesc = $courseinfo{'description'};
}
$category = "Group portfolio in the course '$coursedesc'";
} else {
$category = 'Portfolio files belonging to ';
if ($env{'user.name'} eq 'public' &&
$env{'user.domain'} eq 'public') {
$category .= &plainname($uname,$udom);
} else {
$category .= &aboutmewrapper(&plainname($uname,$udom),$uname,$udom);
}
}
} elsif ($activity eq 'groups') {
$category = 'Groups in this course';
} else {
$category = 'Communication';
}
my $showstart = &Apache::lonlocal::locallocaltime($startblock);
my $showend = &Apache::lonlocal::locallocaltime($endblock);
$output = '<br />'.&mt('[_1] will be inaccessible between [_2] and [_3] because communication is being blocked.',$category,$showstart,$showend).'<br />';
if (!($activity eq 'port' && !($ownitem) && !($is_course))) {
$output .= build_block_table($startblock,$endblock,\%setters);
}
}
return $output;
}
sub build_block_table {
my ($startblock,$endblock,$setters) = @_;
my %lt = &Apache::lonlocal::texthash(
'cacb' => 'Currently active communication blocks',
'cour' => 'Course',
'dura' => 'Duration',
'blse' => 'Block set by'
);
my $output;
$output = '<br />'.$lt{'cacb'}.':<br />';
$output .= Apache::loncommon::start_data_table();
$output .= '
<tr>
<th>'.$lt{'cour'}.'</th>
<th>'.$lt{'dura'}.'</th>
<th>'.$lt{'blse'}.'</th>
</tr>
';
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);
if (defined($env{'user.name'}) && defined($env{'user.domain'})
&& $env{'user.name'} ne 'public'
&& $env{'user.domain'} ne 'public') {
$fullname = Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
}
my ($openblock,$closeblock) = @{$$setters{$course}{times}[$i]};
$openblock = &Apache::lonlocal::locallocaltime($openblock);
$closeblock= &Apache::lonlocal::locallocaltime($closeblock);
$output .= &Apache::loncommon::start_data_table_row().
'<td>'.$courseinfo{'description'}.'</td>'.
'<td>'.$openblock.' to '.$closeblock.'</td>'.
'<td>'.$fullname.'</td>'.
&Apache::loncommon::end_data_table_row();
}
}
$output .= Apache::loncommon::end_data_table();
}
1;
__END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>