--- loncom/lonnet/perl/lonnet.pm 2007/01/12 21:36:42 1.816.2.3 +++ loncom/lonnet/perl/lonnet.pm 2006/12/28 20:09:10 1.817 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.816.2.3 2007/01/12 21:36:42 albertel Exp $ +# $Id: lonnet.pm,v 1.817 2006/12/28 20:09:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -920,14 +920,12 @@ sub getsection { # If there is a role which has expired, return it. # $courseid = &courseid_to_courseurl($courseid); - foreach my $line (split(/\&/,&reply('dump:'.$udom.':'.$unam.':roles', - &homeserver($unam,$udom)))) { - my ($key,$value)=split(/\=/,$line,2); - $key=&unescape($key); + my %roleshash = &dump('roles',$udom,$unam,$courseid); + foreach my $key (keys(%roleshash)) { next if ($key !~/^\Q$courseid\E(?:\/)*(\w+)*\_st$/); my $section=$1; if ($key eq $courseid.'_st') { $section=''; } - my ($dummy,$end,$start)=split(/\_/,&unescape($value)); + my ($dummy,$end,$start)=split(/\_/,&unescape($roleshash{$key})); my $now=time; if (defined($end) && $end && ($now > $end)) { $Expired{$end}=$section; @@ -3546,7 +3544,7 @@ sub is_portfolio_url { sub is_portfolio_file { my ($file) = @_; - if (($file =~ /^portfolio/) || ($file =~ /^groups\/\w+\/portfolio/)) { + if (($file =~ /^portfolio/) || ($file =~ /^groups\/\w\/portfolio/)) { return 1; } return; @@ -3558,7 +3556,7 @@ sub is_portfolio_file { sub customaccess { my ($priv,$uri)=@_; my ($urole,$urealm)=split(/\./,$env{'request.role'},2); - my (undef,$udom,$ucrs,$usec)=split(/\//,$urealm); + my ($udom,$ucrs,$usec)=split(/\//,$urealm); $udom = &LONCAPA::clean_domain($udom); $ucrs = &LONCAPA::clean_username($ucrs); my $access=0; @@ -4098,18 +4096,6 @@ sub log_query { return get_query_reply($queryid); } -# -------------------------- Update MySQL table for portfolio file - -sub update_portfolio_table { - my ($uname,$udom,$file_name,$query,$group) = @_; - my $homeserver = &homeserver($uname,$udom); - my $queryid= - &reply("querysend:".$query.':'.&escape($uname.':'.$udom).':'. - &escape($file_name).':'.&escape($group),$homeserver); - my $reply = &get_query_reply($queryid); - return $reply; -} - # ------- Request retrieval of institutional classlists for course(s) sub fetch_enrollment_query { @@ -4527,37 +4513,32 @@ sub get_users_groups { $grouplist = ''; my $courseurl = &courseid_to_courseurl($courseid); my %roleshash = &dump('roles',$udom,$uname,$courseurl); - my ($tmp) = keys(%roleshash); - if ($tmp=~/^error:/) { - &logthis('Error retrieving roles: '.$tmp.' for '.$uname.':'.$udom); - } else { - my $access_end = $env{'course.'.$courseid. - '.default_enrollment_end_date'}; - my $now = time; - foreach my $key (keys(%roleshash)) { - if ($key =~ /^\Q$courseurl\E\/(\w+)\_gr$/) { - my $group = $1; - if ($roleshash{$key} =~ /_(\d+)_(\d+)$/) { - my $start = $2; - my $end = $1; - if ($start == -1) { next; } # deleted from group - if (($start!=0) && ($start>$now)) { next; } - if (($end!=0) && ($end<$now)) { - if ($access_end && $access_end < $now) { - if ($access_end - $end < 86400) { - push(@usersgroups,$group); - } + my $access_end = $env{'course.'.$courseid. + '.default_enrollment_end_date'}; + my $now = time; + foreach my $key (keys(%roleshash)) { + if ($key =~ /^\Q$courseurl\E\/(\w+)\_gr$/) { + my $group = $1; + if ($roleshash{$key} =~ /_(\d+)_(\d+)$/) { + my $start = $2; + my $end = $1; + if ($start == -1) { next; } # deleted from group + if (($start!=0) && ($start>$now)) { next; } + if (($end!=0) && ($end<$now)) { + if ($access_end && $access_end < $now) { + if ($access_end - $end < 86400) { + push(@usersgroups,$group); } - next; } - push(@usersgroups,$group); + next; } + push(@usersgroups,$group); } } - @usersgroups = &sort_course_groups($courseid,@usersgroups); - $grouplist = join(':',@usersgroups); - &do_cache_new('getgroups',$hashid,$grouplist,$cachetime); } + @usersgroups = &sort_course_groups($courseid,@usersgroups); + $grouplist = join(':',@usersgroups); + &do_cache_new('getgroups',$hashid,$grouplist,$cachetime); } return @usersgroups; } @@ -5278,15 +5259,6 @@ sub modify_access_controls { # remove lock my @del_lock = ($file_name."\0".'locked_access_records'); my $dellockoutcome = &del('file_permissions',\@del_lock,$domain,$user); - my ($file,$group); - if (&is_course($domain,$user)) { - ($group,$file) = split(/\//,$file_name,2); - } else { - $file = $file_name; - } - my $sqlresult = - &update_portfolio_table($user,$domain,$file,'portfolio_access', - $group); } else { $outcome = "error: could not obtain lockfile\n"; }