version 1.417, 2009/07/25 15:25:10
|
version 1.419, 2009/07/31 02:20:12
|
Line 3674 sub put_course_id_hash_handler {
|
Line 3674 sub put_course_id_hash_handler {
|
# will be returned. Pre-2.2.0 legacy entries from |
# will be returned. Pre-2.2.0 legacy entries from |
# nohist_courseiddump will only contain usernames. |
# nohist_courseiddump will only contain usernames. |
# type - optional parameter for selection |
# type - optional parameter for selection |
# regexp_ok - if true, allow the supplied institutional code |
# regexp_ok - if 1 or -1 allow the supplied institutional code |
# filter to behave as a regular expression. |
# filter to behave as a regular expression: |
|
# 1 will not exclude the course if the instcode matches the RE |
|
# -1 will exclude the course if the instcode matches the RE |
# rtn_as_hash - whether to return the information available for |
# rtn_as_hash - whether to return the information available for |
# each matched item as a frozen hash of all |
# each matched item as a frozen hash of all |
# key, value pairs in the item's hash, or as a |
# key, value pairs in the item's hash, or as a |
Line 3691 sub put_course_id_hash_handler {
|
Line 3693 sub put_course_id_hash_handler {
|
# caller - if set to 'coursecatalog', courses set to be hidden |
# caller - if set to 'coursecatalog', courses set to be hidden |
# from course catalog will be excluded from results (unless |
# from course catalog will be excluded from results (unless |
# overridden by "showhidden". |
# overridden by "showhidden". |
|
# cloner - escaped username:domain of course cloner (if picking course to# |
|
# clone). |
|
# cc_clone_list - escaped comma separated list of courses for which |
|
# course cloner has active CC role (and so can clone |
|
# automatically). |
|
# cloneonly - filter by courses for which cloner has rights to clone. |
# |
# |
# $client - The socket open on the client. |
# $client - The socket open on the client. |
# Returns: |
# Returns: |
Line 3703 sub dump_course_id_handler {
|
Line 3711 sub dump_course_id_handler {
|
|
|
my ($udom,$since,$description,$instcodefilter,$ownerfilter,$coursefilter, |
my ($udom,$since,$description,$instcodefilter,$ownerfilter,$coursefilter, |
$typefilter,$regexp_ok,$rtn_as_hash,$selfenrollonly,$catfilter,$showhidden, |
$typefilter,$regexp_ok,$rtn_as_hash,$selfenrollonly,$catfilter,$showhidden, |
$caller) =split(/:/,$tail); |
$caller,$cloner,$cc_clone_list,$cloneonly) =split(/:/,$tail); |
my $now = time; |
my $now = time; |
|
my ($cloneruname,$clonerudom,%cc_clone); |
if (defined($description)) { |
if (defined($description)) { |
$description=&unescape($description); |
$description=&unescape($description); |
} else { |
} else { |
Line 3747 sub dump_course_id_handler {
|
Line 3756 sub dump_course_id_handler {
|
if (defined($catfilter)) { |
if (defined($catfilter)) { |
$catfilter=&unescape($catfilter); |
$catfilter=&unescape($catfilter); |
} |
} |
|
if (defined($cloner)) { |
|
$cloner = &unescape($cloner); |
|
($cloneruname,$clonerudom) = ($cloner =~ /^($LONCAPA::match_username):($LONCAPA::match_domain)$/); |
|
} |
|
if (defined($cc_clone_list)) { |
|
$cc_clone_list = &unescape($cc_clone_list); |
|
my @cc_cloners = split('&',$cc_clone_list); |
|
foreach my $cid (@cc_cloners) { |
|
my ($clonedom,$clonenum) = split(':',$cid); |
|
next if ($clonedom ne $udom); |
|
$cc_clone{$clonedom.'_'.$clonenum} = 1; |
|
} |
|
} |
|
|
my $unpack = 1; |
my $unpack = 1; |
if ($description eq '.' && $instcodefilter eq '.' && $coursefilter eq '.' && |
if ($description eq '.' && $instcodefilter eq '.' && $coursefilter eq '.' && |
$typefilter eq '.') { |
$typefilter eq '.') { |
Line 3769 sub dump_course_id_handler {
|
Line 3792 sub dump_course_id_handler {
|
$lasttime = $hashref->{$lasttime_key}; |
$lasttime = $hashref->{$lasttime_key}; |
next if ($lasttime<$since); |
next if ($lasttime<$since); |
} |
} |
|
my ($canclone,$valchange); |
my $items = &Apache::lonnet::thaw_unescape($value); |
my $items = &Apache::lonnet::thaw_unescape($value); |
if (ref($items) eq 'HASH') { |
if (ref($items) eq 'HASH') { |
$is_hash = 1; |
$is_hash = 1; |
|
if (defined($clonerudom)) { |
|
if ($items->{'cloners'}) { |
|
my @cloneable = split(',',$items->{'cloners'}); |
|
if (@cloneable) { |
|
if (grep(/^\*$/,@cloneable)) { |
|
$canclone = 1; |
|
} elsif (grep(/^\*:\Q$clonerudom\E$/,@cloneable)) { |
|
$canclone = 1; |
|
} elsif (grep(/^\Q$cloneruname\E:\Q$clonerudom\E$/,@cloneable)) { |
|
$canclone = 1; |
|
} |
|
} |
|
unless ($canclone) { |
|
if ($cloneruname ne '' && $clonerudom ne '') { |
|
if ($cc_clone{$unesc_key}) { |
|
$canclone = 1; |
|
$items->{'cloners'} .= ','.$cloneruname.':'. |
|
$clonerudom; |
|
$valchange = 1; |
|
} |
|
} |
|
} |
|
} elsif (defined($cloneruname)) { |
|
if ($cc_clone{$unesc_key}) { |
|
$canclone = 1; |
|
$items->{'cloners'} = $cloneruname.':'.$clonerudom; |
|
$valchange = 1; |
|
} |
|
} |
|
} |
if ($unpack || !$rtn_as_hash) { |
if ($unpack || !$rtn_as_hash) { |
$unesc_val{'descr'} = $items->{'description'}; |
$unesc_val{'descr'} = $items->{'description'}; |
$unesc_val{'inst_code'} = $items->{'inst_code'}; |
$unesc_val{'inst_code'} = $items->{'inst_code'}; |
$unesc_val{'owner'} = $items->{'owner'}; |
$unesc_val{'owner'} = $items->{'owner'}; |
$unesc_val{'type'} = $items->{'type'}; |
$unesc_val{'type'} = $items->{'type'}; |
|
$unesc_val{'cloners'} = $items->{'cloners'}; |
} |
} |
$selfenroll_types = $items->{'selfenroll_types'}; |
$selfenroll_types = $items->{'selfenroll_types'}; |
$selfenroll_end = $items->{'selfenroll_end_date'}; |
$selfenroll_end = $items->{'selfenroll_end_date'}; |
Line 3807 sub dump_course_id_handler {
|
Line 3862 sub dump_course_id_handler {
|
} |
} |
} else { |
} else { |
next if ($catfilter ne ''); |
next if ($catfilter ne ''); |
next if ($selfenrollonly); |
next if ($selfenrollonly); |
|
if ((defined($clonerudom)) && (defined($cloneruname))) { |
|
if ($cc_clone{$unesc_key}) { |
|
$canclone = 1; |
|
$val{'cloners'} = &escape($cloneruname.':'.$clonerudom); |
|
} |
|
} |
$is_hash = 0; |
$is_hash = 0; |
my @courseitems = split(/:/,$value); |
my @courseitems = split(/:/,$value); |
$lasttime = pop(@courseitems); |
$lasttime = pop(@courseitems); |
Line 3816 sub dump_course_id_handler {
|
Line 3877 sub dump_course_id_handler {
|
} |
} |
($val{'descr'},$val{'inst_code'},$val{'owner'},$val{'type'}) = @courseitems; |
($val{'descr'},$val{'inst_code'},$val{'owner'},$val{'type'}) = @courseitems; |
} |
} |
|
if ($cloneonly) { |
|
next unless ($canclone); |
|
} |
my $match = 1; |
my $match = 1; |
if ($description ne '.') { |
if ($description ne '.') { |
if (!$is_hash) { |
if (!$is_hash) { |
Line 3829 sub dump_course_id_handler {
|
Line 3893 sub dump_course_id_handler {
|
if (!$is_hash) { |
if (!$is_hash) { |
$unesc_val{'inst_code'} = &unescape($val{'inst_code'}); |
$unesc_val{'inst_code'} = &unescape($val{'inst_code'}); |
} |
} |
if ($regexp_ok) { |
if ($regexp_ok == 1) { |
if (eval{$unesc_val{'inst_code'} !~ /$instcodefilter/}) { |
if (eval{$unesc_val{'inst_code'} !~ /$instcodefilter/}) { |
$match = 0; |
$match = 0; |
} |
} |
|
} elsif ($regexp_ok == -1) { |
|
if (eval{$unesc_val{'inst_code'} =~ /$instcodefilter/}) { |
|
$match = 0; |
|
} |
} else { |
} else { |
if (eval{$unesc_val{'inst_code'} !~ /\Q$instcodefilter\E/i}) { |
if (eval{$unesc_val{'inst_code'} !~ /\Q$instcodefilter\E/i}) { |
$match = 0; |
$match = 0; |
Line 3898 sub dump_course_id_handler {
|
Line 3966 sub dump_course_id_handler {
|
if ($match == 1) { |
if ($match == 1) { |
if ($rtn_as_hash) { |
if ($rtn_as_hash) { |
if ($is_hash) { |
if ($is_hash) { |
$qresult.=$key.'='.$value.'&'; |
if ($valchange) { |
|
my $newvalue = &Apache::lonnet::freeze_escape($items); |
|
$qresult.=$key.'='.$newvalue.'&'; |
|
} else { |
|
$qresult.=$key.'='.$value.'&'; |
|
} |
} else { |
} else { |
my %rtnhash = ( 'description' => &unescape($val{'descr'}), |
my %rtnhash = ( 'description' => &unescape($val{'descr'}), |
'inst_code' => &unescape($val{'inst_code'}), |
'inst_code' => &unescape($val{'inst_code'}), |
'owner' => &unescape($val{'owner'}), |
'owner' => &unescape($val{'owner'}), |
'type' => &unescape($val{'type'}), |
'type' => &unescape($val{'type'}), |
|
'cloners' => &unescape($val{'cloners'}), |
); |
); |
my $items = &Apache::lonnet::freeze_escape(\%rtnhash); |
my $items = &Apache::lonnet::freeze_escape(\%rtnhash); |
$qresult.=$key.'='.$items.'&'; |
$qresult.=$key.'='.$items.'&'; |