version 1.305, 2009/08/06 20:40:59
|
version 1.306, 2009/08/08 00:36:00
|
Line 216 END_SCRIPT
|
Line 216 END_SCRIPT
|
|
|
sub build_tools_display { |
sub build_tools_display { |
my ($ccuname,$ccdomain,$context) = @_; |
my ($ccuname,$ccdomain,$context) = @_; |
my (@usertools,%userenv,$output); |
my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay, |
|
$colspan); |
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
'blog' => "Personal User Blog", |
'blog' => "Personal User Blog", |
'aboutme' => "Personal Information Page", |
'aboutme' => "Personal Information Page", |
Line 235 sub build_tools_display {
|
Line 236 sub build_tools_display {
|
'requestcourses.official','requestcourses.unofficial', |
'requestcourses.official','requestcourses.unofficial', |
'requestcourses.community'); |
'requestcourses.community'); |
@usertools = ('official','unofficial','community'); |
@usertools = ('official','unofficial','community'); |
|
@options =('norequest','approve','autolimit','validate'); |
|
%validations = &Apache::lonnet::auto_courserequest_checks($ccdomain); |
|
%reqtitles = &courserequest_titles(); |
|
%reqdisplay = &courserequest_display(); |
|
$colspan = ' colspan="2"'; |
} else { |
} else { |
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, |
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, |
'tools.aboutme','tools.portfolio','tools.blog'); |
'tools.aboutme','tools.portfolio','tools.blog'); |
@usertools = ('aboutme','blog','portfolio'); |
@usertools = ('aboutme','blog','portfolio'); |
} |
} |
foreach my $item (@usertools) { |
foreach my $item (@usertools) { |
my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off); |
my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off, |
|
$currdisp,$custdisp,$custradio); |
$cust_off = 'checked="checked" '; |
$cust_off = 'checked="checked" '; |
$tool_on = 'checked="checked" '; |
$tool_on = 'checked="checked" '; |
$curr_access = |
$curr_access = |
&Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, |
&Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, |
$context); |
$context); |
if ($userenv{$context.'.'.$item} eq '') { |
if ($userenv{$context.'.'.$item} ne '') { |
$custom_access = |
|
&mt('Availability determined currently from default setting.'); |
|
if (!$curr_access) { |
|
$tool_off = 'checked="checked" '; |
|
$tool_on = ''; |
|
} |
|
} else { |
|
$custom_access = |
|
&mt('Availability determined currently from custom setting.'); |
|
$cust_on = ' checked="checked" '; |
$cust_on = ' checked="checked" '; |
$cust_off = ''; |
$cust_off = ''; |
if ($userenv{$context.'.'.$item} == 0) { |
} |
$tool_off = 'checked="checked" '; |
if ($context eq 'requestcourses') { |
$tool_on = ''; |
if ($userenv{$context.'.'.$item} eq '') { |
|
$custom_access = &mt('Currently from default setting.'); |
|
} else { |
|
$custom_access = &mt('Currently from custom setting.'); |
|
} |
|
} else { |
|
if ($userenv{$context.'.'.$item} eq '') { |
|
$custom_access = |
|
&mt('Availability determined currently from default setting.'); |
|
if (!$curr_access) { |
|
$tool_off = 'checked="checked" '; |
|
$tool_on = ''; |
|
} |
|
} else { |
|
$custom_access = |
|
&mt('Availability determined currently from custom setting.'); |
|
if ($userenv{$context.'.'.$item} == 0) { |
|
$tool_off = 'checked="checked" '; |
|
$tool_on = ''; |
|
} |
} |
} |
} |
} |
$output .= ' <tr class="LC_info_row">'."\n". |
$output .= ' <tr class="LC_info_row">'."\n". |
' <td>'.$lt{$item}.'</td>'."\n". |
' <td'.$colspan.'>'.$lt{$item}.'</td>'."\n". |
' </tr>'."\n". |
' </tr>'."\n". |
&Apache::loncommon::start_data_table_row()."\n". |
&Apache::loncommon::start_data_table_row()."\n"; |
' <td>'.$custom_access.(' 'x5).$lt{'avai'}.': '. |
if ($context eq 'requestcourses') { |
($curr_access?&mt('Yes'):&mt('No')).'</td>'."\n". |
my ($curroption,$currlimit); |
|
$curroption = $userenv{$context.'.'.$item}; |
|
if (!$curroption) { |
|
$curroption = 'norequest'; |
|
} |
|
if ($curroption =~ /^autolimit=(\d*)$/) { |
|
$currlimit = $1; |
|
$currdisp = &mt('Yes, up to [quant,_1,request]/user',$currlimit); |
|
} else { |
|
$currdisp = $reqdisplay{$curroption}; |
|
} |
|
$custdisp = '<table>'; |
|
foreach my $option (@options) { |
|
my $val = $option; |
|
if ($option eq 'norequest') { |
|
$val = 0; |
|
} |
|
if ($option eq 'validate') { |
|
my $canvalidate = 0; |
|
if (ref($validations{$item}) eq 'HASH') { |
|
if ($validations{$item}{'_custom_'}) { |
|
$canvalidate = 1; |
|
} |
|
} |
|
next if (!$canvalidate); |
|
} |
|
my $checked = ''; |
|
if ($option eq $curroption) { |
|
$checked = ' checked="checked"'; |
|
} elsif ($option eq 'autolimit') { |
|
if ($curroption =~ /^autolimit/) { |
|
$checked = ' checked="checked"'; |
|
} |
|
} |
|
$custdisp .= '<tr><td><span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="crsreq_'.$item. |
|
'" value="'.$val.'"'.$checked.' />'. |
|
$reqtitles{$option}.'</label> '; |
|
if ($option eq 'autolimit') { |
|
$custdisp .= '<input type="text" name="crsreq_'. |
|
$item.'_limit" size="1" '. |
|
'value="'.$currlimit.'" />'; |
|
} |
|
$custdisp .= '</span></td></tr>'; |
|
} |
|
$custdisp .= '</table>'; |
|
$custradio = '</span></td><td>'.&mt('Custom setting').'<br />'.$custdisp; |
|
} else { |
|
$currdisp = ($curr_access?&mt('Yes'):&mt('No')); |
|
$custdisp = '<span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="'.$context.'_'.$item.'"'. |
|
' value="1"'. $tool_on.'/>'.&mt('On').'</label> <label>'. |
|
'<input type="radio" name="'.$context.'_'.$item.'" value="0" '. |
|
$tool_off.'/>'.&mt('Off').'</label></span>'; |
|
$custradio = (' 'x2).'--'.$lt{'cusa'}.': '.$custdisp. |
|
'</span>'; |
|
} |
|
$output .= ' <td'.$colspan.'>'.$custom_access.(' 'x4). |
|
$lt{'avai'}.': '.$currdisp.'</td>'."\n". |
&Apache::loncommon::end_data_table_row()."\n". |
&Apache::loncommon::end_data_table_row()."\n". |
&Apache::loncommon::start_data_table_row()."\n". |
&Apache::loncommon::start_data_table_row()."\n". |
' <td><span class="LC_nobreak">'.$lt{'chse'}.': <label>'. |
' <td style="vertical-align:top;"><span class="LC_nobreak">'. |
|
$lt{'chse'}.': <label>'. |
'<input type="radio" name="custom'.$item.'" value="0" '. |
'<input type="radio" name="custom'.$item.'" value="0" '. |
$cust_off.'/>'.$lt{'usde'}.'</label> '. |
$cust_off.'/>'.$lt{'usde'}.'</label>'.(' ' x3). |
'<label><input type="radio" name="custom'.$item.'" value="1" '. |
'<label><input type="radio" name="custom'.$item.'" value="1" '. |
$cust_on.'/>'.$lt{'uscu'}.'</label> -- '. |
$cust_on.'/>'.$lt{'uscu'}.'</label>'.$custradio.'</td>'. |
$lt{'cusa'}.': <label>'. |
|
'<input type="radio" name="'.$context.'_'.$item.'" value="1" '. |
|
$tool_on.'/>'.&mt('On').'</label> <label>'. |
|
'<input type="radio" name="'.$context.'_'.$item.'" value="0" '. |
|
$tool_off.'/>'.&mt('Off').'</label></span></td>'."\n". |
|
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
return $output; |
return $output; |
Line 289 sub build_tools_display {
|
Line 360 sub build_tools_display {
|
|
|
sub coursereq_externaluser { |
sub coursereq_externaluser { |
my ($ccuname,$ccdomain,$cdom) = @_; |
my ($ccuname,$ccdomain,$cdom) = @_; |
my (@usertools,%userenv,$output); |
my (@usertools,@options,%validations,%userenv,$output); |
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
'official' => 'Can request creation of official courses', |
'official' => 'Can request creation of official courses', |
'unofficial' => 'Can request creation of unofficial courses', |
'unofficial' => 'Can request creation of unofficial courses', |
Line 300 sub coursereq_externaluser {
|
Line 371 sub coursereq_externaluser {
|
'reqcrsotherdom.official','reqcrsotherdom.unofficial', |
'reqcrsotherdom.official','reqcrsotherdom.unofficial', |
'reqcrsotherdom.community'); |
'reqcrsotherdom.community'); |
@usertools = ('official','unofficial','community'); |
@usertools = ('official','unofficial','community'); |
|
@options = ('approve','validate','autolimit'); |
|
%validations = &Apache::lonnet::auto_courserequest_checks($cdom); |
|
my $optregex = join('|',@options); |
|
my %reqtitles = &courserequest_titles(); |
foreach my $item (@usertools) { |
foreach my $item (@usertools) { |
my ($tool_on,$tool_off); |
my ($curroption,$currlimit,$tooloff); |
$tool_off = 'checked="checked" '; |
|
if ($userenv{'reqcrsotherdom.'.$item} ne '') { |
if ($userenv{'reqcrsotherdom.'.$item} ne '') { |
my @curr = split(',',$userenv{'reqcrsotherdom.'.$item}); |
my @curr = split(',',$userenv{'reqcrsotherdom.'.$item}); |
if (grep(/^\Q$cdom\E$/,@curr)) { |
if (grep(/^\Q$cdom\E:($optregex)=?(\d*)$/,@curr)) { |
$tool_on = 'checked="checked" '; |
$curroption = $1; |
$tool_off = ''; |
$currlimit = $2; |
|
if (!$curroption) { |
|
$curroption = 'norequest'; |
|
} |
} |
} |
|
} else { |
|
$curroption = 'norequest'; |
|
$tooloff = ' checked="checked"'; |
|
} |
|
$output.= &Apache::loncommon::start_data_table_row()."\n". |
|
' <td><span class="LC_nobreak">'.$lt{$item}.': '. |
|
'<label><input type="radio" name="reqcrsotherdom_'.$item. |
|
'" value="0"'.$tooloff.' />'.$reqtitles{'norequest'}. |
|
'</label> '; |
|
foreach my $option (@options) { |
|
if ($option eq 'validate') { |
|
my $canvalidate = 0; |
|
if (ref($validations{$item}) eq 'HASH') { |
|
if ($validations{$item}{'_external_'}) { |
|
$canvalidate = 1; |
|
} |
|
} |
|
next if (!$canvalidate); |
|
} |
|
my $checked = ''; |
|
if ($option eq $curroption) { |
|
$checked = ' checked="checked"'; |
|
} |
|
$output .= '<span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="reqcrsotherdom_'.$item. |
|
'" value="'.$option.'"'.$checked.' />'. |
|
$reqtitles{$option}.'</label> '; |
|
if ($option eq 'autolimit') { |
|
$output .= '<input type="text" name="reqcrsotherdom_'. |
|
$item.'_limit" size="1" '. |
|
'value="'.$currlimit.'" />'; |
|
} |
|
$output .= ' ' |
} |
} |
$output .= &Apache::loncommon::start_data_table_row()."\n". |
$output .= '</span></td>'."\n". |
' <td><span class="LC_nobreak">'.$lt{$item}.': <label>'. |
|
'<input type="radio" name="reqcrsotherdom_'.$item.'" value="1" '. |
|
$tool_on.'/>'.&mt('Yes').'</label> <label>'. |
|
'<input type="radio" name="reqcrsotherdom_'.$item.'" value="0" '. |
|
$tool_off.'/>'.&mt('No').'</label></span></td>'."\n". |
|
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
return $output; |
return $output; |
} |
} |
|
|
|
sub courserequest_titles { |
|
my %titles = &Apache::lonlocal::texthash ( |
|
official => 'Official', |
|
unofficial => 'Unofficial', |
|
community => 'Communities', |
|
norequest => 'Not allowed', |
|
approve => 'Approval by Dom. Coord.', |
|
validate => 'With validation', |
|
autolimit => 'Numerical limit', |
|
); |
|
return %titles; |
|
} |
|
|
|
sub courserequest_display { |
|
my %titles = &Apache::lonlocal::texthash ( |
|
approve => 'Yes, need approval', |
|
validate => 'Yes, with validation', |
|
norequest => 'No', |
|
); |
|
return %titles; |
|
} |
|
|
# =================================================================== Phase one |
# =================================================================== Phase one |
|
|
sub print_username_entry_form { |
sub print_username_entry_form { |
Line 2031 sub update_user_data {
|
Line 2158 sub update_user_data {
|
} |
} |
} |
} |
foreach my $item (@requestcourses) { |
foreach my $item (@requestcourses) { |
$newcustom{$item} = $env{'form.requestcourses_'.$item}; |
$newcustom{$item} = $env{'form.crsreq_'.$item}; |
|
if ($env{'form.crsreq_'.$item} eq 'autolimit') { |
|
$newcustom{$item} .= '='; |
|
unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) { |
|
$newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'}; |
|
} |
|
} |
$changed{$item} = &tool_admin($item,$newcustom{$item}, |
$changed{$item} = &tool_admin($item,$newcustom{$item}, |
\%changeHash,'requestcourses'); |
\%changeHash,'requestcourses'); |
} |
} |
Line 2677 sub tool_changes {
|
Line 2810 sub tool_changes {
|
return; |
return; |
} |
} |
if ($context eq 'reqcrsotherdom') { |
if ($context eq 'reqcrsotherdom') { |
|
my @options = ('approve','validate','autolimit'); |
|
my $optregex = join('|',@options); |
|
my %reqdisplay = &courserequest_display(); |
my $cdom = $env{'request.role.domain'}; |
my $cdom = $env{'request.role.domain'}; |
foreach my $tool (@{$usertools}) { |
foreach my $tool (@{$usertools}) { |
$oldaccesstext->{$tool} = &mt('no'); |
$oldaccesstext->{$tool} = &mt('no'); |
Line 2695 sub tool_changes {
|
Line 2831 sub tool_changes {
|
my @curr = split(',',$userenv->{$context.'.'.$tool}); |
my @curr = split(',',$userenv->{$context.'.'.$tool}); |
my @new; |
my @new; |
my $changedoms; |
my $changedoms; |
if (grep(/^\Q$cdom\E$/,@curr)) { |
my $newop = $env{'form.'.$context.'_'.$tool}; |
|
if ($newop eq 'autolimit') { |
|
$newop .= '='; |
|
unless ($env{'form.'.$context.'_'.$tool.'_limit'} =~ /\D/) { |
|
$newop .= $env{'form.'.$context.'_'.$tool.'_limit'}; |
|
} |
|
} |
|
if (grep(/^\Q$cdom:($optregex\=?\d*)\E$/,@curr)) { |
$oldaccesstext->{$tool} = &mt('yes'); |
$oldaccesstext->{$tool} = &mt('yes'); |
unless ($env{'form.'.$context.'_'.$tool}) { |
my $oldop = $1; |
|
if ($oldop ne $newop) { |
$changedoms = 1; |
$changedoms = 1; |
foreach my $dom (@curr) { |
foreach my $dom (@curr) { |
unless ($dom eq $cdom) { |
unless ($dom eq $cdom) { |
push(@new,$dom); |
push(@new,$dom); |
} |
} |
} |
} |
|
if ($newop) { |
|
push(@new,$cdom.':'.$newop); |
|
} |
|
@new = sort(@new); |
} |
} |
} elsif ($env{'form.'.$context.'_'.$tool}) { |
} elsif ($env{'form.'.$context.'_'.$tool}) { |
$changedoms = 1; |
$changedoms = 1; |
@new = sort(@curr,$cdom); |
@new = sort(@curr,$cdom.':'.$newop); |
} |
} |
$newaccesstext->{$tool} = $oldaccesstext->{$tool}; |
$newaccesstext->{$tool} = $oldaccesstext->{$tool}; |
if ($changedoms) { |
if ($changedoms) { |
Line 2719 sub tool_changes {
|
Line 2867 sub tool_changes {
|
$context); |
$context); |
if ($changed->{$tool}) { |
if ($changed->{$tool}) { |
if ($env{'form.'.$context.'_'.$tool}) { |
if ($env{'form.'.$context.'_'.$tool}) { |
$newaccesstext->{$tool} = &mt('yes'); |
if ($env{'form.'.$context.'_'.$tool} eq 'autolimit') { |
|
if ($env{'form.'.$context.'_'.$tool.'_limit'} =~ /\D/) { |
|
$newaccesstext->{$tool} = &mt('Yes, processed automatically'); |
|
} else { |
|
$newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user).',$env{'form.'.$context.'_'.$tool.'_limit'}); |
|
} |
|
} else { |
|
$newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}}; |
|
} |
} else { |
} else { |
$newaccesstext->{$tool} = &mt('no'); |
$newaccesstext->{$tool} = &mt('No'); |
} |
} |
} |
} |
} |
} |
Line 2730 sub tool_changes {
|
Line 2886 sub tool_changes {
|
return; |
return; |
} |
} |
foreach my $tool (@{$usertools}) { |
foreach my $tool (@{$usertools}) { |
|
my $newval; |
|
if ($context eq 'requestcourses') { |
|
$newval = $env{'form.crsreq_'.$tool}; |
|
if ($newval eq 'autolimit') { |
|
$newval .= '='.$env{'form.crsreq_'.$tool.'_limit'}; |
|
} |
|
} else { |
|
$newval = $env{'form.'.$context.'_'.$tool}; |
|
} |
if ($userenv->{$context.'.'.$tool} ne '') { |
if ($userenv->{$context.'.'.$tool} ne '') { |
$oldaccess->{$tool} = &mt('custom'); |
$oldaccess->{$tool} = &mt('custom'); |
if ($userenv->{$context.'.'.$tool}) { |
if ($userenv->{$context.'.'.$tool}) { |
Line 2739 sub tool_changes {
|
Line 2904 sub tool_changes {
|
} |
} |
$changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool}; |
$changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool}; |
if ($env{'form.custom'.$tool} == 1) { |
if ($env{'form.custom'.$tool} == 1) { |
if ($env{'form.'.$context.'_'.$tool} ne $userenv->{$context.'.'.$tool}) { |
if ($newval ne $userenv->{$context.'.'.$tool}) { |
$changed->{$tool} = &tool_admin($tool,$env{'form.'.$context.'_'.$tool}, |
$changed->{$tool} = &tool_admin($tool,$newval,$changeHash, |
$changeHash,$context); |
$context); |
if ($changed->{$tool}) { |
if ($changed->{$tool}) { |
$newaccess->{$tool} = &mt('custom'); |
$newaccess->{$tool} = &mt('custom'); |
if ($env{'form.'.$context.'_'.$tool}) { |
if ($newval) { |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
} else { |
} else { |
$newaccesstext->{$tool} = &mt("availability set to 'off'"); |
$newaccesstext->{$tool} = &mt("availability set to 'off'"); |
Line 2777 sub tool_changes {
|
Line 2942 sub tool_changes {
|
} else { |
} else { |
$oldaccess->{$tool} = &mt('default'); |
$oldaccess->{$tool} = &mt('default'); |
if ($env{'form.custom'.$tool} == 1) { |
if ($env{'form.custom'.$tool} == 1) { |
$changed->{$tool} = &tool_admin($tool,$env{'form.'.$context.'_'.$tool}, |
$changed->{$tool} = &tool_admin($tool,$newval,$changeHash, |
$changeHash,$context); |
$context); |
if ($changed->{$tool}) { |
if ($changed->{$tool}) { |
$newaccess->{$tool} = &mt('custom'); |
$newaccess->{$tool} = &mt('custom'); |
if ($env{'form.'.$context.'_'.$tool}) { |
if ($newval) { |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
$newaccesstext->{$tool} = &mt("availability set to 'on'"); |
} else { |
} else { |
$newaccesstext->{$tool} = &mt("availability set to 'off'"); |
$newaccesstext->{$tool} = &mt("availability set to 'off'"); |