Annotation of loncom/interface/lonblockingstatus.pm, revision 1.13
1.1 droeschl 1: # The LearningOnline Network with CAPA
2: # displays the blocking status table
3: #
1.13 ! raeburn 4: # $Id: lonblockingstatus.pm,v 1.12 2013/01/15 18:24:15 raeburn Exp $
1.1 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28: #
29: package Apache::lonblockingstatus;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::loncommon();
1.3 kalberla 34: use Apache::lonnet;
35: use Apache::lonlocal;
1.8 raeburn 36: use LONCAPA qw(:DEFAULT :match);
1.1 droeschl 37:
38: sub handler {
39: my $r = shift;
1.8 raeburn 40: &Apache::loncommon::no_cache($r);
41: &Apache::loncommon::content_type($r,'text/html');
1.6 droeschl 42:
1.1 droeschl 43: $r->send_http_header;
44: return OK if $r->header_only;
45:
1.8 raeburn 46: my (%activities,$activity,$origurl);
1.13 ! raeburn 47: map { $activities{$_} = 1; } ('boards','chat','msgdisplay','blogs','groups','port','printout','docs','passwd');
1.1 droeschl 48:
1.8 raeburn 49: # determine what kind of blocking we want details for
50: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['activity','url']);
51: $activity = $env{'form.activity'};
52:
53: my $title = 'Communication Blocking Status Information';
54:
1.11 raeburn 55: if (($activity eq 'docs') || ($activity eq 'printout')) {
1.8 raeburn 56: $title = 'Blocking Status Information';
57: $origurl = $env{'form.url'};
58: }
59: $r->print(&Apache::loncommon::start_page($title,undef,
60: {'only_body' => 1}));
61:
62: if (($activity eq '') || (!$activities{$activity})) {
63: $r->print('<span class="LC_error">'.&mt('Error: unknown activity type blocked').'</span>');
64: } else {
65: $r->print(&blockpage($activity,$origurl));
66: }
1.6 droeschl 67:
1.8 raeburn 68: $r->print(&Apache::loncommon::end_page());
1.6 droeschl 69:
1.1 droeschl 70: return OK;
71: }
1.6 droeschl 72:
73:
74: sub blockpage {
1.8 raeburn 75: my ($activity,$origurl) = @_;
1.6 droeschl 76:
77: # in case of a portfolio block we need to determine the owner of the files
78: # we're trying to look at. This information is passed via query string.
79: my ($uname, $udom);
80:
1.13 ! raeburn 81: if (($activity eq 'port') ||
! 82: (($activity eq 'passwd') && ($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))) {
1.8 raeburn 83: &Apache::loncommon::get_unprocessed_cgi(
1.6 droeschl 84: $ENV{'QUERY_STRING'}, ['udom', 'uname'] );
85:
86: ($uname, $udom) = ($env{'form.uname'}, $env{'form.udom'});
1.8 raeburn 87: if (($uname !~ /^$match_username$/) || ($udom !~ /^$match_domain$/)) {
1.13 ! raeburn 88: if ($activity eq 'port') {
! 89: return '<span class="LC_error">'.
! 90: &mt('Information about the owner of the portfolio files you were trying to view was missing or invalid.').
! 91: '</span><br />'.
! 92: &mt('Without valid owner information, the reason why access is blocked can not be determined');
! 93: } else {
! 94: return '<span class="LC_error">'.
! 95: &mt('Information about the username and/or domain for which you were trying to reset a password was missing or invalid.').
! 96: '</span><br />'.
! 97: &mt('Without valid information, the reason why access is blocked can not be determined');
! 98: }
1.8 raeburn 99: }
1.6 droeschl 100: }
101:
102:
103: # retrieve start/end of possible active blocking
1.4 kalberla 104: my %setters;
1.8 raeburn 105: my ($startblock,$endblock,$triggerblock) =
1.9 raeburn 106: &Apache::loncommon::blockcheck(\%setters,$activity,$uname,$udom,$origurl);
1.6 droeschl 107:
108: # nothing to do if there's no active blocking
109: unless ($startblock && $endblock) { return ''; }
110:
111: # lookup $activity -> description
112: #possible activity #corresponding description
1.8 raeburn 113: my %descs = (
114: boards => 'Discussion posts in this course',
115: chat => 'Chat Room',
116: msgdisplay => 'This message',
117: blogs => 'Blogs',
118: groups => 'Groups in this course',
1.11 raeburn 119: printout => 'Printout generation',
1.8 raeburn 120: docs => 'Course Content',
1.13 ! raeburn 121: passwd => 'Changing of passwords',
1.8 raeburn 122: );
123:
124: if ($activity eq 'groups' || $activity eq 'boards') {
1.12 raeburn 125: if (&Apache::loncommon::course_type() eq 'Community') {
1.8 raeburn 126: $descs{'boards'} = 'Discussion posts in this community',
127: $descs{'groups'} = 'Groups in this community',
128: $descs{'docs'} = 'Community Content',
129: }
130: }
131:
132: my $description = $descs{$activity};
133: if ($activity eq 'port') {
134: $description = &get_portfolio_category($uname,$udom,\%setters);
135: }
136: if ($description eq '') {
137: $description = 'Communication';
138: }
1.6 droeschl 139:
140: my $showstart = Apache::lonlocal::locallocaltime($startblock);
141: my $showend = Apache::lonlocal::locallocaltime($endblock);
142:
143: my $output;
144:
1.8 raeburn 145: if ( ref($description) ne 'ARRAY' ) {
1.6 droeschl 146: #default: $description is one of the above descriptions
1.8 raeburn 147: if ($activity eq 'docs') {
1.9 raeburn 148: $output=&mt( 'Access to the content page you are attempting to'
1.8 raeburn 149: . ' view will be unavailable between [_1] and [_2] because'
1.10 raeburn 150: . ' access to selected '.$description.' is being blocked.'
1.8 raeburn 151: ,$showstart, $showend);
1.13 ! raeburn 152: } elsif (($activity eq 'printout') || ($activity eq 'passwd')) {
1.11 raeburn 153: $output = mt( $description
154: . ' will be unavailable between [_1] and [_2] because'
155: . ' this functionality is being blocked.'
156: ,$showstart, $showend);
1.8 raeburn 157: } else {
158: $output = mt( $description
159: . ' will be inaccessible between [_1] and [_2] because'
160: . ' communication is being blocked.'
161: ,$showstart, $showend);
162: }
1.6 droeschl 163: } else {
164: # @$description is is the array returned from get_portfolio_category()
165: # and contains the description (e.g. "Portfolio files belonging to [_1]"
166: # and the value for [_1]
167: $output = mt( $$description[0]
168: . ' will be inaccessible between [_2] and [_3] because'
169: . ' communication is being blocked.'
170: ,$$description[1], $showstart, $showend)
171: }
172:
173: $output = "<p class=\"LC_info\">$output</p>";
174:
175: # show a table containing details, except if user is trying to look
176: # at a different user's portfolio files
177: if ( $activity ne 'port' # no portfolio
178: || ( $uname eq $env{'user.name'} # or own portfolio
179: && $udom eq $env{'user.domain'} )
180: || Apache::lonnet::is_course($udom, $uname) ) # or portfolio of a course
181: {
1.8 raeburn 182: $output .= &build_block_table(\%setters);
1.4 kalberla 183: }
1.6 droeschl 184:
1.5 kalberla 185: return $output;
186: }
187:
188: sub build_block_table {
1.8 raeburn 189: my ($setters) = @_;
1.5 kalberla 190: my %lt = &Apache::lonlocal::texthash(
1.11 raeburn 191: 'cacb' => 'Currently active communication/content blocks',
1.5 kalberla 192: 'cour' => 'Course',
193: 'dura' => 'Duration',
194: 'blse' => 'Block set by'
195: );
196: my $output;
1.6 droeschl 197: $output = Apache::loncommon::start_data_table()
198: . Apache::loncommon::data_table_caption($lt{'cacb'})
199: . Apache::loncommon::start_data_table_header_row()
200: . "<th>$lt{'cour'}</th> <th>$lt{'dura'}</th> <th>$lt{'blse'}</th>"
201: . Apache::loncommon::end_data_table_header_row();
202:
1.5 kalberla 203: foreach my $course (keys(%{$setters})) {
204: my %courseinfo=&Apache::lonnet::coursedescription($course);
205: for (my $i=0; $i<@{$$setters{$course}{staff}}; $i++) {
206: my ($uname,$udom) = @{$$setters{$course}{staff}[$i]};
207: my $fullname = Apache::loncommon::plainname($uname,$udom);
208: if (defined($env{'user.name'}) && defined($env{'user.domain'})
209: && $env{'user.name'} ne 'public'
1.6 droeschl 210: && $env{'user.domain'} ne 'public')
211: {
1.5 kalberla 212: $fullname = Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
213: }
1.11 raeburn 214: my $triggertype = $$setters{$course}{triggers}[$i];
1.8 raeburn 215: if ($triggertype) {
216: $fullname .= &mt(' (triggered by you when starting timer)');
217: }
1.5 kalberla 218: my ($openblock,$closeblock) = @{$$setters{$course}{times}[$i]};
219: $openblock = &Apache::lonlocal::locallocaltime($openblock);
220: $closeblock= &Apache::lonlocal::locallocaltime($closeblock);
1.6 droeschl 221: my $duration = mt('[_1] to [_2]', $openblock, $closeblock);
222: $output .= Apache::loncommon::start_data_table_row()
223: . "<td>$courseinfo{'description'}</td>"
224: . "<td>$duration</td>"
225: . "<td>$fullname</td>"
226: . Apache::loncommon::end_data_table_row();
1.5 kalberla 227: }
228: }
229: $output .= Apache::loncommon::end_data_table();
1.4 kalberla 230: }
1.1 droeschl 231:
1.6 droeschl 232: sub get_portfolio_category {
233: my ($uname, $udom, $setters) = @_;
234:
235: if ($uname eq $env{'user.name'} && $udom eq $env{'user.domain'}) {
236: # user's portolfio files
237:
238: return 'Your portfolio files';
239:
240: } elsif (Apache::lonnet::is_course($udom, $uname)) {
241: # group portfolio files
242:
243: my $coursedesc;
244:
245: foreach my $course (keys(%{$setters})) {
246: my %courseinfo = Apache::lonnet::coursedescription($course);
247: $coursedesc = $courseinfo{'description'};
248: }
249:
250: return ["Group portfolio in the course '[_1]'", $coursedesc];
251:
252: } else {
253: # different user's portfolio files
254:
255: my $plainname = Apache::loncommon::plainname($uname, $udom);
256:
257: unless ( $env{'user.name'} eq 'public'
258: && $env{'user.domain'} eq 'public' )
259: {
260: $plainname = Apache::loncommon::aboutmewrapper(
261: $plainname, $uname, $udom);
262: }
263:
264: return ['Portfolio files belonging to [_1]', $plainname];
265: }
266: }
267:
1.1 droeschl 268: 1;
269: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>