version 1.1075.2.13, 2012/08/07 13:15:28
|
version 1.1118, 2013/03/20 01:26:15
|
Line 67 use Apache::lonhtmlcommon();
|
Line 67 use Apache::lonhtmlcommon();
|
use Apache::loncoursedata(); |
use Apache::loncoursedata(); |
use Apache::lontexconvert(); |
use Apache::lontexconvert(); |
use Apache::lonclonecourse(); |
use Apache::lonclonecourse(); |
|
use Apache::lonuserutils(); |
|
use Apache::lonuserstate(); |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use DateTime::TimeZone; |
use DateTime::TimeZone; |
use DateTime::Locale::Catalog; |
use DateTime::Locale::Catalog; |
|
use Text::Aspell; |
|
use Authen::Captcha; |
|
use Captcha::reCAPTCHA; |
|
|
# ---------------------------------------------- Designs |
# ---------------------------------------------- Designs |
use vars qw(%defaultdesign); |
use vars qw(%defaultdesign); |
Line 154 sub ssi_with_retries {
|
Line 159 sub ssi_with_retries {
|
# ----------------------------------------------- Filetypes/Languages/Copyright |
# ----------------------------------------------- Filetypes/Languages/Copyright |
my %language; |
my %language; |
my %supported_language; |
my %supported_language; |
|
my %supported_codes; |
my %latex_language; # For choosing hyphenation in <transl..> |
my %latex_language; # For choosing hyphenation in <transl..> |
my %latex_language_bykey; # for choosing hyphenation from metadata |
my %latex_language_bykey; # for choosing hyphenation from metadata |
my %cprtag; |
my %cprtag; |
Line 188 BEGIN {
|
Line 194 BEGIN {
|
while (my $line = <$fh>) { |
while (my $line = <$fh>) { |
next if ($line=~/^\#/); |
next if ($line=~/^\#/); |
chomp($line); |
chomp($line); |
my ($key,$two,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line)); |
my ($key,$code,$country,$three,$enc,$val,$sup,$latex)=(split(/\t/,$line)); |
$language{$key}=$val.' - '.$enc; |
$language{$key}=$val.' - '.$enc; |
if ($sup) { |
if ($sup) { |
$supported_language{$key}=$sup; |
$supported_language{$key}=$sup; |
|
$supported_codes{$key} = $code; |
} |
} |
if ($latex) { |
if ($latex) { |
$latex_language_bykey{$key} = $latex; |
$latex_language_bykey{$key} = $latex; |
$latex_language{$two} = $latex; |
$latex_language{$code} = $latex; |
} |
} |
} |
} |
close($fh); |
close($fh); |
Line 524 ENDAUTHORBRW
|
Line 531 ENDAUTHORBRW
|
} |
} |
|
|
sub coursebrowser_javascript { |
sub coursebrowser_javascript { |
my ($domainfilter,$sec_element,$formname,$role_element,$crstype) = @_; |
my ($domainfilter,$sec_element,$formname,$role_element,$crstype, |
|
$credits_element) = @_; |
my $wintitle = 'Course_Browser'; |
my $wintitle = 'Course_Browser'; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$wintitle = 'Community_Browser'; |
$wintitle = 'Community_Browser'; |
Line 587 sub coursebrowser_javascript {
|
Line 595 sub coursebrowser_javascript {
|
} |
} |
$id_functions |
$id_functions |
ENDSTDBRW |
ENDSTDBRW |
if (($sec_element ne '') || ($role_element ne '')) { |
if (($sec_element ne '') || ($role_element ne '') || ($credits_element ne '')) { |
$output .= &setsec_javascript($sec_element,$formname,$role_element); |
$output .= &setsec_javascript($sec_element,$formname,$role_element, |
|
$credits_element); |
} |
} |
$output .= ' |
$output .= ' |
// ]]> |
// ]]> |
Line 657 if (!Array.prototype.indexOf) {
|
Line 666 if (!Array.prototype.indexOf) {
|
var n = 0; |
var n = 0; |
if (arguments.length > 0) { |
if (arguments.length > 0) { |
n = Number(arguments[1]); |
n = Number(arguments[1]); |
if (n !== n) { // shortcut for verifying if it's NaN |
if (n !== n) { // shortcut for verifying if it is NaN |
n = 0; |
n = 0; |
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { |
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { |
n = (n > 0 || -1) * Math.floor(Math.abs(n)); |
n = (n > 0 || -1) * Math.floor(Math.abs(n)); |
Line 745 ENDUSERBRW
|
Line 754 ENDUSERBRW
|
} |
} |
|
|
sub setsec_javascript { |
sub setsec_javascript { |
my ($sec_element,$formname,$role_element) = @_; |
my ($sec_element,$formname,$role_element,$credits_element) = @_; |
my (@courserolenames,@communityrolenames,$rolestr,$courserolestr, |
my (@courserolenames,@communityrolenames,$rolestr,$courserolestr, |
$communityrolestr); |
$communityrolestr); |
if ($role_element ne '') { |
if ($role_element ne '') { |
Line 840 function setRole(crstype) {
|
Line 849 function setRole(crstype) {
|
} |
} |
|; |
|; |
} |
} |
|
if ($credits_element) { |
|
$setsections .= qq| |
|
function setCredits(defaultcredits) { |
|
document.$formname.$credits_element.value = defaultcredits; |
|
return; |
|
} |
|
|; |
|
} |
return $setsections; |
return $setsections; |
} |
} |
|
|
Line 885 sub check_uncheck_jscript {
|
Line 902 sub check_uncheck_jscript {
|
function checkAll(field) { |
function checkAll(field) { |
if (field.length > 0) { |
if (field.length > 0) { |
for (i = 0; i < field.length; i++) { |
for (i = 0; i < field.length; i++) { |
field[i].checked = true ; |
if (!field[i].disabled) { |
|
field[i].checked = true; |
|
} |
} |
} |
} else { |
} else { |
field.checked = true |
if (!field.disabled) { |
|
field.checked = true; |
|
} |
} |
} |
} |
} |
|
|
Line 990 sub select_language {
|
Line 1011 sub select_language {
|
$langchoices{$code} = &plainlanguagedescription($id); |
$langchoices{$code} = &plainlanguagedescription($id); |
} |
} |
} |
} |
|
%langchoices = &Apache::lonlocal::texthash(%langchoices); |
return &select_form($selected,$name,\%langchoices); |
return &select_form($selected,$name,\%langchoices); |
} |
} |
|
|
=pod |
=pod |
|
|
|
|
|
=item * &list_languages() |
|
|
|
Returns an array reference that is suitable for use in language prompters. |
|
Each array element is itself a two element array. The first element |
|
is the language code. The second element a descsriptiuon of the |
|
language itself. This is suitable for use in e.g. |
|
&Apache::edit::select_arg (once dereferenced that is). |
|
|
|
=cut |
|
|
|
sub list_languages { |
|
my @lang_choices; |
|
|
|
foreach my $id (&languageids()) { |
|
my $code = &supportedlanguagecode($id); |
|
if ($code) { |
|
my $selector = $supported_codes{$id}; |
|
my $description = &plainlanguagedescription($id); |
|
push (@lang_choices, [$selector, $description]); |
|
} |
|
} |
|
return \@lang_choices; |
|
} |
|
|
|
=pod |
|
|
=item * &linked_select_forms(...) |
=item * &linked_select_forms(...) |
|
|
linked_select_forms returns a string containing a <script></script> block |
linked_select_forms returns a string containing a <script></script> block |
Line 1021 linked_select_forms takes the following
|
Line 1070 linked_select_forms takes the following
|
|
|
=item * $menuorder, the order of values in the first menu |
=item * $menuorder, the order of values in the first menu |
|
|
|
=item * $onchangefirst, additional javascript call to execute for an onchange |
|
event for the first <select> tag |
|
|
|
=item * $onchangesecond, additional javascript call to execute for an onchange |
|
event for the second <select> tag |
|
|
=back |
=back |
|
|
Below is an example of such a hash. Only the 'text', 'default', and |
Below is an example of such a hash. Only the 'text', 'default', and |
Line 1074 sub linked_select_forms {
|
Line 1129 sub linked_select_forms {
|
$secondselectname, |
$secondselectname, |
$hashref, |
$hashref, |
$menuorder, |
$menuorder, |
|
$onchangefirst, |
|
$onchangesecond |
) = @_; |
) = @_; |
my $second = "document.$formname.$secondselectname"; |
my $second = "document.$formname.$secondselectname"; |
my $first = "document.$formname.$firstselectname"; |
my $first = "document.$formname.$firstselectname"; |
Line 1130 function select1_changed() {
|
Line 1187 function select1_changed() {
|
</script> |
</script> |
END |
END |
# output the initial values for the selection lists |
# output the initial values for the selection lists |
$result .= "<select size=\"1\" name=\"$firstselectname\" onchange=\"select1_changed()\">\n"; |
$result .= "<select size=\"1\" name=\"$firstselectname\" onchange=\"select1_changed();$onchangefirst\">\n"; |
my @order = sort(keys(%{$hashref})); |
my @order = sort(keys(%{$hashref})); |
if (ref($menuorder) eq 'ARRAY') { |
if (ref($menuorder) eq 'ARRAY') { |
@order = @{$menuorder}; |
@order = @{$menuorder}; |
Line 1143 END
|
Line 1200 END
|
$result .= "</select>\n"; |
$result .= "</select>\n"; |
my %select2 = %{$hashref->{$firstdefault}->{'select2'}}; |
my %select2 = %{$hashref->{$firstdefault}->{'select2'}}; |
$result .= $middletext; |
$result .= $middletext; |
$result .= "<select size=\"1\" name=\"$secondselectname\">\n"; |
$result .= "<select size=\"1\" name=\"$secondselectname\""; |
|
if ($onchangesecond) { |
|
$result .= ' onchange="'.$onchangesecond.'"'; |
|
} |
|
$result .= ">\n"; |
my $seconddefault = $hashref->{$firstdefault}->{'default'}; |
my $seconddefault = $hashref->{$firstdefault}->{'default'}; |
|
|
my @secondorder = sort(keys(%select2)); |
my @secondorder = sort(keys(%select2)); |
Line 2475 END
|
Line 2536 END
|
return $result; |
return $result; |
} |
} |
|
|
sub authform_authorwarning{ |
sub authform_authorwarning { |
my $result=''; |
my $result=''; |
$result='<i>'. |
$result='<i>'. |
&mt('As a general rule, only authors or co-authors should be '. |
&mt('As a general rule, only authors or co-authors should be '. |
Line 2484 sub authform_authorwarning{
|
Line 2545 sub authform_authorwarning{
|
return $result; |
return $result; |
} |
} |
|
|
sub authform_nochange{ |
sub authform_nochange { |
my %in = ( |
my %in = ( |
formname => 'document.cu', |
formname => 'document.cu', |
kerb_def_dom => 'MSU.EDU', |
kerb_def_dom => 'MSU.EDU', |
@_, |
@_, |
); |
); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
my $result; |
my $result; |
if (keys(%can_assign) == 0) { |
if (!$authnum) { |
$result = &mt('Under you current role you are not permitted to change login settings for this user'); |
$result = &mt('Under your current role you are not permitted to change login settings for this user'); |
} else { |
} else { |
$result = '<label>'.&mt('[_1] Do not change login data', |
$result = '<label>'.&mt('[_1] Do not change login data', |
'<input type="radio" name="login" value="nochange" '. |
'<input type="radio" name="login" value="nochange" '. |
Line 2513 sub authform_kerberos {
|
Line 2574 sub authform_kerberos {
|
); |
); |
my ($check4,$check5,$krbcheck,$krbarg,$krbver,$result,$authtype, |
my ($check4,$check5,$krbcheck,$krbarg,$krbver,$result,$authtype, |
$autharg,$jscall); |
$autharg,$jscall); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
if ($in{'kerb_def_auth'} eq 'krb5') { |
if ($in{'kerb_def_auth'} eq 'krb5') { |
$check5 = ' checked="checked"'; |
$check5 = ' checked="checked"'; |
} else { |
} else { |
Line 2563 sub authform_kerberos {
|
Line 2624 sub authform_kerberos {
|
if (defined($in{'mode'})) { |
if (defined($in{'mode'})) { |
if ($in{'mode'} eq 'modifycourse') { |
if ($in{'mode'} eq 'modifycourse') { |
if ($authnum == 1) { |
if ($authnum == 1) { |
$authtype = '<input type="hidden" name="login" value="krb" />'; |
$authtype = '<input type="radio" name="login" value="krb" />'; |
} |
} |
} |
} |
} |
} |
Line 2575 sub authform_kerberos {
|
Line 2636 sub authform_kerberos {
|
$krbcheck.' />'; |
$krbcheck.' />'; |
} |
} |
if (($can_assign{'krb4'} && $can_assign{'krb5'}) || |
if (($can_assign{'krb4'} && $can_assign{'krb5'}) || |
($can_assign{'krb4'} && !$can_assign{'krb5'} && |
($can_assign{'krb4'} && !$can_assign{'krb5'} && |
$in{'curr_authtype'} eq 'krb5') || |
$in{'curr_authtype'} eq 'krb5') || |
(!$can_assign{'krb4'} && $can_assign{'krb5'} && |
(!$can_assign{'krb4'} && $can_assign{'krb5'} && |
$in{'curr_authtype'} eq 'krb4')) { |
$in{'curr_authtype'} eq 'krb4')) { |
$result .= &mt |
$result .= &mt |
('[_1] Kerberos authenticated with domain [_2] '. |
('[_1] Kerberos authenticated with domain [_2] '. |
Line 2613 sub authform_kerberos {
|
Line 2674 sub authform_kerberos {
|
return $result; |
return $result; |
} |
} |
|
|
sub authform_internal{ |
sub authform_internal { |
my %in = ( |
my %in = ( |
formname => 'document.cu', |
formname => 'document.cu', |
kerb_def_dom => 'MSU.EDU', |
kerb_def_dom => 'MSU.EDU', |
@_, |
@_, |
); |
); |
my ($intcheck,$intarg,$result,$authtype,$autharg,$jscall); |
my ($intcheck,$intarg,$result,$authtype,$autharg,$jscall); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
if (defined($in{'curr_authtype'})) { |
if (defined($in{'curr_authtype'})) { |
if ($in{'curr_authtype'} eq 'int') { |
if ($in{'curr_authtype'} eq 'int') { |
if ($can_assign{'int'}) { |
if ($can_assign{'int'}) { |
Line 2649 sub authform_internal{
|
Line 2710 sub authform_internal{
|
if (defined($in{'mode'})) { |
if (defined($in{'mode'})) { |
if ($in{'mode'} eq 'modifycourse') { |
if ($in{'mode'} eq 'modifycourse') { |
if ($authnum == 1) { |
if ($authnum == 1) { |
$authtype = '<input type="hidden" name="login" value="int" />'; |
$authtype = '<input type="radio" name="login" value="int" />'; |
} |
} |
} |
} |
} |
} |
Line 2668 sub authform_internal{
|
Line 2729 sub authform_internal{
|
return $result; |
return $result; |
} |
} |
|
|
sub authform_local{ |
sub authform_local { |
my %in = ( |
my %in = ( |
formname => 'document.cu', |
formname => 'document.cu', |
kerb_def_dom => 'MSU.EDU', |
kerb_def_dom => 'MSU.EDU', |
@_, |
@_, |
); |
); |
my ($loccheck,$locarg,$result,$authtype,$autharg,$jscall); |
my ($loccheck,$locarg,$result,$authtype,$autharg,$jscall); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
if (defined($in{'curr_authtype'})) { |
if (defined($in{'curr_authtype'})) { |
if ($in{'curr_authtype'} eq 'loc') { |
if ($in{'curr_authtype'} eq 'loc') { |
if ($can_assign{'loc'}) { |
if ($can_assign{'loc'}) { |
Line 2704 sub authform_local{
|
Line 2765 sub authform_local{
|
if (defined($in{'mode'})) { |
if (defined($in{'mode'})) { |
if ($in{'mode'} eq 'modifycourse') { |
if ($in{'mode'} eq 'modifycourse') { |
if ($authnum == 1) { |
if ($authnum == 1) { |
$authtype = '<input type="hidden" name="login" value="loc" />'; |
$authtype = '<input type="radio" name="login" value="loc" />'; |
} |
} |
} |
} |
} |
} |
Line 2722 sub authform_local{
|
Line 2783 sub authform_local{
|
return $result; |
return $result; |
} |
} |
|
|
sub authform_filesystem{ |
sub authform_filesystem { |
my %in = ( |
my %in = ( |
formname => 'document.cu', |
formname => 'document.cu', |
kerb_def_dom => 'MSU.EDU', |
kerb_def_dom => 'MSU.EDU', |
@_, |
@_, |
); |
); |
my ($fsyscheck,$result,$authtype,$autharg,$jscall); |
my ($fsyscheck,$result,$authtype,$autharg,$jscall); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); |
if (defined($in{'curr_authtype'})) { |
if (defined($in{'curr_authtype'})) { |
if ($in{'curr_authtype'} eq 'fsys') { |
if ($in{'curr_authtype'} eq 'fsys') { |
if ($can_assign{'fsys'}) { |
if ($can_assign{'fsys'}) { |
Line 2755 sub authform_filesystem{
|
Line 2816 sub authform_filesystem{
|
if (defined($in{'mode'})) { |
if (defined($in{'mode'})) { |
if ($in{'mode'} eq 'modifycourse') { |
if ($in{'mode'} eq 'modifycourse') { |
if ($authnum == 1) { |
if ($authnum == 1) { |
$authtype = '<input type="hidden" name="login" value="fsys" />'; |
$authtype = '<input type="radio" name="login" value="fsys" />'; |
} |
} |
} |
} |
} |
} |
Line 2986 sub get_related_words {
|
Line 3047 sub get_related_words {
|
untie %thesaurus_db; |
untie %thesaurus_db; |
return @Words; |
return @Words; |
} |
} |
|
############################################################### |
|
# |
|
# Spell checking |
|
# |
|
|
|
=pod |
|
|
|
=head1 Spell checking |
|
|
|
=over 4 |
|
|
|
=item * &check_spelling($wordlist $language) |
|
|
|
Takes a string containing words and feeds it to an external |
|
spellcheck program via a pipeline. Returns a string containing |
|
them mis-spelled words. |
|
|
|
Parameters: |
|
|
|
=over 4 |
|
|
|
=item - $wordlist |
|
|
|
String that will be fed into the spellcheck program. |
|
|
|
=item - $language |
|
|
|
Language string that specifies the language for which the spell |
|
check will be performed. |
|
|
|
=back |
|
|
|
=back |
|
|
|
Note: This sub assumes that aspell is installed. |
|
|
|
|
|
=cut |
|
|
|
|
=pod |
=pod |
|
|
Line 2993 sub get_related_words {
|
Line 3093 sub get_related_words {
|
|
|
=cut |
=cut |
|
|
|
sub check_spelling { |
|
my ($wordlist, $language) = @_; |
|
my @misspellings; |
|
|
|
# Generate the speller and set the langauge. |
|
# if explicitly selected: |
|
|
|
my $speller = Text::Aspell->new; |
|
if ($language) { |
|
$speller->set_option('lang', $language); |
|
} |
|
|
|
# Turn the word list into an array of words by splittingon whitespace |
|
|
|
my @words = split(/\s+/, $wordlist); |
|
|
|
foreach my $word (@words) { |
|
if(! $speller->check($word)) { |
|
push(@misspellings, $word); |
|
} |
|
} |
|
return join(' ', @misspellings); |
|
|
|
} |
|
|
# -------------------------------------------------------------- Plaintext name |
# -------------------------------------------------------------- Plaintext name |
=pod |
=pod |
|
|
Line 3226 sub aboutmewrapper {
|
Line 3351 sub aboutmewrapper {
|
if (!defined($username) && !defined($domain)) { |
if (!defined($username) && !defined($domain)) { |
return; |
return; |
} |
} |
return '<a href="/adm/'.$domain.'/'.$username.'/aboutme?forcestudent=1"'. |
return '<a href="/adm/'.$domain.'/'.$username.'/aboutme"'. |
($target?' target="'.$target.'"':'').($class?' class="'.$class.'"':'').' title="'.&mt("View this user's personal information page").'">'.$link.'</a>'; |
($target?' target="'.$target.'"':'').($class?' class="'.$class.'"':'').' title="'.&mt("View this user's personal information page").'">'.$link.'</a>'; |
} |
} |
|
|
Line 4879 sub CSTR_pageheader {
|
Line 5004 sub CSTR_pageheader {
|
|
|
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; |
my ($udom,$uname,$thisdisfn)= |
my ($udom,$uname,$thisdisfn)= |
($trailfile =~ m{^\Q$londocroot\E/priv/([^/]+)/([^/]+)/(.*)$}); |
($trailfile =~ m{^\Q$londocroot\E/priv/([^/]+)/([^/]+)(?:|/(.*))$}); |
my $formaction = "/priv/$udom/$uname/$thisdisfn"; |
my $formaction = "/priv/$udom/$uname/$thisdisfn"; |
$formaction =~ s{/+}{/}g; |
$formaction =~ s{/+}{/}g; |
|
|
Line 4954 Inputs:
|
Line 5079 Inputs:
|
|
|
=item * $bgcolor, used to override the bgcolor on a webpage to a specific value |
=item * $bgcolor, used to override the bgcolor on a webpage to a specific value |
|
|
=item * $no_inline_link, if true and in remote mode, don't show the |
|
'Switch To Inline Menu' link |
|
|
|
=item * $args, optional argument valid values are |
=item * $args, optional argument valid values are |
no_auto_mt_title -> prevents &mt()ing the title arg |
no_auto_mt_title -> prevents &mt()ing the title arg |
inherit_jsmath -> when creating popup window in a page, |
inherit_jsmath -> when creating popup window in a page, |
should it have jsmath forced on by the |
should it have jsmath forced on by the |
current page |
current page |
|
|
|
=item * $advtoolsref, optional argument, ref to an array containing |
|
inlineremote items to be added in "Functions" menu below |
|
breadcrumbs. |
|
|
=back |
=back |
|
|
Returns: A uniform header for LON-CAPA web pages. |
Returns: A uniform header for LON-CAPA web pages. |
Line 4974 other decorations will be returned.
|
Line 5100 other decorations will be returned.
|
|
|
sub bodytag { |
sub bodytag { |
my ($title,$function,$addentries,$bodyonly,$domain,$forcereg, |
my ($title,$function,$addentries,$bodyonly,$domain,$forcereg, |
$no_nav_bar,$bgcolor,$no_inline_link,$args)=@_; |
$no_nav_bar,$bgcolor,$args,$advtoolsref)=@_; |
|
|
my $public; |
my $public; |
if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) |
if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) |
Line 5016 sub bodytag {
|
Line 5142 sub bodytag {
|
} |
} |
|
|
if (!$realm) { $realm=' '; } |
if (!$realm) { $realm=' '; } |
# Set messages |
|
my $messages=&domainlogo($domain); |
|
|
|
my $extra_body_attr = &make_attr_string($forcereg,\%design); |
my $extra_body_attr = &make_attr_string($forcereg,\%design); |
|
|
Line 5052 sub bodytag {
|
Line 5176 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']); |
&get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); |
|
|
if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { |
if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { |
return $bodytag; |
return $bodytag; |
} |
} |
|
|
if ($env{'request.state'} eq 'construct') { $forcereg=1; } |
|
|
|
unless ($env{'environment.remote'} eq 'on') { |
if ($env{'request.state'} eq 'construct') { $forcereg=1; } |
|
|
# if ($env{'request.state'} eq 'construct') { |
# if ($env{'request.state'} eq 'construct') { |
# $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 |
Line 5067 sub bodytag {
|
Line 5189 sub bodytag {
|
|
|
|
|
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { |
unless ($env{'request.noversionuri'} =~ m{/res/adm/pages/bookmarkmenu/}) { |
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">$name $role<br /> |
<em>$realm</em> $dc_info</div>|; |
<em>$realm</em> $dc_info</div>|; |
|
} |
|
return $bodytag; |
return $bodytag; |
} |
} |
|
|
Line 5099 sub bodytag {
|
Line 5219 sub bodytag {
|
if ($env{'request.state'} eq 'construct') { |
if ($env{'request.state'} eq 'construct') { |
$bodytag .= &Apache::lonmenu::innerregister($forcereg, |
$bodytag .= &Apache::lonmenu::innerregister($forcereg, |
$args->{'bread_crumbs'}); |
$args->{'bread_crumbs'}); |
} elsif ($forcereg) { |
} elsif ($forcereg) { |
$bodytag .= &Apache::lonmenu::innerregister($forcereg); |
$bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, |
|
$args->{'group'}); |
|
} else { |
|
$bodytag .= |
|
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
|
$forcereg,$args->{'group'}, |
|
$args->{'bread_crumbs'}, |
|
$advtoolsref); |
} |
} |
}else{ |
}else{ |
# this is to seperate menu from content when there's no secondary |
# this is to seperate menu from content when there's no secondary |
Line 5110 sub bodytag {
|
Line 5237 sub bodytag {
|
} |
} |
|
|
return $bodytag; |
return $bodytag; |
} |
|
|
|
# |
|
# Top frame rendering, Remote is up |
|
# |
|
|
|
my $imgsrc = $img; |
|
if ($img =~ /^\/adm/) { |
|
$imgsrc = &lonhttpdurl($img); |
|
} |
|
my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />'; |
|
|
|
# Explicit link to get inline menu |
|
my $menu= ($no_inline_link?'' |
|
:'<a href="/adm/remote?action=collapse" target="_top">'.&mt('Switch to Inline Menu Mode').'</a>'); |
|
|
|
if ($dc_info) { |
|
$dc_info = qq|<span class="LC_cusr_subheading">($dc_info)</span>|; |
|
} |
|
|
|
unless ($env{'form.inhibitmenu'}) { |
|
$bodytag .= qq|<div id="LC_nav_bar">$name $role</div> |
|
<ol class="LC_primary_menu LC_right"> |
|
<li>$menu</li> |
|
</ol><div id="LC_realm"> $realm $dc_info</div>|; |
|
} |
|
my $funclist; |
|
if ($env{'request.state'} eq 'construct') { |
|
if (!$public){ |
|
if ($env{'request.state'} eq 'construct') { |
|
$funclist = &Apache::lonhtmlcommon::scripttag( |
|
&Apache::lonmenu::utilityfunctions(), 'start'). |
|
&Apache::lonhtmlcommon::scripttag('','end'). |
|
&Apache::lonmenu::innerregister($forcereg, |
|
$args->{'bread_crumbs'}); |
|
} |
|
} |
|
} |
|
return(<<ENDBODY); |
|
$bodytag |
|
<table id="LC_title_bar" class="LC_with_remote"> |
|
<tr><td>$upperleft</td> |
|
<td>$messages </td> |
|
</tr> |
|
<tr><td>$titleinfo $dc_info $menu</td> |
|
</tr> |
|
</table> |
|
$funclist |
|
ENDBODY |
|
} |
} |
|
|
sub dc_courseid_toggle { |
sub dc_courseid_toggle { |
Line 5190 sub make_attr_string {
|
Line 5268 sub make_attr_string {
|
delete($attr_ref->{$key}); |
delete($attr_ref->{$key}); |
} |
} |
} |
} |
if ($env{'environment.remote'} eq 'on') { |
$attr_ref->{'onload'} = $on_load; |
$attr_ref->{'onload'} = |
$attr_ref->{'onunload'}= $on_unload; |
&Apache::lonmenu::loadevents(). $on_load; |
|
$attr_ref->{'onunload'}= |
|
&Apache::lonmenu::unloadevents().$on_unload; |
|
} else { |
|
$attr_ref->{'onload'} = $on_load; |
|
$attr_ref->{'onunload'}= $on_unload; |
|
} |
|
} |
} |
|
|
my $attr_string; |
my $attr_string; |
Line 5371 form, .inline {
|
Line 5442 form, .inline {
|
|
|
.LC_error { |
.LC_error { |
color: red; |
color: red; |
font-size: larger; |
|
} |
} |
|
|
.LC_warning, |
.LC_warning { |
|
color: darkorange; |
|
} |
|
|
.LC_diff_removed { |
.LC_diff_removed { |
color: red; |
color: red; |
} |
} |
Line 5537 td.LC_table_cell_checkbox {
|
Line 5610 td.LC_table_cell_checkbox {
|
text-align: left; |
text-align: left; |
} |
} |
|
|
.LC_head_subbox { |
.LC_head_subbox, .LC_actionbox { |
clear:both; |
clear:both; |
background: #F8F8F8; /* $sidebg; */ |
background: #F8F8F8; /* $sidebg; */ |
border: 1px solid $sidebg; |
border: 1px solid $sidebg; |
margin: 0 0 10px 0; |
margin: 0 0 10px 0; |
padding: 3px; |
padding: 3px; |
text-align: left; |
text-align: left; |
} |
} |
Line 5674 table.LC_nested tr.LC_empty_row td {
|
Line 5747 table.LC_nested tr.LC_empty_row td {
|
padding: 8px; |
padding: 8px; |
} |
} |
|
|
table.LC_data_table tr.LC_empty_row td { |
table.LC_data_table tr.LC_empty_row td, |
|
table.LC_data_table tr.LC_footer_row td { |
background-color: $sidebg; |
background-color: $sidebg; |
} |
} |
|
|
Line 6236 div.LC_docs_entry_move {
|
Line 6310 div.LC_docs_entry_move {
|
|
|
table.LC_data_table tr > td.LC_docs_entry_commands, |
table.LC_data_table tr > td.LC_docs_entry_commands, |
table.LC_data_table tr > td.LC_docs_entry_parameter { |
table.LC_data_table tr > td.LC_docs_entry_parameter { |
background: #DDDDDD; |
|
font-size: x-small; |
font-size: x-small; |
} |
} |
|
|
Line 6609 ol.LC_docs_parameters li.LC_docs_paramet
|
Line 6682 ol.LC_docs_parameters li.LC_docs_paramet
|
} |
} |
|
|
ul#LC_secondary_menu { |
ul#LC_secondary_menu { |
clear: both; |
clear: right; |
color: $fontmenu; |
color: $fontmenu; |
background: $tabbg; |
background: $tabbg; |
list-style: none; |
list-style: none; |
Line 6624 ul#LC_secondary_menu li {
|
Line 6697 ul#LC_secondary_menu li {
|
font-weight: bold; |
font-weight: bold; |
line-height: 1.8em; |
line-height: 1.8em; |
border-right: 1px solid black; |
border-right: 1px solid black; |
vertical-align: middle; |
|
float: left; |
float: left; |
} |
} |
|
|
Line 7110 ul.LC_funclist li {
|
Line 7182 ul.LC_funclist li {
|
cursor:pointer; |
cursor:pointer; |
} |
} |
|
|
|
/* |
|
styles used by TTH when "Default set of options to pass to tth/m |
|
when converting TeX" in course settings has been set |
|
|
|
option passed: -t |
|
|
|
*/ |
|
|
|
td div.comp { margin-top: -0.6ex; margin-bottom: -1ex;} |
|
td div.comb { margin-top: -0.6ex; margin-bottom: -.6ex;} |
|
td div.hrcomp { line-height: 0.9; margin-top: -0.8ex; margin-bottom: -1ex;} |
|
td div.norm {line-height:normal;} |
|
|
|
/* |
|
option passed -y3 |
|
*/ |
|
|
|
span.roman {font-family: serif; font-style: normal; font-weight: normal;} |
|
span.overacc2 {position: relative; left: .8em; top: -1.2ex;} |
|
span.overacc1 {position: relative; left: .6em; top: -1.2ex;} |
|
|
END |
END |
} |
} |
|
|
Line 7163 sub headtag {
|
Line 7256 sub headtag {
|
if (!$args->{'frameset'}) { |
if (!$args->{'frameset'}) { |
$result .= &Apache::lonhtmlcommon::htmlareaheaders(); |
$result .= &Apache::lonhtmlcommon::htmlareaheaders(); |
} |
} |
if ($args->{'force_register'}) { |
if ($args->{'force_register'} && $env{'request.noversionuri'} !~ m{^/res/adm/pages/}) { |
$result .= &Apache::lonmenu::registerurl(1); |
$result .= Apache::lonxml::display_title(); |
} |
} |
if (!$args->{'no_nav_bar'} |
if (!$args->{'no_nav_bar'} |
&& !$args->{'only_body'} |
&& !$args->{'only_body'} |
Line 7373 $args - additional optional args support
|
Line 7466 $args - additional optional args support
|
skip_phases -> hash ref of |
skip_phases -> hash ref of |
head -> skip the <html><head> generation |
head -> skip the <html><head> generation |
body -> skip all <body> generation |
body -> skip all <body> generation |
no_inline_link -> if true and in remote mode, don't show the |
|
'Switch To Inline Menu' link |
|
no_auto_mt_title -> prevent &mt()ing the title arg |
no_auto_mt_title -> prevent &mt()ing the title arg |
inherit_jsmath -> when creating popup window in a page, |
inherit_jsmath -> when creating popup window in a page, |
should it have jsmath forced on by the |
should it have jsmath forced on by the |
current page |
current page |
bread_crumbs -> Array containing breadcrumbs |
bread_crumbs -> Array containing breadcrumbs |
bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs |
bread_crumbs_component -> if exists show it as headline else show only the breadcrumbs |
|
group -> includes the current group, if page is for a |
|
specific group |
|
|
=back |
=back |
|
|
Line 7393 sub start_page {
|
Line 7486 sub start_page {
|
#&Apache::lonnet::logthis("start_page ".join(':',caller(0))); |
#&Apache::lonnet::logthis("start_page ".join(':',caller(0))); |
|
|
$env{'internal.start_page'}++; |
$env{'internal.start_page'}++; |
my $result; |
my ($result,@advtools); |
|
|
if (! exists($args->{'skip_phases'}{'head'}) ) { |
if (! exists($args->{'skip_phases'}{'head'}) ) { |
$result .= &xml_begin() . &headtag($title, $head_extra, $args); |
$result .= &xml_begin() . &headtag($title, $head_extra, $args); |
Line 7410 sub start_page {
|
Line 7503 sub start_page {
|
$args->{'function'}, $args->{'add_entries'}, |
$args->{'function'}, $args->{'add_entries'}, |
$args->{'only_body'}, $args->{'domain'}, |
$args->{'only_body'}, $args->{'domain'}, |
$args->{'force_register'}, $args->{'no_nav_bar'}, |
$args->{'force_register'}, $args->{'no_nav_bar'}, |
$args->{'bgcolor'}, $args->{'no_inline_link'}, |
$args->{'bgcolor'}, $args, |
$args); |
\@advtools); |
} |
} |
} |
} |
|
|
Line 7440 sub start_page {
|
Line 7533 sub start_page {
|
&Apache::lonhtmlcommon::add_breadcrumb($crumb); |
&Apache::lonhtmlcommon::add_breadcrumb($crumb); |
} |
} |
} |
} |
|
# if @advtools array contains items add then to the breadcrumbs |
|
if (@advtools > 0) { |
|
&Apache::lonmenu::advtools_crumbs(@advtools); |
|
} |
|
|
#if bread_crumbs_component exists show it as headline else show only the breadcrumbs |
#if bread_crumbs_component exists show it as headline else show only the breadcrumbs |
if(exists($args->{'bread_crumbs_component'})){ |
if(exists($args->{'bread_crumbs_component'})){ |
Line 7835 sub simple_error_page {
|
Line 7932 sub simple_error_page {
|
my ($r,$title,$msg) = @_; |
my ($r,$title,$msg) = @_; |
my $page = |
my $page = |
&Apache::loncommon::start_page($title). |
&Apache::loncommon::start_page($title). |
&mt($msg). |
'<p class="LC_error">'.&mt($msg).'</p>'. |
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
if (ref($r)) { |
if (ref($r)) { |
$r->print($page); |
$r->print($page); |
Line 8128 sub get_sections {
|
Line 8225 sub get_sections {
|
my %sectioncount; |
my %sectioncount; |
my $now = time; |
my $now = time; |
|
|
if (!defined($possible_roles) || (grep(/^st$/,@$possible_roles))) { |
my $check_students = 1; |
|
my $only_students = 0; |
|
if (ref($possible_roles) eq 'ARRAY') { |
|
if (grep(/^st$/,@{$possible_roles})) { |
|
if (@{$possible_roles} == 1) { |
|
$only_students = 1; |
|
} |
|
} else { |
|
$check_students = 0; |
|
} |
|
} |
|
|
|
if ($check_students) { |
my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum); |
my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum); |
my $sec_index = &Apache::loncoursedata::CL_SECTION(); |
my $sec_index = &Apache::loncoursedata::CL_SECTION(); |
my $status_index = &Apache::loncoursedata::CL_STATUS(); |
my $status_index = &Apache::loncoursedata::CL_STATUS(); |
Line 8155 sub get_sections {
|
Line 8264 sub get_sections {
|
} |
} |
} |
} |
} |
} |
|
if ($only_students) { |
|
return %sectioncount; |
|
} |
my %courseroles = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); |
my %courseroles = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); |
foreach my $user (sort(keys(%courseroles))) { |
foreach my $user (sort(keys(%courseroles))) { |
if ($user !~ /^(\w{2})/) { next; } |
if ($user !~ /^(\w{2})/) { next; } |
Line 8952 sub user_rule_formats {
|
Line 9064 sub user_rule_formats {
|
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($domain,$check); |
my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($domain,$check); |
if ((ref($rules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) { |
if ((ref($rules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) { |
if (@{$ruleorder} > 0) { |
if (@{$ruleorder} > 0) { |
$output = '<br />'.&mt("$text{$check} with the following format(s) may <span class=\"LC_cusr_emph\">only</span> be used for verified users at [_1]:",$domdesc).' <ul>'; |
$output = '<br />'. |
|
&mt($text{$check}.' with the following format(s) may [_1]only[_2] be used for verified users at [_3]:', |
|
'<span class="LC_cusr_emph">','</span>',$domdesc). |
|
' <ul>'; |
foreach my $rule (@{$ruleorder}) { |
foreach my $rule (@{$ruleorder}) { |
if (ref($curr_rules) eq 'ARRAY') { |
if (ref($curr_rules) eq 'ARRAY') { |
if (grep(/^\Q$rule\E$/,@{$curr_rules})) { |
if (grep(/^\Q$rule\E$/,@{$curr_rules})) { |
Line 9470 sub ask_for_embedded_content {
|
Line 9585 sub ask_for_embedded_content {
|
$toplevel = $url; |
$toplevel = $url; |
if ($args->{'context'} eq 'paste') { |
if ($args->{'context'} eq 'paste') { |
($cdom,$cnum) = ($url =~ m{^\Q/uploaded/\E($match_domain)/($match_courseid)/}); |
($cdom,$cnum) = ($url =~ m{^\Q/uploaded/\E($match_domain)/($match_courseid)/}); |
($path) = |
($path) = |
($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/}); |
($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{^/}{}; |
} |
} |
} |
} |
} 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'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
Line 9664 sub ask_for_embedded_content {
|
Line 9779 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); |
} |
} |
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') { |
Line 11285 sub process_extracted_files {
|
Line 11400 sub process_extracted_files {
|
if ($env{'form.folderpath'}) { |
if ($env{'form.folderpath'}) { |
my @items = split('&',$env{'form.folderpath'}); |
my @items = split('&',$env{'form.folderpath'}); |
$folders{'0'} = $items[-2]; |
$folders{'0'} = $items[-2]; |
$containers{'0'}='sequence'; |
if ($env{'form.folderpath'} =~ /\:1$/) { |
} elsif ($env{'form.pagepath'}) { |
$containers{'0'}='page'; |
my @items = split('&',$env{'form.pagepath'}); |
} else { |
$folders{'0'} = $items[-2]; |
$containers{'0'}='sequence'; |
$containers{'0'}='page'; |
} |
} |
} |
my @archdirs = &get_env_multiple('form.archive_directory'); |
my @archdirs = &get_env_multiple('form.archive_directory'); |
if ($numitems) { |
if ($numitems) { |
Line 11407 sub process_extracted_files {
|
Line 11522 sub process_extracted_files {
|
} |
} |
} |
} |
} else { |
} else { |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
} |
} |
} |
} |
for (my $i=1; $i<=$numitems; $i++) { |
for (my $i=1; $i<=$numitems; $i++) { |
Line 11429 sub process_extracted_files {
|
Line 11544 sub process_extracted_files {
|
} |
} |
if ($itemidx eq '') { |
if ($itemidx eq '') { |
$itemidx = 0; |
$itemidx = 0; |
} |
} |
if (grep(/^\Q$referrer{$i}\E$/,@archdirs)) { |
if (grep(/^\Q$referrer{$i}\E$/,@archdirs)) { |
if ($mapinner{$referrer{$i}}) { |
if ($mapinner{$referrer{$i}}) { |
$fullpath = "$prefix$dir/$docstype/$mapinner{$referrer{$i}}"; |
$fullpath = "$prefix$dir/$docstype/$mapinner{$referrer{$i}}"; |
Line 11476 sub process_extracted_files {
|
Line 11591 sub process_extracted_files {
|
$showpath = "$relpath/$title"; |
$showpath = "$relpath/$title"; |
} else { |
} else { |
$showpath = "/$title"; |
$showpath = "/$title"; |
} |
} |
$result .= '<li>'.&mt('[_1] included as a dependency',$showpath).'</li>'."\n"; |
$result .= '<li>'.&mt('[_1] included as a dependency',$showpath).'</li>'."\n"; |
} |
} |
unless ($ishome) { |
unless ($ishome) { |
my $fetch = "$fullpath/$title"; |
my $fetch = "$fullpath/$title"; |
$fetch =~ s/^\Q$prefix$dir\E//; |
$fetch =~ s/^\Q$prefix$dir\E//; |
$prompttofetch{$fetch} = 1; |
$prompttofetch{$fetch} = 1; |
} |
} |
} |
} |
Line 11491 sub process_extracted_files {
|
Line 11606 sub process_extracted_files {
|
$path,$env{'form.archive_content_'.$referrer{$i}}).'<br />'; |
$path,$env{'form.archive_content_'.$referrer{$i}}).'<br />'; |
} |
} |
} else { |
} else { |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
$warning .= &mt('Item extracted from archive: [_1] has unexpected path.',$path).'<br />'; |
} |
} |
} |
} |
if (keys(%todelete)) { |
if (keys(%todelete)) { |
Line 11550 sub cleanup_empty_dirs {
|
Line 11665 sub cleanup_empty_dirs {
|
my $numitems = 0; |
my $numitems = 0; |
foreach my $item (@dircontents) { |
foreach my $item (@dircontents) { |
if (-d "$path/$item") { |
if (-d "$path/$item") { |
&recurse_dirs("$path/$item"); |
&cleanup_empty_dirs("$path/$item"); |
if (-e "$path/$item") { |
if (-e "$path/$item") { |
$numitems ++; |
$numitems ++; |
} |
} |
Line 13099 sub commit_customrole {
|
Line 13214 sub commit_customrole {
|
} |
} |
|
|
sub commit_standardrole { |
sub commit_standardrole { |
my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_; |
my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context,$credits) = @_; |
my ($output,$logmsg,$linefeed); |
my ($output,$logmsg,$linefeed); |
if ($context eq 'auto') { |
if ($context eq 'auto') { |
$linefeed = "\n"; |
$linefeed = "\n"; |
Line 13108 sub commit_standardrole {
|
Line 13223 sub commit_standardrole {
|
} |
} |
if ($three eq 'st') { |
if ($three eq 'st') { |
my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end, |
my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end, |
$one,$two,$sec,$context); |
$one,$two,$sec,$context,$credits); |
if (($result =~ /^error/) || ($result eq 'not_in_class') || |
if (($result =~ /^error/) || ($result eq 'not_in_class') || |
($result eq 'unknown_course') || ($result eq 'refused')) { |
($result eq 'unknown_course') || ($result eq 'refused')) { |
$output = $logmsg.' '.&mt('Error: ').$result."\n"; |
$output = $logmsg.' '.&mt('Error: ').$result."\n"; |
Line 13139 sub commit_standardrole {
|
Line 13254 sub commit_standardrole {
|
} |
} |
|
|
sub commit_studentrole { |
sub commit_studentrole { |
my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_; |
my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context, |
|
$credits) = @_; |
my ($result,$linefeed,$oldsecurl,$newsecurl); |
my ($result,$linefeed,$oldsecurl,$newsecurl); |
if ($context eq 'auto') { |
if ($context eq 'auto') { |
$linefeed = "\n"; |
$linefeed = "\n"; |
Line 13186 sub commit_studentrole {
|
Line 13302 sub commit_studentrole {
|
} |
} |
} |
} |
if (($expire_role_result eq 'ok') || ($secchange == 0)) { |
if (($expire_role_result eq 'ok') || ($secchange == 0)) { |
$modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid,'',$context); |
$modify_section_result = |
|
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef, |
|
undef,undef,undef,$sec, |
|
$end,$start,'','',$cid, |
|
'',$context,$credits); |
if ($modify_section_result =~ /^ok/) { |
if ($modify_section_result =~ /^ok/) { |
if ($secchange == 1) { |
if ($secchange == 1) { |
if ($sec eq '') { |
if ($sec eq '') { |
Line 13208 sub commit_studentrole {
|
Line 13328 sub commit_studentrole {
|
} |
} |
} |
} |
} else { |
} else { |
if ($secchange) { |
if ($secchange) { |
$$logmsg .= &mt('Error when attempting section change for [_1] from old section "[_2]" to new section: "[_3]" in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed; |
$$logmsg .= &mt('Error when attempting section change for [_1] from old section "[_2]" to new section: "[_3]" in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed; |
} else { |
} else { |
$$logmsg .= &mt('Error when attempting to modify role for [_1] for section: "[_2]" in course [_3] -error:',$uname,$sec,$cid).' '.$modify_section_result.$linefeed; |
$$logmsg .= &mt('Error when attempting to modify role for [_1] for section: "[_2]" in course [_3] -error:',$uname,$sec,$cid).' '.$modify_section_result.$linefeed; |
Line 13217 sub commit_studentrole {
|
Line 13337 sub commit_studentrole {
|
$result = $modify_section_result; |
$result = $modify_section_result; |
} elsif ($secchange == 1) { |
} elsif ($secchange == 1) { |
if ($oldsec eq '') { |
if ($oldsec eq '') { |
$$logmsg .= &mt('Error when attempting to expire existing role without a section for [_1] in course [_3] -error: ',$uname,$cid).' '.$expire_role_result.$linefeed; |
$$logmsg .= &mt('Error when attempting to expire existing role without a section for [_1] in course [_2] -error: ',$uname,$cid).' '.$expire_role_result.$linefeed; |
} else { |
} else { |
$$logmsg .= &mt('Error when attempting to expire existing role for [_1] in section [_2] in course [_3] -error: ',$uname,$oldsec,$cid).' '.$expire_role_result.$linefeed; |
$$logmsg .= &mt('Error when attempting to expire existing role for [_1] in section [_2] in course [_3] -error: ',$uname,$oldsec,$cid).' '.$expire_role_result.$linefeed; |
} |
} |
Line 13243 sub commit_studentrole {
|
Line 13363 sub commit_studentrole {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub show_role_extent { |
|
my ($scope,$context,$role) = @_; |
|
$scope =~ s{^/}{}; |
|
my @courseroles = &Apache::lonuserutils::roles_by_context('course',1); |
|
push(@courseroles,'co'); |
|
my @authorroles = &Apache::lonuserutils::roles_by_context('author'); |
|
if (($context eq 'course') || (grep(/^\Q$role\E/,@courseroles))) { |
|
$scope =~ s{/}{_}; |
|
return '<span class="LC_cusr_emph">'.$env{'course.'.$scope.'.description'}.'</span>'; |
|
} elsif (($context eq 'author') || (grep(/^\Q$role\E/,@authorroles))) { |
|
my ($audom,$auname) = split(/\//,$scope); |
|
return &mt('[_1] Author Space','<span class="LC_cusr_emph">'. |
|
&Apache::loncommon::plainname($auname,$audom).'</span>'); |
|
} else { |
|
$scope =~ s{/$}{}; |
|
return &mt('Domain: [_1]','<span class="LC_cusr_emph">'. |
|
&Apache::lonnet::domain($scope,'description').'</span>'); |
|
} |
|
} |
|
|
############################################################ |
############################################################ |
############################################################ |
############################################################ |
|
|
Line 13435 sub construct_course {
|
Line 13575 sub construct_course {
|
} else { |
} else { |
$cenv{'internal.courseowner'} = $args->{'curruser'}; |
$cenv{'internal.courseowner'} = $args->{'curruser'}; |
} |
} |
|
if ($args->{'defaultcredits'}) { |
|
$cenv{'internal.defaultcredits'} = $args->{'defaultcredits'}; |
|
} |
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'} = ''; |
Line 13884 sub init_user_environment {
|
Line 14027 sub init_user_environment {
|
\%userenv,\%domdef,\%is_adv); |
\%userenv,\%domdef,\%is_adv); |
} |
} |
|
|
|
$userenv{'canrequest.author'} = |
|
&Apache::lonnet::usertools_access($username,$domain,'requestauthor', |
|
'reload','requestauthor', |
|
\%userenv,\%domdef,\%is_adv); |
|
my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'], |
|
$domain,$username); |
|
my $reqstatus = $reqauthor{'author_status'}; |
|
if ($reqstatus eq 'approval' || $reqstatus eq 'approved') { |
|
if (ref($reqauthor{'author'}) eq 'HASH') { |
|
$userenv{'requestauthorqueued'} = $reqstatus.':'. |
|
$reqauthor{'author'}{'timestamp'}; |
|
} |
|
} |
|
|
$env{'user.environment'} = "$lonids/$cookie.id"; |
$env{'user.environment'} = "$lonids/$cookie.id"; |
|
|
if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id", |
if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id", |
Line 14035 sub update_content_constraints {
|
Line 14192 sub update_content_constraints {
|
return; |
return; |
} |
} |
|
|
|
sub allmaps_incourse { |
|
my ($cdom,$cnum,$chome,$cid) = @_; |
|
if ($cdom eq '' || $cnum eq '' || $chome eq '' || $cid eq '') { |
|
$cid = $env{'request.course.id'}; |
|
$cdom = $env{'course.'.$cid.'.domain'}; |
|
$cnum = $env{'course.'.$cid.'.num'}; |
|
$chome = $env{'course.'.$cid.'.home'}; |
|
} |
|
my %allmaps = (); |
|
my $lastchange = |
|
&Apache::lonnet::get_coursechange($cdom,$cnum); |
|
if ($lastchange > $env{'request.course.tied'}) { |
|
my ($furl,$ferr) = &Apache::lonuserstate::readmap("$cdom/$cnum"); |
|
unless ($ferr) { |
|
&update_content_constraints($cdom,$cnum,$chome,$cid); |
|
} |
|
} |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (defined($navmap)) { |
|
foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_map() },1,0,1)) { |
|
$allmaps{$res->src()} = 1; |
|
} |
|
} |
|
return \%allmaps; |
|
} |
|
|
sub parse_supplemental_title { |
sub parse_supplemental_title { |
my ($title) = @_; |
my ($title) = @_; |
|
|
Line 14058 sub parse_supplemental_title {
|
Line 14241 sub parse_supplemental_title {
|
return $title; |
return $title; |
} |
} |
|
|
|
sub symb_to_docspath { |
|
my ($symb) = @_; |
|
return unless ($symb); |
|
my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($symb); |
|
if ($resurl=~/\.(sequence|page)$/) { |
|
$mapurl=$resurl; |
|
} elsif ($resurl eq 'adm/navmaps') { |
|
$mapurl=$env{'course.'.$env{'request.course.id'}.'.url'}; |
|
} |
|
my $mapresobj; |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
if (ref($navmap)) { |
|
$mapresobj = $navmap->getResourceByUrl($mapurl); |
|
} |
|
$mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1}; |
|
my $type=$2; |
|
my $path; |
|
if (ref($mapresobj)) { |
|
my $pcslist = $mapresobj->map_hierarchy(); |
|
if ($pcslist ne '') { |
|
foreach my $pc (split(/,/,$pcslist)) { |
|
next if ($pc <= 1); |
|
my $res = $navmap->getByMapPc($pc); |
|
if (ref($res)) { |
|
my $thisurl = $res->src(); |
|
$thisurl=~s{^.*/([^/]+)\.\w+$}{$1}; |
|
my $thistitle = $res->title(); |
|
$path .= '&'. |
|
&Apache::lonhtmlcommon::entity_encode($thisurl).'&'. |
|
&Apache::lonhtmlcommon::entity_encode($thistitle). |
|
':'.$res->randompick(). |
|
':'.$res->randomout(). |
|
':'.$res->encrypted(). |
|
':'.$res->randomorder(). |
|
':'.$res->is_page(); |
|
} |
|
} |
|
} |
|
$path =~ s/^\&//; |
|
my $maptitle = $mapresobj->title(); |
|
if ($mapurl eq 'default') { |
|
$maptitle = 'Main Course Documents'; |
|
} |
|
$path .= (($path ne '')? '&' : ''). |
|
&Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
|
&Apache::lonhtmlcommon::entity_encode($maptitle). |
|
':'.$mapresobj->randompick(). |
|
':'.$mapresobj->randomout(). |
|
':'.$mapresobj->encrypted(). |
|
':'.$mapresobj->randomorder(). |
|
':'.$mapresobj->is_page(); |
|
} else { |
|
my $maptitle = &Apache::lonnet::gettitle($mapurl); |
|
my $ispage = (($type eq 'page')? 1 : ''); |
|
if ($mapurl eq 'default') { |
|
$maptitle = 'Main Course Documents'; |
|
} |
|
$path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'. |
|
&Apache::lonhtmlcommon::entity_encode($maptitle).':::::'.$ispage; |
|
} |
|
unless ($mapurl eq 'default') { |
|
$path = 'default&'. |
|
&Apache::lonhtmlcommon::entity_encode('Main Course Documents'). |
|
':::::&'.$path; |
|
} |
|
return $path; |
|
} |
|
|
|
sub captcha_display { |
|
my ($context,$lonhost) = @_; |
|
my ($output,$error); |
|
my ($captcha,$pubkey,$privkey) = &get_captcha_config($context,$lonhost); |
|
if ($captcha eq 'original') { |
|
$output = &create_captcha(); |
|
unless ($output) { |
|
$error = 'captcha'; |
|
} |
|
} elsif ($captcha eq 'recaptcha') { |
|
$output = &create_recaptcha($pubkey); |
|
unless ($output) { |
|
$error = 'recaptcha'; |
|
} |
|
} |
|
return ($output,$error); |
|
} |
|
|
|
sub captcha_response { |
|
my ($context,$lonhost) = @_; |
|
my ($captcha_chk,$captcha_error); |
|
my ($captcha,$pubkey,$privkey) = &get_captcha_config($context,$lonhost); |
|
if ($captcha eq 'original') { |
|
($captcha_chk,$captcha_error) = &check_captcha(); |
|
} elsif ($captcha eq 'recaptcha') { |
|
$captcha_chk = &check_recaptcha($privkey); |
|
} else { |
|
$captcha_chk = 1; |
|
} |
|
return ($captcha_chk,$captcha_error); |
|
} |
|
|
|
sub get_captcha_config { |
|
my ($context,$lonhost) = @_; |
|
my ($captcha,$pubkey,$privkey,$hashtocheck); |
|
my $hostname = &Apache::lonnet::hostname($lonhost); |
|
my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname); |
|
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
|
if ($context eq 'usercreation') { |
|
my %domconfig = &Apache::lonnet::get_dom('configuration',[$context],$serverhomedom); |
|
if (ref($domconfig{$context}) eq 'HASH') { |
|
$hashtocheck = $domconfig{$context}{'cancreate'}; |
|
if (ref($hashtocheck) eq 'HASH') { |
|
if ($hashtocheck->{'captcha'} eq 'recaptcha') { |
|
if (ref($hashtocheck->{'recaptchakeys'}) eq 'HASH') { |
|
$pubkey = $hashtocheck->{'recaptchakeys'}{'public'}; |
|
$privkey = $hashtocheck->{'recaptchakeys'}{'private'}; |
|
} |
|
if ($privkey && $pubkey) { |
|
$captcha = 'recaptcha'; |
|
} else { |
|
$captcha = 'original'; |
|
} |
|
} elsif ($hashtocheck->{'captcha'} ne 'notused') { |
|
$captcha = 'original'; |
|
} |
|
} |
|
} else { |
|
$captcha = 'captcha'; |
|
} |
|
} elsif ($context eq 'login') { |
|
my %domconfhash = &Apache::loncommon::get_domainconf($serverhomedom); |
|
if ($domconfhash{$serverhomedom.'.login.captcha'} eq 'recaptcha') { |
|
$pubkey = $domconfhash{$serverhomedom.'.login.recaptchakeys_public'}; |
|
$privkey = $domconfhash{$serverhomedom.'.login.recaptchakeys_private'}; |
|
if ($privkey && $pubkey) { |
|
$captcha = 'recaptcha'; |
|
} else { |
|
$captcha = 'original'; |
|
} |
|
} elsif ($domconfhash{$serverhomedom.'.login.captcha'} eq 'original') { |
|
$captcha = 'original'; |
|
} |
|
} |
|
return ($captcha,$pubkey,$privkey); |
|
} |
|
|
|
sub create_captcha { |
|
my %captcha_params = &captcha_settings(); |
|
my ($output,$maxtries,$tries) = ('',10,0); |
|
while ($tries < $maxtries) { |
|
$tries ++; |
|
my $captcha = Authen::Captcha->new ( |
|
output_folder => $captcha_params{'output_dir'}, |
|
data_folder => $captcha_params{'db_dir'}, |
|
); |
|
my $md5sum = $captcha->generate_code($captcha_params{'numchars'}); |
|
|
|
if (-e $Apache::lonnet::perlvar{'lonCaptchaDir'}.'/'.$md5sum.'.png') { |
|
$output = '<input type="hidden" name="crypt" value="'.$md5sum.'" />'."\n". |
|
&mt('Type in the letters/numbers shown below').' '. |
|
'<input type="text" size="5" name="code" value="" /><br />'. |
|
'<img src="'.$captcha_params{'www_output_dir'}.'/'.$md5sum.'.png" />'; |
|
last; |
|
} |
|
} |
|
return $output; |
|
} |
|
|
|
sub captcha_settings { |
|
my %captcha_params = ( |
|
output_dir => $Apache::lonnet::perlvar{'lonCaptchaDir'}, |
|
www_output_dir => "/captchaspool", |
|
db_dir => $Apache::lonnet::perlvar{'lonCaptchaDb'}, |
|
numchars => '5', |
|
); |
|
return %captcha_params; |
|
} |
|
|
|
sub check_captcha { |
|
my ($captcha_chk,$captcha_error); |
|
my $code = $env{'form.code'}; |
|
my $md5sum = $env{'form.crypt'}; |
|
my %captcha_params = &captcha_settings(); |
|
my $captcha = Authen::Captcha->new( |
|
output_folder => $captcha_params{'output_dir'}, |
|
data_folder => $captcha_params{'db_dir'}, |
|
); |
|
$captcha_chk = $captcha->check_code($code,$md5sum); |
|
my %captcha_hash = ( |
|
0 => 'Code not checked (file error)', |
|
-1 => 'Failed: code expired', |
|
-2 => 'Failed: invalid code (not in database)', |
|
-3 => 'Failed: invalid code (code does not match crypt)', |
|
); |
|
if ($captcha_chk != 1) { |
|
$captcha_error = $captcha_hash{$captcha_chk} |
|
} |
|
return ($captcha_chk,$captcha_error); |
|
} |
|
|
|
sub create_recaptcha { |
|
my ($pubkey) = @_; |
|
my $captcha = Captcha::reCAPTCHA->new; |
|
return $captcha->get_options_setter({theme => 'white'})."\n". |
|
$captcha->get_html($pubkey). |
|
&mt('If either word is hard to read, [_1] will replace them.', |
|
'<image src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />'). |
|
'<br /><br />'; |
|
} |
|
|
|
sub check_recaptcha { |
|
my ($privkey) = @_; |
|
my $captcha_chk; |
|
my $captcha = Captcha::reCAPTCHA->new; |
|
my $captcha_result = |
|
$captcha->check_answer( |
|
$privkey, |
|
$ENV{'REMOTE_ADDR'}, |
|
$env{'form.recaptcha_challenge_field'}, |
|
$env{'form.recaptcha_response_field'}, |
|
); |
|
if ($captcha_result->{is_valid}) { |
|
$captcha_chk = 1; |
|
} |
|
return $captcha_chk; |
|
} |
|
|
=pod |
=pod |
|
|
=back |
=back |