version 1.102.2.8, 2010/01/26 15:47:27
|
version 1.102.2.9, 2010/02/22 18:39:13
|
Line 199 sub handler {
|
Line 199 sub handler {
|
} |
} |
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['login','rolecolors', |
&Apache::lonnet::get_dom('configuration',['login','rolecolors', |
'quotas','autoenroll','autoupdate','directorysrch', |
'quotas','autoenroll','autoupdate','autocreate', |
'usercreation','usermodification','contacts','defaults', |
'directorysrch','usercreation','usermodification', |
'scantron','coursecategories','serverstatuses', |
'contacts','defaults','scantron','coursecategories', |
'requestcourses','coursedefaults'],$dom); |
'serverstatuses','requestcourses','coursedefaults'],$dom); |
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', |
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', |
'autoupdate','directorysrch','contacts', |
'autoupdate','autocreate','directorysrch','contacts', |
'usercreation','usermodification','scantron', |
'usercreation','usermodification','scantron', |
'requestcourses','coursecategories','serverstatuses', |
'requestcourses','coursecategories','serverstatuses', |
'coursedefaults'); |
'coursedefaults'); |
Line 254 sub handler {
|
Line 254 sub handler {
|
{col1 => 'User population', |
{col1 => 'User population', |
col2 => 'Updataeable user data'}], |
col2 => 'Updataeable user data'}], |
}, |
}, |
|
'autocreate' => |
|
{ text => 'Auto-course creation settings', |
|
help => 'Domain_Configuration_Auto_Creation', |
|
header => [{col1 => 'Configuration Setting', |
|
col2 => 'Value',}], |
|
}, |
'directorysrch' => |
'directorysrch' => |
{ text => 'Institutional directory searches', |
{ text => 'Institutional directory searches', |
help => 'Domain_Configuration_InstDirectory_Search', |
help => 'Domain_Configuration_InstDirectory_Search', |
Line 393 sub process_changes {
|
Line 399 sub process_changes {
|
$output = &modify_autoenroll($dom,%domconfig); |
$output = &modify_autoenroll($dom,%domconfig); |
} elsif ($action eq 'autoupdate') { |
} elsif ($action eq 'autoupdate') { |
$output = &modify_autoupdate($dom,%domconfig); |
$output = &modify_autoupdate($dom,%domconfig); |
|
} elsif ($action eq 'autocreate') { |
|
$output = &modify_autocreate($dom,%domconfig); |
} elsif ($action eq 'directorysrch') { |
} elsif ($action eq 'directorysrch') { |
$output = &modify_directorysrch($dom,%domconfig); |
$output = &modify_directorysrch($dom,%domconfig); |
} elsif ($action eq 'usercreation') { |
} elsif ($action eq 'usercreation') { |
Line 432 sub print_config_box {
|
Line 440 sub print_config_box {
|
&Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n". |
&Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n". |
'</tr>'; |
'</tr>'; |
$rowtotal ++; |
$rowtotal ++; |
if (($action eq 'autoupdate') || ($action eq 'rolecolors') || |
my $numheaders = 1; |
($action eq 'usercreation') || ($action eq 'usermodification') || |
if (ref($item->{'header'}) eq 'ARRAY') { |
($action eq 'coursecategories') || ($action eq 'requestcourses')) { |
$numheaders = scalar(@{$item->{'header'}}); |
|
} |
|
if ($numheaders > 1) { |
my $colspan = ''; |
my $colspan = ''; |
if (($action eq 'rolecolors') || ($action eq 'coursecategories')) { |
if (($action eq 'rolecolors') || ($action eq 'coursecategories')) { |
$colspan = ' colspan="2"'; |
$colspan = ' colspan="2"'; |
Line 580 sub print_config_box {
|
Line 590 sub print_config_box {
|
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
} elsif ($action eq 'autoenroll') { |
} elsif ($action eq 'autoenroll') { |
$output .= &print_autoenroll($dom,$settings,\$rowtotal); |
$output .= &print_autoenroll($dom,$settings,\$rowtotal); |
|
} elsif ($action eq 'autocreate') { |
|
$output .= &print_autocreate($dom,$settings,\$rowtotal); |
} elsif ($action eq 'directorysrch') { |
} elsif ($action eq 'directorysrch') { |
$output .= &print_directorysrch($dom,$settings,\$rowtotal); |
$output .= &print_directorysrch($dom,$settings,\$rowtotal); |
} elsif ($action eq 'contacts') { |
} elsif ($action eq 'contacts') { |
Line 1137 sub print_quotas {
|
Line 1149 sub print_quotas {
|
my ($css_class,%titles); |
my ($css_class,%titles); |
if ($context eq 'requestcourses') { |
if ($context eq 'requestcourses') { |
@usertools = ('official','unofficial','community'); |
@usertools = ('official','unofficial','community'); |
@options =('norequest','approval','autolimit','validate'); |
@options =('norequest','approval','validate','autolimit'); |
%validations = &Apache::lonnet::auto_courserequest_checks($dom); |
%validations = &Apache::lonnet::auto_courserequest_checks($dom); |
%titles = &courserequest_titles(); |
%titles = &courserequest_titles(); |
} else { |
} else { |
Line 1206 sub print_quotas {
|
Line 1218 sub print_quotas {
|
$cell{$item} .= '<span class="LC_nobreak"><label>'. |
$cell{$item} .= '<span class="LC_nobreak"><label>'. |
'<input type="radio" name="crsreq_'.$item. |
'<input type="radio" name="crsreq_'.$item. |
'_'.$type.'" value="'.$val.'"'.$checked.' />'. |
'_'.$type.'" value="'.$val.'"'.$checked.' />'. |
$titles{$option}.'</label> '; |
$titles{$option}.'</label>'; |
if ($option eq 'autolimit') { |
if ($option eq 'autolimit') { |
$cell{$item} .= '<input type="text" name="crsreq_'. |
$cell{$item} .= ' <input type="text" name="crsreq_'. |
$item.'_limit_'.$type.'" size="1" '. |
$item.'_limit_'.$type.'" size="1" '. |
'value="'.$currlimit.'" />'; |
'value="'.$currlimit.'" />'; |
} |
} |
|
$cell{$item} .= '</span> '; |
if ($option eq 'autolimit') { |
if ($option eq 'autolimit') { |
$cell{$item} .= $titles{'unlimited'}; |
$cell{$item} .= $titles{'unlimited'}; |
} |
} |
$cell{$item} .= '</span> '; |
|
} |
} |
} else { |
} else { |
my $checked = 'checked="checked" '; |
my $checked = 'checked="checked" '; |
Line 1314 sub print_quotas {
|
Line 1326 sub print_quotas {
|
'_default" value="'.$val.'"'.$checked.' />'. |
'_default" value="'.$val.'"'.$checked.' />'. |
$titles{$option}.'</label>'; |
$titles{$option}.'</label>'; |
if ($option eq 'autolimit') { |
if ($option eq 'autolimit') { |
$defcell{$item} .= '<input type="text" name="crsreq_'. |
$defcell{$item} .= ' <input type="text" name="crsreq_'. |
$item.'_limit_default" size="1" '. |
$item.'_limit_default" size="1" '. |
'value="'.$currlimit.'" />'; |
'value="'.$currlimit.'" />'; |
} |
} |
$defcell{$item} .= '</span> '; |
$defcell{$item} .= '</span> '; |
if ($option eq 'autolimit') { |
if ($option eq 'autolimit') { |
$defcell{$item} .= $titles{'unlimited'}; |
$defcell{$item} .= $titles{'unlimited'}; |
} |
} |
Line 1417 sub print_quotas {
|
Line 1429 sub print_quotas {
|
'__LC_adv" value="'.$val.'"'.$checked.' />'. |
'__LC_adv" value="'.$val.'"'.$checked.' />'. |
$titles{$option}.'</label>'; |
$titles{$option}.'</label>'; |
if ($option eq 'autolimit') { |
if ($option eq 'autolimit') { |
$advcell{$item} .= '<input type="text" name="crsreq_'. |
$advcell{$item} .= ' <input type="text" name="crsreq_'. |
$item.'_limit__LC_adv" size="1" '. |
$item.'_limit__LC_adv" size="1" '. |
'value="'.$currlimit.'" />'; |
'value="'.$currlimit.'" />'; |
} |
} |
$advcell{$item} .= '</span> '; |
$advcell{$item} .= '</span> '; |
if ($option eq 'autolimit') { |
if ($option eq 'autolimit') { |
$advcell{$item} .= $titles{'unlimited'}; |
$advcell{$item} .= $titles{'unlimited'}; |
} |
} |
Line 1651 sub print_autoupdate {
|
Line 1663 sub print_autoupdate {
|
return $datatable; |
return $datatable; |
} |
} |
|
|
|
sub print_autocreate { |
|
my ($dom,$settings,$rowtotal) = @_; |
|
my (%createon,%createoff); |
|
my $curr_dc; |
|
my @types = ('xml','req'); |
|
if (ref($settings) eq 'HASH') { |
|
foreach my $item (@types) { |
|
$createoff{$item} = ' checked="checked" '; |
|
$createon{$item} = ' '; |
|
if (exists($settings->{$item})) { |
|
if ($settings->{$item}) { |
|
$createon{$item} = ' checked="checked" '; |
|
$createoff{$item} = ' '; |
|
} |
|
} |
|
} |
|
$curr_dc = $settings->{'xmldc'}; |
|
} else { |
|
foreach my $item (@types) { |
|
$createoff{$item} = ' checked="checked" '; |
|
$createon{$item} = ' '; |
|
} |
|
} |
|
$$rowtotal += 2; |
|
my $datatable='<tr class="LC_odd_row">'. |
|
'<td>'.&mt('Create pending official courses from XML files').'</td>'. |
|
'<td class="LC_right_item"><span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="autocreate_xml"'. |
|
$createon{'xml'}.' value="1" />'.&mt('Yes').'</label> '. |
|
'<label><input type="radio" name="autocreate_xml"'. |
|
$createoff{'xml'}.' value="0" />'.&mt('No').'</label></span>'; |
|
my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc); |
|
if ($numdc > 1) { |
|
$datatable .= '</td><tr><td>'. |
|
&mt('XML files processed as: (choose Dom. Coord.)'). |
|
'</td><td class="LC_left_item">'.$dctable.'</td></tr>'. |
|
'<tr class="LC_odd_row">'; |
|
$$rowtotal ++ ; |
|
} else { |
|
$datatable .= '</td></tr><tr>'; |
|
} |
|
$datatable .= '<td>'.&mt('Create pending requests for official courses (if validated)').'</td>'. |
|
'<td class="LC_right_item"><span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="autocreate_req"'. |
|
$createon{'req'}.' value="1" />'.&mt('Yes').'</label> '. |
|
'<label><input type="radio" name="autocreate_req"'. |
|
$createoff{'req'}.' value="0" />'.&mt('No').'</label></span></td>'. |
|
'</tr>'; |
|
return $datatable; |
|
} |
|
|
sub print_directorysrch { |
sub print_directorysrch { |
my ($dom,$settings,$rowtotal) = @_; |
my ($dom,$settings,$rowtotal) = @_; |
my $srchon = ' '; |
my $srchon = ' '; |
Line 3922 sub modify_quotas {
|
Line 3985 sub modify_quotas {
|
} |
} |
if ($context eq 'requestcourses') { |
if ($context eq 'requestcourses') { |
@usertools = ('official','unofficial','community'); |
@usertools = ('official','unofficial','community'); |
@options =('norequest','approval','autolimit','validate'); |
@options =('norequest','approval','validate','autolimit'); |
%validations = &Apache::lonnet::auto_courserequest_checks($dom); |
%validations = &Apache::lonnet::auto_courserequest_checks($dom); |
%titles = &courserequest_titles(); |
%titles = &courserequest_titles(); |
$toolregexp = join('|',@usertools); |
$toolregexp = join('|',@usertools); |
Line 4376 sub modify_autoupdate {
|
Line 4439 sub modify_autoupdate {
|
return $resulttext; |
return $resulttext; |
} |
} |
|
|
|
sub modify_autocreate { |
|
my ($dom,%domconfig) = @_; |
|
my ($resulttext,%changes,%currautocreate,%newvals,%autocreatehash); |
|
if (ref($domconfig{'autocreate'}) eq 'HASH') { |
|
foreach my $key (keys(%{$domconfig{'autocreate'}})) { |
|
$currautocreate{$key} = $domconfig{'autocreate'}{$key}; |
|
} |
|
} |
|
my %title= ( xml => 'Auto-creation of courses in XML course description files', |
|
req => 'Auto-creation of validated requests for official courses', |
|
xmldc => 'Identity of course creator of courses from XML files', |
|
); |
|
my @types = ('xml','req'); |
|
foreach my $item (@types) { |
|
$newvals{$item} = $env{'form.autocreate_'.$item}; |
|
$newvals{$item} =~ s/\D//g; |
|
$newvals{$item} = 0 if ($newvals{$item} eq ''); |
|
} |
|
$newvals{'xmldc'} = $env{'form.autocreate_xmldc'}; |
|
my %domcoords = &get_active_dcs($dom); |
|
unless (exists($domcoords{$newvals{'xmldc'}})) { |
|
$newvals{'xmldc'} = ''; |
|
} |
|
%autocreatehash = ( |
|
autocreate => { xml => $newvals{'xml'}, |
|
req => $newvals{'req'}, |
|
} |
|
); |
|
if ($newvals{'xmldc'} ne '') { |
|
$autocreatehash{'autocreate'}{'xmldc'} = $newvals{'xmldc'}; |
|
} |
|
my $putresult = &Apache::lonnet::put_dom('configuration',\%autocreatehash, |
|
$dom); |
|
if ($putresult eq 'ok') { |
|
my @items = @types; |
|
if ($newvals{'xml'}) { |
|
push(@items,'xmldc'); |
|
} |
|
foreach my $item (@items) { |
|
if (exists($currautocreate{$item})) { |
|
if ($currautocreate{$item} ne $newvals{$item}) { |
|
$changes{$item} = 1; |
|
} |
|
} elsif ($newvals{$item}) { |
|
$changes{$item} = 1; |
|
} |
|
} |
|
if (keys(%changes) > 0) { |
|
my @offon = ('off','on'); |
|
$resulttext = &mt('Changes made:').'<ul>'; |
|
foreach my $item (@types) { |
|
if ($changes{$item}) { |
|
my $newtxt = $offon[$newvals{$item}]; |
|
$resulttext .= '<li>'.&mt("$title{$item} set to [_1]$newtxt [_2]",'<b>','</b>').'</li>'; |
|
} |
|
} |
|
if ($changes{'xmldc'}) { |
|
my ($dcname,$dcdom) = split(':',$newvals{'xmldc'}); |
|
my $newtxt = &Apache::loncommon::plainname($dcname,$dcdom); |
|
$resulttext .= '<li>'.&mt("$title{'xmldc'} set to [_1]$newtxt [_2]",'<b>','</b>').'</li>'; |
|
} |
|
$resulttext .= '</ul>'; |
|
} else { |
|
$resulttext = &mt('No changes made to auto-creation settings'); |
|
} |
|
} else { |
|
$resulttext = '<span class="LC_error">'. |
|
&mt('An error occurred: [_1]',$putresult).'</span>'; |
|
} |
|
return $resulttext; |
|
} |
|
|
sub modify_directorysrch { |
sub modify_directorysrch { |
my ($dom,%domconfig) = @_; |
my ($dom,%domconfig) = @_; |
my ($resulttext,%changes); |
my ($resulttext,%changes); |
Line 5130 sub modify_usermodification {
|
Line 5265 sub modify_usermodification {
|
} |
} |
my @modifiable; |
my @modifiable; |
if ($context eq 'selfcreate') { |
if ($context eq 'selfcreate') { |
$resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Self-creation of account by users with status: [_1] ',$rolename).'</span> - '.&mt('modifiable fields (if institutional data blank): '); |
$resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Self-creation of account by users with status: [_1]',$rolename).'</span> - '.&mt('modifiable fields (if institutional data blank): '); |
} else { |
} else { |
$resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: '); |
$resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: '); |
} |
} |
Line 5796 sub recurse_cat_deletes {
|
Line 5931 sub recurse_cat_deletes {
|
return; |
return; |
} |
} |
|
|
|
sub get_active_dcs { |
|
my ($dom) = @_; |
|
my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']); |
|
my %domcoords; |
|
my $numdcs = 0; |
|
my $now = time; |
|
foreach my $server (keys(%dompersonnel)) { |
|
foreach my $user (sort(keys(%{$dompersonnel{$server}}))) { |
|
my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user); |
|
my ($end,$start) = split(':',$dompersonnel{$server}{$user}); |
|
if (($end eq '') || ($end == 0) || ($end > $now)) { |
|
if ($start <= $now) { |
|
$domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user}; |
|
} |
|
} |
|
} |
|
} |
|
return %domcoords; |
|
} |
|
|
|
sub active_dc_picker { |
|
my ($dom,$curr_dc) = @_; |
|
my %domcoords = &get_active_dcs($dom); |
|
my @dcs = sort(keys(%domcoords)); |
|
my $numdcs = scalar(@dcs); |
|
my $datatable; |
|
my $numinrow = 2; |
|
if ($numdcs > 1) { |
|
$datatable = '<table>'; |
|
for (my $i=0; $i<@dcs; $i++) { |
|
my $rem = $i%($numinrow); |
|
if ($rem == 0) { |
|
if ($i > 0) { |
|
$datatable .= '</tr>'; |
|
} |
|
$datatable .= '<tr>'; |
|
} |
|
my $check = ' '; |
|
if ($curr_dc eq '') { |
|
if (!$i) { |
|
$check = ' checked="checked" '; |
|
} |
|
} elsif ($dcs[$i] eq $curr_dc) { |
|
$check = ' checked="checked" '; |
|
} |
|
if ($i == @dcs - 1) { |
|
my $colsleft = $numinrow - $rem; |
|
if ($colsleft > 1) { |
|
$datatable .= '<td colspan="'.$colsleft.'">'; |
|
} else { |
|
$datatable .= '<td>'; |
|
} |
|
} else { |
|
$datatable .= '<td>'; |
|
} |
|
my ($dcname,$dcdom) = split(':',$dcs[$i]); |
|
$datatable .= '<span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="autocreate_xmldc"'. |
|
' value="'.$dcs[$i].'"'.$check.'/>'. |
|
&Apache::loncommon::plainname($dcname,$dcdom). |
|
'</label></span></td>'; |
|
} |
|
$datatable .= '</tr></table>'; |
|
} elsif (@dcs) { |
|
$datatable .= '<input type="hidden" name="autocreate_dc" value="'. |
|
$dcs[0].'" />'; |
|
} |
|
return ($numdcs,$datatable); |
|
} |
|
|
1; |
1; |