version 1.1024, 2009/08/28 19:43:10
|
version 1.1071, 2010/06/25 04:37:54
|
Line 99 use LONCAPA::Configuration;
|
Line 99 use LONCAPA::Configuration;
|
my $readit; |
my $readit; |
my $max_connection_retries = 10; # Or some such value. |
my $max_connection_retries = 10; # Or some such value. |
|
|
my $upload_photo_form = 0; #Variable to check when user upload a photo 0=not 1=true |
|
|
|
require Exporter; |
require Exporter; |
|
|
our @ISA = qw (Exporter); |
our @ISA = qw (Exporter); |
Line 667 sub userload {
|
Line 665 sub userload {
|
return $userloadpercent; |
return $userloadpercent; |
} |
} |
|
|
# ------------------------------------------ Fight off request when overloaded |
|
|
|
sub overloaderror { |
|
my ($r,$checkserver)=@_; |
|
unless ($checkserver) { $checkserver=$perlvar{'lonHostID'}; } |
|
my $loadavg; |
|
if ($checkserver eq $perlvar{'lonHostID'}) { |
|
open(my $loadfile,'/proc/loadavg'); |
|
$loadavg=<$loadfile>; |
|
$loadavg =~ s/\s.*//g; |
|
$loadavg = 100*$loadavg/$perlvar{'lonLoadLim'}; |
|
close($loadfile); |
|
} else { |
|
$loadavg=&reply('load',$checkserver); |
|
} |
|
my $overload=$loadavg-100; |
|
if ($overload>0) { |
|
$r->err_headers_out->{'Retry-After'}=$overload; |
|
$r->log_error('Overload of '.$overload.' on '.$checkserver); |
|
return 413; |
|
} |
|
return ''; |
|
} |
|
|
|
# ------------------------------ Find server with least workload from spare.tab |
# ------------------------------ Find server with least workload from spare.tab |
|
|
sub spareserver { |
sub spareserver { |
Line 785 sub changepass {
|
Line 759 sub changepass {
|
my ($uname,$udom,$currentpass,$newpass,$server,$context)=@_; |
my ($uname,$udom,$currentpass,$newpass,$server,$context)=@_; |
$currentpass = &escape($currentpass); |
$currentpass = &escape($currentpass); |
$newpass = &escape($newpass); |
$newpass = &escape($newpass); |
my $answer = reply("encrypt:passwd:$udom:$uname:$currentpass:$newpass:$context", |
my $lonhost = $perlvar{'lonHostID'}; |
|
my $answer = reply("encrypt:passwd:$udom:$uname:$currentpass:$newpass:$context:$lonhost", |
$server); |
$server); |
if (! $answer) { |
if (! $answer) { |
&logthis("No reply on password change request to $server ". |
&logthis("No reply on password change request to $server ". |
Line 810 sub changepass {
|
Line 785 sub changepass {
|
} elsif ($answer =~ "^refused") { |
} elsif ($answer =~ "^refused") { |
&logthis("$server refused to change $uname in $udom password because ". |
&logthis("$server refused to change $uname in $udom password because ". |
"it was sent an unencrypted request to change the password."); |
"it was sent an unencrypted request to change the password."); |
|
} elsif ($answer =~ "invalid_client") { |
|
&logthis("$server refused to change $uname in $udom password because ". |
|
"it was a reset by e-mail originating from an invalid server."); |
} |
} |
return $answer; |
return $answer; |
} |
} |
Line 1349 sub get_domain_defaults {
|
Line 1327 sub get_domain_defaults {
|
my %domdefaults; |
my %domdefaults; |
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['defaults','quotas', |
&Apache::lonnet::get_dom('configuration',['defaults','quotas', |
'requestcourses','inststatus'],$domain); |
'requestcourses','inststatus', |
|
'coursedefaults'],$domain); |
if (ref($domconfig{'defaults'}) eq 'HASH') { |
if (ref($domconfig{'defaults'}) eq 'HASH') { |
$domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; |
$domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'}; |
$domdefaults{'auth_def'} = $domconfig{'defaults'}{'auth_def'}; |
$domdefaults{'auth_def'} = $domconfig{'defaults'}{'auth_def'}; |
Line 1384 sub get_domain_defaults {
|
Line 1363 sub get_domain_defaults {
|
$domdefaults{$item} = $domconfig{'inststatus'}{$item}; |
$domdefaults{$item} = $domconfig{'inststatus'}{$item}; |
} |
} |
} |
} |
|
if (ref($domconfig{'coursedefaults'}) eq 'HASH') { |
|
foreach my $item ('canuse_pdfforms') { |
|
$domdefaults{$item} = $domconfig{'coursedefaults'}{$item}; |
|
} |
|
} |
&Apache::lonnet::do_cache_new('domdefaults',$domain,\%domdefaults, |
&Apache::lonnet::do_cache_new('domdefaults',$domain,\%domdefaults, |
$cachetime); |
$cachetime); |
return %domdefaults; |
return %domdefaults; |
Line 1718 sub userenvironment {
|
Line 1702 sub userenvironment {
|
unless ($uhome eq 'no_host') { |
unless ($uhome eq 'no_host') { |
my @answer=split(/\&/, |
my @answer=split(/\&/, |
&reply('get:'.$udom.':'.$unam.':environment:'.$items,$uhome)); |
&reply('get:'.$udom.':'.$unam.':environment:'.$items,$uhome)); |
|
if ($#answer==0 && $answer[0] =~ /^(con_lost|error:|no_such_host)/i) { |
|
return %returnhash; |
|
} |
my $i; |
my $i; |
for ($i=0;$i<=$#what;$i++) { |
for ($i=0;$i<=$#what;$i++) { |
$returnhash{$what[$i]}=&unescape($answer[$i]); |
$returnhash{$what[$i]}=&unescape($answer[$i]); |
Line 2143 sub clean_filename {
|
Line 2130 sub clean_filename {
|
$fname=~s/\.(\d+)(?=\.)/_$1/g; |
$fname=~s/\.(\d+)(?=\.)/_$1/g; |
return $fname; |
return $fname; |
} |
} |
#This Function check if a Image max 400px width and height 500px. If not then scale the image down |
# This Function checks if an Image's dimensions exceed either $resizewidth (width) |
|
# or $resizeheight (height) - both pixels. If so, the image is scaled to produce an |
|
# image with the same aspect ratio as the original, but with dimensions which do |
|
# not exceed $resizewidth and $resizeheight. |
|
|
sub resizeImage { |
sub resizeImage { |
my($img_url) = @_; |
my ($img_path,$resizewidth,$resizeheight) = @_; |
my $ima = Image::Magick->new; |
my $ima = Image::Magick->new; |
$ima->Read($img_url); |
my $resized; |
if($ima->Get('width') > 400) |
if (-e $img_path) { |
{ |
$ima->Read($img_path); |
my $factor = $ima->Get('width')/400; |
if (($resizewidth =~ /^\d+$/) && ($resizeheight > 0)) { |
$ima->Scale( width=>400, height=>$ima->Get('height')/$factor ); |
my $width = $ima->Get('width'); |
} |
my $height = $ima->Get('height'); |
if($ima->Get('height') > 500) |
if ($width > $resizewidth) { |
{ |
my $factor = $width/$resizewidth; |
my $factor = $ima->Get('height')/500; |
my $newheight = $height/$factor; |
$ima->Scale( width=>$ima->Get('width')/$factor, height=>500); |
$ima->Scale(width=>$resizewidth,height=>$newheight); |
} |
$resized = 1; |
|
} |
$ima->Write($img_url); |
} |
} |
if (($resizeheight =~ /^\d+$/) && ($resizeheight > 0)) { |
|
my $width = $ima->Get('width'); |
#Wrapper function for userphotoupload |
my $height = $ima->Get('height'); |
sub userphotoupload |
if ($height > $resizeheight) { |
{ |
my $factor = $height/$resizeheight; |
my($formname,$subdir) = @_; |
my $newwidth = $width/$factor; |
$upload_photo_form = 1; |
$ima->Scale(width=>$newwidth,height=>$resizeheight); |
return &userfileupload($formname,undef,$subdir); |
$resized = 1; |
|
} |
|
} |
|
if ($resized) { |
|
$ima->Write($img_path); |
|
} |
|
} |
|
return; |
} |
} |
|
|
# --------------- Take an uploaded file and put it into the userfiles directory |
# --------------- Take an uploaded file and put it into the userfiles directory |
Line 2183 sub userphotoupload
|
Line 2181 sub userphotoupload
|
# $dsetudom - domain for permanaent storage of uploaded file |
# $dsetudom - domain for permanaent storage of uploaded file |
# $thumbwidth - width (pixels) of thumbnail to make for uploaded image |
# $thumbwidth - width (pixels) of thumbnail to make for uploaded image |
# $thumbheight - height (pixels) of thumbnail to make for uploaded image |
# $thumbheight - height (pixels) of thumbnail to make for uploaded image |
|
# $resizewidth - width (pixels) to which to resize uploaded image |
|
# $resizeheight - height (pixels) to which to resize uploaded image |
# |
# |
# output: url of file in userspace, or error: <message> |
# output: url of file in userspace, or error: <message> |
# or /adm/notfound.html if failure to upload occurse |
# or /adm/notfound.html if failure to upload occurse |
|
|
|
|
sub userfileupload { |
sub userfileupload { |
my ($formname,$coursedoc,$subdir,$parser,$allfiles,$codebase,$destuname, |
my ($formname,$coursedoc,$subdir,$parser,$allfiles,$codebase,$destuname, |
$destudom,$thumbwidth,$thumbheight)=@_; |
$destudom,$thumbwidth,$thumbheight,$resizewidth,$resizeheight)=@_; |
if (!defined($subdir)) { $subdir='unknown'; } |
if (!defined($subdir)) { $subdir='unknown'; } |
my $fname=$env{'form.'.$formname.'.filename'}; |
my $fname=$env{'form.'.$formname.'.filename'}; |
$fname=&clean_filename($fname); |
$fname=&clean_filename($fname); |
Line 2240 sub userfileupload {
|
Line 2239 sub userfileupload {
|
if ($env{'form.folder'} =~ m/^(default|supplemental)/) { |
if ($env{'form.folder'} =~ m/^(default|supplemental)/) { |
return &finishuserfileupload($docuname,$docudom, |
return &finishuserfileupload($docuname,$docudom, |
$formname,$fname,$parser,$allfiles, |
$formname,$fname,$parser,$allfiles, |
$codebase,$thumbwidth,$thumbheight); |
$codebase,$thumbwidth,$thumbheight, |
|
$resizewidth,$resizeheight); |
} else { |
} else { |
$fname=$env{'form.folder'}.'/'.$fname; |
$fname=$env{'form.folder'}.'/'.$fname; |
return &process_coursefile('uploaddoc',$docuname,$docudom, |
return &process_coursefile('uploaddoc',$docuname,$docudom, |
Line 2252 sub userfileupload {
|
Line 2252 sub userfileupload {
|
my $docudom=$destudom; |
my $docudom=$destudom; |
return &finishuserfileupload($docuname,$docudom,$formname,$fname, |
return &finishuserfileupload($docuname,$docudom,$formname,$fname, |
$parser,$allfiles,$codebase, |
$parser,$allfiles,$codebase, |
$thumbwidth,$thumbheight); |
$thumbwidth,$thumbheight, |
|
$resizewidth,$resizeheight); |
|
|
} else { |
} else { |
my $docuname=$env{'user.name'}; |
my $docuname=$env{'user.name'}; |
Line 2263 sub userfileupload {
|
Line 2264 sub userfileupload {
|
} |
} |
return &finishuserfileupload($docuname,$docudom,$formname,$fname, |
return &finishuserfileupload($docuname,$docudom,$formname,$fname, |
$parser,$allfiles,$codebase, |
$parser,$allfiles,$codebase, |
$thumbwidth,$thumbheight); |
$thumbwidth,$thumbheight, |
|
$resizewidth,$resizeheight); |
} |
} |
} |
} |
|
|
sub finishuserfileupload { |
sub finishuserfileupload { |
my ($docuname,$docudom,$formname,$fname,$parser,$allfiles,$codebase, |
my ($docuname,$docudom,$formname,$fname,$parser,$allfiles,$codebase, |
$thumbwidth,$thumbheight) = @_; |
$thumbwidth,$thumbheight,$resizewidth,$resizeheight) = @_; |
my $path=$docudom.'/'.$docuname.'/'; |
my $path=$docudom.'/'.$docuname.'/'; |
my $filepath=$perlvar{'lonDocRoot'}; |
my $filepath=$perlvar{'lonDocRoot'}; |
|
|
Line 2301 sub finishuserfileupload {
|
Line 2303 sub finishuserfileupload {
|
return '/adm/notfound.html'; |
return '/adm/notfound.html'; |
} |
} |
close(FH); |
close(FH); |
if($upload_photo_form==1) |
if ($resizewidth && $resizeheight) { |
{ |
my $mm = new File::MMagic; |
resizeImage($filepath.'/'.$file); |
my $mime_type = $mm->checktype_filename($filepath.'/'.$file); |
$upload_photo_form = 0; |
if ($mime_type =~ m{^image/}) { |
|
&resizeImage($filepath.'/'.$file,$resizewidth,$resizeheight); |
|
} |
} |
} |
} |
} |
if ($parser eq 'parse') { |
if ($parser eq 'parse') { |
Line 2725 sub userrolelog {
|
Line 2729 sub userrolelog {
|
if (($trole=~/^ca/) || ($trole=~/^aa/) || |
if (($trole=~/^ca/) || ($trole=~/^aa/) || |
($trole=~/^in/) || ($trole=~/^cc/) || |
($trole=~/^in/) || ($trole=~/^cc/) || |
($trole=~/^ep/) || ($trole=~/^cr/) || |
($trole=~/^ep/) || ($trole=~/^cr/) || |
($trole=~/^ta/)) { |
($trole=~/^ta/) || ($trole=~/^co/)) { |
my (undef,$rudom,$runame,$rsec)=split(/\//,$area); |
my (undef,$rudom,$runame,$rsec)=split(/\//,$area); |
$userrolehash |
$userrolehash |
{$trole.':'.$username.':'.$domain.':'.$runame.':'.$rudom.':'.$rsec} |
{$trole.':'.$username.':'.$domain.':'.$runame.':'.$rudom.':'.$rsec} |
Line 2734 sub userrolelog {
|
Line 2738 sub userrolelog {
|
if (($env{'request.role'} =~ /dc\./) && |
if (($env{'request.role'} =~ /dc\./) && |
(($trole=~/^au/) || ($trole=~/^in/) || |
(($trole=~/^au/) || ($trole=~/^in/) || |
($trole=~/^cc/) || ($trole=~/^ep/) || |
($trole=~/^cc/) || ($trole=~/^ep/) || |
($trole=~/^cr/) || ($trole=~/^ta/))) { |
($trole=~/^cr/) || ($trole=~/^ta/) || |
|
($trole=~/^co/))) { |
$userrolehash |
$userrolehash |
{$trole.':'.$username.':'.$domain.':'.$env{'user.name'}.':'.$env{'user.domain'}.':'} |
{$trole.':'.$username.':'.$domain.':'.$env{'user.name'}.':'.$env{'user.domain'}.':'} |
=$tend.':'.$tstart; |
=$tend.':'.$tstart; |
Line 2755 sub courserolelog {
|
Line 2760 sub courserolelog {
|
if (($trole eq 'cc') || ($trole eq 'in') || |
if (($trole eq 'cc') || ($trole eq 'in') || |
($trole eq 'ep') || ($trole eq 'ad') || |
($trole eq 'ep') || ($trole eq 'ad') || |
($trole eq 'ta') || ($trole eq 'st') || |
($trole eq 'ta') || ($trole eq 'st') || |
($trole=~/^cr/) || ($trole eq 'gr')) { |
($trole=~/^cr/) || ($trole eq 'gr') || |
|
($trole eq 'co')) { |
if ($area =~ m-^/($match_domain)/($match_courseid)/?([^/]*)-) { |
if ($area =~ m-^/($match_domain)/($match_courseid)/?([^/]*)-) { |
my $cdom = $1; |
my $cdom = $1; |
my $cnum = $2; |
my $cnum = $2; |
Line 2989 sub getannounce {
|
Line 2995 sub getannounce {
|
|
|
sub courseidput { |
sub courseidput { |
my ($domain,$storehash,$coursehome,$caller) = @_; |
my ($domain,$storehash,$coursehome,$caller) = @_; |
|
return unless (ref($storehash) eq 'HASH'); |
my $outcome; |
my $outcome; |
if ($caller eq 'timeonly') { |
if ($caller eq 'timeonly') { |
my $cids = ''; |
my $cids = ''; |
Line 3027 sub courseidput {
|
Line 3034 sub courseidput {
|
sub courseiddump { |
sub courseiddump { |
my ($domfilter,$descfilter,$sincefilter,$instcodefilter,$ownerfilter, |
my ($domfilter,$descfilter,$sincefilter,$instcodefilter,$ownerfilter, |
$coursefilter,$hostidflag,$hostidref,$typefilter,$regexp_ok, |
$coursefilter,$hostidflag,$hostidref,$typefilter,$regexp_ok, |
$selfenrollonly,$catfilter,$showhidden,$caller,$cloner,$cc_clone,$cloneonly)=@_; |
$selfenrollonly,$catfilter,$showhidden,$caller,$cloner,$cc_clone, |
|
$cloneonly,$createdbefore,$createdafter,$creationcontext,$domcloner)=@_; |
my $as_hash = 1; |
my $as_hash = 1; |
my %returnhash; |
my %returnhash; |
if (!$domfilter) { $domfilter=''; } |
if (!$domfilter) { $domfilter=''; } |
Line 3047 sub courseiddump {
|
Line 3055 sub courseiddump {
|
':'.&escape($regexp_ok).':'.$as_hash.':'. |
':'.&escape($regexp_ok).':'.$as_hash.':'. |
&escape($selfenrollonly).':'.&escape($catfilter).':'. |
&escape($selfenrollonly).':'.&escape($catfilter).':'. |
$showhidden.':'.$caller.':'.&escape($cloner).':'. |
$showhidden.':'.$caller.':'.&escape($cloner).':'. |
&escape($cc_clone).':'.$cloneonly,$tryserver); |
&escape($cc_clone).':'.$cloneonly.':'. |
|
&escape($createdbefore).':'.&escape($createdafter).':'. |
|
&escape($creationcontext).':'.$domcloner, |
|
$tryserver); |
my @pairs=split(/\&/,$rep); |
my @pairs=split(/\&/,$rep); |
foreach my $item (@pairs) { |
foreach my $item (@pairs) { |
my ($key,$value)=split(/\=/,$item,2); |
my ($key,$value)=split(/\=/,$item,2); |
Line 3070 sub courseiddump {
|
Line 3081 sub courseiddump {
|
return %returnhash; |
return %returnhash; |
} |
} |
|
|
|
sub courselastaccess { |
|
my ($cdom,$cnum,$hostidref) = @_; |
|
my %returnhash; |
|
if ($cdom && $cnum) { |
|
my $chome = &homeserver($cnum,$cdom); |
|
if ($chome ne 'no_host') { |
|
my $rep = &reply('courselastaccess:'.$cdom.':'.$cnum,$chome); |
|
&extract_lastaccess(\%returnhash,$rep); |
|
} |
|
} else { |
|
if (!$cdom) { $cdom=''; } |
|
my %libserv = &all_library(); |
|
foreach my $tryserver (keys(%libserv)) { |
|
if (ref($hostidref) eq 'ARRAY') { |
|
next unless (grep(/^\Q$tryserver\E$/,@{$hostidref})); |
|
} |
|
if (($cdom eq '') || (&host_domain($tryserver) eq $cdom)) { |
|
my $rep = &reply('courselastaccess:'.&host_domain($tryserver).':',$tryserver); |
|
&extract_lastaccess(\%returnhash,$rep); |
|
} |
|
} |
|
} |
|
return %returnhash; |
|
} |
|
|
|
sub extract_lastaccess { |
|
my ($returnhash,$rep) = @_; |
|
if (ref($returnhash) eq 'HASH') { |
|
unless ($rep eq 'unknown_command' || $rep eq 'no_such_host' || |
|
$rep eq 'con_lost' || $rep eq 'rejected' || $rep eq 'refused' || |
|
$rep eq '') { |
|
my @pairs=split(/\&/,$rep); |
|
foreach my $item (@pairs) { |
|
my ($key,$value)=split(/\=/,$item,2); |
|
$key = &unescape($key); |
|
next if ($key =~ /^error: 2 /); |
|
$returnhash->{$key} = &thaw_unescape($value); |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
# ---------------------------------------------------------- DC e-mail |
# ---------------------------------------------------------- DC e-mail |
|
|
sub dcmailput { |
sub dcmailput { |
Line 3130 sub get_domain_roles {
|
Line 3184 sub get_domain_roles {
|
return %personnel; |
return %personnel; |
} |
} |
|
|
# ----------------------------------------------------------- Check out an item |
# ----------------------------------------------------------- Interval timing |
|
|
sub get_first_access { |
sub get_first_access { |
my ($type,$argsymb)=@_; |
my ($type,$argsymb)=@_; |
Line 3166 sub set_first_access {
|
Line 3220 sub set_first_access {
|
return 'already_set'; |
return 'already_set'; |
} |
} |
|
|
sub checkout { |
|
my ($symb,$tuname,$tudom,$tcrsid)=@_; |
|
my $now=time; |
|
my $lonhost=$perlvar{'lonHostID'}; |
|
my $infostr=&escape( |
|
'CHECKOUTTOKEN&'. |
|
$tuname.'&'. |
|
$tudom.'&'. |
|
$tcrsid.'&'. |
|
$symb.'&'. |
|
$now.'&'.$ENV{'REMOTE_ADDR'}); |
|
my $token=&reply('tmpput:'.$infostr,$lonhost); |
|
if ($token=~/^error\:/) { |
|
&logthis("<font color=\"blue\">WARNING: ". |
|
"Checkout tmpput failed ".$tudom.' - '.$tuname.' - '.$symb. |
|
"</font>"); |
|
return ''; |
|
} |
|
|
|
$token=~s/^(\d+)\_.*\_(\d+)$/$1\*$2\*$lonhost/; |
|
$token=~tr/a-z/A-Z/; |
|
|
|
my %infohash=('resource.0.outtoken' => $token, |
|
'resource.0.checkouttime' => $now, |
|
'resource.0.outremote' => $ENV{'REMOTE_ADDR'}); |
|
|
|
unless (&cstore(\%infohash,$symb,$tcrsid,$tudom,$tuname) eq 'ok') { |
|
return ''; |
|
} else { |
|
&logthis("<font color=\"blue\">WARNING: ". |
|
"Checkout cstore failed ".$tudom.' - '.$tuname.' - '.$symb. |
|
"</font>"); |
|
} |
|
|
|
if (&log($tudom,$tuname,&homeserver($tuname,$tudom), |
|
&escape('Checkout '.$infostr.' - '. |
|
$token)) ne 'ok') { |
|
return ''; |
|
} else { |
|
&logthis("<font color=\"blue\">WARNING: ". |
|
"Checkout log failed ".$tudom.' - '.$tuname.' - '.$symb. |
|
"</font>"); |
|
} |
|
return $token; |
|
} |
|
|
|
# ------------------------------------------------------------ Check in an item |
|
|
|
sub checkin { |
|
my $token=shift; |
|
my $now=time; |
|
my ($ta,$tb,$lonhost)=split(/\*/,$token); |
|
$lonhost=~tr/A-Z/a-z/; |
|
my $dtoken=$ta.'_'.&hostname($lonhost).'_'.$tb; |
|
$dtoken=~s/\W/\_/g; |
|
my ($dummy,$tuname,$tudom,$tcrsid,$symb,$chtim,$rmaddr)= |
|
split(/\&/,&unescape(&reply('tmpget:'.$dtoken,$lonhost))); |
|
|
|
unless (($tuname) && ($tudom)) { |
|
&logthis('Check in '.$token.' ('.$dtoken.') failed'); |
|
return ''; |
|
} |
|
|
|
unless (&allowed('mgr',$tcrsid)) { |
|
&logthis('Check in '.$token.' ('.$dtoken.') unauthorized: '. |
|
$env{'user.name'}.' - '.$env{'user.domain'}); |
|
return ''; |
|
} |
|
|
|
my %infohash=('resource.0.intoken' => $token, |
|
'resource.0.checkintime' => $now, |
|
'resource.0.inremote' => $ENV{'REMOTE_ADDR'}); |
|
|
|
unless (&cstore(\%infohash,$symb,$tcrsid,$tudom,$tuname) eq 'ok') { |
|
return ''; |
|
} |
|
|
|
if (&log($tudom,$tuname,&homeserver($tuname,$tudom), |
|
&escape('Checkin - '.$token)) ne 'ok') { |
|
return ''; |
|
} |
|
|
|
return ($symb,$tuname,$tudom,$tcrsid); |
|
} |
|
|
|
# --------------------------------------------- Set Expire Date for Spreadsheet |
# --------------------------------------------- Set Expire Date for Spreadsheet |
|
|
sub expirespread { |
sub expirespread { |
Line 3795 sub privileged {
|
Line 3764 sub privileged {
|
my ($username,$domain)=@_; |
my ($username,$domain)=@_; |
my $rolesdump=&reply("dump:$domain:$username:roles", |
my $rolesdump=&reply("dump:$domain:$username:roles", |
&homeserver($username,$domain)); |
&homeserver($username,$domain)); |
if (($rolesdump eq 'con_lost') || ($rolesdump eq '')) { return 0; } |
if (($rolesdump eq 'con_lost') || ($rolesdump eq '') || |
|
($rolesdump =~ /^error:/)) { |
|
return 0; |
|
} |
my $now=time; |
my $now=time; |
if ($rolesdump ne '') { |
if ($rolesdump ne '') { |
foreach my $entry (split(/&/,$rolesdump)) { |
foreach my $entry (split(/&/,$rolesdump)) { |
Line 3823 sub privileged {
|
Line 3795 sub privileged {
|
|
|
sub rolesinit { |
sub rolesinit { |
my ($domain,$username,$authhost)=@_; |
my ($domain,$username,$authhost)=@_; |
my %userroles; |
my $now=time; |
|
my %userroles = ('user.login.time' => $now); |
my $rolesdump=reply("dump:$domain:$username:roles",$authhost); |
my $rolesdump=reply("dump:$domain:$username:roles",$authhost); |
if (($rolesdump eq 'con_lost') || ($rolesdump eq '')) { return \%userroles; } |
if (($rolesdump eq 'con_lost') || ($rolesdump eq '') || |
|
($rolesdump =~ /^error:/)) { |
|
return \%userroles; |
|
} |
my %allroles=(); |
my %allroles=(); |
my %allgroups=(); |
my %allgroups=(); |
my $now=time; |
|
%userroles = ('user.login.time' => $now); |
|
my $group_privs; |
my $group_privs; |
|
|
if ($rolesdump ne '') { |
if ($rolesdump ne '') { |
Line 3895 sub custom_roleprivs {
|
Line 3869 sub custom_roleprivs {
|
if (($rdummy ne 'con_lost') && ($roledef ne '')) { |
if (($rdummy ne 'con_lost') && ($roledef ne '')) { |
my ($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef); |
my ($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef); |
if (defined($syspriv)) { |
if (defined($syspriv)) { |
|
if ($trest =~ /^$match_community$/) { |
|
$syspriv =~ s/bre\&S//; |
|
} |
$$allroles{'cm./'}.=':'.$syspriv; |
$$allroles{'cm./'}.=':'.$syspriv; |
$$allroles{$spec.'./'}.=':'.$syspriv; |
$$allroles{$spec.'./'}.=':'.$syspriv; |
} |
} |
Line 3943 sub standard_roleprivs {
|
Line 3920 sub standard_roleprivs {
|
} |
} |
|
|
sub set_userprivs { |
sub set_userprivs { |
my ($userroles,$allroles,$allgroups) = @_; |
my ($userroles,$allroles,$allgroups,$groups_roles) = @_; |
my $author=0; |
my $author=0; |
my $adv=0; |
my $adv=0; |
my %grouproles = (); |
my %grouproles = (); |
if (keys(%{$allgroups}) > 0) { |
if (keys(%{$allgroups}) > 0) { |
|
my @groupkeys; |
foreach my $role (keys(%{$allroles})) { |
foreach my $role (keys(%{$allroles})) { |
my ($trole,$area,$sec,$extendedarea); |
push(@groupkeys,$role); |
if ($role =~ m-^(\w+|cr/$match_domain/$match_username/\w+)\.(/$match_domain/$match_courseid)(/?\w*)\.-) { |
} |
$trole = $1; |
if (ref($groups_roles) eq 'HASH') { |
$area = $2; |
foreach my $key (keys(%{$groups_roles})) { |
$sec = $3; |
unless (grep(/^\Q$key\E$/,@groupkeys)) { |
$extendedarea = $area.$sec; |
push(@groupkeys,$key); |
if (exists($$allgroups{$area})) { |
} |
foreach my $group (keys(%{$$allgroups{$area}})) { |
} |
my $spec = $trole.'.'.$extendedarea; |
} |
$grouproles{$spec.'.'.$area.'/'.$group} = |
if (@groupkeys > 0) { |
|
foreach my $role (@groupkeys) { |
|
my ($trole,$area,$sec,$extendedarea); |
|
if ($role =~ m-^(\w+|cr/$match_domain/$match_username/\w+)\.(/$match_domain/$match_courseid)(/?\w*)\.-) { |
|
$trole = $1; |
|
$area = $2; |
|
$sec = $3; |
|
$extendedarea = $area.$sec; |
|
if (exists($$allgroups{$area})) { |
|
foreach my $group (keys(%{$$allgroups{$area}})) { |
|
my $spec = $trole.'.'.$extendedarea; |
|
$grouproles{$spec.'.'.$area.'/'.$group} = |
$$allgroups{$area}{$group}; |
$$allgroups{$area}{$group}; |
|
} |
} |
} |
} |
} |
} |
} |
Line 4003 sub role_status {
|
Line 3993 sub role_status {
|
$$tstatus='is'; |
$$tstatus='is'; |
if ($$tstart && $$tstart>$then) { |
if ($$tstart && $$tstart>$then) { |
$$tstatus='future'; |
$$tstatus='future'; |
if ($$tstart && $$tstart>$refresh) { |
if ($$tstart<$now) { |
if ($$tstart<$now) { |
if ($$tstart && $$tstart>$refresh) { |
if (($$where ne '') && ($$role ne '')) { |
if (($$where ne '') && ($$role ne '')) { |
my (%allroles,%allgroups,$group_privs); |
my (%allroles,%allgroups,$group_privs, |
|
%groups_roles,@rolecodes); |
my %userroles = ( |
my %userroles = ( |
'user.role.'.$$role.'.'.$$where => $$tstart.'.'.$$tend |
'user.role.'.$$role.'.'.$$where => $$tstart.'.'.$$tend |
); |
); |
|
@rolecodes = ('cm'); |
my $spec=$$role.'.'.$$where; |
my $spec=$$role.'.'.$$where; |
my ($tdummy,$tdomain,$trest)=split(/\//,$$where); |
my ($tdummy,$tdomain,$trest)=split(/\//,$$where); |
if ($$role eq 'gr') { |
|
my %rolehash = &get('roles',[$$where.'_'.$$role],$env{'user.domain'}, |
|
$env{'user.name'})=@_; |
|
my ($trole) = split('_',$role,1); |
|
(undef,my $group_privs) = split(/\//,$trole); |
|
$group_privs = &unescape($group_privs); |
|
} |
|
if ($$role =~ /^cr\//) { |
if ($$role =~ /^cr\//) { |
&custom_roleprivs(\%allroles,$$role,$tdomain,$trest,$spec,$$where); |
&custom_roleprivs(\%allroles,$$role,$tdomain,$trest,$spec,$$where); |
|
push(@rolecodes,'cr'); |
} elsif ($$role eq 'gr') { |
} elsif ($$role eq 'gr') { |
|
push(@rolecodes,$$role); |
my %rolehash = &get('roles',[$$where.'_'.$$role],$env{'user.domain'}, |
my %rolehash = &get('roles',[$$where.'_'.$$role],$env{'user.domain'}, |
$env{'user.name'}); |
$env{'user.name'}); |
my $trole = split('_',$rolehash{$$where.'_'.$$role},1); |
my ($trole) = split('_',$rolehash{$$where.'_'.$$role},2); |
(undef,my $group_privs) = split(/\//,$trole); |
(undef,my $group_privs) = split(/\//,$trole); |
$group_privs = &unescape($group_privs); |
$group_privs = &unescape($group_privs); |
&group_roleprivs(\%allgroups,$$where,$group_privs,$$tend,$$tstart); |
&group_roleprivs(\%allgroups,$$where,$group_privs,$$tend,$$tstart); |
|
my %course_roles = &get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',['active'],['cc','co','in','ta','ep','ad','st','cr'],[$tdomain],1); |
|
if (keys(%course_roles) > 0) { |
|
my ($tnum) = ($trest =~ /^($match_courseid)/); |
|
if ($tdomain ne '' && $tnum ne '') { |
|
foreach my $key (keys(%course_roles)) { |
|
if ($key =~ /^\Q$tnum\E:\Q$tdomain\E:([^:]+):?([^:]*)/) { |
|
my $crsrole = $1; |
|
my $crssec = $2; |
|
if ($crsrole =~ /^cr/) { |
|
unless (grep(/^cr$/,@rolecodes)) { |
|
push(@rolecodes,'cr'); |
|
} |
|
} else { |
|
unless(grep(/^\Q$crsrole\E$/,@rolecodes)) { |
|
push(@rolecodes,$crsrole); |
|
} |
|
} |
|
my $rolekey = $crsrole.'./'.$tdomain.'/'.$tnum; |
|
if ($crssec ne '') { |
|
$rolekey .= '/'.$crssec; |
|
} |
|
$rolekey .= './'; |
|
$groups_roles{$rolekey} = \@rolecodes; |
|
} |
|
} |
|
} |
|
} |
} else { |
} else { |
|
push(@rolecodes,$$role); |
&standard_roleprivs(\%allroles,$$role,$tdomain,$spec,$trest,$$where); |
&standard_roleprivs(\%allroles,$$role,$tdomain,$spec,$trest,$$where); |
} |
} |
my ($author,$adv)= &set_userprivs(\%userroles,\%allroles,\%allgroups); |
my ($author,$adv)= &set_userprivs(\%userroles,\%allroles,\%allgroups,\%groups_roles); |
&appenv(\%userroles,[$$role,'cm']); |
&appenv(\%userroles,\@rolecodes); |
&log($env{'user.domain'},$env{'user.name'},$env{'user.home'},"Role ".$role); |
&log($env{'user.domain'},$env{'user.name'},$env{'user.home'},"Role ".$role); |
$$tstatus = 'is'; |
|
} |
} |
} |
} |
|
$$tstatus = 'is'; |
} |
} |
} |
} |
if ($$tend) { |
if ($$tend) { |
Line 4546 sub get_portfolio_access {
|
Line 4561 sub get_portfolio_access {
|
my (%allgroups,%allroles); |
my (%allgroups,%allroles); |
my ($start,$end,$role,$sec,$group); |
my ($start,$end,$role,$sec,$group); |
foreach my $envkey (%env) { |
foreach my $envkey (%env) { |
if ($envkey =~ m-^user\.role\.(gr|cc|in|ta|ep|st)\./($match_domain)/($match_courseid)/?([^/]*)$-) { |
if ($envkey =~ m-^user\.role\.(gr|cc|co|in|ta|ep|ad|st)\./($match_domain)/($match_courseid)/?([^/]*)$-) { |
my $cid = $2.'_'.$3; |
my $cid = $2.'_'.$3; |
if ($1 eq 'gr') { |
if ($1 eq 'gr') { |
$group = $4; |
$group = $4; |
Line 4728 sub usertools_access {
|
Line 4743 sub usertools_access {
|
$toolstatus = $env{'environment.'.$context.'.'.$tool}; |
$toolstatus = $env{'environment.'.$context.'.'.$tool}; |
$inststatus = $env{'environment.inststatus'}; |
$inststatus = $env{'environment.inststatus'}; |
} else { |
} else { |
my %userenv = &userenvironment($udom,$uname,$context.'.'.$tool); |
my %userenv = &userenvironment($udom,$uname,$context.'.'.$tool,'inststatus'); |
$toolstatus = $userenv{$context.'.'.$tool}; |
$toolstatus = $userenv{$context.'.'.$tool}; |
$inststatus = $userenv{'inststatus'}; |
$inststatus = $userenv{'inststatus'}; |
} |
} |
Line 4794 sub usertools_access {
|
Line 4809 sub usertools_access {
|
} |
} |
} |
} |
|
|
|
sub is_course_owner { |
|
my ($cdom,$cnum,$udom,$uname) = @_; |
|
if (($udom eq '') || ($uname eq '')) { |
|
$udom = $env{'user.domain'}; |
|
$uname = $env{'user.name'}; |
|
} |
|
unless (($udom eq '') || ($uname eq '')) { |
|
if (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.courseowner'})) { |
|
if ($env{'course.'.$cdom.'_'.$cnum.'.internal.courseowner'} eq $uname.':'.$udom) { |
|
return 1; |
|
} else { |
|
my %courseinfo = &Apache::lonnet::coursedescription($cdom.'/'.$cnum); |
|
if ($courseinfo{'internal.courseowner'} eq $uname.':'.$udom) { |
|
return 1; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
sub is_advanced_user { |
sub is_advanced_user { |
my ($udom,$uname) = @_; |
my ($udom,$uname) = @_; |
my %roleshash = &get_my_roles($uname,$udom,'userroles',undef,undef,undef,1); |
my %roleshash = &get_my_roles($uname,$udom,'userroles',undef,undef,undef,1); |
Line 4829 sub is_advanced_user {
|
Line 4865 sub is_advanced_user {
|
return $is_adv; |
return $is_adv; |
} |
} |
|
|
|
sub check_can_request { |
|
my ($dom,$can_request,$request_domains) = @_; |
|
my $canreq = 0; |
|
my ($types,$typename) = &Apache::loncommon::course_types(); |
|
my @options = ('approval','validate','autolimit'); |
|
my $optregex = join('|',@options); |
|
if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) { |
|
foreach my $type (@{$types}) { |
|
if (&usertools_access($env{'user.name'}, |
|
$env{'user.domain'}, |
|
$type,undef,'requestcourses')) { |
|
$canreq ++; |
|
if (ref($request_domains) eq 'HASH') { |
|
push(@{$request_domains->{$type}},$env{'user.domain'}); |
|
} |
|
if ($dom eq $env{'user.domain'}) { |
|
$can_request->{$type} = 1; |
|
} |
|
} |
|
if ($env{'environment.reqcrsotherdom.'.$type} ne '') { |
|
my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type}); |
|
if (@curr > 0) { |
|
foreach my $item (@curr) { |
|
if (ref($request_domains) eq 'HASH') { |
|
my ($otherdom) = ($item =~ /^($match_domain):($optregex)(=?\d*)$/); |
|
if ($otherdom ne '') { |
|
if (ref($request_domains->{$type}) eq 'ARRAY') { |
|
unless (grep(/^\Q$otherdom\E$/,@{$request_domains->{$type}})) { |
|
push(@{$request_domains->{$type}},$otherdom); |
|
} |
|
} else { |
|
push(@{$request_domains->{$type}},$otherdom); |
|
} |
|
} |
|
} |
|
} |
|
unless($dom eq $env{'user.domain'}) { |
|
$canreq ++; |
|
if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) { |
|
$can_request->{$type} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return $canreq; |
|
} |
|
|
# ---------------------------------------------- Custom access rule evaluation |
# ---------------------------------------------- Custom access rule evaluation |
|
|
sub customaccess { |
sub customaccess { |
Line 4983 sub allowed {
|
Line 5068 sub allowed {
|
my $statecond=0; |
my $statecond=0; |
my $courseprivid=''; |
my $courseprivid=''; |
|
|
|
my $ownaccess; |
|
# Community Coordinator or Assistant Co-author browsing resource space. |
|
if (($priv eq 'bro') && ($env{'user.author'})) { |
|
if ($uri eq '') { |
|
$ownaccess = 1; |
|
} else { |
|
if (($env{'user.domain'} ne '') && ($env{'user.name'} ne '')) { |
|
my $udom = $env{'user.domain'}; |
|
my $uname = $env{'user.name'}; |
|
if ($uri =~ m{^\Q$udom\E/?$}) { |
|
$ownaccess = 1; |
|
} elsif ($uri =~ m{^\Q$udom\E/\Q$uname\E/?}) { |
|
unless ($uri =~ m{\.\./}) { |
|
$ownaccess = 1; |
|
} |
|
} elsif (($udom ne 'public') && ($uname ne 'public')) { |
|
my $now = time; |
|
if ($uri =~ m{^([^/]+)/?$}) { |
|
my $adom = $1; |
|
foreach my $key (keys(%env)) { |
|
if ($key =~ m{^user\.role\.(ca|aa)/\Q$adom\E}) { |
|
my ($start,$end) = split('.',$env{$key}); |
|
if (($now >= $start) && (!$end || $end < $now)) { |
|
$ownaccess = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} elsif ($uri =~ m{^([^/]+)/([^/]+)/?}) { |
|
my $adom = $1; |
|
my $aname = $2; |
|
foreach my $role ('ca','aa') { |
|
if ($env{"user.role.$role./$adom/$aname"}) { |
|
my ($start,$end) = |
|
split('.',$env{"user.role.$role./$adom/$aname"}); |
|
if (($now >= $start) && (!$end || $end < $now)) { |
|
$ownaccess = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
# Course |
# Course |
|
|
if ($env{'user.priv.'.$env{'request.role'}.'./'}=~/\Q$priv\E\&([^\:]*)/) { |
if ($env{'user.priv.'.$env{'request.role'}.'./'}=~/\Q$priv\E\&([^\:]*)/) { |
$thisallowed.=$1; |
unless (($priv eq 'bro') && (!$ownaccess)) { |
|
$thisallowed.=$1; |
|
} |
} |
} |
|
|
# Domain |
# Domain |
|
|
if ($env{'user.priv.'.$env{'request.role'}.'./'.(split(/\//,$uri))[0].'/'} |
if ($env{'user.priv.'.$env{'request.role'}.'./'.(split(/\//,$uri))[0].'/'} |
=~/\Q$priv\E\&([^\:]*)/) { |
=~/\Q$priv\E\&([^\:]*)/) { |
$thisallowed.=$1; |
unless (($priv eq 'bro') && (!$ownaccess)) { |
|
$thisallowed.=$1; |
|
} |
} |
} |
|
|
# Course: uri itself is a course |
# Course: uri itself is a course |
Line 5003 sub allowed {
|
Line 5139 sub allowed {
|
|
|
if ($env{'user.priv.'.$env{'request.role'}.'.'.$courseuri} |
if ($env{'user.priv.'.$env{'request.role'}.'.'.$courseuri} |
=~/\Q$priv\E\&([^\:]*)/) { |
=~/\Q$priv\E\&([^\:]*)/) { |
$thisallowed.=$1; |
unless (($priv eq 'bro') && (!$ownaccess)) { |
|
$thisallowed.=$1; |
|
} |
} |
} |
|
|
# URI is an uploaded document for this course, default permissions don't matter |
# URI is an uploaded document for this course, default permissions don't matter |
Line 5611 sub auto_validate_instcode {
|
Line 5749 sub auto_validate_instcode {
|
$homeserver = &domain($cdom,'primary'); |
$homeserver = &domain($cdom,'primary'); |
} |
} |
} |
} |
my $response=&unescape(&reply('autovalidateinstcode:'.$cdom.':'. |
$response=&unescape(&reply('autovalidateinstcode:'.$cdom.':'. |
&escape($instcode).':'.&escape($owner),$homeserver)); |
&escape($instcode).':'.&escape($owner),$homeserver)); |
return $response; |
my ($outcome,$description) = map { &unescape($_); } split('&',$response,2); |
|
return ($outcome,$description); |
} |
} |
|
|
sub auto_create_password { |
sub auto_create_password { |
Line 6022 sub devalidate_getgroups_cache {
|
Line 6161 sub devalidate_getgroups_cache {
|
|
|
sub plaintext { |
sub plaintext { |
my ($short,$type,$cid,$forcedefault) = @_; |
my ($short,$type,$cid,$forcedefault) = @_; |
if ($short =~ /^cr/) { |
if ($short =~ m{^cr/}) { |
return (split('/',$short))[-1]; |
return (split('/',$short))[-1]; |
} |
} |
if (!defined($cid)) { |
if (!defined($cid)) { |
$cid = $env{'request.course.id'}; |
$cid = $env{'request.course.id'}; |
} |
} |
if (defined($cid) && ($env{'course.'.$cid.'.'.$short.'.plaintext'} ne '')) { |
|
unless ($forcedefault) { |
|
my $roletext = $env{'course.'.$cid.'.'.$short.'.plaintext'}; |
|
&Apache::lonlocal::mt_escape(\$roletext); |
|
return &Apache::lonlocal::mt($roletext); |
|
} |
|
} |
|
my %rolenames = ( |
my %rolenames = ( |
Course => 'std', |
Course => 'std', |
Community => 'alt1', |
Community => 'alt1', |
); |
); |
if (defined($type) && |
if ($cid ne '') { |
defined($rolenames{$type}) && |
if ($env{'course.'.$cid.'.'.$short.'.plaintext'} ne '') { |
defined($prp{$short}{$rolenames{$type}})) { |
unless ($forcedefault) { |
|
my $roletext = $env{'course.'.$cid.'.'.$short.'.plaintext'}; |
|
&Apache::lonlocal::mt_escape(\$roletext); |
|
return &Apache::lonlocal::mt($roletext); |
|
} |
|
} |
|
} |
|
if ((defined($type)) && (defined($rolenames{$type})) && |
|
(defined($rolenames{$type})) && |
|
(defined($prp{$short}{$rolenames{$type}}))) { |
return &Apache::lonlocal::mt($prp{$short}{$rolenames{$type}}); |
return &Apache::lonlocal::mt($prp{$short}{$rolenames{$type}}); |
} else { |
} elsif ($cid ne '') { |
return &Apache::lonlocal::mt($prp{$short}{'std'}); |
my $crstype = $env{'course.'.$cid.'.type'}; |
|
if (($crstype ne '') && (defined($rolenames{$crstype})) && |
|
(defined($prp{$short}{$rolenames{$crstype}}))) { |
|
return &Apache::lonlocal::mt($prp{$short}{$rolenames{$crstype}}); |
|
} |
} |
} |
|
return &Apache::lonlocal::mt($prp{$short}{'std'}); |
} |
} |
|
|
# ----------------------------------------------------------------- Assign Role |
# ----------------------------------------------------------------- Assign Role |
Line 6058 sub assignrole {
|
Line 6204 sub assignrole {
|
my $cwosec=$url; |
my $cwosec=$url; |
$cwosec=~s/^\/($match_domain)\/($match_courseid)\/.*/$1\/$2/; |
$cwosec=~s/^\/($match_domain)\/($match_courseid)\/.*/$1\/$2/; |
unless (&allowed('ccr',$cwosec)) { |
unless (&allowed('ccr',$cwosec)) { |
&logthis('Refused custom assignrole: '. |
my $refused = 1; |
$udom.' '.$uname.' '.$url.' '.$role.' '.$end.' '.$start.' by '. |
if ($context eq 'requestcourses') { |
$env{'user.name'}.' at '.$env{'user.domain'}); |
if (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')) { |
return 'refused'; |
if ($role =~ m{^cr/($match_domain)/($match_username)/([^/]+)$}) { |
|
if (($1 eq $env{'user.domain'}) && ($2 eq $env{'user.name'})) { |
|
my ($cdom,$cnum) = ($cwosec =~ m{^/?($match_domain)/($match_courseid)$}); |
|
my %crsenv = &userenvironment($cdom,$cnum,('internal.courseowner')); |
|
if ($crsenv{'internal.courseowner'} eq |
|
$env{'user.name'}.':'.$env{'user.domain'}) { |
|
$refused = ''; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($refused) { |
|
&logthis('Refused custom assignrole: '. |
|
$udom.' '.$uname.' '.$url.' '.$role.' '.$end.' '.$start. |
|
' by '.$env{'user.name'}.' at '.$env{'user.domain'}); |
|
return 'refused'; |
|
} |
} |
} |
$mrole='cr'; |
$mrole='cr'; |
} elsif ($role =~ /^gr\//) { |
} elsif ($role =~ /^gr\//) { |
Line 6087 sub assignrole {
|
Line 6250 sub assignrole {
|
$refused = 1; |
$refused = 1; |
} |
} |
if ($refused) { |
if ($refused) { |
if (($selfenroll == 1) && ($role eq 'st') && ($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'})) { |
my ($cdom,$cnum) = ($cwosec =~ m{^/?($match_domain)/($match_courseid)$}); |
|
if (!$selfenroll && $context eq 'course') { |
|
my %crsenv; |
|
if ($role eq 'cc' || $role eq 'co') { |
|
%crsenv = &userenvironment($cdom,$cnum,('internal.courseowner')); |
|
if (($role eq 'cc') && ($cnum !~ /^$match_community$/)) { |
|
if ($env{'request.role'} eq 'cc./'.$cdom.'/'.$cnum) { |
|
if ($crsenv{'internal.courseowner'} eq |
|
$env{'user.name'}.':'.$env{'user.domain'}) { |
|
$refused = ''; |
|
} |
|
} |
|
} elsif (($role eq 'co') && ($cnum =~ /^$match_community$/)) { |
|
if ($env{'request.role'} eq 'co./'.$cdom.'/'.$cnum) { |
|
if ($crsenv{'internal.courseowner'} eq |
|
$env{'user.name'}.':'.$env{'user.domain'}) { |
|
$refused = ''; |
|
} |
|
} |
|
} |
|
} |
|
} elsif (($selfenroll == 1) && ($role eq 'st') && ($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'})) { |
$refused = ''; |
$refused = ''; |
} elsif ($context eq 'requestcourses') { |
} elsif ($context eq 'requestcourses') { |
if (($role eq 'cc') && ($env{'user.name'} ne '' && $env{'user.domain'} ne '')) { |
my @possroles = ('st','ta','ep','in','cc','co'); |
my ($cdom,$cnum) = ($cwosec =~ m{^/($match_domain)/($match_courseid)$}); |
if ((grep(/^\Q$role\E$/,@possroles)) && ($env{'user.name'} ne '' && $env{'user.domain'} ne '')) { |
my %crsenv = &userenvironment($cdom,$cnum,('internal.courseowner')); |
my $wrongcc; |
if ($crsenv{'internal.courseowner'} eq |
if ($cnum =~ /^$match_community$/) { |
$env{'user.name'}.':'.$env{'user.domain'}) { |
$wrongcc = 1 if ($role eq 'cc'); |
$refused = ''; |
} else { |
|
$wrongcc = 1 if ($role eq 'co'); |
|
} |
|
unless ($wrongcc) { |
|
my %crsenv = &userenvironment($cdom,$cnum,('internal.courseowner')); |
|
if ($crsenv{'internal.courseowner'} eq |
|
$env{'user.name'}.':'.$env{'user.domain'}) { |
|
$refused = ''; |
|
} |
} |
} |
} |
} |
} |
} |
Line 6146 sub assignrole {
|
Line 6338 sub assignrole {
|
&Apache::longroup::group_changes($udom,$uname,$url,$role,$origend, |
&Apache::longroup::group_changes($udom,$uname,$url,$role,$origend, |
$origstart,$selfenroll,$context); |
$origstart,$selfenroll,$context); |
} |
} |
|
if ($role eq 'cc') { |
|
&autoupdate_coowners($url,$end,$start,$uname,$udom); |
|
} |
} |
} |
return $answer; |
return $answer; |
} |
} |
|
|
|
sub autoupdate_coowners { |
|
my ($url,$end,$start,$uname,$udom) = @_; |
|
my ($cdom,$cnum) = ($url =~ m{^/($match_domain)/($match_courseid)}); |
|
if (($cdom ne '') && ($cnum ne '')) { |
|
my $now = time; |
|
my %domdesign = &Apache::loncommon::get_domainconf($cdom); |
|
if ($domdesign{$cdom.'.autoassign.co-owners'}) { |
|
my %coursehash = &coursedescription($cdom.'_'.$cnum); |
|
my $instcode = $coursehash{'internal.coursecode'}; |
|
if ($instcode ne '') { |
|
if (($start && $start <= $now) && ($end == 0) || ($end > $now)) { |
|
unless ($coursehash{'internal.courseowner'} eq $uname.':'.$udom) { |
|
my ($delcoowners,@newcoowners,$putresult,$delresult,$coowners); |
|
my ($result,$desc) = &auto_validate_instcode($cnum,$cdom,$instcode,$uname.':'.$udom); |
|
if ($result eq 'valid') { |
|
if ($coursehash{'internal.co-owners'}) { |
|
foreach my $coowner (split(',',$coursehash{'internal.co-owners'})) { |
|
push(@newcoowners,$coowner); |
|
} |
|
unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) { |
|
push(@newcoowners,$uname.':'.$udom); |
|
} |
|
@newcoowners = sort(@newcoowners); |
|
} else { |
|
push(@newcoowners,$uname.':'.$udom); |
|
} |
|
} else { |
|
if ($coursehash{'internal.co-owners'}) { |
|
foreach my $coowner (split(',',$coursehash{'internal.co-owners'})) { |
|
unless ($coowner eq $uname.':'.$udom) { |
|
push(@newcoowners,$coowner); |
|
} |
|
} |
|
unless (@newcoowners > 0) { |
|
$delcoowners = 1; |
|
$coowners = ''; |
|
} |
|
} |
|
} |
|
if (@newcoowners || $delcoowners) { |
|
&store_coowners($cdom,$cnum,$coursehash{'home'}, |
|
$delcoowners,@newcoowners); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
sub store_coowners { |
|
my ($cdom,$cnum,$chome,$delcoowners,@newcoowners) = @_; |
|
my $cid = $cdom.'_'.$cnum; |
|
my ($coowners,$delresult,$putresult); |
|
if (@newcoowners) { |
|
$coowners = join(',',@newcoowners); |
|
my %coownershash = ( |
|
'internal.co-owners' => $coowners, |
|
); |
|
$putresult = &put('environment',\%coownershash,$cdom,$cnum); |
|
if ($putresult eq 'ok') { |
|
if ($env{'course.'.$cid.'.num'} eq $cnum) { |
|
&appenv({'course.'.$cid.'.internal.co-owners' => $coowners}); |
|
} |
|
} |
|
} |
|
if ($delcoowners) { |
|
$delresult = &Apache::lonnet::del('environment',['internal.co-owners'],$cdom,$cnum); |
|
if ($delresult eq 'ok') { |
|
if ($env{'course.'.$cid.'.internal.co-owners'}) { |
|
&Apache::lonnet::delenv('course.'.$cid.'.internal.co-owners'); |
|
} |
|
} |
|
} |
|
if (($putresult eq 'ok') || ($delresult eq 'ok')) { |
|
my %crsinfo = |
|
&Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.'); |
|
if (ref($crsinfo{$cid}) eq 'HASH') { |
|
$crsinfo{$cid}{'co-owners'} = \@newcoowners; |
|
my $cidput = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime'); |
|
} |
|
} |
|
} |
|
|
# -------------------------------------------------- Modify user authentication |
# -------------------------------------------------- Modify user authentication |
# Overrides without validation |
# Overrides without validation |
|
|
Line 6182 sub modifyuser {
|
Line 6461 sub modifyuser {
|
my ($udom, $uname, $uid, |
my ($udom, $uname, $uid, |
$umode, $upass, $first, |
$umode, $upass, $first, |
$middle, $last, $gene, |
$middle, $last, $gene, |
$forceid, $desiredhome, $email, $inststatus)=@_; |
$forceid, $desiredhome, $email, $inststatus, $candelete)=@_; |
$udom= &LONCAPA::clean_domain($udom); |
$udom= &LONCAPA::clean_domain($udom); |
$uname=&LONCAPA::clean_username($uname); |
$uname=&LONCAPA::clean_username($uname); |
|
my $showcandelete = 'none'; |
|
if (ref($candelete) eq 'ARRAY') { |
|
if (@{$candelete} > 0) { |
|
$showcandelete = join(', ',@{$candelete}); |
|
} |
|
} |
&logthis('Call to modify user '.$udom.', '.$uname.', '.$uid.', '. |
&logthis('Call to modify user '.$udom.', '.$uname.', '.$uid.', '. |
$umode.', '.$first.', '.$middle.', '. |
$umode.', '.$first.', '.$middle.', '. |
$last.', '.$gene.'(forceid: '.$forceid.')'. |
$last.', '.$gene.'(forceid: '.$forceid.'; candelete: '.$showcandelete.')'. |
(defined($desiredhome) ? ' desiredhome = '.$desiredhome : |
(defined($desiredhome) ? ' desiredhome = '.$desiredhome : |
' desiredhome not specified'). |
' desiredhome not specified'). |
' by '.$env{'user.name'}.' at '.$env{'user.domain'}. |
' by '.$env{'user.name'}.' at '.$env{'user.domain'}. |
Line 6252 sub modifyuser {
|
Line 6537 sub modifyuser {
|
%names = @tmp; |
%names = @tmp; |
} |
} |
# |
# |
# Make sure to not trash student environment if instructor does not bother |
# If name, email and/or uid are blank (e.g., because an uploaded file |
# to supply name and email information |
# of users did not contain them), do not overwrite existing values |
# |
# unless field is in $candelete array ref. |
|
# |
|
|
|
my @fields = ('firstname','middlename','lastname','generation', |
|
'permanentemail','id'); |
|
my %newvalues; |
|
if (ref($candelete) eq 'ARRAY') { |
|
foreach my $field (@fields) { |
|
if (grep(/^\Q$field\E$/,@{$candelete})) { |
|
if ($field eq 'firstname') { |
|
$names{$field} = $first; |
|
} elsif ($field eq 'middlename') { |
|
$names{$field} = $middle; |
|
} elsif ($field eq 'lastname') { |
|
$names{$field} = $last; |
|
} elsif ($field eq 'generation') { |
|
$names{$field} = $gene; |
|
} elsif ($field eq 'permanentemail') { |
|
$names{$field} = $email; |
|
} elsif ($field eq 'id') { |
|
$names{$field} = $uid; |
|
} |
|
} |
|
} |
|
} |
if ($first) { $names{'firstname'} = $first; } |
if ($first) { $names{'firstname'} = $first; } |
if (defined($middle)) { $names{'middlename'} = $middle; } |
if (defined($middle)) { $names{'middlename'} = $middle; } |
if ($last) { $names{'lastname'} = $last; } |
if ($last) { $names{'lastname'} = $last; } |
Line 6426 sub createcourse {
|
Line 6735 sub createcourse {
|
$course_owner,$crstype,$cnum,$context,$category)=@_; |
$course_owner,$crstype,$cnum,$context,$category)=@_; |
$url=&declutter($url); |
$url=&declutter($url); |
my $cid=''; |
my $cid=''; |
unless (&allowed('ccc',$udom)) { |
if ($context eq 'requestcourses') { |
if ($context eq 'requestcourses') { |
my $can_create = 0; |
unless (&usertools_access($course_owner,$udom,$category,undef,$context)) { |
my ($ownername,$ownerdom) = split(':',$course_owner); |
return 'refused'; |
if ($udom eq $ownerdom) { |
|
if (&usertools_access($ownername,$ownerdom,$category,undef, |
|
$context)) { |
|
$can_create = 1; |
|
} |
|
} else { |
|
my %userenv = &userenvironment($ownerdom,$ownername,'reqcrsotherdom.'. |
|
$category); |
|
if ($userenv{'reqcrsotherdom.'.$category} ne '') { |
|
my @curr = split(',',$userenv{'reqcrsotherdom.'.$category}); |
|
if (@curr > 0) { |
|
my @options = qw(approval validate autolimit); |
|
my $optregex = join('|',@options); |
|
if (grep(/^\Q$udom\E:($optregex)(=?\d*)$/,@curr)) { |
|
$can_create = 1; |
|
} |
|
} |
|
} |
|
} |
|
if ($can_create) { |
|
unless ($ownername eq $env{'user.name'} && $ownerdom eq $env{'user.domain'}) { |
|
unless (&allowed('ccc',$udom)) { |
|
return 'refused'; |
|
} |
} |
} |
} else { |
} else { |
return 'refused'; |
return 'refused'; |
} |
} |
|
} elsif (!&allowed('ccc',$udom)) { |
|
return 'refused'; |
} |
} |
# --------------------------------------------------------------- Get Unique ID |
# --------------------------------------------------------------- Get Unique ID |
my $uname; |
my $uname; |
Line 6442 sub createcourse {
|
Line 6776 sub createcourse {
|
if (($chome eq '') || ($chome eq 'no_host')) { |
if (($chome eq '') || ($chome eq 'no_host')) { |
$uname = $cnum; |
$uname = $cnum; |
} else { |
} else { |
$uname = &generate_coursenum($udom); |
$uname = &generate_coursenum($udom,$crstype); |
} |
} |
} else { |
} else { |
$uname = &generate_coursenum($udom); |
$uname = &generate_coursenum($udom,$crstype); |
} |
} |
return $uname if ($uname =~ /^error/); |
return $uname if ($uname =~ /^error/); |
# -------------------------------------------------- Check supplied server name |
# -------------------------------------------------- Check supplied server name |
$course_server = $env{'user.homeserver'} if (! defined($course_server)); |
if (!defined($course_server)) { |
if (! &is_library($course_server)) { |
if (defined(&domain($udom,'primary'))) { |
return 'error:bad server name '.$course_server; |
$course_server = &domain($udom,'primary'); |
|
} else { |
|
$course_server = $env{'user.home'}; |
|
} |
|
} |
|
my %host_servers = |
|
&Apache::lonnet::get_servers($udom,'library'); |
|
unless ($host_servers{$course_server}) { |
|
return 'error: invalid home server for course: '.$course_server; |
} |
} |
# ------------------------------------------------------------- Make the course |
# ------------------------------------------------------------- Make the course |
my $reply=&reply('encrypt:makeuser:'.$udom.':'.$uname.':none::', |
my $reply=&reply('encrypt:makeuser:'.$udom.':'.$uname.':none::', |
Line 6463 sub createcourse {
|
Line 6805 sub createcourse {
|
} |
} |
# ----------------------------------------------------------------- Course made |
# ----------------------------------------------------------------- Course made |
# log existence |
# log existence |
|
my $now = time; |
my $newcourse = { |
my $newcourse = { |
$udom.'_'.$uname => { |
$udom.'_'.$uname => { |
description => $description, |
description => $description, |
inst_code => $inst_code, |
inst_code => $inst_code, |
owner => $course_owner, |
owner => $course_owner, |
type => $crstype, |
type => $crstype, |
|
creator => $env{'user.name'}.':'. |
|
$env{'user.domain'}, |
|
created => $now, |
|
context => $context, |
}, |
}, |
}; |
}; |
&courseidput($udom,$newcourse,$uhome,'notime'); |
&courseidput($udom,$newcourse,$uhome,'notime'); |
Line 6493 ENDINITMAP
|
Line 6840 ENDINITMAP
|
} |
} |
# ----------------------------------------------------------- Write preferences |
# ----------------------------------------------------------- Write preferences |
&writecoursepref($udom.'_'.$uname, |
&writecoursepref($udom.'_'.$uname, |
('description' => $description, |
('description' => $description, |
'url' => $topurl)); |
'url' => $topurl, |
|
'internal.creator' => $env{'user.name'}.':'. |
|
$env{'user.domain'}, |
|
'internal.created' => $now, |
|
'internal.creationcontext' => $context) |
|
); |
return '/'.$udom.'/'.$uname; |
return '/'.$udom.'/'.$uname; |
} |
} |
|
|
# ------------------------------------------------------------------- Create ID |
# ------------------------------------------------------------------- Create ID |
sub generate_coursenum { |
sub generate_coursenum { |
my ($udom) = @_; |
my ($udom,$crstype) = @_; |
my $domdesc = &domain($udom); |
my $domdesc = &domain($udom); |
return 'error: invalid domain' if ($domdesc eq ''); |
return 'error: invalid domain' if ($domdesc eq ''); |
my $uname=int(1+rand(9)). |
my $first; |
|
if ($crstype eq 'Community') { |
|
$first = '0'; |
|
} else { |
|
$first = int(1+rand(9)); |
|
} |
|
my $uname=$first. |
('a'..'z','A'..'Z','0'..'9')[int(rand(62))]. |
('a'..'z','A'..'Z','0'..'9')[int(rand(62))]. |
substr($$.time,0,5).unpack("H8",pack("I32",time)). |
substr($$.time,0,5).unpack("H8",pack("I32",time)). |
unpack("H2",pack("I32",int(rand(255)))).$perlvar{'lonHostID'}; |
unpack("H2",pack("I32",int(rand(255)))).$perlvar{'lonHostID'}; |
# ----------------------------------------------- Make sure that does not exist |
# ----------------------------------------------- Make sure that does not exist |
my $uhome=&homeserver($uname,$udom,'true'); |
my $uhome=&homeserver($uname,$udom,'true'); |
unless (($uhome eq '') || ($uhome eq 'no_host')) { |
unless (($uhome eq '') || ($uhome eq 'no_host')) { |
$uname=int(1+rand(9)). |
if ($crstype eq 'Community') { |
|
$first = '0'; |
|
} else { |
|
$first = int(1+rand(9)); |
|
} |
|
$uname=$first. |
('a'..'z','A'..'Z','0'..'9')[int(rand(62))]. |
('a'..'z','A'..'Z','0'..'9')[int(rand(62))]. |
substr($$.time,0,5).unpack("H8",pack("I32",time)). |
substr($$.time,0,5).unpack("H8",pack("I32",time)). |
unpack("H2",pack("I32",int(rand(255)))).$perlvar{'lonHostID'}; |
unpack("H2",pack("I32",int(rand(255)))).$perlvar{'lonHostID'}; |
Line 7769 sub add_prefix_and_part {
|
Line 8132 sub add_prefix_and_part {
|
# ---------------------------------------------------------------- Get metadata |
# ---------------------------------------------------------------- Get metadata |
|
|
my %metaentry; |
my %metaentry; |
|
my %importedpartids; |
sub metadata { |
sub metadata { |
my ($uri,$what,$liburi,$prefix,$depthcount)=@_; |
my ($uri,$what,$liburi,$prefix,$depthcount)=@_; |
$uri=&declutter($uri); |
$uri=&declutter($uri); |
Line 7795 sub metadata {
|
Line 8159 sub metadata {
|
if (defined($cached)) { return $result->{':'.$what}; } |
if (defined($cached)) { return $result->{':'.$what}; } |
} |
} |
{ |
{ |
|
# Imported parts would go here |
|
my %importedids=(); |
|
my @origfileimportpartids=(); |
|
my $importedparts=0; |
# |
# |
# Is this a recursive call for a library? |
# Is this a recursive call for a library? |
# |
# |
Line 7878 sub metadata {
|
Line 8246 sub metadata {
|
# This is not a package - some other kind of start tag |
# This is not a package - some other kind of start tag |
# |
# |
my $entry=$token->[1]; |
my $entry=$token->[1]; |
my $unikey; |
my $unikey=''; |
if ($entry eq 'import') { |
|
$unikey=''; |
|
} else { |
|
$unikey=$entry; |
|
} |
|
$unikey.=&add_prefix_and_part($prefix,$token->[2]->{'part'}); |
|
|
|
if (defined($token->[2]->{'id'})) { |
|
$unikey.='_'.$token->[2]->{'id'}; |
|
} |
|
|
|
if ($entry eq 'import') { |
if ($entry eq 'import') { |
# |
# |
# Importing a library here |
# Importing a library here |
# |
# |
|
my $location=$parser->get_text('/import'); |
|
my $dir=$filename; |
|
$dir=~s|[^/]*$||; |
|
$location=&filelocation($dir,$location); |
|
|
|
my $importmode=$token->[2]->{'importmode'}; |
|
if ($importmode eq 'problem') { |
|
# Import as problem/response |
|
$unikey=&add_prefix_and_part($prefix,$token->[2]->{'part'}); |
|
} elsif ($importmode eq 'part') { |
|
# Import as part(s) |
|
$importedparts=1; |
|
# We need to get the original file and the imported file to get the part order correct |
|
# Good news: we do not need to worry about nested libraries, since parts cannot be nested |
|
# Load and inspect original file |
|
if ($#origfileimportpartids<0) { |
|
undef(%importedpartids); |
|
my $origfilelocation=$perlvar{'lonDocRoot'}.&clutter($uri); |
|
my $origfile=&getfile($origfilelocation); |
|
@origfileimportpartids=($origfile=~/<(part|import)[^>]*id\s*=\s*[\"\']([^\"\']+)[\"\'][^>]*>/gs); |
|
} |
|
|
|
# Load and inspect imported file |
|
my $impfile=&getfile($location); |
|
my @impfilepartids=($impfile=~/<part[^>]*id\s*=\s*[\"\']([^\"\']+)[\"\'][^>]*>/gs); |
|
if ($#impfilepartids>=0) { |
|
# This problem had parts |
|
$importedpartids{$token->[2]->{'id'}}=join(',',@impfilepartids); |
|
} else { |
|
# Importing by turning a single problem into a problem part |
|
# It gets the import-tags ID as part-ID |
|
$unikey=&add_prefix_and_part($prefix,$token->[2]->{'id'}); |
|
$importedpartids{$token->[2]->{'id'}}=$token->[2]->{'id'}; |
|
} |
|
} else { |
|
# Normal import |
|
$unikey=&add_prefix_and_part($prefix,$token->[2]->{'part'}); |
|
if (defined($token->[2]->{'id'})) { |
|
$unikey.='_'.$token->[2]->{'id'}; |
|
} |
|
} |
|
|
if ($depthcount<20) { |
if ($depthcount<20) { |
my $location=$parser->get_text('/import'); |
|
my $dir=$filename; |
|
$dir=~s|[^/]*$||; |
|
$location=&filelocation($dir,$location); |
|
my $metadata = |
my $metadata = |
&metadata($uri,'keys', $location,$unikey, |
&metadata($uri,'keys', $location,$unikey, |
$depthcount+1); |
$depthcount+1); |
Line 7906 sub metadata {
|
Line 8302 sub metadata {
|
$metaentry{':'.$meta}=$metaentry{':'.$meta}; |
$metaentry{':'.$meta}=$metaentry{':'.$meta}; |
$metathesekeys{$meta}=1; |
$metathesekeys{$meta}=1; |
} |
} |
} |
|
} else { |
|
|
|
|
} |
|
} else { |
|
# |
|
# Not importing, some other kind of non-package, non-library start tag |
|
# |
|
$unikey=$entry.&add_prefix_and_part($prefix,$token->[2]->{'part'}); |
|
if (defined($token->[2]->{'id'})) { |
|
$unikey.='_'.$token->[2]->{'id'}; |
|
} |
if (defined($token->[2]->{'name'})) { |
if (defined($token->[2]->{'name'})) { |
$unikey.='_'.$token->[2]->{'name'}; |
$unikey.='_'.$token->[2]->{'name'}; |
} |
} |
Line 7982 sub metadata {
|
Line 8385 sub metadata {
|
grep { ! $seen{$_} ++ } (split(',',$metaentry{':packages'})); |
grep { ! $seen{$_} ++ } (split(',',$metaentry{':packages'})); |
$metaentry{':packages'} = join(',',@uniq_packages); |
$metaentry{':packages'} = join(',',@uniq_packages); |
|
|
|
if ($importedparts) { |
|
# We had imported parts and need to rebuild partorder |
|
$metaentry{':partorder'}=''; |
|
$metathesekeys{'partorder'}=1; |
|
for (my $index=0;$index<$#origfileimportpartids;$index+=2) { |
|
if ($origfileimportpartids[$index] eq 'part') { |
|
# original part, part of the problem |
|
$metaentry{':partorder'}.=','.$origfileimportpartids[$index+1]; |
|
} else { |
|
# we have imported parts at this position |
|
$metaentry{':partorder'}.=','.$importedpartids{$origfileimportpartids[$index+1]}; |
|
} |
|
} |
|
$metaentry{':partorder'}=~s/^\,//; |
|
} |
|
|
$metaentry{':keys'} = join(',',keys(%metathesekeys)); |
$metaentry{':keys'} = join(',',keys(%metathesekeys)); |
&metadata_generate_part0(\%metathesekeys,\%metaentry,$uri); |
&metadata_generate_part0(\%metathesekeys,\%metaentry,$uri); |
$metaentry{':allpossiblekeys'}=join(',',keys %metathesekeys); |
$metaentry{':allpossiblekeys'}=join(',',keys %metathesekeys); |
Line 8162 sub symbverify {
|
Line 8581 sub symbverify {
|
|
|
if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db', |
if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db', |
&GDBM_READER(),0640)) { |
&GDBM_READER(),0640)) { |
|
if (($thisurl =~ m{^/adm/wrapper/ext/}) || ($thisurl =~ m{^ext/})) { |
|
$thisurl =~ s/\?.+$//; |
|
} |
my $ids=$bighash{'ids_'.&clutter($thisurl)}; |
my $ids=$bighash{'ids_'.&clutter($thisurl)}; |
unless ($ids) { |
unless ($ids) { |
$ids=$bighash{'ids_/'.$thisurl}; |
$ids=$bighash{'ids_/'.$thisurl}; |
Line 8170 sub symbverify {
|
Line 8592 sub symbverify {
|
# ------------------------------------------------------------------- Has ID(s) |
# ------------------------------------------------------------------- Has ID(s) |
foreach my $id (split(/\,/,$ids)) { |
foreach my $id (split(/\,/,$ids)) { |
my ($mapid,$resid)=split(/\./,$id); |
my ($mapid,$resid)=split(/\./,$id); |
|
if ($thisfn =~ m{^/adm/wrapper/ext/}) { |
|
$symb =~ s/\?.+$//; |
|
} |
if ( |
if ( |
&symbclean(&declutter($bighash{'map_id_'.$mapid}).'___'.$resid.'___'.$thisfn) |
&symbclean(&declutter($bighash{'map_id_'.$mapid}).'___'.$resid.'___'.$thisfn) |
eq $symb) { |
eq $symb) { |
Line 9046 sub declutter {
|
Line 9471 sub declutter {
|
$thisfn=~s|^adm/wrapper/||; |
$thisfn=~s|^adm/wrapper/||; |
$thisfn=~s|^adm/coursedocs/showdoc/||; |
$thisfn=~s|^adm/coursedocs/showdoc/||; |
$thisfn=~s/^res\///; |
$thisfn=~s/^res\///; |
$thisfn=~s/\?.+$//; |
unless (($thisfn =~ /^ext/) || ($thisfn =~ /\.(page|sequence)___\d+___ext/)) { |
|
$thisfn=~s/\?.+$//; |
|
} |
return $thisfn; |
return $thisfn; |
} |
} |
|
|
Line 9058 sub clutter {
|
Line 9485 sub clutter {
|
|| $thisfn =~ m{^/adm/(includes|pages)} ) { |
|| $thisfn =~ m{^/adm/(includes|pages)} ) { |
$thisfn='/res'.$thisfn; |
$thisfn='/res'.$thisfn; |
} |
} |
if ($thisfn !~m|/adm|) { |
if ($thisfn !~m|^/adm|) { |
if ($thisfn =~ m|/ext/|) { |
if ($thisfn =~ m|^/ext/|) { |
$thisfn='/adm/wrapper'.$thisfn; |
$thisfn='/adm/wrapper'.$thisfn; |
} else { |
} else { |
my ($ext) = ($thisfn =~ /\.(\w+)$/); |
my ($ext) = ($thisfn =~ /\.(\w+)$/); |
Line 9334 sub get_dns {
|
Line 9761 sub get_dns {
|
return %libserv; |
return %libserv; |
} |
} |
|
|
|
sub unique_library { |
|
#2x reverse removes all hostnames that appear more than once |
|
my %unique = reverse &all_library(); |
|
return reverse %unique; |
|
} |
|
|
sub get_servers { |
sub get_servers { |
&load_hosts_tab() if (!$loaded); |
&load_hosts_tab() if (!$loaded); |
|
|
Line 9357 sub get_dns {
|
Line 9790 sub get_dns {
|
return %result; |
return %result; |
} |
} |
|
|
|
sub get_unique_servers { |
|
my %unique = reverse &get_servers(@_); |
|
return reverse %unique; |
|
} |
|
|
sub host_domain { |
sub host_domain { |
&load_hosts_tab() if (!$loaded); |
&load_hosts_tab() if (!$loaded); |
|
|
Line 9919 modifyuserauth($udom,$uname,$umode,$upas
|
Line 10357 modifyuserauth($udom,$uname,$umode,$upas
|
|
|
=item * |
=item * |
|
|
modifyuser($udom,$uname,$uid,$umode,$upass,$first,$middle,$last,$gene, |
modifyuser($udom,$uname,$uid,$umode,$upass,$first,$middle,$last, $gene, |
$forceid,$desiredhome,$email,$inststatus) : |
$forceid,$desiredhome,$email,$inststatus,$candelete) : |
modify user |
|
|
will update user information (firstname,middlename,lastname,generation, |
|
permanentemail), and if forceid is true, student/employee ID also. |
|
A user's institutional affiliation(s) can also be updated. |
|
User information fields will not be overwritten with empty entries |
|
unless the field is included in the $candelete array reference. |
|
This array is included when a single user is modified via "Manage Users", |
|
or when Autoupdate.pl is run by cron in a domain. |
|
|
=item * |
=item * |
|
|
Line 10086 createcourse($udom,$description,$url,$co
|
Line 10531 createcourse($udom,$description,$url,$co
|
|
|
=item * |
=item * |
|
|
generate_coursenum($udom) : get a unique (unused) course number in domain $udom |
generate_coursenum($udom,$crstype) : get a unique (unused) course number in domain $udom for course type $crstype (Course or Community). |
|
|
=back |
=back |
|
|