[LON-CAPA-cvs] cvs: rat / lonpageflip.pm lonuserstate.pm loncom lonenc.pm loncom/auth lonroles.pm
www
lon-capa-cvs@mail.lon-capa.org
Tue, 30 May 2006 19:47:40 -0000
www Tue May 30 15:47:40 2006 EDT
Modified files:
/loncom lonenc.pm
/loncom/auth lonroles.pm
/rat lonpageflip.pm lonuserstate.pm
Log:
Bug #1223: error when first resource is hidden
Also: error when first resource is encrypted
Index: loncom/lonenc.pm
diff -u loncom/lonenc.pm:1.15 loncom/lonenc.pm:1.16
--- loncom/lonenc.pm:1.15 Tue May 30 08:45:12 2006
+++ loncom/lonenc.pm Tue May 30 15:47:28 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# URL translation for encrypted filenames
#
-# $Id: lonenc.pm,v 1.15 2006/05/30 12:45:12 www Exp $
+# $Id: lonenc.pm,v 1.16 2006/05/30 19:47:28 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,7 +32,6 @@
use Apache::lonnet;
use Crypt::IDEA;
use Time::HiRes qw(gettimeofday);
-use lib '/home/httpd/lib/perl/';
use LONCAPA;
sub encryptseed {
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.150 loncom/auth/lonroles.pm:1.151
--- loncom/auth/lonroles.pm:1.150 Tue May 30 13:15:00 2006
+++ loncom/auth/lonroles.pm Tue May 30 15:47:36 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.150 2006/05/30 17:15:00 www Exp $
+# $Id: lonroles.pm,v 1.151 2006/05/30 19:47:36 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,8 +39,8 @@
use Apache::lonhtmlcommon;
use Apache::lonannounce;
use Apache::lonlocal;
+use Apache::lonpageflip();
use GDBM_File;
-use lib '/home/httpd/lib/perl/';
use LONCAPA;
@@ -306,6 +306,11 @@
}
}
}
+# Are we allowed to look at the first resource?
+ if (!&Apache::lonnet::allowed('bre',$furl)) {
+# Guess not ...
+ $furl=&Apache::lonpageflip::first_accessible_resource();
+ }
&redirect_user($r,&mt('Entering Course'),
$furl,$msg,
$env{'environment.remotenavmap'});
Index: rat/lonpageflip.pm
diff -u rat/lonpageflip.pm:1.68 rat/lonpageflip.pm:1.69
--- rat/lonpageflip.pm:1.68 Mon May 8 18:14:15 2006
+++ rat/lonpageflip.pm Tue May 30 15:47:40 2006
@@ -2,7 +2,7 @@
#
# Page flip handler
#
-# $Id: lonpageflip.pm,v 1.68 2006/05/08 22:14:15 albertel Exp $
+# $Id: lonpageflip.pm,v 1.69 2006/05/30 19:47:40 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -200,6 +200,30 @@
ENDNAV
$r->print(&Apache::loncommon::end_page());
}
+
+sub first_accessible_resource {
+ my $furl;
+ if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'.db',
+ &GDBM_READER(),0640)) {
+ $furl=$hash{'first_url'};
+ if (!&Apache::lonnet::allowed('bre',$furl)) {
+# Wow, we cannot see this ... move forward to the next one that we can see
+ my ($newrid,$newmap)=&move($hash{'first_rid'},$hash{'first_mapurl'},'forward');
+# Build the new URL
+ my ($newresid,$newmapid)=split(/\./,$newrid);
+ my $symb=&Apache::lonnet::encode_symb($newmap,$newresid,$hash{'src_'.$newrid});
+ $furl=&add_get_param($hash{'src_'.$newrid},{ 'symb' => $symb });
+ if ($hash{'encrypted_'.$newrid}) {
+ $furl=&Apache::lonenc::encrypted($furl);
+ }
+ }
+ untie(%hash);
+ return $furl;
+ } else {
+ return '/adm/navmaps';
+ }
+}
+
# ================================================================ Main Handler
sub handler {
@@ -229,12 +253,7 @@
}
$currenturl=~s/\.\d+\.(\w+)$/\.$1/;
if ($direction eq 'firstres') {
- my $furl;
- if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
- &GDBM_READER(),0640)) {
- $furl=$bighash{'first_url'};
- untie(%bighash);
- }
+ my $furl=&first_accessible_resource();
&Apache::loncommon::content_type($r,'text/html');
$r->header_out(Location =>
'http://'.$ENV{'HTTP_HOST'}.$furl);
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.115 rat/lonuserstate.pm:1.116
--- rat/lonuserstate.pm:1.115 Tue May 30 15:11:37 2006
+++ rat/lonuserstate.pm Tue May 30 15:47:40 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Construct and maintain state and binary representation of course for user
#
-# $Id: lonuserstate.pm,v 1.115 2006/05/30 19:11:37 raeburn Exp $
+# $Id: lonuserstate.pm,v 1.116 2006/05/30 19:47:40 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,7 +42,6 @@
use Opcode;
use Apache::lonenc;
use Fcntl qw(:flock);
-use lib '/home/httpd/lib/perl/';
use LONCAPA;
@@ -53,7 +52,8 @@
my %parmhash;# The hash with the parameters
my @cond; # Array with all of the conditions
my $errtext; # variable with all errors
-my $retfurl; # variable with the very first URL in the course
+my $retfrid; # variable with the very first RID in the course
+my $retfurl; # first URL
my %randompick; # randomly picked resources
my %randompickseed; # optional seed for randomly picking resources
my %encurl; # URLs in this folder are supposed to be encrypted
@@ -363,10 +363,9 @@
my $encrypt=&Apache::lonnet::EXT('resource.0.encrypturl',$symb);
if ($encflag || lc($encrypt) eq 'yes') { $encurl{$rid}=1; }
- if (($retfurl eq '') && ($hash{'src_'.$rid})
+ if (($retfrid eq '') && ($hash{'src_'.$rid})
&& ($hash{'src_'.$rid}!~/\.sequence$/)) {
- $retfurl=$hash{'src_'.$rid}.(($hash{'src_'.$rid}=~/\?/)?'&':'?').
- 'symb='.$symb;
+ $retfrid=$rid;
}
if (defined($hash{'conditions_'.$rid})) {
$hash{'conditions_'.$rid}=simplify(
@@ -573,7 +572,7 @@
undef %randompick;
undef %hiddenurl;
undef %encurl;
- $retfurl='';
+ $retfrid='';
if ($lock && (tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT(),0640)) &&
(tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT(),0640))) {
%hash=();
@@ -591,6 +590,7 @@
&Apache::lonnet::appenv("request.course.id" => $short,
"request.course.fn" => $fn,
"request.course.uri" => $uri);
+ $env{'request.course.id'}=$short;
&traceroute('0',$hash{'map_start_'.$uri},'&');
&accinit($uri,$short,$fn);
&hiddenurls();
@@ -612,6 +612,14 @@
}
# ----------------------------------------------- Close hashes to finally store
# --------------------------------- Routine must pass this point, no early outs
+ $hash{'first_rid'}=$retfrid;
+ my ($mapid,$resid)=split(/\./,$retfrid);
+ $hash{'first_mapurl'}=$hash{'map_id_'.$mapid};
+ my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$retfrid});
+ $retfurl=&add_get_param($hash{'src_'.$retfrid},{ 'symb' => $symb });
+ if ($hash{'encrypted_'.$retfrid}) {
+ $retfurl=&Apache::lonenc::encrypted($retfurl,(&Apache::lonnet::allowed('adv') ne 'F'));
+ }
$hash{'first_url'}=$retfurl;
unless ((untie(%hash)) && (untie(%parmhash))) {
&Apache::lonnet::logthis("<font color=blue>WARNING: ".