version 1.636.2.3, 2008/03/18 23:00:51
|
version 1.647, 2008/03/20 19:46:44
|
Line 78 my $readit;
|
Line 78 my $readit;
|
## Global Variables |
## Global Variables |
## |
## |
|
|
|
|
|
# ----------------------------------------------- SSI with retries: |
|
# |
|
|
|
=pod |
|
|
|
=head1 Server Side incliude with retries: |
|
|
|
=over 4 |
|
|
|
=item * ssi_with_retries(resource, retries form) |
|
|
|
Performs an ssi with some number of retries. Retries continue either |
|
until the result is ok or until the retry count supplied by the |
|
caller is exhausted. |
|
|
|
Inputs: |
|
resource - Identifies the resource to insert. |
|
retries - Count of the number of retries allowed. |
|
form - Hash that identifies the rendering options. |
|
|
|
Returns: |
|
content - The content of the response. If retries were exhausted this is empty. |
|
response - The response from the last attempt (which may or may not have been successful. |
|
|
|
=cut |
|
|
|
sub ssi_with_retries { |
|
my ($resource, $retries, %form) = @_; |
|
|
|
|
|
my $ok = 0; # True if we got a good response. |
|
my $content; |
|
my $response; |
|
|
|
# Try to get the ssi done. within the retries count: |
|
|
|
do { |
|
($content, $response) = &Apache::lonnet::ssi($resource, %form); |
|
$ok = $response->is_success; |
|
$retries--; |
|
} while (!$ok && ($retries > 0)); |
|
|
|
if (!$ok) { |
|
$content = ''; # On error return an empty content. |
|
} |
|
return ($content, $response); |
|
|
|
} |
|
|
|
|
|
|
# ----------------------------------------------- Filetypes/Languages/Copyright |
# ----------------------------------------------- Filetypes/Languages/Copyright |
my %language; |
my %language; |
my %supported_language; |
my %supported_language; |
Line 319 sub storeresurl {
|
Line 371 sub storeresurl {
|
unless ($resurl=~/^\/res/) { return 0; } |
unless ($resurl=~/^\/res/) { return 0; } |
$resurl=~s/\/$//; |
$resurl=~s/\/$//; |
&Apache::lonnet::put('environment',{'lastresurl' => $resurl}); |
&Apache::lonnet::put('environment',{'lastresurl' => $resurl}); |
&Apache::lonnet::appenv('environment.lastresurl' => $resurl); |
&Apache::lonnet::appenv({'environment.lastresurl' => $resurl}); |
return 1; |
return 1; |
} |
} |
|
|
Line 2242 sub get_assignable_auth {
|
Line 2294 sub get_assignable_auth {
|
} |
} |
|
|
############################################################### |
############################################################### |
## Get Authentication Defaults for Domain ## |
|
############################################################### |
|
|
|
=pod |
|
|
|
=head1 Domains and Authentication |
|
|
|
Returns default authentication type and an associated argument as |
|
listed in file 'domain.tab'. |
|
|
|
=over 4 |
|
|
|
=item * get_auth_defaults |
|
|
|
get_auth_defaults($target_domain) returns the default authentication |
|
type and an associated argument (initial password or a kerberos domain). |
|
These values are stored in lonTabs/domain.tab |
|
|
|
($def_auth, $def_arg) = &get_auth_defaults($target_domain); |
|
|
|
If target_domain is not found in domain.tab, returns nothing (''). |
|
|
|
=cut |
|
|
|
#------------------------------------------- |
|
sub get_auth_defaults { |
|
my $domain=shift; |
|
return (&Apache::lonnet::domain($domain,'auth_def'), |
|
&Apache::lonnet::domain($domain,'auth_arg_def')); |
|
|
|
} |
|
############################################################### |
|
## End Get Authentication Defaults for Domain ## |
|
############################################################### |
|
|
|
############################################################### |
|
## Get Kerberos Defaults for Domain ## |
## Get Kerberos Defaults for Domain ## |
############################################################### |
############################################################### |
## |
## |
Line 2292 sub get_auth_defaults {
|
Line 2308 sub get_auth_defaults {
|
=item * get_kerberos_defaults |
=item * get_kerberos_defaults |
|
|
get_kerberos_defaults($target_domain) returns the default kerberos |
get_kerberos_defaults($target_domain) returns the default kerberos |
version and domain. If not found in domain.tabs, it defaults to |
version and domain. If not found, it defaults to version 4 and the |
version 4 and the domain of the server. |
domain of the server. |
|
|
($def_version, $def_krb_domain) = &get_kerberos_defaults($target_domain); |
($def_version, $def_krb_domain) = &get_kerberos_defaults($target_domain); |
|
|
Line 2302 version 4 and the domain of the server.
|
Line 2318 version 4 and the domain of the server.
|
#------------------------------------------- |
#------------------------------------------- |
sub get_kerberos_defaults { |
sub get_kerberos_defaults { |
my $domain=shift; |
my $domain=shift; |
my ($krbdef,$krbdefdom) = |
my ($krbdef,$krbdefdom); |
&Apache::loncommon::get_auth_defaults($domain); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); |
unless ($krbdef =~/^krb/ && $krbdefdom) { |
if (($domdefaults{'auth_def'} =~/^krb(4|5)$/) && ($domdefaults{'auth_arg_def'} ne '')) { |
|
$krbdef = $domdefaults{'auth_def'}; |
|
$krbdefdom = $domdefaults{'auth_arg_def'}; |
|
} else { |
$ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/; |
$ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/; |
my $krbdefdom=$1; |
my $krbdefdom=$1; |
$krbdefdom=~tr/a-z/A-Z/; |
$krbdefdom=~tr/a-z/A-Z/; |
Line 2883 sub preferred_languages {
|
Line 2902 sub preferred_languages {
|
map { (split(/\s*;\s*/,$_))[0] } (split(/\s*,\s*/,$browser)); |
map { (split(/\s*;\s*/,$_))[0] } (split(/\s*,\s*/,$browser)); |
push(@languages,@browser); |
push(@languages,@browser); |
} |
} |
if (&Apache::lonnet::domain($env{'user.domain'},'lang_def')) { |
|
@languages=(@languages, |
foreach my $domtype ($env{'user.domain'},$env{'request.role.domain'}, |
&Apache::lonnet::domain($env{'user.domain'}, |
$Apache::lonnet::perlvar{'lonDefDomain'}) { |
'lang_def')); |
if ($domtype ne '') { |
} |
my %domdefs = &Apache::lonnet::get_domain_defaults($domtype); |
if (&Apache::lonnet::domain($env{'request.role.domain'},'lang_def')) { |
if ($domdefs{'lang_def'} ne '') { |
@languages=(@languages, |
push(@languages,$domdefs{'lang_def'}); |
&Apache::lonnet::domain($env{'request.role.domain'}, |
} |
'lang_def')); |
} |
} |
|
if (&Apache::lonnet::domain($Apache::lonnet::perlvar{'lonDefDomain'}, |
|
'lang_def')) { |
|
@languages=(@languages, |
|
&Apache::lonnet::domain($Apache::lonnet::perlvar{'lonDefDomain'}, |
|
'lang_def')); |
|
} |
} |
# turn "en-ca" into "en-ca,en" |
# turn "en-ca" into "en-ca,en" |
my @genlanguages; |
my @genlanguages; |
Line 3981 ENDROLE
|
Line 3994 ENDROLE
|
$dc_info = '('.$dc_info.')'; |
$dc_info = '('.$dc_info.')'; |
} |
} |
|
|
if ($env{'environment.remote'} eq 'off') { |
if (($env{'environment.remote'} eq 'off') || ($args->{'suppress_header_logos'})) { |
# No Remote |
# No Remote |
if ($env{'request.state'} eq 'construct') { |
if ($env{'request.state'} eq 'construct') { |
$forcereg=1; |
$forcereg=1; |
Line 4006 ENDROLE
|
Line 4019 ENDROLE
|
$titleinfo = |
$titleinfo = |
&Apache::loncommon::help_open_menu('','',3,'Authoring') |
&Apache::loncommon::help_open_menu('','',3,'Authoring') |
.'<b>'.&mt('Construction Space').'</b>: ' |
.'<b>'.&mt('Construction Space').'</b>: ' |
.'<form name="dirs" method="post" action="'.$formaction.'"' |
.'<form name="dirs" method="post" action="'.$formaction |
.' target="_top"><tt><b>' |
.'" target="_top"><tt><b>' |
.&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv','','+1',1)."<font size=\"+1\">$lastitem</font></b></tt><br />" |
.&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv','','+1',1)."<font size=\"+1\">$lastitem</font></b></tt><br />" |
.&Apache::lonhtmlcommon::select_recent('construct','recent','this.form.action=this.form.recent.value;this.form.submit()') |
.&Apache::lonhtmlcommon::select_recent('construct','recent','this.form.action=this.form.recent.value;this.form.submit()') |
.'</form>' |
.'</form>' |
Line 4777 table.LC_pick_box td.LC_pick_box_title {
|
Line 4790 table.LC_pick_box td.LC_pick_box_title {
|
width: 184px; |
width: 184px; |
padding: 8px; |
padding: 8px; |
} |
} |
|
table.LC_pick_box td.LC_selfenroll_pick_box_title { |
|
background: $tabbg; |
|
font-weight: bold; |
|
text-align: right; |
|
width: 350px; |
|
padding: 8px; |
|
} |
|
|
table.LC_pick_box td.LC_pick_box_value { |
table.LC_pick_box td.LC_pick_box_value { |
text-align: left; |
text-align: left; |
padding: 8px; |
padding: 8px; |
Line 5321 Inputs: none
|
Line 5342 Inputs: none
|
|
|
sub font_settings { |
sub font_settings { |
my $headerstring=''; |
my $headerstring=''; |
if (($env{'browser.os'} eq 'mac') && (!$env{'browser.mathml'})) { |
if (!$env{'browser.mathml'} && $env{'browser.unicode'}) { |
$headerstring.= |
|
'<meta Content-Type="text/html; charset=x-mac-roman" />'; |
|
} elsif (!$env{'browser.mathml'} && $env{'browser.unicode'}) { |
|
$headerstring.= |
$headerstring.= |
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; |
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; |
} |
} |
Line 6692 sub personal_data_fieldtitles {
|
Line 6710 sub personal_data_fieldtitles {
|
return %fieldtitles; |
return %fieldtitles; |
} |
} |
|
|
|
sub sorted_inst_types { |
|
my ($dom) = @_; |
|
my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($dom); |
|
my $othertitle = &mt('All users'); |
|
if ($env{'request.course.id'}) { |
|
$othertitle = 'any'; |
|
} |
|
my @types; |
|
if (ref($order) eq 'ARRAY') { |
|
@types = @{$order}; |
|
} |
|
if (@types == 0) { |
|
if (ref($usertypes) eq 'HASH') { |
|
@types = sort(keys(%{$usertypes})); |
|
} |
|
} |
|
if (keys(%{$usertypes}) > 0) { |
|
$othertitle = &mt('Other users'); |
|
if ($env{'request.course.id'}) { |
|
$othertitle = 'other'; |
|
} |
|
} |
|
return ($othertitle,$usertypes,\@types); |
|
} |
|
|
|
sub get_institutional_codes { |
|
my ($settings,$allcourses,$LC_code) = @_; |
|
# Get complete list of course sections to update |
|
my @currsections = (); |
|
my @currxlists = (); |
|
my $coursecode = $$settings{'internal.coursecode'}; |
|
|
|
if ($$settings{'internal.sectionnums'} ne '') { |
|
@currsections = split(/,/,$$settings{'internal.sectionnums'}); |
|
} |
|
|
|
if ($$settings{'internal.crosslistings'} ne '') { |
|
@currxlists = split(/,/,$$settings{'internal.crosslistings'}); |
|
} |
|
|
|
if (@currxlists > 0) { |
|
foreach (@currxlists) { |
|
if (m/^([^:]+):(\w*)$/) { |
|
unless (grep/^$1$/,@{$allcourses}) { |
|
push @{$allcourses},$1; |
|
$$LC_code{$1} = $2; |
|
} |
|
} |
|
} |
|
} |
|
|
|
if (@currsections > 0) { |
|
foreach (@currsections) { |
|
if (m/^(\w+):(\w*)$/) { |
|
my $sec = $coursecode.$1; |
|
my $lc_sec = $2; |
|
unless (grep/^$sec$/,@{$allcourses}) { |
|
push @{$allcourses},$sec; |
|
$$LC_code{$sec} = $lc_sec; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
=pod |
=pod |
|
|
=back |
=back |
Line 7400 sub DrawBarGraph {
|
Line 7484 sub DrawBarGraph {
|
$ValuesHash{$id.'.'.$key} = $value; |
$ValuesHash{$id.'.'.$key} = $value; |
} |
} |
# |
# |
&Apache::lonnet::appenv(%ValuesHash); |
&Apache::lonnet::appenv(\%ValuesHash); |
return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />'; |
return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />'; |
} |
} |
|
|
Line 7490 sub DrawXYGraph {
|
Line 7574 sub DrawXYGraph {
|
$ValuesHash{$id.'.'.$key} = $value; |
$ValuesHash{$id.'.'.$key} = $value; |
} |
} |
# |
# |
&Apache::lonnet::appenv(%ValuesHash); |
&Apache::lonnet::appenv(\%ValuesHash); |
return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />'; |
return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />'; |
} |
} |
|
|
Line 7592 sub DrawXYYGraph {
|
Line 7676 sub DrawXYYGraph {
|
$ValuesHash{$id.'.'.$key} = $value; |
$ValuesHash{$id.'.'.$key} = $value; |
} |
} |
# |
# |
&Apache::lonnet::appenv(%ValuesHash); |
&Apache::lonnet::appenv(\%ValuesHash); |
return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />'; |
return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />'; |
} |
} |
|
|
Line 7724 sub store_settings {
|
Line 7808 sub store_settings {
|
'got error:'.$put_result); |
'got error:'.$put_result); |
} |
} |
# Make sure these settings stick around in this session, too |
# Make sure these settings stick around in this session, too |
&Apache::lonnet::appenv(%AppHash); |
&Apache::lonnet::appenv(\%AppHash); |
return; |
return; |
} |
} |
|
|
Line 8087 sub construct_course {
|
Line 8171 sub construct_course {
|
$outcome .= $clonemsg.$linefeed; |
$outcome .= $clonemsg.$linefeed; |
my %oldcenv=&Apache::lonnet::dump('environment',$$crsudom,$$crsunum); |
my %oldcenv=&Apache::lonnet::dump('environment',$$crsudom,$$crsunum); |
# Copy all files |
# Copy all files |
&Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid); |
&Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid,$args->{'datemode'},$args->{'dateshift'}); |
# Restore URL |
# Restore URL |
$cenv{'url'}=$oldcenv{'url'}; |
$cenv{'url'}=$oldcenv{'url'}; |
# Restore title |
# Restore title |
Line 8134 sub construct_course {
|
Line 8218 sub construct_course {
|
} else { |
} else { |
$cenv{'internal.courseowner'} = $args->{'curruser'}; |
$cenv{'internal.courseowner'} = $args->{'curruser'}; |
} |
} |
|
|
my @badclasses = (); # Used to accumulate sections/crosslistings that did not pass classlist access check for course owner. |
my @badclasses = (); # Used to accumulate sections/crosslistings that did not pass classlist access check for course owner. |
if ($args->{'crssections'}) { |
if ($args->{'crssections'}) { |
$cenv{'internal.sectionnums'} = ''; |
$cenv{'internal.sectionnums'} = ''; |