[LON-CAPA-cvs] cvs: loncom /metadata_database searchcat.pl
raeburn
raeburn@source.lon-capa.org
Fri, 26 Mar 2010 13:29:31 -0000
raeburn Fri Mar 26 13:29:31 2010 EDT
Modified files:
/loncom/metadata_database searchcat.pl
Log:
- When populating allusers table:
- Use hash of courseIDs from single call to lonnet::courseiddump() for domain, instead of individual call to lonnet::is_course() to test if user is a course.
- Check if directory in lonUsers/$dom/$1/$2/$3/$uname is for a user
by testing for existence of passwd file.
Index: loncom/metadata_database/searchcat.pl
diff -u loncom/metadata_database/searchcat.pl:1.77 loncom/metadata_database/searchcat.pl:1.78
--- loncom/metadata_database/searchcat.pl:1.77 Wed Jul 25 23:17:43 2007
+++ loncom/metadata_database/searchcat.pl Fri Mar 26 13:29:31 2010
@@ -2,7 +2,7 @@
# The LearningOnline Network
# searchcat.pl "Search Catalog" batch script
#
-# $Id: searchcat.pl,v 1.77 2007/07/25 23:17:43 raeburn Exp $
+# $Id: searchcat.pl,v 1.78 2010/03/26 13:29:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -123,7 +123,7 @@
'portfolio' => 'portfolio_metadata',
'access' => 'portfolio_access',
'addedfields' => 'portfolio_addedfields',
- 'allusers' => 'allusers',
+ 'allusers' => 'allusers',
);
my %newnames;
@@ -135,6 +135,8 @@
#
# Only run if machine is a library server
exit if ($Apache::lonnet::perlvar{'lonRole'} ne 'library');
+my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
+
#
# Make sure this process is running from user=www
my $wwwid=getpwnam('www');
@@ -223,7 +225,7 @@
}, join('/',($Apache::lonnet::perlvar{'lonDocRoot'},'res',$dom,$user)) );
}
# Search for all users and public portfolio files
- my (%allusers,%portusers);
+ my (%allusers,%portusers,%courses);
if ($oneuser) {
%portusers = (
$oneuser => '',
@@ -231,14 +233,21 @@
%allusers = (
$oneuser => '',
);
+ %courses = &courseiddump($dom,'.',1,'.','.',$oneuser,undef,
+ undef,'.');
} else {
+ # get courseIDs for domain on current machine
+ %courses=&Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',1,[$hostid],'.');
my $dir = $Apache::lonnet::perlvar{lonUsersDir}.'/'.$dom;
&descend_tree($dom,$dir,0,\%portusers,\%allusers);
}
foreach my $uname (keys(%portusers)) {
my $urlstart = '/uploaded/'.$dom.'/'.$uname;
my $pathstart = &propath($dom,$uname).'/userfiles';
- my $is_course = &Apache::lonnet::is_course($dom,$uname);
+ my $is_course = '';
+ if (exists($courses{$dom.'_'.$uname})) {
+ $is_course = 1;
+ }
my $curr_perm = &Apache::lonnet::get_portfile_permissions($dom,$uname);
my %access = &Apache::lonnet::get_access_controls($curr_perm);
foreach my $file (keys(%access)) {
@@ -263,6 +272,7 @@
}
# Update allusers
foreach my $uname (keys(%allusers)) {
+ next if (exists($courses{$dom.'_'.$uname}));
my %userdata =
&Apache::lonnet::get('environment',['firstname','lastname',
'middlename','generation','id','permanentemail'],$dom,$uname);
@@ -346,9 +356,9 @@
&descend_tree($dom,$dir.'/'.$item,$depth,$allportusers,$alldomusers);
} else {
if (-e $dir.'/'.$item.'/file_permissions.db') {
- $$allportusers{$item} = '';
+ $$allportusers{$item} = '';
}
- if (!&Apache::lonnet::is_course($dom,$item)) {
+ if (-e $dir.'/'.$item.'/passwd') {
$$alldomusers{$item} = '';
}
}