version 1.1118, 2013/03/20 01:26:15
|
version 1.1135, 2013/07/03 05:03:12
|
Line 2191 sub select_level_form {
|
Line 2191 sub select_level_form {
|
|
|
=pod |
=pod |
|
|
=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms) |
=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms) |
|
|
Returns a string containing a <select name='$name' size='1'> form to |
Returns a string containing a <select name='$name' size='1'> form to |
allow a user to select the domain to preform an operation in. |
allow a user to select the domain to preform an operation in. |
Line 2204 If the $showdomdesc flag is set, the dom
|
Line 2204 If the $showdomdesc flag is set, the dom
|
|
|
The optional $onchange argument specifies what should occur if the domain selector is changed, e.g., 'this.form.submit()' if the form is to be automatically submitted. |
The optional $onchange argument specifies what should occur if the domain selector is changed, e.g., 'this.form.submit()' if the form is to be automatically submitted. |
|
|
The optional $incdoms is a reference to an array of domains which will be the only available options. |
The optional $incdoms is a reference to an array of domains which will be the only available options. |
|
|
|
The optional $excdoms is a reference to an array of domains which will be excluded from the available options. |
|
|
=cut |
=cut |
|
|
#------------------------------------------- |
#------------------------------------------- |
sub select_dom_form { |
sub select_dom_form { |
my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms) = @_; |
my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms) = @_; |
if ($onchange) { |
if ($onchange) { |
$onchange = ' onchange="'.$onchange.'"'; |
$onchange = ' onchange="'.$onchange.'"'; |
} |
} |
my @domains; |
my (@domains,%exclude); |
if (ref($incdoms) eq 'ARRAY') { |
if (ref($incdoms) eq 'ARRAY') { |
@domains = sort {lc($a) cmp lc($b)} (@{$incdoms}); |
@domains = sort {lc($a) cmp lc($b)} (@{$incdoms}); |
} else { |
} else { |
@domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains()); |
@domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains()); |
} |
} |
if ($includeempty) { @domains=('',@domains); } |
if ($includeempty) { @domains=('',@domains); } |
|
if (ref($excdoms) eq 'ARRAY') { |
|
map { $exclude{$_} = 1; } @{$excdoms}; |
|
} |
my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n"; |
my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n"; |
foreach my $dom (@domains) { |
foreach my $dom (@domains) { |
|
next if ($exclude{$dom}); |
$selectdomain.="<option value=\"$dom\" ". |
$selectdomain.="<option value=\"$dom\" ". |
($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom; |
($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom; |
if ($showdomdesc) { |
if ($showdomdesc) { |
Line 4926 sub designparm {
|
Line 4932 sub designparm {
|
|
|
Inputs: $url (usually will be undef). |
Inputs: $url (usually will be undef). |
|
|
Returns: Path to Construction Space containing the resource or |
Returns: Path to Authoring Space containing the resource or |
directory being viewed (or for which action is being taken). |
directory being viewed (or for which action is being taken). |
If $url is provided, and begins /priv/<domain>/<uname> |
If $url is provided, and begins /priv/<domain>/<uname> |
the path will be that portion of the $context argument. |
the path will be that portion of the $context argument. |
Line 4989 Input: (optional) filename from which br
|
Line 4995 Input: (optional) filename from which br
|
is appropriate for use in building the breadcrumb trail. |
is appropriate for use in building the breadcrumb trail. |
|
|
Returns: HTML div with CSTR path and recent box |
Returns: HTML div with CSTR path and recent box |
To be included on Construction Space pages |
To be included on Authoring Space pages |
|
|
=cut |
=cut |
|
|
Line 5020 sub CSTR_pageheader {
|
Line 5026 sub CSTR_pageheader {
|
my $output = |
my $output = |
'<div>' |
'<div>' |
.&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it? |
.&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it? |
.'<b>'.&mt('Construction Space:').'</b> ' |
.'<b>'.&mt('Authoring Space:').'</b> ' |
.'<form name="dirs" method="post" action="'.$formaction |
.'<form name="dirs" method="post" action="'.$formaction |
.'" target="_top">' #FIXME lonpubdir: target="_parent" |
.'" target="_top">' #FIXME lonpubdir: target="_parent" |
.&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv/'.$udom,undef,undef); |
.&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv/'.$udom,undef,undef); |
Line 5149 sub bodytag {
|
Line 5155 sub bodytag {
|
my $bodytag = "<body $extra_body_attr>". |
my $bodytag = "<body $extra_body_attr>". |
&Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'}); |
&Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'}); |
|
|
if ($bodyonly) { |
&get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); |
|
|
|
if (($bodyonly) || ($no_nav_bar) || ($env{'form.inhibitmenu'} eq 'yes')) { |
return $bodytag; |
return $bodytag; |
} |
} |
|
|
my $name = &plainname($env{'user.name'},$env{'user.domain'}); |
|
if ($public) { |
if ($public) { |
undef($role); |
undef($role); |
} else { |
|
$name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'}, |
|
undef,'LC_menubuttons_link'); |
|
} |
} |
|
|
my $titleinfo = '<h1>'.$title.'</h1>'; |
my $titleinfo = '<h1>'.$title.'</h1>'; |
Line 5174 sub bodytag {
|
Line 5178 sub bodytag {
|
} |
} |
|
|
$role = '<span class="LC_nobreak">('.$role.')</span>' if $role; |
$role = '<span class="LC_nobreak">('.$role.')</span>' if $role; |
&get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); |
|
|
|
if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { |
|
return $bodytag; |
|
} |
|
|
|
if ($env{'request.state'} eq 'construct') { $forcereg=1; } |
if ($env{'request.state'} eq 'construct') { $forcereg=1; } |
|
|
Line 5186 sub bodytag {
|
Line 5185 sub bodytag {
|
# $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls |
# $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls |
# } |
# } |
|
|
|
$bodytag .= Apache::lonhtmlcommon::scripttag( |
|
Apache::lonmenu::utilityfunctions(), 'start'); |
|
|
|
my ($left,$right) = Apache::lonmenu::primary_menu(); |
|
|
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
if ($dc_info) { |
if ($dc_info) { |
$dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|; |
$dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|; |
} |
} |
$bodytag .= qq|<div id="LC_nav_bar">$name $role<br /> |
$bodytag .= qq|<div id="LC_nav_bar">$left $role<br /> |
<em>$realm</em> $dc_info</div>|; |
<em>$realm</em> $dc_info</div>|; |
return $bodytag; |
return $bodytag; |
} |
} |
|
|
unless ($env{'request.symb'} =~ m/\.page___\d+___/) { |
unless ($env{'request.symb'} =~ m/\.page___\d+___/) { |
$bodytag .= qq|<div id="LC_nav_bar">$name $role</div>|; |
$bodytag .= qq|<div id="LC_nav_bar">$left $role</div>|; |
} |
} |
|
|
$bodytag .= Apache::lonhtmlcommon::scripttag( |
$bodytag .= $right; |
Apache::lonmenu::utilityfunctions(), 'start'); |
|
|
|
$bodytag .= Apache::lonmenu::primary_menu(); |
|
|
|
if ($dc_info) { |
if ($dc_info) { |
$dc_info = &dc_courseid_toggle($dc_info); |
$dc_info = &dc_courseid_toggle($dc_info); |
Line 5404 form, .inline {
|
Line 5403 form, .inline {
|
vertical-align:middle; |
vertical-align:middle; |
} |
} |
|
|
|
.LC_floatleft { |
|
float: left; |
|
} |
|
|
|
.LC_floatright { |
|
float: right; |
|
} |
|
|
.LC_400Box { |
.LC_400Box { |
width:400px; |
width:400px; |
} |
} |
Line 6474 div.LC_edit_problem_saves {
|
Line 6481 div.LC_edit_problem_saves {
|
padding-bottom: 5px; |
padding-bottom: 5px; |
} |
} |
|
|
|
.LC_edit_opt { |
|
padding-left: 1em; |
|
white-space: nowrap; |
|
} |
|
|
img.stift { |
img.stift { |
border-width: 0; |
border-width: 0; |
vertical-align: middle; |
vertical-align: middle; |
Line 6488 div.LC_createcourse {
|
Line 6500 div.LC_createcourse {
|
} |
} |
|
|
.LC_dccid { |
.LC_dccid { |
|
float: right; |
margin: 0.2em 0 0 0; |
margin: 0.2em 0 0 0; |
padding: 0; |
padding: 0; |
font-size: 90%; |
font-size: 90%; |
Line 6585 fieldset > legend {
|
Line 6598 fieldset > legend {
|
} |
} |
|
|
ol.LC_primary_menu { |
ol.LC_primary_menu { |
float: right; |
|
margin: 0; |
margin: 0; |
padding: 0; |
padding: 0; |
background-color: $pgbg_or_bgcolor; |
background-color: $pgbg_or_bgcolor; |
Line 6729 ul#LC_secondary_menu li ul li {
|
Line 6741 ul#LC_secondary_menu li ul li {
|
vertical-align: top; |
vertical-align: top; |
border-left: 1px solid black; |
border-left: 1px solid black; |
border-right: 1px solid black; |
border-right: 1px solid black; |
background-color: $data_table_light |
background-color: $data_table_light; |
list-style:none; |
list-style:none; |
float: none; |
float: none; |
} |
} |
Line 7807 sub LCprogressbar {
|
Line 7819 sub LCprogressbar {
|
$LCcurrentid=$$.'_'.$LCidcnt; |
$LCcurrentid=$$.'_'.$LCidcnt; |
my $starting=&mt('Starting'); |
my $starting=&mt('Starting'); |
my $content=(<<ENDPROGBAR); |
my $content=(<<ENDPROGBAR); |
<p> |
|
<div id="progressbar$LCcurrentid"> |
<div id="progressbar$LCcurrentid"> |
<span class="pblabel">$starting</span> |
<span class="pblabel">$starting</span> |
</div> |
</div> |
</p> |
|
ENDPROGBAR |
ENDPROGBAR |
&r_print($r,$content.&LCprogressbar_script($LCcurrentid)); |
&r_print($r,$content.&LCprogressbar_script($LCcurrentid)); |
} |
} |
Line 8414 sub get_course_users {
|
Line 8424 sub get_course_users {
|
active => 'Active', |
active => 'Active', |
future => 'Future', |
future => 'Future', |
); |
); |
my %nothide; |
my (%nothide,@possdoms); |
if ($hidepriv) { |
if ($hidepriv) { |
my %coursehash=&Apache::lonnet::coursedescription($cdom.'_'.$cnum); |
my %coursehash=&Apache::lonnet::coursedescription($cdom.'_'.$cnum); |
foreach my $user (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) { |
foreach my $user (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) { |
Line 8424 sub get_course_users {
|
Line 8434 sub get_course_users {
|
$nothide{$user} = 1; |
$nothide{$user} = 1; |
} |
} |
} |
} |
|
my @possdoms = ($cdom); |
|
if ($coursehash{'checkforpriv'}) { |
|
push(@possdoms,split(/,/,$coursehash{'checkforpriv'})); |
|
} |
} |
} |
foreach my $person (sort(keys(%coursepersonnel))) { |
foreach my $person (sort(keys(%coursepersonnel))) { |
my $match = 0; |
my $match = 0; |
Line 8459 sub get_course_users {
|
Line 8473 sub get_course_users {
|
} |
} |
if ($uname ne '' && $udom ne '') { |
if ($uname ne '' && $udom ne '') { |
if ($hidepriv) { |
if ($hidepriv) { |
if ((&Apache::lonnet::privileged($uname,$udom)) && |
if ((&Apache::lonnet::privileged($uname,$udom,\@possdoms)) && |
(!$nothide{$uname.':'.$udom})) { |
(!$nothide{$uname.':'.$udom})) { |
next; |
next; |
} |
} |
Line 8547 sub get_user_info {
|
Line 8561 sub get_user_info {
|
|
|
=item * &get_user_quota() |
=item * &get_user_quota() |
|
|
Retrieves quota assigned for storage of portfolio files for a user |
Retrieves quota assigned for storage of user files. |
|
Default is to report quota for portfolio files. |
|
|
Incoming parameters: |
Incoming parameters: |
1. user's username |
1. user's username |
2. user's domain |
2. user's domain |
|
3. quota name - portfolio, author, or course |
|
(if no quota name provided, defaults to portfolio). |
|
|
Returns: |
Returns: |
1. Disk quota (in Mb) assigned to student. |
1. Disk quota (in Mb) assigned to student. |
Line 8565 Returns:
|
Line 8582 Returns:
|
|
|
If a value has been stored in the user's environment, |
If a value has been stored in the user's environment, |
it will return that, otherwise it returns the maximal default |
it will return that, otherwise it returns the maximal default |
defined for the user's instituional status(es) in the domain. |
defined for the user's institutional status(es) in the domain. |
|
|
=cut |
=cut |
|
|
Line 8573 defined for the user's instituional stat
|
Line 8590 defined for the user's instituional stat
|
|
|
|
|
sub get_user_quota { |
sub get_user_quota { |
my ($uname,$udom) = @_; |
my ($uname,$udom,$quotaname) = @_; |
my ($quota,$quotatype,$settingstatus,$defquota); |
my ($quota,$quotatype,$settingstatus,$defquota); |
if (!defined($udom)) { |
if (!defined($udom)) { |
$udom = $env{'user.domain'}; |
$udom = $env{'user.domain'}; |
Line 8588 sub get_user_quota {
|
Line 8605 sub get_user_quota {
|
$defquota = 0; |
$defquota = 0; |
} else { |
} else { |
my $inststatus; |
my $inststatus; |
if ($udom eq $env{'user.domain'} && $uname eq $env{'user.name'}) { |
if ($quotaname eq 'course') { |
$quota = $env{'environment.portfolioquota'}; |
if (($env{'course.'.$udom.'_'.$uname.'.num'} eq $uname) && |
$inststatus = $env{'environment.inststatus'}; |
($env{'course.'.$udom.'_'.$uname.'.domain'} eq $udom)) { |
} else { |
$quota = $env{'course.'.$udom.'_'.$uname.'.internal.uploadquota'}; |
my %userenv = |
} else { |
&Apache::lonnet::get('environment',['portfolioquota', |
my %cenv = &Apache::lonnet::coursedescription("$udom/$uname"); |
'inststatus'],$udom,$uname); |
$quota = $cenv{'internal.uploadquota'}; |
my ($tmp) = keys(%userenv); |
} |
if ($tmp !~ /^(con_lost|error|no_such_host)/i) { |
|
$quota = $userenv{'portfolioquota'}; |
|
$inststatus = $userenv{'inststatus'}; |
|
} else { |
|
undef(%userenv); |
|
} |
|
} |
|
($defquota,$settingstatus) = &default_quota($udom,$inststatus); |
|
if ($quota eq '') { |
|
$quota = $defquota; |
|
$quotatype = 'default'; |
|
} else { |
} else { |
$quotatype = 'custom'; |
if ($udom eq $env{'user.domain'} && $uname eq $env{'user.name'}) { |
|
if ($quotaname eq 'author') { |
|
$quota = $env{'environment.authorquota'}; |
|
} else { |
|
$quota = $env{'environment.portfolioquota'}; |
|
} |
|
$inststatus = $env{'environment.inststatus'}; |
|
} else { |
|
my %userenv = |
|
&Apache::lonnet::get('environment',['portfolioquota', |
|
'authorquota','inststatus'],$udom,$uname); |
|
my ($tmp) = keys(%userenv); |
|
if ($tmp !~ /^(con_lost|error|no_such_host)/i) { |
|
if ($quotaname eq 'author') { |
|
$quota = $userenv{'authorquota'}; |
|
} else { |
|
$quota = $userenv{'portfolioquota'}; |
|
} |
|
$inststatus = $userenv{'inststatus'}; |
|
} else { |
|
undef(%userenv); |
|
} |
|
} |
|
} |
|
if ($quota eq '' || wantarray) { |
|
if ($quotaname eq 'course') { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($udom); |
|
$defquota = $domdefs{'uploadquota'}; |
|
} else { |
|
($defquota,$settingstatus) = &default_quota($udom,$inststatus,$quotaname); |
|
} |
|
if ($quota eq '') { |
|
$quota = $defquota; |
|
$quotatype = 'default'; |
|
} else { |
|
$quotatype = 'custom'; |
|
} |
} |
} |
} |
} |
if (wantarray) { |
if (wantarray) { |
Line 8633 Incoming parameters:
|
Line 8675 Incoming parameters:
|
status types (e.g., faculty, staff, student etc.) |
status types (e.g., faculty, staff, student etc.) |
which apply to the user for whom the default is being retrieved. |
which apply to the user for whom the default is being retrieved. |
If the institutional status string in undefined, the domain |
If the institutional status string in undefined, the domain |
default quota will be returned. |
default quota will be returned. |
|
3. quota name - portfolio, author, or course |
|
(if no quota name provided, defaults to portfolio). |
|
|
Returns: |
Returns: |
1. Default disk quota (in Mb) for user portfolios in the domain. |
1. Default disk quota (in Mb) for user portfolios in the domain. |
Line 8657 default quota returned.
|
Line 8701 default quota returned.
|
|
|
|
|
sub default_quota { |
sub default_quota { |
my ($udom,$inststatus) = @_; |
my ($udom,$inststatus,$quotaname) = @_; |
my ($defquota,$settingstatus); |
my ($defquota,$settingstatus); |
my %quotahash = &Apache::lonnet::get_dom('configuration', |
my %quotahash = &Apache::lonnet::get_dom('configuration', |
['quotas'],$udom); |
['quotas'],$udom); |
|
my $key = 'defaultquota'; |
|
if ($quotaname eq 'author') { |
|
$key = 'authorquota'; |
|
} |
if (ref($quotahash{'quotas'}) eq 'HASH') { |
if (ref($quotahash{'quotas'}) eq 'HASH') { |
if ($inststatus ne '') { |
if ($inststatus ne '') { |
my @statuses = map { &unescape($_); } split(/:/,$inststatus); |
my @statuses = map { &unescape($_); } split(/:/,$inststatus); |
foreach my $item (@statuses) { |
foreach my $item (@statuses) { |
if (ref($quotahash{'quotas'}{'defaultquota'}) eq 'HASH') { |
if (ref($quotahash{'quotas'}{$key}) eq 'HASH') { |
if ($quotahash{'quotas'}{'defaultquota'}{$item} ne '') { |
if ($quotahash{'quotas'}{$key}{$item} ne '') { |
if ($defquota eq '') { |
if ($defquota eq '') { |
$defquota = $quotahash{'quotas'}{'defaultquota'}{$item}; |
$defquota = $quotahash{'quotas'}{$key}{$item}; |
$settingstatus = $item; |
$settingstatus = $item; |
} elsif ($quotahash{'quotas'}{'defaultquota'}{$item} > $defquota) { |
} elsif ($quotahash{'quotas'}{$key}{$item} > $defquota) { |
$defquota = $quotahash{'quotas'}{'defaultquota'}{$item}; |
$defquota = $quotahash{'quotas'}{$key}{$item}; |
$settingstatus = $item; |
$settingstatus = $item; |
} |
} |
} |
} |
} else { |
} elsif ($key eq 'defaultquota') { |
if ($quotahash{'quotas'}{$item} ne '') { |
if ($quotahash{'quotas'}{$item} ne '') { |
if ($defquota eq '') { |
if ($defquota eq '') { |
$defquota = $quotahash{'quotas'}{$item}; |
$defquota = $quotahash{'quotas'}{$item}; |
Line 8689 sub default_quota {
|
Line 8737 sub default_quota {
|
} |
} |
} |
} |
if ($defquota eq '') { |
if ($defquota eq '') { |
if (ref($quotahash{'quotas'}{'defaultquota'}) eq 'HASH') { |
if (ref($quotahash{'quotas'}{$key}) eq 'HASH') { |
$defquota = $quotahash{'quotas'}{'defaultquota'}{'default'}; |
$defquota = $quotahash{'quotas'}{$key}{'default'}; |
} else { |
} elsif ($key eq 'defaultquota') { |
$defquota = $quotahash{'quotas'}{'default'}; |
$defquota = $quotahash{'quotas'}{'default'}; |
} |
} |
$settingstatus = 'default'; |
$settingstatus = 'default'; |
} |
} |
} else { |
} else { |
$settingstatus = 'default'; |
$settingstatus = 'default'; |
$defquota = 20; |
if ($quotaname eq 'author') { |
|
$defquota = 500; |
|
} else { |
|
$defquota = 20; |
|
} |
} |
} |
if (wantarray) { |
if (wantarray) { |
return ($defquota,$settingstatus); |
return ($defquota,$settingstatus); |
Line 8707 sub default_quota {
|
Line 8759 sub default_quota {
|
} |
} |
} |
} |
|
|
|
############################################### |
|
|
|
=pod |
|
|
|
=item * &excess_filesize_authorspace() |
|
|
|
Returns warning message if upload of file to authoring space, or copying |
|
of existing file within authoring space will cause quota to be exceeded. |
|
|
|
Inputs: 6 |
|
1. username |
|
2. domain |
|
3. directory path for top level of current authoring space |
|
4. filename of file for which action is being requested |
|
5. filesize (kB) of file |
|
6. action being taken: copy or upload. |
|
|
|
Returns: 1 scalar: HTML to display containing warning if quota would be exceeded, |
|
otherwise return null. |
|
|
|
=cut |
|
|
|
sub excess_filesize_authorspace { |
|
my ($uname,$udom,$authorspace,$filename,$filesize,$action) = @_; |
|
my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in MB |
|
$disk_quota = int($disk_quota * 1000); |
|
my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,$authorspace); |
|
if (($current_disk_usage + $filesize) > $disk_quota) { |
|
return '<p><span class="LC_warning">'. |
|
&mt("Unable to $action [_1]. (size = [_2] kilobytes). Disk quota will be exceeded.", |
|
'<span class="LC_filename">'.$filename.'</span>',$filesize).'</span>'. |
|
'<br />'.&mt('Disk quota is [_1] kilobytes. Your current disk usage is [_2] kilobytes.', |
|
$disk_quota,$current_disk_usage). |
|
'</p>'; |
|
} |
|
return; |
|
} |
|
|
|
############################################### |
|
|
|
|
sub get_secgrprole_info { |
sub get_secgrprole_info { |
my ($cdom,$cnum,$needroles,$type) = @_; |
my ($cdom,$cnum,$needroles,$type) = @_; |
my %sections_count = &get_sections($cdom,$cnum); |
my %sections_count = &get_sections($cdom,$cnum); |
Line 9550 sub ask_for_embedded_content {
|
Line 9643 sub ask_for_embedded_content {
|
my $heading = &mt('Upload embedded files'); |
my $heading = &mt('Upload embedded files'); |
my $buttontext = &mt('Upload'); |
my $buttontext = &mt('Upload'); |
|
|
my $navmap; |
my ($navmap,$cdom,$cnum); |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
$navmap = Apache::lonnavmaps::navmap->new(); |
if ($actionurl eq '/adm/dependencies') { |
|
$navmap = Apache::lonnavmaps::navmap->new(); |
|
} |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
} |
} |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
if (($actionurl eq '/adm/portfolio') || |
|
($actionurl eq '/adm/coursegrp_portfolio')) { |
my $current_path='/'; |
my $current_path='/'; |
if ($env{'form.currentpath'}) { |
if ($env{'form.currentpath'}) { |
$current_path = $env{'form.currentpath'}; |
$current_path = $env{'form.currentpath'}; |
} |
} |
if ($actionurl eq '/adm/coursegrp_portfolio') { |
if ($actionurl eq '/adm/coursegrp_portfolio') { |
$udom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$udom = $cdom; |
$uname = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$uname = $cnum; |
$url = '/userfiles/groups/'.$env{'form.group'}.'/portfolio'; |
$url = '/userfiles/groups/'.$env{'form.group'}.'/portfolio'; |
} else { |
} else { |
$udom = $env{'user.domain'}; |
$udom = $env{'user.domain'}; |
Line 9593 sub ask_for_embedded_content {
|
Line 9691 sub ask_for_embedded_content {
|
} |
} |
} elsif ($actionurl eq '/adm/dependencies') { |
} elsif ($actionurl eq '/adm/dependencies') { |
if ($env{'request.course.id'} ne '') { |
if ($env{'request.course.id'} ne '') { |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
if (ref($args) eq 'HASH') { |
if (ref($args) eq 'HASH') { |
$url = $args->{'docs_url'}; |
$url = $args->{'docs_url'}; |
$title = $args->{'docs_title'}; |
$title = $args->{'docs_title'}; |
$toplevel = "/$url"; |
$toplevel = $url; |
|
unless ($toplevel =~ m{^/}) { |
|
$toplevel = "/$url"; |
|
} |
($rem) = ($toplevel =~ m{^(.+/)[^/]+$}); |
($rem) = ($toplevel =~ m{^(.+/)[^/]+$}); |
($path) = |
if ($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/portfolio/syllabus\E)}) { |
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); |
$path = $1; |
|
} else { |
|
($path) = |
|
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); |
|
} |
$fileloc = &Apache::lonnet::filelocation('',$toplevel); |
$fileloc = &Apache::lonnet::filelocation('',$toplevel); |
$fileloc =~ s{^/}{}; |
$fileloc =~ s{^/}{}; |
($filename) = ($fileloc =~ m{.+/([^/]+)$}); |
($filename) = ($fileloc =~ m{.+/([^/]+)$}); |
$heading = &mt('Status of dependencies in [_1]',"$title ($filename)"); |
$heading = &mt('Status of dependencies in [_1]',"$title ($filename)"); |
} |
} |
} |
} |
} |
} elsif ($actionurl eq "/public/$cdom/$cnum/syllabus") { |
my $now = time(); |
$udom = $cdom; |
foreach my $embed_file (keys(%{$allfiles})) { |
$uname = $cnum; |
|
$url = "/uploaded/$cdom/$cnum/portfolio/syllabus"; |
|
$toplevel = $url; |
|
$path = $url; |
|
$fileloc = &Apache::lonnet::filelocation('',$toplevel).'/'; |
|
$fileloc =~ s{^/}{}; |
|
} |
|
foreach my $file (keys(%{$allfiles})) { |
|
my $embed_file; |
|
if (($path eq "/uploaded/$cdom/$cnum/portfolio/syllabus") && ($file =~ m{^\Q$path/\E(.+)$})) { |
|
$embed_file = $1; |
|
} else { |
|
$embed_file = $file; |
|
} |
my $absolutepath; |
my $absolutepath; |
if ($embed_file =~ m{^\w+://}) { |
if ($embed_file =~ m{^\w+://}) { |
$newfiles{$embed_file} = 1; |
$newfiles{$embed_file} = 1; |
Line 9648 sub ask_for_embedded_content {
|
Line 9764 sub ask_for_embedded_content {
|
my $dirptr = 16384; |
my $dirptr = 16384; |
foreach my $path (keys(%subdependencies)) { |
foreach my $path (keys(%subdependencies)) { |
$currsubfile{$path} = {}; |
$currsubfile{$path} = {}; |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
if (($actionurl eq '/adm/portfolio') || |
|
($actionurl eq '/adm/coursegrp_portfolio')) { |
my ($sublistref,$listerror) = |
my ($sublistref,$listerror) = |
&Apache::lonnet::dirlist($url.$path,$udom,$uname,$getpropath); |
&Apache::lonnet::dirlist($url.$path,$udom,$uname,$getpropath); |
if (ref($sublistref) eq 'ARRAY') { |
if (ref($sublistref) eq 'ARRAY') { |
Line 9664 sub ask_for_embedded_content {
|
Line 9781 sub ask_for_embedded_content {
|
} |
} |
} elsif (($actionurl eq '/adm/dependencies') || |
} elsif (($actionurl eq '/adm/dependencies') || |
(($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && |
(($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && |
($args->{'context'} eq 'paste'))) { |
($args->{'context'} eq 'paste')) || |
|
($actionurl eq "/public/$cdom/$cnum/syllabus")) { |
if ($env{'request.course.id'} ne '') { |
if ($env{'request.course.id'} ne '') { |
my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); |
my $dir; |
|
if ($actionurl eq "/public/$cdom/$cnum/syllabus") { |
|
$dir = $fileloc; |
|
} else { |
|
($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); |
|
} |
if ($dir ne '') { |
if ($dir ne '') { |
my ($sublistref,$listerror) = |
my ($sublistref,$listerror) = |
&Apache::lonnet::dirlist($dir.$path,$cdom,$cnum,$getpropath,undef,'/'); |
&Apache::lonnet::dirlist($dir.$path,$cdom,$cnum,$getpropath,undef,'/'); |
Line 9714 sub ask_for_embedded_content {
|
Line 9837 sub ask_for_embedded_content {
|
} |
} |
} |
} |
my %currfile; |
my %currfile; |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
if (($actionurl eq '/adm/portfolio') || |
|
($actionurl eq '/adm/coursegrp_portfolio')) { |
my ($dirlistref,$listerror) = |
my ($dirlistref,$listerror) = |
&Apache::lonnet::dirlist($url,$udom,$uname,$getpropath); |
&Apache::lonnet::dirlist($url,$udom,$uname,$getpropath); |
if (ref($dirlistref) eq 'ARRAY') { |
if (ref($dirlistref) eq 'ARRAY') { |
Line 9730 sub ask_for_embedded_content {
|
Line 9854 sub ask_for_embedded_content {
|
} |
} |
} elsif (($actionurl eq '/adm/dependencies') || |
} elsif (($actionurl eq '/adm/dependencies') || |
(($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && |
(($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') && |
($args->{'context'} eq 'paste'))) { |
($args->{'context'} eq 'paste')) || |
|
($actionurl eq "/public/$cdom/$cnum/syllabus")) { |
if ($env{'request.course.id'} ne '') { |
if ($env{'request.course.id'} ne '') { |
my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); |
my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$}); |
if ($dir ne '') { |
if ($dir ne '') { |
Line 9765 sub ask_for_embedded_content {
|
Line 9890 sub ask_for_embedded_content {
|
($file eq $filename.'.bak') || |
($file eq $filename.'.bak') || |
($dependencies{$file})) { |
($dependencies{$file})) { |
if ($actionurl eq '/adm/dependencies') { |
if ($actionurl eq '/adm/dependencies') { |
next if (($rem ne '') && |
unless ($toplevel =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus\E}) { |
(($env{"httpref.$rem".$file} ne '') || |
next if (($rem ne '') && |
(ref($navmap) && |
(($env{"httpref.$rem".$file} ne '') || |
(($navmap->getResourceByUrl($rem.$file) ne '') || |
(ref($navmap) && |
(($file =~ /^(.*\.s?html?)\.bak$/i) && |
(($navmap->getResourceByUrl($rem.$file) ne '') || |
($navmap->getResourceByUrl($rem.$1))))))); |
(($file =~ /^(.*\.s?html?)\.bak$/i) && |
|
($navmap->getResourceByUrl($rem.$1))))))); |
|
} |
} |
} |
$unused{$file} = 1; |
$unused{$file} = 1; |
} |
} |
Line 9779 sub ask_for_embedded_content {
|
Line 9906 sub ask_for_embedded_content {
|
($args->{'context'} eq 'paste')) { |
($args->{'context'} eq 'paste')) { |
$counter = scalar(keys(%existing)); |
$counter = scalar(keys(%existing)); |
$numpathchg = scalar(keys(%pathchanges)); |
$numpathchg = scalar(keys(%pathchanges)); |
return ($output,$counter,$numpathchg,\%existing); |
return ($output,$counter,$numpathchg,\%existing); |
|
} elsif (($actionurl eq "/public/$cdom/$cnum/syllabus") && |
|
(ref($args) eq 'HASH') && ($args->{'context'} eq 'rewrites')) { |
|
$counter = scalar(keys(%existing)); |
|
$numpathchg = scalar(keys(%pathchanges)); |
|
return ($output,$counter,$numpathchg,\%existing,\%mapping); |
} |
} |
foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%newfiles)) { |
foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%newfiles)) { |
if ($actionurl eq '/adm/dependencies') { |
if ($actionurl eq '/adm/dependencies') { |
next if ($embed_file =~ m{^\w+://}); |
next if ($embed_file =~ m{^\w+://}); |
} |
} |
$upload_output .= &start_data_table_row(). |
$upload_output .= &start_data_table_row(). |
'<td><img src="'.&icon($embed_file).'" /> '. |
'<td valign="top"><img src="'.&icon($embed_file).'" /> '. |
'<span class="LC_filename">'.$embed_file.'</span>'; |
'<span class="LC_filename">'.$embed_file.'</span>'; |
unless ($mapping{$embed_file} eq $embed_file) { |
unless ($mapping{$embed_file} eq $embed_file) { |
$upload_output .= '<br /><span class="LC_info" style="font-size:smaller;">'.&mt('changed from: [_1]',$mapping{$embed_file}).'</span>'; |
$upload_output .= '<br /><span class="LC_info" style="font-size:smaller;">'. |
|
&mt('changed from: [_1]',$mapping{$embed_file}).'</span>'; |
} |
} |
$upload_output .= '</td><td>'; |
$upload_output .= '</td>'; |
if ($args->{'ignore_remote_references'} && $embed_file =~ m{^\w+://}) { |
if ($args->{'ignore_remote_references'} && $embed_file =~ m{^\w+://}) { |
$upload_output.='<span class="LC_warning">'.&mt("URL points to other server.").'</span>'; |
$upload_output.='<td align="right">'. |
|
'<span class="LC_info LC_fontsize_medium">'. |
|
&mt("URL points to web address").'</span>'; |
$numremref++; |
$numremref++; |
} elsif ($args->{'error_on_invalid_names'} |
} elsif ($args->{'error_on_invalid_names'} |
&& $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) { |
&& $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) { |
$upload_output.='<span class="LC_warning">'.&mt('Invalid characters').'</span>'; |
$upload_output.='<td align="right"><span class="LC_warning">'. |
|
&mt('Invalid characters').'</span>'; |
$numinvalid++; |
$numinvalid++; |
} else { |
} else { |
$upload_output .= &embedded_file_element('upload_embedded',$counter, |
$upload_output .= '<td>'. |
|
&embedded_file_element('upload_embedded',$counter, |
$embed_file,\%mapping, |
$embed_file,\%mapping, |
$allfiles,$codebase,'upload'); |
$allfiles,$codebase,'upload'); |
$counter ++; |
$counter ++; |
Line 9829 sub ask_for_embedded_content {
|
Line 9966 sub ask_for_embedded_content {
|
$counter ++; |
$counter ++; |
} else { |
} else { |
$upload_output .= &start_data_table_row(). |
$upload_output .= &start_data_table_row(). |
'<td><span class="LC_filename">'.$embed_file.'</span></td>'; |
'<td valign="top"><img src="'.&icon($embed_file).'" /> '. |
'<td><span class="LC_warning">'.&mt('Already exists').'</span></td>'. |
'<span class="LC_filename">'.$embed_file.'</span></td>'. |
|
'<td align="right"><span class="LC_info LC_fontsize_medium">'.&mt('Already exists').'</span></td>'. |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
} |
} |
Line 9925 sub ask_for_embedded_content {
|
Line 10063 sub ask_for_embedded_content {
|
$output = '<b>'.&mt('Referenced files').'</b>:<br />'; |
$output = '<b>'.&mt('Referenced files').'</b>:<br />'; |
if ($applies > 1) { |
if ($applies > 1) { |
$output .= |
$output .= |
&mt('No files need to be uploaded, as one of the following applies to each reference:').'<ul>'; |
&mt('No dependencies need to be uploaded, as one of the following applies to each reference:').'<ul>'; |
if ($numremref) { |
if ($numremref) { |
$output .= '<li>'.&mt('reference is to a URL which points to another server').'</li>'."\n"; |
$output .= '<li>'.&mt('reference is to a URL which points to another server').'</li>'."\n"; |
} |
} |
Line 9968 sub ask_for_embedded_content {
|
Line 10106 sub ask_for_embedded_content {
|
$chgcount ++; |
$chgcount ++; |
} |
} |
} |
} |
if ($counter) { |
if (($counter) || ($numunused)) { |
if ($numpathchg) { |
if ($numpathchg) { |
$output .= '<input type ="hidden" name="number_pathchange_items" value="'. |
$output .= '<input type ="hidden" name="number_pathchange_items" value="'. |
$numpathchg.'" />'."\n"; |
$numpathchg.'" />'."\n"; |
Line 9981 sub ask_for_embedded_content {
|
Line 10119 sub ask_for_embedded_content {
|
} elsif ($actionurl eq '/adm/dependencies') { |
} elsif ($actionurl eq '/adm/dependencies') { |
$output .= '<input type="hidden" name="action" value="process_changes" />'; |
$output .= '<input type="hidden" name="action" value="process_changes" />'; |
} |
} |
$output .= '<input type ="submit" value="'.$buttontext.'" />'."\n".'</form>'."\n"; |
$output .= '<input type ="submit" value="'.$buttontext.'" />'."\n".'</form>'."\n"; |
} elsif ($numpathchg) { |
} elsif ($numpathchg) { |
my %pathchange = (); |
my %pathchange = (); |
$output .= &modify_html_form('pathchange',$actionurl,$state,\%pathchange,$pathchange_output); |
$output .= &modify_html_form('pathchange',$actionurl,$state,\%pathchange,$pathchange_output); |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { |
$output .= '<p>'.&mt('or').'</p>'; |
$output .= '<p>'.&mt('or').'</p>'; |
} |
} |
} |
} |
return ($output,$counter,$numpathchg); |
return ($output,$counter,$numpathchg); |
} |
} |
Line 10123 sub upload_embedded {
|
Line 10261 sub upload_embedded {
|
$output .= &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1).'<br />'; |
$output .= &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1).'<br />'; |
next; |
next; |
} elsif ($fname=~/\.(\d+)\.(\w+)$/) { |
} elsif ($fname=~/\.(\d+)\.(\w+)$/) { |
$output .= &mt('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2).'<br />'; |
$output .= &mt('Filename not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2).'<br />'; |
next; |
next; |
} |
} |
$env{'form.embedded_item_'.$i.'.filename'}=$fname; |
$env{'form.embedded_item_'.$i.'.filename'}=$fname; |
|
my $subdir = $path; |
|
$subdir =~ s{/+$}{}; |
if ($context eq 'portfolio') { |
if ($context eq 'portfolio') { |
my $result; |
my $result; |
if ($state eq 'existingfile') { |
if ($state eq 'existingfile') { |
$result= |
$result= |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'existingfile', |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'existingfile', |
$dirpath.$env{'form.currentpath'}.$path); |
$dirpath.$env{'form.currentpath'}.$subdir); |
} else { |
} else { |
$result= |
$result= |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'', |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'', |
$dirpath. |
$dirpath. |
$env{'form.currentpath'}.$path); |
$env{'form.currentpath'}.$subdir); |
if ($result !~ m|^/uploaded/|) { |
if ($result !~ m|^/uploaded/|) { |
$output .= '<span class="LC_error">' |
$output .= '<span class="LC_error">' |
.&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].' |
.&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].' |
Line 10149 sub upload_embedded {
|
Line 10289 sub upload_embedded {
|
$path.$fname.'</span>').'<br />'; |
$path.$fname.'</span>').'<br />'; |
} |
} |
} |
} |
} elsif ($context eq 'coursedoc') { |
} elsif (($context eq 'coursedoc') || ($context eq 'syllabus')) { |
|
my $extendedsubdir = $dirpath.'/'.$subdir; |
|
$extendedsubdir =~ s{/+$}{}; |
my $result = |
my $result = |
&Apache::lonnet::userfileupload('embedded_item_'.$i,'coursedoc', |
&Apache::lonnet::userfileupload('embedded_item_'.$i,$context,$extendedsubdir); |
$dirpath.'/'.$path); |
|
if ($result !~ m|^/uploaded/|) { |
if ($result !~ m|^/uploaded/|) { |
$output .= '<span class="LC_error">' |
$output .= '<span class="LC_error">' |
.&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].' |
.&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].' |
Line 10162 sub upload_embedded {
|
Line 10303 sub upload_embedded {
|
} else { |
} else { |
$output .= &mt('Uploaded [_1]','<span class="LC_filename">'. |
$output .= &mt('Uploaded [_1]','<span class="LC_filename">'. |
$path.$fname.'</span>').'<br />'; |
$path.$fname.'</span>').'<br />'; |
|
if ($context eq 'syllabus') { |
|
&Apache::lonnet::make_public_indefinitely($result); |
|
} |
} |
} |
} else { |
} else { |
# Save the file |
# Save the file |
Line 10293 sub modify_html_form {
|
Line 10437 sub modify_html_form {
|
} |
} |
|
|
sub modify_html_refs { |
sub modify_html_refs { |
my ($context,$dirpath,$uname,$udom,$dir_root) = @_; |
my ($context,$dirpath,$uname,$udom,$dir_root,$url) = @_; |
my $container; |
my $container; |
if ($context eq 'portfolio') { |
if ($context eq 'portfolio') { |
$container = $env{'form.container'}; |
$container = $env{'form.container'}; |
Line 10302 sub modify_html_refs {
|
Line 10446 sub modify_html_refs {
|
} elsif ($context eq 'manage_dependencies') { |
} elsif ($context eq 'manage_dependencies') { |
(undef,undef,$container) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
(undef,undef,$container) = &Apache::lonnet::decode_symb($env{'form.symb'}); |
$container = "/$container"; |
$container = "/$container"; |
|
} elsif ($context eq 'syllabus') { |
|
$container = $url; |
} else { |
} else { |
$container = $Apache::lonnet::perlvar{'lonDocRoot'}.$env{'form.filename'}; |
$container = $Apache::lonnet::perlvar{'lonDocRoot'}.$env{'form.filename'}; |
} |
} |
my (%allfiles,%codebase,$output,$content); |
my (%allfiles,%codebase,$output,$content); |
my @changes = &get_env_multiple('form.namechange'); |
my @changes = &get_env_multiple('form.namechange'); |
unless (@changes > 0) { |
unless ((@changes > 0) || ($context eq 'syllabus')) { |
if (wantarray) { |
if (wantarray) { |
return ('',0,0); |
return ('',0,0); |
} else { |
} else { |
Line 10315 sub modify_html_refs {
|
Line 10461 sub modify_html_refs {
|
} |
} |
} |
} |
if (($context eq 'portfolio') || ($context eq 'coursedoc') || |
if (($context eq 'portfolio') || ($context eq 'coursedoc') || |
($context eq 'manage_dependencies')) { |
($context eq 'manage_dependencies') || ($context eq 'syllabus')) { |
unless ($container =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/}) { |
unless ($container =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/}) { |
if (wantarray) { |
if (wantarray) { |
return ('',0,0); |
return ('',0,0); |
Line 10371 sub modify_html_refs {
|
Line 10517 sub modify_html_refs {
|
if ($content =~ m{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}) { |
if ($content =~ m{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}) { |
my $numchg = ($content =~ s{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}{$1$newname$2}gi); |
my $numchg = ($content =~ s{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}{$1$newname$2}gi); |
$count += $numchg; |
$count += $numchg; |
|
$allfiles{$newname} = $allfiles{$ref}; |
} |
} |
if ($env{'form.embedded_codebase_'.$i} ne '') { |
if ($env{'form.embedded_codebase_'.$i} ne '') { |
$codebase = &unescape($env{'form.embedded_codebase_'.$i}); |
$codebase = &unescape($env{'form.embedded_codebase_'.$i}); |
Line 10379 sub modify_html_refs {
|
Line 10526 sub modify_html_refs {
|
} |
} |
} |
} |
} |
} |
|
my $skiprewrites; |
if ($count || $codebasecount) { |
if ($count || $codebasecount) { |
my $saveresult; |
my $saveresult; |
if (($context eq 'portfolio') || ($context eq 'coursedoc') || |
if (($context eq 'portfolio') || ($context eq 'coursedoc') || |
($context eq 'manage_dependencies')) { |
($context eq 'manage_dependencies') || ($context eq 'syllabus')) { |
my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult); |
my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult); |
if ($url eq $container) { |
if ($url eq $container) { |
my ($fname) = ($container =~ m{/([^/]+)$}); |
my ($fname) = ($container =~ m{/([^/]+)$}); |
Line 10395 sub modify_html_refs {
|
Line 10543 sub modify_html_refs {
|
'<span class="LC_filename">'. |
'<span class="LC_filename">'. |
$container.'</span>').'</p>'; |
$container.'</span>').'</p>'; |
} |
} |
|
if ($context eq 'syllabus') { |
|
unless ($saveresult eq 'ok') { |
|
$skiprewrites = 1; |
|
} |
|
} |
} else { |
} else { |
if (open(my $fh,">$container")) { |
if (open(my $fh,">$container")) { |
print $fh $content; |
print $fh $content; |
Line 10410 sub modify_html_refs {
|
Line 10563 sub modify_html_refs {
|
} |
} |
} |
} |
} |
} |
|
if (($context eq 'syllabus') && (!$skiprewrites)) { |
|
my ($actionurl,$state); |
|
$actionurl = "/public/$udom/$uname/syllabus"; |
|
my ($ignore,$num,$numpathchanges,$existing,$mapping) = |
|
&ask_for_embedded_content($actionurl,$state,\%allfiles, |
|
\%codebase, |
|
{'context' => 'rewrites', |
|
'ignore_remote_references' => 1,}); |
|
if (ref($mapping) eq 'HASH') { |
|
my $rewrites = 0; |
|
foreach my $key (keys(%{$mapping})) { |
|
next if ($key =~ m{^https?://}); |
|
my $ref = $mapping->{$key}; |
|
my $newname = "/uploaded/$udom/$uname/portfolio/syllabus/$key"; |
|
my $attrib; |
|
if (ref($allfiles{$mapping->{$key}}) eq 'ARRAY') { |
|
$attrib = join('|',@{$allfiles{$mapping->{$key}}}); |
|
} |
|
if ($content =~ m{($attrib\s*=\s*['"]?)\Q$ref\E(['"]?)}) { |
|
my $numchg = ($content =~ s{($attrib\s*=\s*['"]?)\Q$ref\E(['"]?)}{$1$newname$2}gi); |
|
$rewrites += $numchg; |
|
} |
|
} |
|
if ($rewrites) { |
|
my $saveresult; |
|
my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult); |
|
if ($url eq $container) { |
|
my ($fname) = ($container =~ m{/([^/]+)$}); |
|
$output .= '<p>'.&mt('Rewrote [quant,_1,link] as [quant,_1,absolute link] in [_2].', |
|
$count,'<span class="LC_filename">'. |
|
$fname.'</span>').'</p>'; |
|
} else { |
|
$output .= '<p class="LC_error">'. |
|
&mt('Error: could not update links in [_1].', |
|
'<span class="LC_filename">'. |
|
$container.'</span>').'</p>'; |
|
|
|
} |
|
} |
|
} |
|
} |
} else { |
} else { |
&logthis('Failed to parse '.$container. |
&logthis('Failed to parse '.$container. |
' to modify references: '.$parse_result); |
' to modify references: '.$parse_result); |
Line 10825 sub process_decompression {
|
Line 11019 sub process_decompression {
|
my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; |
my ($docudom,$docuname,$file,$destination,$dir_root,$hiddenelem) = @_; |
my ($dir,$error,$warning,$output); |
my ($dir,$error,$warning,$output); |
if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) { |
if ($file !~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) { |
$error = &mt('File name not a supported archive file type.'). |
$error = &mt('Filename not a supported archive file type.'). |
'<br />'.&mt('File name should end with one of: [_1].', |
'<br />'.&mt('Filename should end with one of: [_1].', |
'.zip, .tar, .bz2, .gz, .tar.gz, .tar.bz2, .tgz'); |
'.zip, .tar, .bz2, .gz, .tar.gz, .tar.bz2, .tgz'); |
} else { |
} else { |
my $docuhome = &Apache::lonnet::homeserver($docuname,$docudom); |
my $docuhome = &Apache::lonnet::homeserver($docuname,$docudom); |
Line 11712 sub get_folder_hierarchy {
|
Line 11906 sub get_folder_hierarchy {
|
my @pcs = split(/,/,$pcslist); |
my @pcs = split(/,/,$pcslist); |
foreach my $pc (@pcs) { |
foreach my $pc (@pcs) { |
if ($pc == 1) { |
if ($pc == 1) { |
push(@pathitems,&mt('Main Course Documents')); |
push(@pathitems,&mt('Main Content')); |
} else { |
} else { |
my $res = $navmap->getByMapPc($pc); |
my $res = $navmap->getByMapPc($pc); |
if (ref($res)) { |
if (ref($res)) { |
Line 11727 sub get_folder_hierarchy {
|
Line 11921 sub get_folder_hierarchy {
|
} |
} |
if ($showitem) { |
if ($showitem) { |
if ($mapres->{ID} eq '0.0') { |
if ($mapres->{ID} eq '0.0') { |
push(@pathitems,&mt('Main Course Documents')); |
push(@pathitems,&mt('Main Content')); |
} else { |
} else { |
my $maptitle = $mapres->compTitle(); |
my $maptitle = $mapres->compTitle(); |
$maptitle =~ s/\W+/_/g; |
$maptitle =~ s/\W+/_/g; |
Line 13546 sub construct_course {
|
Line 13740 sub construct_course {
|
'pch.users.denied', |
'pch.users.denied', |
'plc.users.denied', |
'plc.users.denied', |
'hidefromcat', |
'hidefromcat', |
|
'checkforpriv', |
'categories'], |
'categories'], |
$$crsudom,$$crsunum); |
$$crsudom,$$crsunum); |
} |
} |
Line 13602 sub construct_course {
|
Line 13797 sub construct_course {
|
# do not hide course coordinator from staff listing, |
# do not hide course coordinator from staff listing, |
# even if privileged |
# even if privileged |
$cenv{'nothideprivileged'}=$args->{'ccuname'}.':'.$args->{'ccdomain'}; |
$cenv{'nothideprivileged'}=$args->{'ccuname'}.':'.$args->{'ccdomain'}; |
|
# add course coordinator's domain to domains to check for privileged users |
|
# if different to course domain |
|
if ($$crsudom ne $args->{'ccdomain'}) { |
|
$cenv{'checkforpriv'} = $args->{'ccdomain'}; |
|
} |
# add crosslistings |
# add crosslistings |
if ($args->{'crsxlist'}) { |
if ($args->{'crsxlist'}) { |
$cenv{'internal.crosslistings'}=''; |
$cenv{'internal.crosslistings'}=''; |
Line 14282 sub symb_to_docspath {
|
Line 14482 sub symb_to_docspath {
|
$path =~ s/^\&//; |
$path =~ s/^\&//; |
my $maptitle = $mapresobj->title(); |
my $maptitle = $mapresobj->title(); |
if ($mapurl eq 'default') { |
if ($mapurl eq 'default') { |
$maptitle = 'Main Course Documents'; |
$maptitle = 'Main Content'; |
} |
} |
$path .= (($path ne '')? '&' : ''). |
$path .= (($path ne '')? '&' : ''). |
&Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
&Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
Line 14296 sub symb_to_docspath {
|
Line 14496 sub symb_to_docspath {
|
my $maptitle = &Apache::lonnet::gettitle($mapurl); |
my $maptitle = &Apache::lonnet::gettitle($mapurl); |
my $ispage = (($type eq 'page')? 1 : ''); |
my $ispage = (($type eq 'page')? 1 : ''); |
if ($mapurl eq 'default') { |
if ($mapurl eq 'default') { |
$maptitle = 'Main Course Documents'; |
$maptitle = 'Main Content'; |
} |
} |
$path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
$path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
&Apache::lonhtmlcommon::entity_encode($maptitle).':::::'.$ispage; |
&Apache::lonhtmlcommon::entity_encode($maptitle).':::::'.$ispage; |
} |
} |
unless ($mapurl eq 'default') { |
unless ($mapurl eq 'default') { |
$path = 'default&'. |
$path = 'default&'. |
&Apache::lonhtmlcommon::entity_encode('Main Course Documents'). |
&Apache::lonhtmlcommon::entity_encode('Main Content'). |
':::::&'.$path; |
':::::&'.$path; |
} |
} |
return $path; |
return $path; |
Line 14446 sub create_recaptcha {
|
Line 14646 sub create_recaptcha {
|
return $captcha->get_options_setter({theme => 'white'})."\n". |
return $captcha->get_options_setter({theme => 'white'})."\n". |
$captcha->get_html($pubkey). |
$captcha->get_html($pubkey). |
&mt('If either word is hard to read, [_1] will replace them.', |
&mt('If either word is hard to read, [_1] will replace them.', |
'<image src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />'). |
'<img src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />'). |
'<br /><br />'; |
'<br /><br />'; |
} |
} |
|
|