[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /auth lonacc.pm publiccheck.pm /interface lonblockingstatus.pm loncommon.pm /localize/localize de.pm

droeschl droeschl@source.lon-capa.org
Fri, 25 Sep 2009 13:52:13 -0000


This is a MIME encoded message

--droeschl1253886733
Content-Type: text/plain

droeschl		Fri Sep 25 13:52:13 2009 EDT

  Modified files:              
    /loncom	loncapa_apache.conf 
    /loncom/auth	lonacc.pm publiccheck.pm 
    /loncom/interface	lonblockingstatus.pm loncommon.pm 
    /loncom/localize/localize	de.pm 
  Log:
  fixed:
  - problem occurring when user tries to view own portfolio files while communication block is active
  - Public user now receive the correct status information popup when accessing portfolio files while com.block. is active
  
  improved:
  - code
  - mt-arguments
  
  added:
  - german translations
  - sub data_table_caption
  - code comments
  
  
  
--droeschl1253886733
Content-Type: text/plain
Content-Disposition: attachment; filename="droeschl-20090925135213.txt"

Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.187 loncom/loncapa_apache.conf:1.188
--- loncom/loncapa_apache.conf:1.187	Wed Aug  5 00:15:15 2009
+++ loncom/loncapa_apache.conf	Fri Sep 25 13:51:31 2009
@@ -1,7 +1,7 @@
 ##
 ## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
 ##
-## $Id: loncapa_apache.conf,v 1.187 2009/08/05 00:15:15 raeburn Exp $
+## $Id: loncapa_apache.conf,v 1.188 2009/09/25 13:51:31 droeschl Exp $
 ##
 
 #
@@ -1223,13 +1223,12 @@
 </Location>
 
 <Location /adm/blockingstatus>
+PerlAccessHandler      Apache::publiccheck
 AuthType LONCAPA
 Require valid-user
 PerlAuthzHandler       Apache::lonacc
-SetHandler perl-script
-PerlHandler Apache::lonblockingstatus
-ErrorDocument     403 /adm/login
-ErrorDocument	  500 /adm/errorhandler
+SetHandler             perl-script
+PerlHandler            Apache::lonblockingstatus
 </Location>
 
 <Location /adm/errorhandler>
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.127 loncom/auth/lonacc.pm:1.128
--- loncom/auth/lonacc.pm:1.127	Thu Jul 23 18:45:39 2009
+++ loncom/auth/lonacc.pm	Fri Sep 25 13:51:44 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.127 2009/07/23 18:45:39 raeburn Exp $
+# $Id: lonacc.pm,v 1.128 2009/09/25 13:51:44 droeschl Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -457,6 +457,7 @@
 	    $env{'user.domain'} eq 'public' &&
 	    $requrl !~ m{^/+(res|public|uploaded)/} &&
 	    $requrl !~ m{^/adm/[^/]+/[^/]+/aboutme/portfolio$ }x &&
+        $requrl !~ m{^/adm/blockingstatus/.*$} &&
 	    $requrl !~ m{^/+adm/(help|logout|restrictedaccess|randomlabel\.png)}) {
 	    $env{'request.querystring'}=$r->args;
 	    $env{'request.firsturl'}=$requrl;
Index: loncom/auth/publiccheck.pm
diff -u loncom/auth/publiccheck.pm:1.16 loncom/auth/publiccheck.pm:1.17
--- loncom/auth/publiccheck.pm:1.16	Wed Jan 14 15:36:42 2009
+++ loncom/auth/publiccheck.pm	Fri Sep 25 13:51:45 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: publiccheck.pm,v 1.16 2009/01/14 15:36:42 raeburn Exp $
+# $Id: publiccheck.pm,v 1.17 2009/09/25 13:51:45 droeschl Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -63,7 +63,8 @@
     if ($requrl=~m|^/public/|
 	|| $requrl=~m|^/adm/help/.*\.hlp$|
 	|| $requrl=~m|^/adm/[^/]+/[^/]+/aboutme/portfolio$|
-	|| (&Apache::lonnet::metadata($requrl,'copyright') eq 'public')) {
+	|| (&Apache::lonnet::metadata($requrl,'copyright') eq 'public') 
+    || $requrl=~m|^/adm/blockingstatus/.*$|) {
         &process_public($r,$requrl);
         return OK;
     } elsif (&Apache::lonnet::is_portfolio_url($requrl)) {
Index: loncom/interface/lonblockingstatus.pm
diff -u loncom/interface/lonblockingstatus.pm:1.5 loncom/interface/lonblockingstatus.pm:1.6
--- loncom/interface/lonblockingstatus.pm:1.5	Mon Jul 27 12:12:48 2009
+++ loncom/interface/lonblockingstatus.pm	Fri Sep 25 13:51:58 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # displays the blocking status table
 #
-# $Id: lonblockingstatus.pm,v 1.5 2009/07/27 12:12:48 kalberla Exp $
+# $Id: lonblockingstatus.pm,v 1.6 2009/09/25 13:51:58 droeschl Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,94 +32,103 @@
 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::start_page(
+                  'Communication Blocking Status Information',
+                  undef, {'only_body' => 1}));
 
+    $r->print(blockpage());
+    
     $r->print(Apache::loncommon::end_page());
+
     return OK;
 }
-sub get_blocking_table{
-    my ($activity,$uname,$udom) = @_;
+
+
+sub blockpage {
+
+    # determine what kind of blocking we want details for
+    Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['activity']);
+    my $activity = $env{'form.activity'};
+
+    if ($activity !~ /^[a-z]+$/) { return 'Error'; }
+
+
+    # in case of a portfolio block we need to determine the owner of the files
+    # we're trying to look at. This information is passed via query string.
+    my ($uname, $udom);
+
+    if ($activity eq 'port') {
+        Apache::loncommon::get_unprocessed_cgi(
+            $ENV{'QUERY_STRING'}, ['udom', 'uname'] );
+
+        ($uname, $udom) = ($env{'form.uname'}, $env{'form.udom'});
+        #TODO sanitize input: $uname, $udom
+    }
+
+
+    # retrieve start/end of possible active blocking
     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);
-            }
+    my ($startblock, $endblock) = Apache::loncommon::blockcheck(
+                                        \%setters, $activity, $uname, $udom);
+
+    # nothing to do if there's no active blocking
+    unless ($startblock && $endblock) { return ''; }
+
+    # lookup $activity -> description
+                   #possible activity          #corresponding description
+    my $description = 
+                   $activity eq 'boards'     ? 'Discussion posts in this course'
+                 : $activity eq 'chat'       ? 'Chat'
+                 : $activity eq 'msgdisplay' ? 'This message'
+                 : $activity eq 'blogs'      ? 'Blogs'
+                 : $activity eq 'groups'     ? 'Groups in this course'
+                 : $activity eq 'port'       ? get_portfolio_category(
+                                                  $uname, $udom, \%setters) 
+                 :                             'Communication';
+
+    my $showstart = Apache::lonlocal::locallocaltime($startblock);
+    my $showend   = Apache::lonlocal::locallocaltime($endblock);
+
+    my $output;
+    
+    if ( ref($description) ne 'ARRAY' ) { 
+        #default: $description is one of the above descriptions
+        $output = mt( $description
+                      . ' will be inaccessible between [_1] and [_2] because'
+                      . ' communication is being blocked.'
+                     ,$showstart, $showend);  
+    } else {
+        # @$description is is the array returned from get_portfolio_category()
+        # and contains the description (e.g. "Portfolio files belonging to [_1]"
+        # and the value for [_1]
+        $output = mt( $$description[0]
+                      . ' will be inaccessible between [_2] and [_3] because'
+                      . ' communication is being blocked.'
+                     ,$$description[1], $showstart, $showend)  
+    }
+
+    $output = "<p class=\"LC_info\">$output</p>";
+
+    # show a table containing details, except if user is trying to look 
+    # at a different user's portfolio files
+    if (   $activity ne 'port'                        # no portfolio
+        || (   $uname eq $env{'user.name'}            # or own portfolio
+            && $udom  eq $env{'user.domain'} ) 
+        || Apache::lonnet::is_course($udom, $uname) ) # or portfolio of a course
+    {
+        $output .= build_block_table($startblock,$endblock,\%setters);
     }
+
     return $output;
 }
 
@@ -132,15 +141,12 @@
         '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>
-';
+    $output  = Apache::loncommon::start_data_table()
+             . Apache::loncommon::data_table_caption($lt{'cacb'})
+             . Apache::loncommon::start_data_table_header_row()
+             . "<th>$lt{'cour'}</th> <th>$lt{'dura'}</th> <th>$lt{'blse'}</th>"
+             . Apache::loncommon::end_data_table_header_row();
+
     foreach my $course (keys(%{$setters})) {
         my %courseinfo=&Apache::lonnet::coursedescription($course);
         for (my $i=0; $i<@{$$setters{$course}{staff}}; $i++) {
@@ -148,21 +154,59 @@
             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') {
+                && $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();
+            my $duration = mt('[_1] to [_2]', $openblock, $closeblock);
+            $output .= Apache::loncommon::start_data_table_row()
+                     . "<td>$courseinfo{'description'}</td>"
+                     . "<td>$duration</td>"
+                     . "<td>$fullname</td>"
+                     . Apache::loncommon::end_data_table_row();
         }
     }
     $output .= Apache::loncommon::end_data_table();
 }
 
+sub get_portfolio_category {
+    my ($uname, $udom, $setters) = @_;
+
+    if ($uname eq $env{'user.name'} && $udom eq $env{'user.domain'}) {
+        # user's portolfio files
+
+        return 'Your portfolio files';
+
+    } elsif (Apache::lonnet::is_course($udom, $uname)) {
+        # group portfolio files
+
+        my $coursedesc;
+
+        foreach my $course (keys(%{$setters})) {
+            my %courseinfo = Apache::lonnet::coursedescription($course);
+            $coursedesc    = $courseinfo{'description'};
+        }
+
+        return ["Group portfolio in the course '[_1]'", $coursedesc];
+        
+    } else {
+        # different user's portfolio files
+        
+        my $plainname = Apache::loncommon::plainname($uname, $udom);
+
+        unless (   $env{'user.name'}   eq 'public' 
+                && $env{'user.domain'} eq 'public' ) 
+        {
+            $plainname = Apache::loncommon::aboutmewrapper(
+                            $plainname, $uname, $udom);
+        }
+
+        return ['Portfolio files belonging to [_1]', $plainname];
+    }
+}
+
 1;
 __END__
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.889 loncom/interface/loncommon.pm:1.890
--- loncom/interface/loncommon.pm:1.889	Mon Sep  7 13:11:33 2009
+++ loncom/interface/loncommon.pm	Fri Sep 25 13:51:58 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.889 2009/09/07 13:11:33 raeburn Exp $
+# $Id: loncommon.pm,v 1.890 2009/09/25 13:51:58 droeschl Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3925,23 +3925,24 @@
 }
 
 sub blocking_status {
-  my $blocked;
   my ($activity,$uname,$udom) = @_;
   my %setters;
+
+  # check for active blocking
   my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom);
-  if ($startblock && $endblock) {
-    $blocked = 1;
-  }
-  if(!wantarray) {
-    return $blocked;
-  }
-  my $output;
-  my $querystring;
-  $querystring = "?activity=$activity";
 
-      $output .= <<"END_MYBLOCK";
-<script type="text/javascript">
-// <![CDATA[
+  my $blocked = $startblock && $endblock ? 1 : 0;
+
+  # caller just wants to know whether a block is active
+  if (!wantarray) { return $blocked; }
+
+  # build a link to a popup window containing the details
+  my $querystring  = "?activity=$activity";
+  # $uname and $udom decide whose portfolio the user is trying to look at
+     $querystring .= "&amp;udom=$udom"      if $udom;
+     $querystring .= "&amp;uname=$uname"    if $uname;
+
+  my $output .= <<'END_MYBLOCK';
     function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
         var options = "width=" + w + ",height=" + h + ",";
         options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
@@ -3949,18 +3950,20 @@
         var newWin = window.open(url, wdwName, options);
         newWin.focus();
     }
-
-// ]]>
-</script>
 END_MYBLOCK
+
+  $output = Apache::lonhtmlcommon::scripttag($output);
+  
   my $popupUrl = "/adm/blockingstatus/$querystring";
+  my $text = mt('Communication Blocked');
+
   $output .= <<"END_BLOCK";
 <div class='LC_comblock'>
   <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring'
-  title='Communication Blocked'>
-  <img class='LC_noBorder LC_middle' title='Communication Blocked' src='/res/adm/pages/comblock.png' alt='Communication Blocked'/></a>
+  title='$text'>
+  <img class='LC_noBorder LC_middle' title='$text' src='/res/adm/pages/comblock.png' alt='$text'/></a>
   <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring' 
-  title='Communication Blocked'>Communication Blocked</a>
+  title='$text'>$text</a>
 </div>
 
 END_BLOCK
@@ -5002,6 +5005,9 @@
   padding: 8px;
 }
 
+table.LC_caption {
+}
+
 table.LC_nested tr.LC_empty_row td {
   padding: 4ex
 }
@@ -6771,6 +6777,11 @@
     sub end_data_table_header_row {
 	return '</tr>'."\n";;
     }
+
+    sub data_table_caption {
+        my $caption = shift;
+        return "<caption class=\"LC_caption\">$caption</caption>";
+    }
 }
 
 =pod
Index: loncom/localize/localize/de.pm
diff -u loncom/localize/localize/de.pm:1.326 loncom/localize/localize/de.pm:1.327
--- loncom/localize/localize/de.pm:1.326	Tue Sep 22 14:29:01 2009
+++ loncom/localize/localize/de.pm	Fri Sep 25 13:52:12 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # German Localization Lexicon
 #
-# $Id: de.pm,v 1.326 2009/09/22 14:29:01 bisitz Exp $
+# $Id: de.pm,v 1.327 2009/09/25 13:52:12 droeschl Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5975,6 +5975,48 @@
    'Configure Blocking of Student Communication during Exams'
 => 'Kommunikationssperre einrichten', # 'Blockieren studentischer Kommunikation während Prüfungen konfigurieren',
 
+   'Communication Blocked'
+=> 'Kommunikation gesperrt',
+
+   'Communication Blocking Status Information'
+=> 'Statusinformationen der Kommunikationssperren',
+
+   'Currently active communication blocks'
+=> 'Zur Zeit aktive Kommunikationssperren',
+
+   'Block set by'
+=> 'Sperre gesetzt von',
+
+   '[_1] to [_2]'
+=> '[_1] bis [_2]',
+
+   "Group portfolio in the course '[_1]' will be inaccessible between [_2] and [_3] because communication is being blocked."
+=> "Auf das Gruppen-Portfolio für '[_1]' kann zwischen [_2] und [_3] nicht zugegriffen werden, da die Kommunikationsmöglichkeit für diese Zeit gesperrt wurde.",
+
+   'Portfolio files belonging to [_1] will be inaccessible between [_2] and [_3] because communication is being blocked.'
+=> 'Auf die Portfolio-Dateien von [_1] kann zwischen [_2] und [_3] nicht zugegriffen werden, da die Kommunikationsmöglichkeit für diese Zeit gesperrt wurde.',
+
+   'Your portfolio files will be inaccessible between [_1] and [_2] because communication is being blocked.'
+=> 'Auf Ihre Portfolio-Dateien kann zwischen [_1] und [_2] nicht zugegriffen werden, da die Kommunikationsmöglichkeit für diese Zeit gesperrt wurde.',
+
+   'Discussion posts in this course will be inaccessible between [_1] and [_2] because communication is being blocked.'
+=> 'Auf Diskussionsbeiträge kann zwischen [_1] und [_2] nicht zugegriffen werden, da die Kommunikationsmöglichkeit für diese Zeit gesperrt wurde.',
+
+   'Chat will be inaccessible between [_1] and [_2] because communication is being blocked.'
+=> 'Auf den Chat kann zwischen [_1] und [_2] nicht zugegriffen werden, da die Kommunikationsmöglichkeit für diese Zeit gesperrt wurde.',
+
+   'This message will be inaccessible between [_1] and [_2] because communication is being blocked.'
+=> 'Auf diese Nachricht kann zwischen [_1] und [_2] nicht zugegriffen werden, da die Kommunikationsmöglichkeit für diese Zeit gesperrt wurde.',
+
+   'Blogs will be inaccessible between [_1] and [_2] because communication is being blocked.'
+=> 'Auf Blogs kann zwischen [_1] und [_2] nicht zugegriffen werden, da die Kommunikationsmöglichkeit für diese Zeit gesperrt wurde.',
+
+   'Groups in this course will be inaccessible between [_1] and [_2] because communication is being blocked.'
+=> 'Auf Gruppen kann zwischen [_1] und [_2] nicht zugegriffen werden, da die Kommunikationsmöglichkeit für diese Zeit gesperrt wurde.',
+
+   'Communication will be inaccessible between [_1] and [_2] because communication is being blocked.'
+=> 'Auf Kommunikation kann zwischen [_1] und [_2] nicht zugegriffen werden, da die Kommunikationsmöglichkeit für diese Zeit gesperrt wurde.',
+
    'Creating PDF'
 => 'Erstellung PDF-Datei',
 

--droeschl1253886733--