version 1.50, 2015/03/26 14:16:11
|
version 1.52.2.6, 2024/07/02 13:55:53
|
Line 105 sub send_selfserve_notification {
|
Line 105 sub send_selfserve_notification {
|
$rawsubj = 'Self-enrollment requests processed'; |
$rawsubj = 'Self-enrollment requests processed'; |
push(@rawmsg,{ |
push(@rawmsg,{ |
mt => 'Enrollment requests in the following course: [_1] have been processed.', |
mt => 'Enrollment requests in the following course: [_1] have been processed.', |
args => ["\n$contextdesc"], |
args => ["\n$contextdesc\n"], |
}); |
}); |
} elsif ($context eq 'domainmanagers') { |
} elsif ($context eq 'domainmanagers') { |
$rawsubj = 'Course/Community requests reviewed'; |
$rawsubj = 'Course/Community requests reviewed'; |
push(@rawmsg,{ |
push(@rawmsg,{ |
mt => 'Course/Community creation requests in the following domain: "[_1]" have been reviewed.', |
mt => 'Course/Community creation requests in the following domain: [_1] have been reviewed.', |
args => ["\n$contextdesc"], |
args => ["\n$contextdesc\n"], |
}); |
}); |
if (ref($textstr) eq 'ARRAY') { |
if (ref($textstr) eq 'ARRAY') { |
push(@rawmsg,@{$textstr}); |
push(@rawmsg,@{$textstr}); |
Line 119 sub send_selfserve_notification {
|
Line 119 sub send_selfserve_notification {
|
} elsif ($context eq 'authormanagers') { |
} elsif ($context eq 'authormanagers') { |
$rawsubj = 'Authoring Space requests reviewed'; |
$rawsubj = 'Authoring Space requests reviewed'; |
push(@rawmsg,{ |
push(@rawmsg,{ |
mt => 'Authoring requests in the following domain: "[_1]" have been reviewed.', |
mt => 'Authoring requests in the following domain: [_1] have been reviewed.', |
args => ["\n$contextdesc"], |
args => ["\n$contextdesc\n"], |
}); |
}); |
if (ref($textstr) eq 'ARRAY') { |
if (ref($textstr) eq 'ARRAY') { |
push(@rawmsg,@{$textstr}); |
push(@rawmsg,@{$textstr}); |
Line 128 sub send_selfserve_notification {
|
Line 128 sub send_selfserve_notification {
|
} elsif ($context eq 'usernamemanagers') { |
} elsif ($context eq 'usernamemanagers') { |
$rawsubj = 'LON-CAPA account requests reviewed'; |
$rawsubj = 'LON-CAPA account requests reviewed'; |
push(@rawmsg,{ |
push(@rawmsg,{ |
mt => 'Account requests in the following domain: "[_1]" have been reviewed.', |
mt => 'Account requests in the following domain: [_1] have been reviewed.', |
args => ["\n$contextdesc"], |
args => ["\n$contextdesc\n"], |
}); |
}); |
if (ref($textstr) eq 'ARRAY') { |
if (ref($textstr) eq 'ARRAY') { |
push(@rawmsg,@{$textstr}); |
push(@rawmsg,@{$textstr}); |
Line 396 sub display_queued_requests {
|
Line 396 sub display_queued_requests {
|
if ($context eq 'pending') { |
if ($context eq 'pending') { |
$disposition = 'pending'; |
$disposition = 'pending'; |
$nextphase = 'requestvalidation'; |
$nextphase = 'requestvalidation'; |
|
} elsif ($context eq 'displaypending') { |
|
$disposition = 'pending'; |
} |
} |
%requesthash = &Apache::lonnet::dump_dom($namespace,$dom,'_'.$disposition); |
%requesthash = &Apache::lonnet::dump_dom($namespace,$dom,'_'.$disposition); |
$nextelement = '<input type="hidden" name="phase" value="'.$nextphase.'" />'; |
$nextelement = '<input type="hidden" name="phase" value="'.$nextphase.'" />'; |
Line 422 sub display_queued_requests {
|
Line 424 sub display_queued_requests {
|
my ($cnum,$disposition) = split('_',$item); |
my ($cnum,$disposition) = split('_',$item); |
$entry = $cnum.':'.$requesthash{$item}{'ownername'}.':'. |
$entry = $cnum.':'.$requesthash{$item}{'ownername'}.':'. |
$requesthash{$item}{'ownerdom'}.':'; |
$requesthash{$item}{'ownerdom'}.':'; |
if ($context eq 'pending') { |
if (($context eq 'pending') || ($context eq 'displaypending')) { |
$entry .= $requesthash{$item}{'instcode'}; |
$entry .= $requesthash{$item}{'instcode'}; |
} else { |
} else { |
$entry .= $requesthash{$item}{'crstype'}; |
$entry .= $requesthash{$item}{'crstype'}; |
Line 441 sub display_queued_requests {
|
Line 443 sub display_queued_requests {
|
if (keys(%queue_by_date) > 0) { |
if (keys(%queue_by_date) > 0) { |
if ($context eq 'course') { |
if ($context eq 'course') { |
$output .= '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>'; |
$output .= '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>'; |
} elsif ($context eq 'pending') { |
} elsif (($context eq 'pending') || ($context eq 'displaypending')) { |
$output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'. |
$output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'. |
'<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'. |
'<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'. |
&mt('Validation is attempted when the request is submitted.').' '.&mt('If unvalidated, the request will be held in a queue.').' '.&mt('Validation of pending requests is automatically repeated daily.').'</p>'; |
&mt('Validation is attempted when the request is submitted.').' '. |
|
&mt('If unvalidated, the request will be held in a queue.').' '. |
|
&mt('Validation of pending requests is automatically repeated daily.').'</p>'; |
} elsif ($context eq 'requestauthor') { |
} elsif ($context eq 'requestauthor') { |
$output .= '<h3>'.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'</h3>'; |
$output .= '<h3>'.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'</h3>'; |
} elsif ($context eq 'requestusername') { |
} elsif ($context eq 'requestusername') { |
Line 472 sub display_queued_requests {
|
Line 476 sub display_queued_requests {
|
if ($context eq 'pending') { |
if ($context eq 'pending') { |
$output .= '<br /><input type="submit" name="validationcheck" value="'. |
$output .= '<br /><input type="submit" name="validationcheck" value="'. |
&mt('Validate').'" /><br />'."\n". |
&mt('Validate').'" /><br />'."\n". |
'<p>'.&mt('Any course/community requests which are successfully validated will be created immediately.').' '.&mt('Unvalidated requests will be listed for manual approval/rejection.').'</p>'; |
'<p>'.&mt('Any course/community requests which are successfully validated will be created immediately.').' '. |
} else { |
&mt('Unvalidated requests will be listed for manual approval/rejection.').'</p>'; |
|
} elsif (($context ne 'helpdesk') && ($context ne 'displaypending')) { |
$output .= '<br /><input type="submit" name="processqueue" value="'.&mt('Save').'" />'; |
$output .= '<br /><input type="submit" name="processqueue" value="'.&mt('Save').'" />'; |
} |
} |
$output .= '</form>'; |
$output .= '</form>'; |
Line 481 sub display_queued_requests {
|
Line 486 sub display_queued_requests {
|
$output .= '<div class="LC_info">'; |
$output .= '<div class="LC_info">'; |
if ($context eq 'course') { |
if ($context eq 'course') { |
$output .= &mt('There are currently no enrollment requests awaiting approval.'); |
$output .= &mt('There are currently no enrollment requests awaiting approval.'); |
} elsif ($context eq 'pending') { |
} elsif (($context eq 'pending') || ($context eq 'displaypending')) { |
$output .= &mt('There are currently no requests for official courses awaiting validation.'); |
$output .= &mt('There are currently no requests for official courses awaiting validation.'); |
} elsif ($context eq 'requestauthor') { |
} elsif ($context eq 'requestauthor') { |
$output .= &mt('There are currently no requests for Authoring Space awaiting approval.'); |
$output .= &mt('There are currently no requests for Authoring Space awaiting approval.'); |
Line 501 sub build_queue_display {
|
Line 506 sub build_queue_display {
|
my %crstypes; |
my %crstypes; |
my $output = &Apache::loncommon::start_data_table(). |
my $output = &Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(); |
&Apache::loncommon::start_data_table_header_row(); |
unless ($context eq 'pending') { |
unless (($context eq 'pending') || ($context eq 'displaypending') || ($context eq 'helpdesk')) { |
$output .= '<th>'.&mt('Action').'</th>'; |
$output .= '<th>'.&mt('Action').'</th>'; |
} |
} |
$output .= '<th>'.&mt('Requestor').'</th>'; |
$output .= '<th>'.&mt('Requestor').'</th>'; |
Line 513 sub build_queue_display {
|
Line 518 sub build_queue_display {
|
} elsif ($context eq 'requestusername') { |
} elsif ($context eq 'requestusername') { |
$output .= '<th>'.&mt('Date requested').'</th>'. |
$output .= '<th>'.&mt('Date requested').'</th>'. |
'<th>'.&mt('Details').'</th>'; |
'<th>'.&mt('Details').'</th>'; |
} elsif ($context eq 'pending' || $context eq 'stillpending') { |
} elsif ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') { |
$output .= '<th>'.&mt('Institutional code').'</th>'. |
$output .= '<th>'.&mt('Institutional code').'</th>'. |
'<th>'.&mt('Date requested').'</th>'. |
'<th>'.&mt('Date requested').'</th>'. |
'<th>'.&mt('Details').'</th>'; |
'<th>'.&mt('Details').'</th>'; |
Line 568 sub build_queue_display {
|
Line 573 sub build_queue_display {
|
} else { |
} else { |
my ($cnum,$ownername,$ownerdom,$type,$cdesc); |
my ($cnum,$ownername,$ownerdom,$type,$cdesc); |
my $queued = 'approval'; |
my $queued = 'approval'; |
if ($context eq 'pending' || $context eq 'stillpending') { |
if ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') { |
($cnum,$ownername,$ownerdom,$instcode,$cdesc)=split(/:/,$request,5); |
($cnum,$ownername,$ownerdom,$instcode,$cdesc)=split(/:/,$request,5); |
$queued = 'pending'; |
$queued = 'pending'; |
} else { |
} else { |
Line 586 sub build_queue_display {
|
Line 591 sub build_queue_display {
|
&Apache::loncommon::plainname($ownername,$ownerdom), |
&Apache::loncommon::plainname($ownername,$ownerdom), |
$ownername,$ownerdom); |
$ownername,$ownerdom); |
} |
} |
unless ($context eq 'pending') { |
unless (($context eq 'pending') || ($context eq 'displaypending') || ($context eq 'helpdesk')) { |
$row = '<td><span class="LC_nobreak"><label>'. |
$row = '<td><span class="LC_nobreak"><label>'. |
'<input type="radio" value="'.$approve.'" name="'.$count.'radioreq" />'.&mt('Approve').'</label>'. |
'<input type="radio" value="'.$approve.'" name="'.$count.'radioreq" />'.&mt('Approve').'</label>'. |
'<label>'.(' 'x2). |
'<label>'.(' 'x2). |
Line 604 sub build_queue_display {
|
Line 609 sub build_queue_display {
|
} elsif ($context eq 'requestusername') { |
} elsif ($context eq 'requestusername') { |
$row .= '<td>'.$showtime.'</td>'."\n". |
$row .= '<td>'.$showtime.'</td>'."\n". |
'<td>'.$detailslink.'</td>'."\n"; |
'<td>'.$detailslink.'</td>'."\n"; |
} else { |
} else { |
if ($context eq 'pending' || $context eq 'stillpending') { |
if ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') { |
$row .= '<td>'.$instcode.'</td>'."\n"; |
$row .= '<td>'.$instcode.'</td>'."\n"; |
} else { |
} else { |
$row .= '<td>'.$crstype.'</td>'."\n"; |
$row .= '<td>'.$crstype.'</td>'."\n"; |
Line 874 sub update_request_queue {
|
Line 879 sub update_request_queue {
|
my $dbname = 'nohist_requestedusernames'; |
my $dbname = 'nohist_requestedusernames'; |
my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom); |
my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom); |
my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser); |
my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser); |
|
|
if (ref($curr{$uname}) eq 'HASH') { |
if (ref($curr{$uname}) eq 'HASH') { |
my ($username,$logtoken,$serverid,$encpass,$courseid,$id,$firstname, |
my ($logtoken,$serverid,$encpass,$courseid,$id,$firstname, |
$middlename,$lastname,$generation,$inststatus); |
$middlename,$lastname,$generation,$inststatus,$email); |
$curr{$uname}{'timestamp'} = $now; |
$curr{$uname}{'timestamp'} = $now; |
$curr{$uname}{'adjudicator'} = $env{'user.name'}.':'.$env{'user.domain'}; |
$curr{$uname}{'adjudicator'} = $env{'user.name'}.':'.$env{'user.domain'}; |
$courseid = $curr{$uname}{'courseid'}; |
$courseid = $curr{$uname}{'courseid'}; |
Line 888 sub update_request_queue {
|
Line 893 sub update_request_queue {
|
$generation = $curr{$uname}{'generation'}; |
$generation = $curr{$uname}{'generation'}; |
$inststatus = $curr{$uname}{'inststatus'}; |
$inststatus = $curr{$uname}{'inststatus'}; |
|
|
my ($key,$caller)=split(/&/,$curr{$uname}{'tmpinfo'}); |
if ($curr{$uname}{'email'} ne '') { |
if ($caller eq 'createaccount') { |
$email = $curr{$uname}{'email'}; |
my $upass = &Apache::loncommon::des_decrypt($key,$curr{$uname}{'upass'}); |
} elsif ($uname =~ /^[^\@]+\@[^\@]+$/) { |
|
$email = $uname; |
|
} |
|
|
|
my $upass; |
|
if ($curr{$uname}{'tmpinfo'}) { |
|
my ($key,$caller)=split(/&/,$curr{$uname}{'tmpinfo'}); |
|
if ($caller eq 'createaccount') { |
|
if ($curr{$uname}{'upass'} eq '') { |
|
$upass = $curr{$uname}{'upass'}; |
|
} else { |
|
$upass = &Apache::loncommon::des_decrypt($key,$curr{$uname}{'upass'}); |
|
} |
|
} else { |
|
push(@processing_errors,$uname); |
|
} |
|
} else { |
|
$upass = $curr{$uname}{'upass'}; |
|
} |
|
if ($upass eq '') { |
|
push(@processing_errors,$uname); |
|
} else { |
undef($curr{$uname}{'upass'}); |
undef($curr{$uname}{'upass'}); |
my $result = |
my $result = |
&Apache::lonnet::modifyuser($cdom,$uname,$id,'internal',$upass, |
&Apache::lonnet::modifyuser($cdom,$uname,$id,'internal',$upass, |
$firstname,$middlename,$lastname, |
$firstname,$middlename,$lastname, |
$generation,undef,undef,$uname); |
$generation,undef,undef,$email); |
if ($result eq 'ok') { |
if ($result eq 'ok') { |
$curr{$uname}{'status'} = 'created'; |
$curr{$uname}{'status'} = 'created'; |
push(@completed,$uname); |
push(@completed,$uname); |
Line 916 sub update_request_queue {
|
Line 942 sub update_request_queue {
|
} else { |
} else { |
push(@processing_errors,$uname); |
push(@processing_errors,$uname); |
} |
} |
} else { |
|
push(@processing_errors,$uname); |
|
} |
} |
} else { |
} else { |
push(@invalidusers,$uname); |
push(@invalidusers,$uname); |
Line 1603 sub course_creation {
|
Line 1627 sub course_creation {
|
$keysmsg,$domdefs,$longroles,$coderef,$customhash) = @_; |
$keysmsg,$domdefs,$longroles,$coderef,$customhash) = @_; |
unless ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH') && |
unless ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH') && |
(ref($longroles) eq 'HASH')) { |
(ref($longroles) eq 'HASH')) { |
return 'error: Invalid request'; |
return ('error: Invalid request'); |
} |
} |
my ($result,$ownername,$ownerdom); |
my ($result,$ownername,$ownerdom,$autocoowner); |
my $crstype = $details->{'crstype'}; |
my $crstype = $details->{'crstype'}; |
my $coursedesc = $details->{'cdescr'}; |
my $coursedesc = $details->{'cdescr'}; |
my $accessstart = $details->{'accessstart'}; |
my $accessstart = $details->{'accessstart'}; |
my $accessend = $details->{'accessend'}; |
my $accessend = $details->{'accessend'}; |
my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom); |
my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses','autoenroll'],$dom); |
if (ref($domconfig{'requestcourses'}) eq 'HASH') { |
if (ref($domconfig{'requestcourses'}) eq 'HASH') { |
if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') { |
if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') { |
if ($domconfig{'requestcourses'}{'uniquecode'}{$crstype}) { |
if ($domconfig{'requestcourses'}{'uniquecode'}{$crstype}) { |
Line 1618 sub course_creation {
|
Line 1642 sub course_creation {
|
} |
} |
} |
} |
} |
} |
|
if (ref($domconfig{'autoenroll'}) eq 'HASH') { |
|
$autocoowner = $domconfig{'autoenroll'}{'co-owners'}; |
|
} |
if ($context eq 'domain') { |
if ($context eq 'domain') { |
$ownername = $details->{'owner'}; |
$ownername = $details->{'owner'}; |
$ownerdom = $details->{'domain'}; |
$ownerdom = $details->{'domain'}; |
Line 1632 sub course_creation {
|
Line 1659 sub course_creation {
|
$owneremail = $emails{$email}; |
$owneremail = $emails{$email}; |
last if ($owneremail ne ''); |
last if ($owneremail ne ''); |
} |
} |
my %reqdetails = &build_batchcreatehash($dom,$context,$details,$owneremail,$domdefs); |
my %reqdetails = &build_batchcreatehash($dom,$cnum,$context,$details,$owneremail,$domdefs); |
my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses', |
my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses', |
\%reqdetails,$longroles,$logmsg,$newusermsg,$addresult, |
\%reqdetails,$longroles,$logmsg,$newusermsg,$addresult, |
$enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype,$coderef); |
$enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype,$coderef); |
Line 1646 sub course_creation {
|
Line 1673 sub course_creation {
|
$postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$result,$ownername, |
$postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$result,$ownername, |
$ownerdom,$fullname,$coursedesc,$code, |
$ownerdom,$fullname,$coursedesc,$code, |
$accessstart,$accessend,$customhash); |
$accessstart,$accessend,$customhash); |
|
if ($autocoowner) { |
|
my $instcode = $details->{'instcode'}; |
|
if (($instcode ne '') && (ref($reqdetails{'users'}) eq 'HASH')) { |
|
my @posscoowners; |
|
my $now = time; |
|
foreach my $person (keys(%{$reqdetails{'users'}})) { |
|
my ($uname,$udom) = split(/:/,$person); |
|
next if (($udom ne $dom) || (($uname eq $ownername) && ($udom eq $ownerdom))); |
|
if ((&Apache::lonnet::homeserver($uname,$udom,1) ne 'no_host') && |
|
(ref($reqdetails{'users'}{$person}) eq 'HASH')) { |
|
if ((grep(/^cc$/,keys(%{$reqdetails{'users'}{$person}}))) && |
|
(ref($reqdetails{'users'}{$person}{'cc'}) eq 'HASH')) { |
|
my $start = $reqdetails{'users'}{$person}{'cc'}{'start'}; |
|
my $end = $reqdetails{'users'}{$person}{'cc'}{'end'}; |
|
if ((($start eq '') || ($start <= $now)) && |
|
(($end eq '') || ($end >= $now))) { |
|
push(@posscoowners,$person); |
|
} |
|
} |
|
} |
|
} |
|
my @coowners; |
|
if (@posscoowners) { |
|
foreach my $user (@posscoowners) { |
|
my ($checkcc,$desc) = |
|
&Apache::lonnet::auto_validate_instcode($cnum,$dom,$instcode,$user); |
|
unless ($checkcc eq 'valid') { |
|
if (ref($reqdetails{'crosslists'}) eq 'HASH') { |
|
foreach my $key (keys(%{$reqdetails{'crosslists'}})) { |
|
if (ref($reqdetails{'crosslists'}{$key}) eq 'HASH') { |
|
my $inst_crosslist = $reqdetails{'crosslists'}{$key}{'inst'}; |
|
if ($inst_crosslist ne '') { |
|
$checkcc = |
|
&Apache::lonnet::auto_validate_inst_crosslist($cnum,$dom,$instcode, |
|
$inst_crosslist,$user); |
|
last if ($checkcc eq 'valid'); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($checkcc eq 'valid') { |
|
if (@coowners > 0) { |
|
unless (grep(/^\Q$user\E$/,@coowners)) { |
|
push(@coowners,$user); |
|
} |
|
} else { |
|
push(@coowners,$user); |
|
} |
|
} |
|
} |
|
} |
|
if (@coowners > 0) { |
|
my $chome = &Apache::lonnet::homeserver($cnum,$dom); |
|
unless ($chome eq 'no_host') { |
|
&Apache::lonnet::store_coowners($dom,$cnum,$chome,'',@coowners); |
|
} |
|
} |
|
} |
|
} |
} else { |
} else { |
$result = 'error: '.$cid; |
$result = 'error: '.$cid; |
} |
} |
Line 1653 sub course_creation {
|
Line 1740 sub course_creation {
|
} |
} |
|
|
sub build_batchcreatehash { |
sub build_batchcreatehash { |
my ($dom,$context,$details,$owneremail,$domdefs) = @_; |
my ($dom,$cnum,$context,$details,$owneremail,$domdefs) = @_; |
my %batchhash; |
my %batchhash; |
my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift enrollstart enrollend accessstart accessend sections crosslists users uniquecode}; |
my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift enrollstart enrollend accessstart accessend sections users uniquecode}; |
if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) { |
if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) { |
my $emailenc = &escape($owneremail); |
my $emailenc = &escape($owneremail); |
my $owner = $details->{'owner'}.':'.$details->{'domain'}; |
my $owner = $details->{'owner'}.':'.$details->{'domain'}; |
foreach my $item (@items) { |
foreach my $item (@items) { |
$batchhash{$item} = $details->{$item}; |
$batchhash{$item} = $details->{$item}; |
} |
} |
|
if (ref($details->{'crosslists'}) eq 'HASH') { |
|
foreach my $key (keys(%{$details->{'crosslists'}})) { |
|
if (ref($details->{'crosslists'}->{$key}) eq 'HASH') { |
|
my $instsec = $details->{crosslists}->{$key}->{instsec}; |
|
$batchhash{'crosslists'}{$key}{'inst'} = $details->{crosslists}->{$key}->{instcode}; |
|
my $crskey = $cnum.':'.$batchhash{'crosslists'}{$key}{'inst'}; |
|
my %formatted = &Apache::lonnet::auto_instsec_reformat($dom,'clutter', |
|
{$crskey => [$instsec]}); |
|
if (ref($formatted{$crskey}) eq 'ARRAY') { |
|
$batchhash{'crosslists'}{$key}{'inst'} .= $formatted{$crskey}->[0]; |
|
} |
|
$batchhash{'crosslists'}{$key}{'loncapa'} = $details->{crosslists}->{$key}->{loncapa}; |
|
} |
|
} |
|
} |
$batchhash{'title'} = $details->{'cdescr'}; |
$batchhash{'title'} = $details->{'cdescr'}; |
$batchhash{'coursecode'} = $details->{'instcode'}; |
$batchhash{'coursecode'} = $details->{'instcode'}; |
if ($domdefs->{'officialcredits'} || $domdefs->{'unofficialcredits'}) { |
if ($domdefs->{'officialcredits'} || $domdefs->{'unofficialcredits'}) { |
Line 1719 sub build_batchcreatehash {
|
Line 1821 sub build_batchcreatehash {
|
$batchhash{'users'}{$owner}{lastname} = $owner_lastname; |
$batchhash{'users'}{$owner}{lastname} = $owner_lastname; |
$batchhash{'users'}{$owner}{emailenc} = $emailenc; |
$batchhash{'users'}{$owner}{emailenc} = $emailenc; |
$batchhash{'users'}{$owner}{owneremail} = $owneremail; |
$batchhash{'users'}{$owner}{owneremail} = $owneremail; |
|
$batchhash{'setcomment'} = 1; |
} |
} |
return %batchhash; |
return %batchhash; |
} |
} |
|
|
sub can_clone_course { |
sub can_clone_course { |
my ($uname,$udom,$clonecrs,$clonedom,$crstype) = @_; |
my ($uname,$udom,$clonecrs,$clonedom,$crstype,$dom,$instcode) = @_; |
my $canclone; |
my $canclone; |
my $ccrole = 'cc'; |
my $ccrole = 'cc'; |
if ($crstype eq 'community') { |
if ($crstype eq 'community') { |
Line 1735 sub can_clone_course {
|
Line 1838 sub can_clone_course {
|
if (exists($roleshash{$clonecrs.':'.$clonedom.':'.$ccrole})) { |
if (exists($roleshash{$clonecrs.':'.$clonedom.':'.$ccrole})) { |
$canclone = 1; |
$canclone = 1; |
} else { |
} else { |
my %courseenv = &Apache::lonnet::userenvironment($clonedom,$clonecrs,('cloners')); |
my %courseenv = &Apache::lonnet::userenvironment($clonedom,$clonecrs, |
|
('cloners','internal.coursecode')); |
my $cloners = $courseenv{'cloners'}; |
my $cloners = $courseenv{'cloners'}; |
|
my $clonefromcode = $courseenv{'internal.coursecode'}; |
if ($cloners ne '') { |
if ($cloners ne '') { |
my @cloneable = split(',',$cloners); |
my @cloneable = split(',',$cloners); |
if (grep(/^\*$/,@cloneable)) { |
if (grep(/^\*$/,@cloneable)) { |
$canclone = 1; |
$canclone = 1; |
} |
} elsif (grep(/^\*:\Q$udom\E$/,@cloneable)) { |
if (grep(/^\*:\Q$udom\E$/,@cloneable)) { |
|
$canclone = 1; |
$canclone = 1; |
} |
} elsif (grep(/^\Q$uname\E:\Q$udom\E$/,@cloneable)) { |
if (grep(/^\Q$uname\E:\Q$udom\E$/,@cloneable)) { |
|
$canclone = 1; |
$canclone = 1; |
} |
} |
|
unless ($canclone) { |
|
if (($clonefromcode) && ($instcode) && ($clonedom eq $dom)) { |
|
my (%gotdomdefaults,%gotcodedefaults); |
|
foreach my $cloner (@cloneable) { |
|
if (($cloner ne '*') && ($cloner !~ /^\*\:$match_domain$/) && |
|
($cloner !~ /^$match_username\:$match_domain$/) && ($cloner ne '')) { |
|
if ($cloner =~ /\=/) { |
|
my (%codedefaults,@code_order); |
|
if (ref($gotcodedefaults{$clonedom}) eq 'HASH') { |
|
if (ref($gotcodedefaults{$clonedom}{'defaults'}) eq 'HASH') { |
|
%codedefaults = %{$gotcodedefaults{$clonedom}{'defaults'}}; |
|
} |
|
if (ref($gotcodedefaults{$clonedom}{'order'}) eq 'ARRAY') { |
|
@code_order = @{$gotcodedefaults{$dom}{'order'}}; |
|
} |
|
} else { |
|
&Apache::lonnet::auto_instcode_defaults($clonedom, |
|
\%codedefaults, |
|
\@code_order); |
|
$gotcodedefaults{$clonedom}{'defaults'} = \%codedefaults; |
|
$gotcodedefaults{$clonedom}{'order'} = \@code_order; |
|
} |
|
if (@code_order > 0) { |
|
if (&Apache::lonnet::check_instcode_cloning(\%codedefaults,\@code_order, |
|
$cloner,$clonefromcode,$instcode)) { |
|
$canclone = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} else { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($clonedom); |
|
if ($domdefs{'canclone'}) { |
|
unless ($domdefs{'canclone'} eq 'none') { |
|
if ($domdefs{'canclone'} eq 'domain') { |
|
if ($udom eq $clonedom) { |
|
$canclone = 1; |
|
} |
|
} elsif (($clonefromcode) && ($instcode) && |
|
($clonedom eq $dom)) { |
|
if (&Apache::lonnet::default_instcode_cloning($clonedom,$domdefs{'canclone'}, |
|
$clonefromcode,$instcode)) { |
|
$canclone = 1; |
|
} |
|
} |
|
} |
|
} |
} |
} |
unless ($canclone) { |
unless ($canclone) { |
if (&Apache::lonnet::is_course_owner($clonedom,$clonecrs,$uname,$udom)) { |
if (&Apache::lonnet::is_course_owner($clonedom,$clonecrs,$uname,$udom)) { |
Line 2162 sub postprocess_crsenv {
|
Line 2316 sub postprocess_crsenv {
|
my %needcrsidput = ( |
my %needcrsidput = ( |
'internal.selfenroll_types' => 1, |
'internal.selfenroll_types' => 1, |
'internal.selfenroll_start_date' => 1, |
'internal.selfenroll_start_date' => 1, |
'internal. selfenroll_end_date' => 1, |
'internal.selfenroll_end_date' => 1, |
); |
); |
my (@needupdate,%newcrsenv); |
my (@needupdate,%newcrsenv); |
foreach my $key (keys(%{$postprocessenv})) { |
foreach my $key (keys(%{$postprocessenv})) { |