version 1.1075.2.94, 2015/05/11 16:07:35
|
version 1.1075.2.116, 2016/10/30 18:04:58
|
Line 72 use Apache::lonuserstate();
|
Line 72 use Apache::lonuserstate();
|
use Apache::courseclassifier(); |
use Apache::courseclassifier(); |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use DateTime::TimeZone; |
use DateTime::TimeZone; |
use DateTime::Locale::Catalog; |
use DateTime::Locale; |
use Encode(); |
use Encode(); |
use Authen::Captcha; |
use Authen::Captcha; |
use Captcha::reCAPTCHA; |
use Captcha::reCAPTCHA; |
|
use JSON::DWIW; |
|
use LWP::UserAgent; |
use Crypt::DES; |
use Crypt::DES; |
use DynaLoader; # for Crypt::DES version |
use DynaLoader; # for Crypt::DES version |
|
|
Line 533 ENDAUTHORBRW
|
Line 535 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) = @_; |
$credits_element,$instcode) = @_; |
my $wintitle = 'Course_Browser'; |
my $wintitle = 'Course_Browser'; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$wintitle = 'Community_Browser'; |
$wintitle = 'Community_Browser'; |
Line 584 sub coursebrowser_javascript {
|
Line 586 sub coursebrowser_javascript {
|
var ownername = document.forms[formid].ccuname.value; |
var ownername = document.forms[formid].ccuname.value; |
var ownerdom = document.forms[formid].ccdomain.options[document.forms[formid].ccdomain.selectedIndex].value; |
var ownerdom = document.forms[formid].ccdomain.options[document.forms[formid].ccdomain.selectedIndex].value; |
url += '&cloner='+ownername+':'+ownerdom; |
url += '&cloner='+ownername+':'+ownerdom; |
|
if (type == 'Course') { |
|
url += '&crscode='+document.forms[formid].crscode.value; |
|
} |
|
} |
|
if (formname == 'requestcrs') { |
|
url += '&crsdom=$domainfilter&crscode=$instcode'; |
} |
} |
if (multflag !=null && multflag != '') { |
if (multflag !=null && multflag != '') { |
url += '&multiple='+multflag; |
url += '&multiple='+multflag; |
Line 928 ENDSCRT
|
Line 936 ENDSCRT
|
} |
} |
|
|
sub select_timezone { |
sub select_timezone { |
my ($name,$selected,$onchange,$includeempty)=@_; |
my ($name,$selected,$onchange,$includeempty,$disabled)=@_; |
my $output='<select name="'.$name.'" '.$onchange.'>'."\n"; |
my $output='<select name="'.$name.'" '.$onchange.$disabled.'>'."\n"; |
if ($includeempty) { |
if ($includeempty) { |
$output .= '<option value=""'; |
$output .= '<option value=""'; |
if (($selected eq '') || ($selected eq 'local')) { |
if (($selected eq '') || ($selected eq 'local')) { |
Line 950 sub select_timezone {
|
Line 958 sub select_timezone {
|
} |
} |
|
|
sub select_datelocale { |
sub select_datelocale { |
my ($name,$selected,$onchange,$includeempty)=@_; |
my ($name,$selected,$onchange,$includeempty,$disabled)=@_; |
my $output='<select name="'.$name.'" '.$onchange.'>'."\n"; |
my $output='<select name="'.$name.'" '.$onchange.$disabled.'>'."\n"; |
if ($includeempty) { |
if ($includeempty) { |
$output .= '<option value=""'; |
$output .= '<option value=""'; |
if ($selected eq '') { |
if ($selected eq '') { |
Line 959 sub select_datelocale {
|
Line 967 sub select_datelocale {
|
} |
} |
$output .= '> </option>'; |
$output .= '> </option>'; |
} |
} |
|
my @languages = &Apache::lonlocal::preferred_languages(); |
my (@possibles,%locale_names); |
my (@possibles,%locale_names); |
my @locales = DateTime::Locale::Catalog::Locales; |
my @locales = DateTime::Locale->ids(); |
foreach my $locale (@locales) { |
foreach my $id (@locales) { |
if (ref($locale) eq 'HASH') { |
if ($id ne '') { |
my $id = $locale->{'id'}; |
my ($en_terr,$native_terr); |
if ($id ne '') { |
my $loc = DateTime::Locale->load($id); |
my $en_terr = $locale->{'en_territory'}; |
if (ref($loc)) { |
my $native_terr = $locale->{'native_territory'}; |
$en_terr = $loc->name(); |
my @languages = &Apache::lonlocal::preferred_languages(); |
$native_terr = $loc->native_name(); |
if (grep(/^en$/,@languages) || !@languages) { |
if (grep(/^en$/,@languages) || !@languages) { |
if ($en_terr ne '') { |
if ($en_terr ne '') { |
$locale_names{$id} = '('.$en_terr.')'; |
$locale_names{$id} = '('.$en_terr.')'; |
Line 982 sub select_datelocale {
|
Line 991 sub select_datelocale {
|
} |
} |
} |
} |
$locale_names{$id} = Encode::encode('UTF-8',$locale_names{$id}); |
$locale_names{$id} = Encode::encode('UTF-8',$locale_names{$id}); |
push (@possibles,$id); |
push(@possibles,$id); |
} |
} |
} |
} |
} |
} |
Line 1002 sub select_datelocale {
|
Line 1011 sub select_datelocale {
|
} |
} |
|
|
sub select_language { |
sub select_language { |
my ($name,$selected,$includeempty) = @_; |
my ($name,$selected,$includeempty,$noedit) = @_; |
my %langchoices; |
my %langchoices; |
if ($includeempty) { |
if ($includeempty) { |
%langchoices = ('' => 'No language preference'); |
%langchoices = ('' => 'No language preference'); |
Line 1014 sub select_language {
|
Line 1023 sub select_language {
|
} |
} |
} |
} |
%langchoices = &Apache::lonlocal::texthash(%langchoices); |
%langchoices = &Apache::lonlocal::texthash(%langchoices); |
return &select_form($selected,$name,\%langchoices); |
return &select_form($selected,$name,\%langchoices,undef,$noedit); |
} |
} |
|
|
=pod |
=pod |
Line 1735 RESIZE
|
Line 1744 RESIZE
|
|
|
} |
} |
|
|
|
sub colorfuleditor_js { |
|
return <<"COLORFULEDIT" |
|
<script type="text/javascript"> |
|
// <![CDATA[> |
|
function fold_box(curDepth, lastresource){ |
|
|
|
// we need a list because there can be several blocks you need to fold in one tag |
|
var block = document.getElementsByName('foldblock_'+curDepth); |
|
// but there is only one folding button per tag |
|
var foldbutton = document.getElementById('folding_btn_'+curDepth); |
|
|
|
if(block.item(0).style.display == 'none'){ |
|
|
|
foldbutton.value = '@{[&mt("Hide")]}'; |
|
for (i = 0; i < block.length; i++){ |
|
block.item(i).style.display = ''; |
|
} |
|
}else{ |
|
|
|
foldbutton.value = '@{[&mt("Show")]}'; |
|
for (i = 0; i < block.length; i++){ |
|
// block.item(i).style.visibility = 'collapse'; |
|
block.item(i).style.display = 'none'; |
|
} |
|
}; |
|
saveState(lastresource); |
|
} |
|
|
|
function saveState (lastresource) { |
|
|
|
var tag_list = getTagList(); |
|
if(tag_list != null){ |
|
var timestamp = new Date().getTime(); |
|
var key = lastresource; |
|
|
|
// the value pattern is: 'time;key1,value1;key2,value2; ... ' |
|
// starting with timestamp |
|
var value = timestamp+';'; |
|
|
|
// building the list of key-value pairs |
|
for(var i = 0; i < tag_list.length; i++){ |
|
value += tag_list[i]+','; |
|
value += document.getElementsByName(tag_list[i])[0].style.display+';'; |
|
} |
|
|
|
// only iterate whole storage if nothing to override |
|
if(localStorage.getItem(key) == null){ |
|
|
|
// prevent storage from growing large |
|
if(localStorage.length > 50){ |
|
var regex_getTimestamp = /^(?:\d)+;/; |
|
var oldest_timestamp = regex_getTimestamp.exec(localStorage.key(0)); |
|
var oldest_key; |
|
|
|
for(var i = 1; i < localStorage.length; i++){ |
|
if (regex_getTimestamp.exec(localStorage.key(i)) < oldest_timestamp) { |
|
oldest_key = localStorage.key(i); |
|
oldest_timestamp = regex_getTimestamp.exec(oldest_key); |
|
} |
|
} |
|
localStorage.removeItem(oldest_key); |
|
} |
|
} |
|
localStorage.setItem(key,value); |
|
} |
|
} |
|
|
|
// restore folding status of blocks (on page load) |
|
function restoreState (lastresource) { |
|
if(localStorage.getItem(lastresource) != null){ |
|
var key = lastresource; |
|
var value = localStorage.getItem(key); |
|
var regex_delTimestamp = /^\d+;/; |
|
|
|
value.replace(regex_delTimestamp, ''); |
|
|
|
var valueArr = value.split(';'); |
|
var pairs; |
|
var elements; |
|
for (var i = 0; i < valueArr.length; i++){ |
|
pairs = valueArr[i].split(','); |
|
elements = document.getElementsByName(pairs[0]); |
|
|
|
for (var j = 0; j < elements.length; j++){ |
|
elements[j].style.display = pairs[1]; |
|
if (pairs[1] == "none"){ |
|
var regex_id = /([_\\d]+)\$/; |
|
regex_id.exec(pairs[0]); |
|
document.getElementById("folding_btn"+RegExp.\$1).value = "Show"; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
function getTagList () { |
|
|
|
var stringToSearch = document.lonhomework.innerHTML; |
|
|
|
var ret = new Array(); |
|
var regex_findBlock = /(foldblock_.*?)"/g; |
|
var tag_list = stringToSearch.match(regex_findBlock); |
|
|
|
if(tag_list != null){ |
|
for(var i = 0; i < tag_list.length; i++){ |
|
ret.push(tag_list[i].replace(/"/, '')); |
|
} |
|
} |
|
return ret; |
|
} |
|
|
|
function saveScrollPosition (resource) { |
|
var tag_list = getTagList(); |
|
|
|
// we dont always want to jump to the first block |
|
// 170 is roughly above the "Problem Editing" header. we just want to save if the user scrolled down further than this |
|
if(\$(window).scrollTop() > 170){ |
|
if(tag_list != null){ |
|
var result; |
|
for(var i = 0; i < tag_list.length; i++){ |
|
if(isElementInViewport(tag_list[i])){ |
|
result += tag_list[i]+';'; |
|
} |
|
} |
|
sessionStorage.setItem('anchor_'+resource, result); |
|
} |
|
} else { |
|
// we dont need to save zero, just delete the item to leave everything tidy |
|
sessionStorage.removeItem('anchor_'+resource); |
|
} |
|
} |
|
|
|
function restoreScrollPosition(resource){ |
|
|
|
var elem = sessionStorage.getItem('anchor_'+resource); |
|
if(elem != null){ |
|
var tag_list = elem.split(';'); |
|
var elem_list; |
|
|
|
for(var i = 0; i < tag_list.length; i++){ |
|
elem_list = document.getElementsByName(tag_list[i]); |
|
|
|
if(elem_list.length > 0){ |
|
elem = elem_list[0]; |
|
break; |
|
} |
|
} |
|
elem.scrollIntoView(); |
|
} |
|
} |
|
|
|
function isElementInViewport(el) { |
|
|
|
// change to last element instead of first |
|
var elem = document.getElementsByName(el); |
|
var rect = elem[0].getBoundingClientRect(); |
|
|
|
return ( |
|
rect.top >= 0 && |
|
rect.left >= 0 && |
|
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */ |
|
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ |
|
); |
|
} |
|
|
|
function autosize(depth){ |
|
var cmInst = window['cm'+depth]; |
|
var fitsizeButton = document.getElementById('fitsize'+depth); |
|
|
|
// is fixed size, switching to dynamic |
|
if (sessionStorage.getItem("autosized_"+depth) == null) { |
|
cmInst.setSize("","auto"); |
|
fitsizeButton.value = "@{[&mt('Fixed size')]}"; |
|
sessionStorage.setItem("autosized_"+depth, "yes"); |
|
|
|
// is dynamic size, switching to fixed |
|
} else { |
|
cmInst.setSize("","300px"); |
|
fitsizeButton.value = "@{[&mt('Dynamic size')]}"; |
|
sessionStorage.removeItem("autosized_"+depth); |
|
} |
|
} |
|
|
|
|
|
|
|
// ]]> |
|
</script> |
|
COLORFULEDIT |
|
} |
|
|
|
sub xmleditor_js { |
|
return <<XMLEDIT |
|
<script type="text/javascript" src="/adm/jQuery/addons/jquery-scrolltofixed.js"></script> |
|
<script type="text/javascript"> |
|
// <![CDATA[> |
|
|
|
function saveScrollPosition (resource) { |
|
|
|
var scrollPos = \$(window).scrollTop(); |
|
sessionStorage.setItem(resource,scrollPos); |
|
} |
|
|
|
function restoreScrollPosition(resource){ |
|
|
|
var scrollPos = sessionStorage.getItem(resource); |
|
\$(window).scrollTop(scrollPos); |
|
} |
|
|
|
// unless internet explorer |
|
if (!(window.navigator.appName == "Microsoft Internet Explorer" && (document.documentMode || document.compatMode))){ |
|
|
|
\$(document).ready(function() { |
|
\$(".LC_edit_actionbar").scrollToFixed(\{zIndex: 100\}); |
|
}); |
|
} |
|
|
|
// inserts text at cursor position into codemirror (xml editor only) |
|
function insertText(text){ |
|
cm.focus(); |
|
var curPos = cm.getCursor(); |
|
cm.replaceRange(text.replace(/ESCAPEDSCRIPT/g,'script'), {line: curPos.line,ch: curPos.ch}); |
|
} |
|
// ]]> |
|
</script> |
|
XMLEDIT |
|
} |
|
|
|
sub insert_folding_button { |
|
my $curDepth = $Apache::lonxml::curdepth; |
|
my $lastresource = $env{'request.ambiguous'}; |
|
|
|
return "<input type=\"button\" id=\"folding_btn_$curDepth\" |
|
value=\"".&mt('Hide')."\" onclick=\"fold_box('$curDepth','$lastresource')\">"; |
|
} |
|
|
|
|
=pod |
=pod |
|
|
=head1 Excel and CSV file utility routines |
=head1 Excel and CSV file utility routines |
Line 1994 sub multiple_select_form {
|
Line 2239 sub multiple_select_form {
|
|
|
=pod |
=pod |
|
|
=item * &select_form($defdom,$name,$hashref,$onchange) |
=item * &select_form($defdom,$name,$hashref,$onchange,$readonly) |
|
|
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 options from a ref to a hash containing: |
allow a user to select options from a ref to a hash containing: |
option_name => displayed text. An optional $onchange can include |
option_name => displayed text. An optional $onchange can include |
a javascript onchange item, e.g., onchange="this.form.submit();" |
a javascript onchange item, e.g., onchange="this.form.submit();". |
|
An optional arg -- $readonly -- if true will cause the select form |
|
to be disabled, e.g., for the case where an instructor has a section- |
|
specific role, and is viewing/modifying parameters. |
|
|
See lonrights.pm for an example invocation and use. |
See lonrights.pm for an example invocation and use. |
|
|
Line 2007 See lonrights.pm for an example invocati
|
Line 2255 See lonrights.pm for an example invocati
|
|
|
#------------------------------------------- |
#------------------------------------------- |
sub select_form { |
sub select_form { |
my ($def,$name,$hashref,$onchange) = @_; |
my ($def,$name,$hashref,$onchange,$readonly) = @_; |
return unless (ref($hashref) eq 'HASH'); |
return unless (ref($hashref) eq 'HASH'); |
if ($onchange) { |
if ($onchange) { |
$onchange = ' onchange="'.$onchange.'"'; |
$onchange = ' onchange="'.$onchange.'"'; |
Line 2181 sub select_level_form {
|
Line 2429 sub select_level_form {
|
|
|
=pod |
=pod |
|
|
=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms) |
=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled) |
|
|
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 2196 The optional $onchange argument specifie
|
Line 2444 The optional $onchange argument specifie
|
|
|
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. |
The optional $excdoms is a reference to an array of domains which will be excluded from the available options. |
|
|
|
The optional $disabled argument, if true, adds the disabled attribute to the select tag. |
|
|
=cut |
=cut |
|
|
#------------------------------------------- |
#------------------------------------------- |
sub select_dom_form { |
sub select_dom_form { |
my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms) = @_; |
my ($defdom,$name,$includeempty,$showdomdesc,$onchange,$incdoms,$excdoms,$disabled) = @_; |
if ($onchange) { |
if ($onchange) { |
$onchange = ' onchange="'.$onchange.'"'; |
$onchange = ' onchange="'.$onchange.'"'; |
} |
} |
|
if ($disabled) { |
|
$disabled = ' disabled="disabled"'; |
|
} |
my (@domains,%exclude); |
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}); |
Line 2216 sub select_dom_form {
|
Line 2469 sub select_dom_form {
|
if (ref($excdoms) eq 'ARRAY') { |
if (ref($excdoms) eq 'ARRAY') { |
map { $exclude{$_} = 1; } @{$excdoms}; |
map { $exclude{$_} = 1; } @{$excdoms}; |
} |
} |
my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n"; |
my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange$disabled>\n"; |
foreach my $dom (@domains) { |
foreach my $dom (@domains) { |
next if ($exclude{$dom}); |
next if ($exclude{$dom}); |
$selectdomain.="<option value=\"$dom\" ". |
$selectdomain.="<option value=\"$dom\" ". |
Line 4629 sub blocking_status {
|
Line 4882 sub blocking_status {
|
# build a link to a popup window containing the details |
# build a link to a popup window containing the details |
my $querystring = "?activity=$activity"; |
my $querystring = "?activity=$activity"; |
# $uname and $udom decide whose portfolio the user is trying to look at |
# $uname and $udom decide whose portfolio the user is trying to look at |
if ($activity eq 'port') { |
if (($activity eq 'port') || ($activity eq 'passwd')) { |
$querystring .= "&udom=$udom" if $udom; |
$querystring .= "&udom=$udom" if ($udom =~ /^$match_domain$/); |
$querystring .= "&uname=$uname" if $uname; |
$querystring .= "&uname=$uname" if ($uname =~ /^$match_username$/); |
} elsif ($activity eq 'docs') { |
} elsif ($activity eq 'docs') { |
$querystring .= '&url='.&HTML::Entities::encode($url,'&"'); |
$querystring .= '&url='.&HTML::Entities::encode($url,'&"'); |
} |
} |
Line 4656 END_MYBLOCK
|
Line 4909 END_MYBLOCK
|
$class = ''; |
$class = ''; |
} elsif ($activity eq 'printout') { |
} elsif ($activity eq 'printout') { |
$text = &mt('Printing Blocked'); |
$text = &mt('Printing Blocked'); |
|
} elsif ($activity eq 'passwd') { |
|
$text = &mt('Password Changing Blocked'); |
} |
} |
$output .= <<"END_BLOCK"; |
$output .= <<"END_BLOCK"; |
<div class='$class'> |
<div class='$class'> |
Line 4674 END_BLOCK
|
Line 4929 END_BLOCK
|
############################################### |
############################################### |
|
|
sub check_ip_acc { |
sub check_ip_acc { |
my ($acc)=@_; |
my ($acc,$clientip)=@_; |
&Apache::lonxml::debug("acc is $acc"); |
&Apache::lonxml::debug("acc is $acc"); |
if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) { |
if (!defined($acc) || $acc =~ /^\s*$/ || $acc =~/^\s*no\s*$/i) { |
return 1; |
return 1; |
} |
} |
my $allowed=0; |
my $allowed=0; |
my $ip=$env{'request.host'} || $ENV{'REMOTE_ADDR'}; |
my $ip=$ENV{'REMOTE_ADDR'} || $clientip || $env{'request.host'}; |
|
|
my $name; |
my $name; |
foreach my $pattern (split(',',$acc)) { |
foreach my $pattern (split(',',$acc)) { |
Line 5121 Inputs:
|
Line 5376 Inputs:
|
|
|
=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, |
|
should it have jsmath forced on by the |
|
current page |
|
|
|
=item * $advtoolsref, optional argument, ref to an array containing |
=item * $advtoolsref, optional argument, ref to an array containing |
inlineremote items to be added in "Functions" menu below |
inlineremote items to be added in "Functions" menu below |
Line 5176 sub bodytag {
|
Line 5428 sub bodytag {
|
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
if ($env{'request.role'} !~ /^cr/) { |
if ($env{'request.role'} !~ /^cr/) { |
$role = &Apache::lonnet::plaintext($role,&course_type()); |
$role = &Apache::lonnet::plaintext($role,&course_type()); |
|
} elsif ($role =~ m{^cr/($match_domain)/\1-domainconfig/(\w+)$}) { |
|
$role = &mt('Helpdesk[_1]',' '.$2); |
|
} else { |
|
$role = (split(/\//,$role,4))[-1]; |
} |
} |
if ($env{'request.course.sec'}) { |
if ($env{'request.course.sec'}) { |
$role .= (' 'x2).'- '.&mt('section:').' '.$env{'request.course.sec'}; |
$role .= (' 'x2).'- '.&mt('section:').' '.$env{'request.course.sec'}; |
Line 5191 sub bodytag {
|
Line 5447 sub bodytag {
|
|
|
# construct main body tag |
# construct main body tag |
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(); |
|
|
&get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); |
&get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); |
|
|
Line 5215 sub bodytag {
|
Line 5471 sub bodytag {
|
$dc_info =~ s/\s+$//; |
$dc_info =~ s/\s+$//; |
} |
} |
|
|
$role = '<span class="LC_nobreak">('.$role.')</span>' if $role; |
$role = '<span class="LC_nobreak">('.$role.')</span>' if ($role && !$env{'browser.mobile'}); |
|
|
if ($env{'request.state'} eq 'construct') { $forcereg=1; } |
if ($env{'request.state'} eq 'construct') { $forcereg=1; } |
|
|
Line 5276 sub bodytag {
|
Line 5532 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,undef, |
$bodytag .= &Apache::lonmenu::innerregister($forcereg,undef, |
$args->{'group'}); |
$args->{'group'}, |
|
$args->{'hide_buttons'}); |
} else { |
} else { |
my $forbodytag; |
my $forbodytag; |
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
&Apache::lonmenu::prepare_functions($env{'request.noversionuri'}, |
Line 5418 sub endbodytag {
|
Line 5675 sub endbodytag {
|
unless ((ref($args) eq 'HASH') && ($args->{'notbody'})) { |
unless ((ref($args) eq 'HASH') && ($args->{'notbody'})) { |
$endbodytag='</body>'; |
$endbodytag='</body>'; |
} |
} |
$endbodytag=&Apache::lontexconvert::jsMath_process()."\n".$endbodytag; |
|
if ( exists( $env{'internal.head.redirect'} ) ) { |
if ( exists( $env{'internal.head.redirect'} ) ) { |
if (!(ref($args) eq 'HASH' && $args->{'noredirectlink'})) { |
if (!(ref($args) eq 'HASH' && $args->{'noredirectlink'})) { |
$endbodytag= |
$endbodytag= |
Line 5593 div.LC_confirm_box .LC_success img {
|
Line 5849 div.LC_confirm_box .LC_success img {
|
vertical-align: middle; |
vertical-align: middle; |
} |
} |
|
|
|
.LC_maxwidth { |
|
max-width: 100%; |
|
height: auto; |
|
} |
|
|
|
.LC_textsize_mobile { |
|
\@media only screen and (max-device-width: 480px) { |
|
-webkit-text-size-adjust:100%; -moz-text-size-adjust:100%; -ms-text-size-adjust:100%; |
|
} |
|
} |
|
|
.LC_icon { |
.LC_icon { |
border: none; |
border: none; |
vertical-align: middle; |
vertical-align: middle; |
Line 5714 table#LC_menubuttons img {
|
Line 5981 table#LC_menubuttons img {
|
vertical-align: middle; |
vertical-align: middle; |
} |
} |
|
|
|
.LC_breadcrumbs_hoverable { |
|
background: $sidebg; |
|
} |
|
|
td.LC_table_cell_checkbox { |
td.LC_table_cell_checkbox { |
text-align: center; |
text-align: center; |
} |
} |
Line 6571 div.LC_edit_problem_footer,
|
Line 6842 div.LC_edit_problem_footer,
|
div.LC_edit_problem_footer div, |
div.LC_edit_problem_footer div, |
div.LC_edit_problem_editxml_header, |
div.LC_edit_problem_editxml_header, |
div.LC_edit_problem_editxml_header div { |
div.LC_edit_problem_editxml_header div { |
margin-top: 5px; |
z-index: 100; |
} |
} |
|
|
div.LC_edit_problem_header_title { |
div.LC_edit_problem_header_title { |
Line 6587 table.LC_edit_problem_header_title {
|
Line 6858 table.LC_edit_problem_header_title {
|
background: $tabbg; |
background: $tabbg; |
} |
} |
|
|
div.LC_edit_problem_discards { |
div.LC_edit_actionbar { |
float: left; |
background-color: $sidebg; |
padding-bottom: 5px; |
margin: 0; |
|
padding: 0; |
|
line-height: 200%; |
} |
} |
|
|
div.LC_edit_problem_saves { |
div.LC_edit_actionbar div{ |
float: right; |
padding: 0; |
padding-bottom: 5px; |
margin: 0; |
|
display: inline-block; |
} |
} |
|
|
.LC_edit_opt { |
.LC_edit_opt { |
Line 6610 div.LC_edit_problem_saves {
|
Line 6884 div.LC_edit_problem_saves {
|
margin-left: 40px; |
margin-left: 40px; |
} |
} |
|
|
|
#LC_edit_problem_codemirror div{ |
|
margin-left: 0px; |
|
} |
|
|
img.stift { |
img.stift { |
border-width: 0; |
border-width: 0; |
vertical-align: middle; |
vertical-align: middle; |
Line 6728 fieldset > legend {
|
Line 7006 fieldset > legend {
|
ol.LC_primary_menu { |
ol.LC_primary_menu { |
margin: 0; |
margin: 0; |
padding: 0; |
padding: 0; |
background-color: $pgbg_or_bgcolor; |
|
} |
} |
|
|
ol#LC_PathBreadcrumbs { |
ol#LC_PathBreadcrumbs { |
Line 6740 ol.LC_primary_menu li {
|
Line 7017 ol.LC_primary_menu li {
|
vertical-align: middle; |
vertical-align: middle; |
text-align: left; |
text-align: left; |
list-style: none; |
list-style: none; |
|
position: relative; |
float: left; |
float: left; |
|
z-index: 100; /* will be displayed above codemirror and underneath the help-layer */ |
|
line-height: 1.5em; |
} |
} |
|
|
ol.LC_primary_menu li a { |
ol.LC_primary_menu li a, |
|
ol.LC_primary_menu li p { |
display: block; |
display: block; |
margin: 0; |
margin: 0; |
padding: 0 5px 0 10px; |
padding: 0 5px 0 10px; |
text-decoration: none; |
text-decoration: none; |
} |
} |
|
|
ol.LC_primary_menu li ul { |
ol.LC_primary_menu li p span.LC_primary_menu_innertitle { |
|
display: inline-block; |
|
width: 95%; |
|
text-align: left; |
|
} |
|
|
|
ol.LC_primary_menu li p span.LC_primary_menu_innerarrow { |
|
display: inline-block; |
|
width: 5%; |
|
float: right; |
|
text-align: right; |
|
font-size: 70%; |
|
} |
|
|
|
ol.LC_primary_menu ul { |
display: none; |
display: none; |
width: 10em; |
width: 15em; |
background-color: $data_table_light; |
background-color: $data_table_light; |
|
position: absolute; |
|
top: 100%; |
|
} |
|
|
|
ol.LC_primary_menu ul ul { |
|
left: 100%; |
|
top: 0; |
} |
} |
|
|
ol.LC_primary_menu li:hover ul, ol.LC_primary_menu li.hover ul { |
ol.LC_primary_menu li:hover > ul, ol.LC_primary_menu li.hover > ul { |
display: block; |
display: block; |
position: absolute; |
position: absolute; |
margin: 0; |
margin: 0; |
Line 6765 ol.LC_primary_menu li:hover ul, ol.LC_pr
|
Line 7067 ol.LC_primary_menu li:hover ul, ol.LC_pr
|
} |
} |
|
|
ol.LC_primary_menu li:hover li, ol.LC_primary_menu li.hover li { |
ol.LC_primary_menu li:hover li, ol.LC_primary_menu li.hover li { |
|
/* First Submenu -> size should be smaller than the menu title of the whole menu */ |
font-size: 90%; |
font-size: 90%; |
vertical-align: top; |
vertical-align: top; |
float: none; |
float: none; |
border-left: 1px solid black; |
border-left: 1px solid black; |
border-right: 1px solid black; |
border-right: 1px solid black; |
|
/* A dark bottom border to visualize different menu options; |
|
overwritten in the create_submenu routine for the last border-bottom of the menu */ |
|
border-bottom: 1px solid $data_table_dark; |
} |
} |
|
|
ol.LC_primary_menu li:hover li a, ol.LC_primary_menu li.hover li a { |
ol.LC_primary_menu li li p:hover { |
background-color:$data_table_light; |
color:$button_hover; |
|
text-decoration:none; |
|
background-color:$data_table_dark; |
} |
} |
|
|
ol.LC_primary_menu li li a:hover { |
ol.LC_primary_menu li li a:hover { |
Line 6781 ol.LC_primary_menu li li a:hover {
|
Line 7089 ol.LC_primary_menu li li a:hover {
|
background-color:$data_table_dark; |
background-color:$data_table_dark; |
} |
} |
|
|
|
/* Font-size equal to the size of the predecessors*/ |
|
ol.LC_primary_menu li:hover li li { |
|
font-size: 100%; |
|
} |
|
|
ol.LC_primary_menu li img { |
ol.LC_primary_menu li img { |
vertical-align: bottom; |
vertical-align: bottom; |
height: 1.1em; |
height: 1.1em; |
Line 6837 ul#LC_secondary_menu li {
|
Line 7150 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 7484 ADDMETA
|
Line 7796 ADDMETA
|
$newurl .= '&origurl='.$requrl; |
$newurl .= '&origurl='.$requrl; |
} |
} |
} |
} |
|
&js_escape(\$msg); |
$result.=<<OFFLOAD |
$result.=<<OFFLOAD |
<meta http-equiv="pragma" content="no-cache" /> |
<meta http-equiv="pragma" content="no-cache" /> |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 7524 OFFLOAD
|
Line 7837 OFFLOAD
|
$result .= '>' |
$result .= '>' |
.$inhibitprint |
.$inhibitprint |
.$head_extra; |
.$head_extra; |
if ($env{'browser.mobile'}) { |
my $clientmobile; |
|
if (($env{'user.name'} eq '') && ($env{'user.domain'} eq '')) { |
|
(undef,undef,undef,undef,undef,undef,$clientmobile) = &decode_user_agent(); |
|
} else { |
|
$clientmobile = $env{'browser.mobile'}; |
|
} |
|
if ($clientmobile) { |
$result .= ' |
$result .= ' |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> |
<meta name="apple-mobile-web-app-capable" content="yes" />'; |
<meta name="apple-mobile-web-app-capable" content="yes" />'; |
Line 7708 $args - additional optional args support
|
Line 8027 $args - additional optional args support
|
no_inline_link -> if true and in remote mode, don't show the |
no_inline_link -> if true and in remote mode, don't show the |
'Switch To Inline Menu' link |
'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, |
|
should it have jsmath forced on by the |
|
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 |
group -> includes the current group, if page is for a |
Line 9201 sub get_secgrprole_info {
|
Line 9517 sub get_secgrprole_info {
|
} |
} |
|
|
sub user_picker { |
sub user_picker { |
my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context) = @_; |
my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype,$context,$fixeddom) = @_; |
my $currdom = $dom; |
my $currdom = $dom; |
|
my @alldoms = &Apache::lonnet::all_domains(); |
|
if (@alldoms == 1) { |
|
my %domsrch = &Apache::lonnet::get_dom('configuration', |
|
['directorysrch'],$alldoms[0]); |
|
my $domdesc = &Apache::lonnet::domain($alldoms[0],'description'); |
|
my $showdom = $domdesc; |
|
if ($showdom eq '') { |
|
$showdom = $dom; |
|
} |
|
if (ref($domsrch{'directorysrch'}) eq 'HASH') { |
|
if ((!$domsrch{'directorysrch'}{'available'}) && |
|
($domsrch{'directorysrch'}{'lcavailable'} eq '0')) { |
|
return (&mt('LON-CAPA directory search is not available in domain: [_1]',$showdom),0); |
|
} |
|
} |
|
} |
my %curr_selected = ( |
my %curr_selected = ( |
srchin => 'dom', |
srchin => 'dom', |
srchby => 'lastname', |
srchby => 'lastname', |
Line 9223 sub user_picker {
|
Line 9555 sub user_picker {
|
} |
} |
$srchterm = $srch->{'srchterm'}; |
$srchterm = $srch->{'srchterm'}; |
} |
} |
my %lt=&Apache::lonlocal::texthash( |
my %html_lt=&Apache::lonlocal::texthash( |
'usr' => 'Search criteria', |
'usr' => 'Search criteria', |
'doma' => 'Domain/institution to search', |
'doma' => 'Domain/institution to search', |
'uname' => 'username', |
'uname' => 'username', |
Line 9236 sub user_picker {
|
Line 9568 sub user_picker {
|
'exact' => 'is', |
'exact' => 'is', |
'contains' => 'contains', |
'contains' => 'contains', |
'begins' => 'begins with', |
'begins' => 'begins with', |
|
); |
|
my %js_lt=&Apache::lonlocal::texthash( |
'youm' => "You must include some text to search for.", |
'youm' => "You must include some text to search for.", |
'thte' => "The text you are searching for must contain at least two characters when using a 'begins' type search.", |
'thte' => "The text you are searching for must contain at least two characters when using a 'begins' type search.", |
'thet' => "The text you are searching for must contain at least three characters when using a 'contains' type search.", |
'thet' => "The text you are searching for must contain at least three characters when using a 'contains' type search.", |
Line 9245 sub user_picker {
|
Line 9579 sub user_picker {
|
'whse' => "When searching by last,first you must include at least one character in the first name.", |
'whse' => "When searching by last,first you must include at least one character in the first name.", |
'thfo' => "The following need to be corrected before the search can be run:", |
'thfo' => "The following need to be corrected before the search can be run:", |
); |
); |
my $domform = &select_dom_form($currdom,'srchdomain',1,1); |
&html_escape(\%html_lt); |
|
&js_escape(\%js_lt); |
|
my $domform; |
|
if ($fixeddom) { |
|
$domform = &select_dom_form($currdom,'srchdomain',1,1,undef,[$currdom]); |
|
} else { |
|
$domform = &select_dom_form($currdom,'srchdomain',1,1); |
|
} |
my $srchinsel = ' <select name="srchin">'; |
my $srchinsel = ' <select name="srchin">'; |
|
|
my @srchins = ('crs','dom','alc','instd'); |
my @srchins = ('crs','dom','alc','instd'); |
Line 9259 sub user_picker {
|
Line 9600 sub user_picker {
|
next if ($option eq 'crs' && !$env{'request.course.id'}); |
next if ($option eq 'crs' && !$env{'request.course.id'}); |
if ($curr_selected{'srchin'} eq $option) { |
if ($curr_selected{'srchin'} eq $option) { |
$srchinsel .= ' |
$srchinsel .= ' |
<option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>'; |
<option value="'.$option.'" selected="selected">'.$html_lt{$option}.'</option>'; |
} else { |
} else { |
$srchinsel .= ' |
$srchinsel .= ' |
<option value="'.$option.'">'.$lt{$option}.'</option>'; |
<option value="'.$option.'">'.$html_lt{$option}.'</option>'; |
} |
} |
} |
} |
$srchinsel .= "\n </select>\n"; |
$srchinsel .= "\n </select>\n"; |
Line 9271 sub user_picker {
|
Line 9612 sub user_picker {
|
foreach my $option ('lastname','lastfirst','uname') { |
foreach my $option ('lastname','lastfirst','uname') { |
if ($curr_selected{'srchby'} eq $option) { |
if ($curr_selected{'srchby'} eq $option) { |
$srchbysel .= ' |
$srchbysel .= ' |
<option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>'; |
<option value="'.$option.'" selected="selected">'.$html_lt{$option}.'</option>'; |
} else { |
} else { |
$srchbysel .= ' |
$srchbysel .= ' |
<option value="'.$option.'">'.$lt{$option}.'</option>'; |
<option value="'.$option.'">'.$html_lt{$option}.'</option>'; |
} |
} |
} |
} |
$srchbysel .= "\n </select>\n"; |
$srchbysel .= "\n </select>\n"; |
Line 9283 sub user_picker {
|
Line 9624 sub user_picker {
|
foreach my $option ('begins','contains','exact') { |
foreach my $option ('begins','contains','exact') { |
if ($curr_selected{'srchtype'} eq $option) { |
if ($curr_selected{'srchtype'} eq $option) { |
$srchtypesel .= ' |
$srchtypesel .= ' |
<option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>'; |
<option value="'.$option.'" selected="selected">'.$html_lt{$option}.'</option>'; |
} else { |
} else { |
$srchtypesel .= ' |
$srchtypesel .= ' |
<option value="'.$option.'">'.$lt{$option}.'</option>'; |
<option value="'.$option.'">'.$html_lt{$option}.'</option>'; |
} |
} |
} |
} |
$srchtypesel .= "\n </select>\n"; |
$srchtypesel .= "\n </select>\n"; |
Line 9371 function validateEntry(callingForm) {
|
Line 9712 function validateEntry(callingForm) {
|
|
|
if (srchterm == "") { |
if (srchterm == "") { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'youm'}\\n"; |
msg += "$js_lt{'youm'}\\n"; |
} |
} |
|
|
if (srchtype== 'begins') { |
if (srchtype== 'begins') { |
if (srchterm.length < 2) { |
if (srchterm.length < 2) { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'thte'}\\n"; |
msg += "$js_lt{'thte'}\\n"; |
} |
} |
} |
} |
|
|
if (srchtype== 'contains') { |
if (srchtype== 'contains') { |
if (srchterm.length < 3) { |
if (srchterm.length < 3) { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'thet'}\\n"; |
msg += "$js_lt{'thet'}\\n"; |
} |
} |
} |
} |
if (srchin == 'instd') { |
if (srchin == 'instd') { |
if (srchdomain == '') { |
if (srchdomain == '') { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'yomc'}\\n"; |
msg += "$js_lt{'yomc'}\\n"; |
} |
} |
} |
} |
if (srchin == 'dom') { |
if (srchin == 'dom') { |
if (srchdomain == '') { |
if (srchdomain == '') { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'ymcd'}\\n"; |
msg += "$js_lt{'ymcd'}\\n"; |
} |
} |
} |
} |
if (srchby == 'lastfirst') { |
if (srchby == 'lastfirst') { |
if (srchterm.indexOf(",") == -1) { |
if (srchterm.indexOf(",") == -1) { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'whus'}\\n"; |
msg += "$js_lt{'whus'}\\n"; |
} |
} |
if (srchterm.indexOf(",") == srchterm.length -1) { |
if (srchterm.indexOf(",") == srchterm.length -1) { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'whse'}\\n"; |
msg += "$js_lt{'whse'}\\n"; |
} |
} |
} |
} |
if (checkok == 0) { |
if (checkok == 0) { |
alert("$lt{'thfo'}\\n"+msg); |
alert("$js_lt{'thfo'}\\n"+msg); |
return; |
return; |
} |
} |
if (checkok == 1) { |
if (checkok == 1) { |
Line 9428 $new_user_create
|
Line 9769 $new_user_create
|
END_BLOCK |
END_BLOCK |
|
|
$output .= &Apache::lonhtmlcommon::start_pick_box(). |
$output .= &Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title($lt{'doma'}). |
&Apache::lonhtmlcommon::row_title($html_lt{'doma'}). |
$domform. |
$domform. |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_title($lt{'usr'}). |
&Apache::lonhtmlcommon::row_title($html_lt{'usr'}). |
$srchbysel. |
$srchbysel. |
$srchtypesel. |
$srchtypesel. |
'<input type="text" size="15" name="srchterm" value="'.$srchterm.'" />'. |
'<input type="text" size="15" name="srchterm" value="'.$srchterm.'" />'. |
Line 9439 END_BLOCK
|
Line 9780 END_BLOCK
|
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::end_pick_box(). |
&Apache::lonhtmlcommon::end_pick_box(). |
'<br />'; |
'<br />'; |
return $output; |
return ($output,1); |
} |
} |
|
|
sub user_rule_check { |
sub user_rule_check { |
my ($usershash,$checks,$alerts,$rulematch,$inst_results,$curr_rules,$got_rules) = @_; |
my ($usershash,$checks,$alerts,$rulematch,$inst_results,$curr_rules,$got_rules) = @_; |
my $response; |
my ($response,%inst_response); |
if (ref($usershash) eq 'HASH') { |
if (ref($usershash) eq 'HASH') { |
foreach my $user (keys(%{$usershash})) { |
if (keys(%{$usershash}) > 1) { |
my ($uname,$udom) = split(/:/,$user); |
my (%by_username,%by_id,%userdoms); |
next if ($udom eq '' || $uname eq ''); |
my $checkid; |
my ($id,$newuser); |
|
if (ref($usershash->{$user}) eq 'HASH') { |
|
$newuser = $usershash->{$user}->{'newuser'}; |
|
$id = $usershash->{$user}->{'id'}; |
|
} |
|
my $inst_response; |
|
if (ref($checks) eq 'HASH') { |
if (ref($checks) eq 'HASH') { |
if (defined($checks->{'username'})) { |
if ((!defined($checks->{'username'})) && (defined($checks->{'id'}))) { |
($inst_response,%{$inst_results->{$user}}) = |
$checkid = 1; |
&Apache::lonnet::get_instuser($udom,$uname); |
} |
} elsif (defined($checks->{'id'})) { |
} |
($inst_response,%{$inst_results->{$user}}) = |
foreach my $user (keys(%{$usershash})) { |
&Apache::lonnet::get_instuser($udom,undef,$id); |
my ($uname,$udom) = split(/:/,$user); |
|
if ($checkid) { |
|
if (ref($usershash->{$user}) eq 'HASH') { |
|
if ($usershash->{$user}->{'id'} ne '') { |
|
$by_id{$udom}{$usershash->{$user}->{'id'}} = $uname; |
|
$userdoms{$udom} = 1; |
|
if (ref($inst_results) eq 'HASH') { |
|
$inst_results->{$uname.':'.$udom} = {}; |
|
} |
|
} |
|
} |
|
} else { |
|
$by_username{$udom}{$uname} = 1; |
|
$userdoms{$udom} = 1; |
|
if (ref($inst_results) eq 'HASH') { |
|
$inst_results->{$uname.':'.$udom} = {}; |
|
} |
|
} |
|
} |
|
foreach my $udom (keys(%userdoms)) { |
|
if (!$got_rules->{$udom}) { |
|
my %domconfig = &Apache::lonnet::get_dom('configuration', |
|
['usercreation'],$udom); |
|
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
|
foreach my $item ('username','id') { |
|
if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') { |
|
$$curr_rules{$udom}{$item} = |
|
$domconfig{'usercreation'}{$item.'_rule'}; |
|
} |
|
} |
|
} |
|
$got_rules->{$udom} = 1; |
|
} |
|
} |
|
if ($checkid) { |
|
foreach my $udom (keys(%by_id)) { |
|
my ($outcome,$results) = &Apache::lonnet::get_multiple_instusers($udom,$by_id{$udom},'id'); |
|
if ($outcome eq 'ok') { |
|
foreach my $id (keys(%{$by_id{$udom}})) { |
|
my $uname = $by_id{$udom}{$id}; |
|
$inst_response{$uname.':'.$udom} = $outcome; |
|
} |
|
if (ref($results) eq 'HASH') { |
|
foreach my $uname (keys(%{$results})) { |
|
if (exists($inst_response{$uname.':'.$udom})) { |
|
$inst_response{$uname.':'.$udom} = $outcome; |
|
$inst_results->{$uname.':'.$udom} = $results->{$uname}; |
|
} |
|
} |
|
} |
|
} |
} |
} |
} else { |
} else { |
($inst_response,%{$inst_results->{$user}}) = |
foreach my $udom (keys(%by_username)) { |
&Apache::lonnet::get_instuser($udom,$uname); |
my ($outcome,$results) = &Apache::lonnet::get_multiple_instusers($udom,$by_username{$udom}); |
return; |
if ($outcome eq 'ok') { |
|
foreach my $uname (keys(%{$by_username{$udom}})) { |
|
$inst_response{$uname.':'.$udom} = $outcome; |
|
} |
|
if (ref($results) eq 'HASH') { |
|
foreach my $uname (keys(%{$results})) { |
|
$inst_results->{$uname.':'.$udom} = $results->{$uname}; |
|
} |
|
} |
|
} |
|
} |
} |
} |
if (!$got_rules->{$udom}) { |
} elsif (keys(%{$usershash}) == 1) { |
my %domconfig = &Apache::lonnet::get_dom('configuration', |
my $user = (keys(%{$usershash}))[0]; |
['usercreation'],$udom); |
my ($uname,$udom) = split(/:/,$user); |
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
if (($udom ne '') && ($uname ne '')) { |
foreach my $item ('username','id') { |
if (ref($usershash->{$user}) eq 'HASH') { |
if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') { |
if (ref($checks) eq 'HASH') { |
$$curr_rules{$udom}{$item} = |
if (defined($checks->{'username'})) { |
$domconfig{'usercreation'}{$item.'_rule'}; |
($inst_response{$user},%{$inst_results->{$user}}) = |
|
&Apache::lonnet::get_instuser($udom,$uname); |
|
} elsif (defined($checks->{'id'})) { |
|
if ($usershash->{$user}->{'id'} ne '') { |
|
($inst_response{$user},%{$inst_results->{$user}}) = |
|
&Apache::lonnet::get_instuser($udom,undef, |
|
$usershash->{$user}->{'id'}); |
|
} else { |
|
($inst_response{$user},%{$inst_results->{$user}}) = |
|
&Apache::lonnet::get_instuser($udom,$uname); |
|
} |
|
} |
|
} else { |
|
($inst_response{$user},%{$inst_results->{$user}}) = |
|
&Apache::lonnet::get_instuser($udom,$uname); |
|
return; |
|
} |
|
if (!$got_rules->{$udom}) { |
|
my %domconfig = &Apache::lonnet::get_dom('configuration', |
|
['usercreation'],$udom); |
|
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
|
foreach my $item ('username','id') { |
|
if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') { |
|
$$curr_rules{$udom}{$item} = |
|
$domconfig{'usercreation'}{$item.'_rule'}; |
|
} |
|
} |
} |
} |
|
$got_rules->{$udom} = 1; |
} |
} |
} |
} |
$got_rules->{$udom} = 1; |
} else { |
|
return; |
|
} |
|
} else { |
|
return; |
|
} |
|
foreach my $user (keys(%{$usershash})) { |
|
my ($uname,$udom) = split(/:/,$user); |
|
next if (($udom eq '') || ($uname eq '')); |
|
my $id; |
|
if (ref($inst_results) eq 'HASH') { |
|
if (ref($inst_results->{$user}) eq 'HASH') { |
|
$id = $inst_results->{$user}->{'id'}; |
|
} |
|
} |
|
if ($id eq '') { |
|
if (ref($usershash->{$user})) { |
|
$id = $usershash->{$user}->{'id'}; |
|
} |
} |
} |
foreach my $item (keys(%{$checks})) { |
foreach my $item (keys(%{$checks})) { |
if (ref($$curr_rules{$udom}) eq 'HASH') { |
if (ref($$curr_rules{$udom}) eq 'HASH') { |
if (ref($$curr_rules{$udom}{$item}) eq 'ARRAY') { |
if (ref($$curr_rules{$udom}{$item}) eq 'ARRAY') { |
if (@{$$curr_rules{$udom}{$item}} > 0) { |
if (@{$$curr_rules{$udom}{$item}} > 0) { |
my %rule_check = &Apache::lonnet::inst_rulecheck($udom,$uname,$id,$item,$$curr_rules{$udom}{$item}); |
my %rule_check = &Apache::lonnet::inst_rulecheck($udom,$uname,$id,$item, |
|
$$curr_rules{$udom}{$item}); |
foreach my $rule (@{$$curr_rules{$udom}{$item}}) { |
foreach my $rule (@{$$curr_rules{$udom}{$item}}) { |
if ($rule_check{$rule}) { |
if ($rule_check{$rule}) { |
$$rulematch{$user}{$item} = $rule; |
$$rulematch{$user}{$item} = $rule; |
if ($inst_response eq 'ok') { |
if ($inst_response{$user} eq 'ok') { |
if (ref($inst_results) eq 'HASH') { |
if (ref($inst_results) eq 'HASH') { |
if (ref($inst_results->{$user}) eq 'HASH') { |
if (ref($inst_results->{$user}) eq 'HASH') { |
if (keys(%{$inst_results->{$user}}) == 0) { |
if (keys(%{$inst_results->{$user}}) == 0) { |
$$alerts{$item}{$udom}{$uname} = 1; |
$$alerts{$item}{$udom}{$uname} = 1; |
|
} elsif ($item eq 'id') { |
|
if ($inst_results->{$user}->{'id'} eq '') { |
|
$$alerts{$item}{$udom}{$uname} = 1; |
|
} |
} |
} |
} |
} |
} |
} |
Line 9761 reservable_now - ref to hash of student_
|
Line 10206 reservable_now - ref to hash of student_
|
|
|
Keys in inner hash are: |
Keys in inner hash are: |
(a) symb: either blank or symb to which slot use is restricted. |
(a) symb: either blank or symb to which slot use is restricted. |
(b) endreserve: end date of reservation period. |
(b) endreserve: end date of reservation period. |
|
(c) uniqueperiod: start,end dates when slot is to be uniquely |
|
selected. |
|
|
sorted_future - ref to array of student_schedulable slots reservable in |
sorted_future - ref to array of student_schedulable slots reservable in |
the future, ordered by start date of reservation period. |
the future, ordered by start date of reservation period. |
Line 9772 future_reservable - ref to hash of stude
|
Line 10219 future_reservable - ref to hash of stude
|
Keys in inner hash are: |
Keys in inner hash are: |
(a) symb: either blank or symb to which slot use is restricted. |
(a) symb: either blank or symb to which slot use is restricted. |
(b) startreserve: start date of reservation period. |
(b) startreserve: start date of reservation period. |
|
(c) uniqueperiod: start,end dates when slot is to be uniquely |
|
selected. |
|
|
=back |
=back |
|
|
Line 9825 sub get_future_slots {
|
Line 10274 sub get_future_slots {
|
my $startreserve = $slots{$slot}->{'startreserve'}; |
my $startreserve = $slots{$slot}->{'startreserve'}; |
my $endreserve = $slots{$slot}->{'endreserve'}; |
my $endreserve = $slots{$slot}->{'endreserve'}; |
my $symb = $slots{$slot}->{'symb'}; |
my $symb = $slots{$slot}->{'symb'}; |
|
my $uniqueperiod; |
|
if (ref($slots{$slot}->{'uniqueperiod'}) eq 'ARRAY') { |
|
$uniqueperiod = join(',',@{$slots{$slot}->{'uniqueperiod'}}); |
|
} |
if (($startreserve < $now) && |
if (($startreserve < $now) && |
(!$endreserve || $endreserve > $now)) { |
(!$endreserve || $endreserve > $now)) { |
my $lastres = $endreserve; |
my $lastres = $endreserve; |
Line 9833 sub get_future_slots {
|
Line 10286 sub get_future_slots {
|
} |
} |
$reservable_now{$slot} = { |
$reservable_now{$slot} = { |
symb => $symb, |
symb => $symb, |
endreserve => $lastres |
endreserve => $lastres, |
|
uniqueperiod => $uniqueperiod, |
}; |
}; |
} elsif (($startreserve > $now) && |
} elsif (($startreserve > $now) && |
(!$endreserve || $endreserve > $startreserve)) { |
(!$endreserve || $endreserve > $startreserve)) { |
$future_reservable{$slot} = { |
$future_reservable{$slot} = { |
symb => $symb, |
symb => $symb, |
startreserve => $startreserve |
startreserve => $startreserve, |
|
uniqueperiod => $uniqueperiod, |
}; |
}; |
} |
} |
} |
} |
Line 14101 sub check_clone {
|
Line 14556 sub check_clone {
|
(&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) { |
(&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) { |
$can_clone = 1; |
$can_clone = 1; |
} else { |
} else { |
my %clonehash = &Apache::lonnet::get('environment',['cloners'], |
my %clonehash = &Apache::lonnet::get('environment',['cloners','internal.coursecode'], |
$args->{'clonedomain'},$args->{'clonecourse'}); |
$args->{'clonedomain'},$args->{'clonecourse'}); |
my @cloners = split(/,/,$clonehash{'cloners'}); |
if ($clonehash{'cloners'} eq '') { |
if (grep(/^\*$/,@cloners)) { |
my %domdefs = &Apache::lonnet::get_domain_defaults($args->{'course_domain'}); |
$can_clone = 1; |
if ($domdefs{'canclone'}) { |
} elsif (grep(/^\*\:\Q$args->{'ccdomain'}\E$/,@cloners)) { |
unless ($domdefs{'canclone'} eq 'none') { |
$can_clone = 1; |
if ($domdefs{'canclone'} eq 'domain') { |
|
if ($args->{'ccdomain'} eq $args->{'clonedomain'}) { |
|
$can_clone = 1; |
|
} |
|
} elsif (($clonehash{'internal.coursecode'}) && ($args->{'crscode'}) && |
|
($args->{'clonedomain'} eq $args->{'course_domain'})) { |
|
if (&Apache::lonnet::default_instcode_cloning($args->{'clonedomain'},$domdefs{'canclone'}, |
|
$clonehash{'internal.coursecode'},$args->{'crscode'})) { |
|
$can_clone = 1; |
|
} |
|
} |
|
} |
|
} |
} else { |
} else { |
|
my @cloners = split(/,/,$clonehash{'cloners'}); |
|
if (grep(/^\*$/,@cloners)) { |
|
$can_clone = 1; |
|
} elsif (grep(/^\*\:\Q$args->{'ccdomain'}\E$/,@cloners)) { |
|
$can_clone = 1; |
|
} elsif (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners)) { |
|
$can_clone = 1; |
|
} |
|
unless ($can_clone) { |
|
if (($clonehash{'internal.coursecode'}) && ($args->{'crscode'}) && |
|
($args->{'clonedomain'} eq $args->{'course_domain'})) { |
|
my (%gotdomdefaults,%gotcodedefaults); |
|
foreach my $cloner (@cloners) { |
|
if (($cloner ne '*') && ($cloner !~ /^\*\:$match_domain$/) && |
|
($cloner !~ /^$match_username\:$match_domain$/) && ($cloner ne '')) { |
|
my (%codedefaults,@code_order); |
|
if (ref($gotcodedefaults{$args->{'clonedomain'}}) eq 'HASH') { |
|
if (ref($gotcodedefaults{$args->{'clonedomain'}}{'defaults'}) eq 'HASH') { |
|
%codedefaults = %{$gotcodedefaults{$args->{'clonedomain'}}{'defaults'}}; |
|
} |
|
if (ref($gotcodedefaults{$args->{'clonedomain'}}{'order'}) eq 'ARRAY') { |
|
@code_order = @{$gotcodedefaults{$args->{'clonedomain'}}{'order'}}; |
|
} |
|
} else { |
|
&Apache::lonnet::auto_instcode_defaults($args->{'clonedomain'}, |
|
\%codedefaults, |
|
\@code_order); |
|
$gotcodedefaults{$args->{'clonedomain'}}{'defaults'} = \%codedefaults; |
|
$gotcodedefaults{$args->{'clonedomain'}}{'order'} = \@code_order; |
|
} |
|
if (@code_order > 0) { |
|
if (&Apache::lonnet::check_instcode_cloning(\%codedefaults,\@code_order, |
|
$cloner,$clonehash{'internal.coursecode'}, |
|
$args->{'crscode'})) { |
|
$can_clone = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
unless ($can_clone) { |
my $ccrole = 'cc'; |
my $ccrole = 'cc'; |
if ($args->{'crstype'} eq 'Community') { |
if ($args->{'crstype'} eq 'Community') { |
$ccrole = 'co'; |
$ccrole = 'co'; |
} |
} |
my %roleshash = |
my %roleshash = |
&Apache::lonnet::get_my_roles($args->{'ccuname'}, |
&Apache::lonnet::get_my_roles($args->{'ccuname'}, |
$args->{'ccdomain'}, |
$args->{'ccdomain'}, |
'userroles',['active'],[$ccrole], |
'userroles',['active'],[$ccrole], |
[$args->{'clonedomain'}]); |
[$args->{'clonedomain'}]); |
if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':'.$ccrole}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) { |
if ($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':'.$ccrole}) { |
$can_clone = 1; |
$can_clone = 1; |
} elsif (&Apache::lonnet::is_course_owner($args->{'clonedomain'},$args->{'clonecourse'},$args->{'ccuname'},$args->{'ccdomain'})) { |
} elsif (&Apache::lonnet::is_course_owner($args->{'clonedomain'},$args->{'clonecourse'}, |
|
$args->{'ccuname'},$args->{'ccdomain'})) { |
$can_clone = 1; |
$can_clone = 1; |
|
} |
|
} |
|
unless ($can_clone) { |
|
if ($args->{'crstype'} eq 'Community') { |
|
$clonemsg = &mt('No new community created.').$linefeed.&mt('The new community could not be cloned from the existing community because the new community owner ([_1]) does not have cloning rights in the existing community ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'}); |
} else { |
} else { |
if ($args->{'crstype'} eq 'Community') { |
$clonemsg = &mt('No new course created.').$linefeed.&mt('The new course could not be cloned from the existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'}); |
$clonemsg = &mt('No new community created.').$linefeed.&mt('The new community could not be cloned from the existing community because the new community owner ([_1]) does not have cloning rights in the existing community ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'}); |
|
} else { |
|
$clonemsg = &mt('No new course created.').$linefeed.&mt('The new course could not be cloned from the existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'}); |
|
} |
|
} |
} |
} |
} |
} |
} |
Line 14400 sub construct_course {
|
Line 14913 sub construct_course {
|
if ($args->{'setcontent'}) { |
if ($args->{'setcontent'}) { |
$cenv{'question.email'}=$args->{'ccuname'}.':'.$args->{'ccdomain'}; |
$cenv{'question.email'}=$args->{'ccuname'}.':'.$args->{'ccdomain'}; |
} |
} |
|
if ($args->{'setcomment'}) { |
|
$cenv{'comment.email'}=$args->{'ccuname'}.':'.$args->{'ccdomain'}; |
|
} |
} |
} |
if ($args->{'reshome'}) { |
if ($args->{'reshome'}) { |
$cenv{'reshome'}=$args->{'reshome'}.'/'; |
$cenv{'reshome'}=$args->{'reshome'}.'/'; |
Line 15341 cloneruname - optional username of new c
|
Line 15857 cloneruname - optional username of new c
|
|
|
clonerudom - optional domain of new course owner |
clonerudom - optional domain of new course owner |
|
|
domcloner - Optional "domcloner" flag; has value=1 if user has ccc priv in domain being filtered by, |
domcloner - optional "domcloner" flag; has value=1 if user has ccc priv in domain being filtered by, |
(used when DC is using course creation form) |
(used when DC is using course creation form) |
|
|
codetitles - reference to array of titles of components in institutional codes (official courses). |
codetitles - reference to array of titles of components in institutional codes (official courses). |
|
|
|
cc_clone - escaped comma separated list of courses for which course cloner has active CC role |
|
(and so can clone automatically) |
|
|
|
reqcrsdom - domain of new course, where search_courses is used to identify potential courses to clone |
|
|
|
reqinstcode - institutional code of new course, where search_courses is used to identify potential |
|
courses to clone |
|
|
Returns: %courses - hash of courses satisfying search criteria, keys = course IDs, values are corresponding colon-separated escaped description, institutional code, owner and type. |
Returns: %courses - hash of courses satisfying search criteria, keys = course IDs, values are corresponding colon-separated escaped description, institutional code, owner and type. |
|
|
Line 15356 Side Effects: None
|
Line 15879 Side Effects: None
|
|
|
|
|
sub search_courses { |
sub search_courses { |
my ($dom,$type,$filter,$numtitles,$cloneruname,$clonerudom,$domcloner,$codetitles) = @_; |
my ($dom,$type,$filter,$numtitles,$cloneruname,$clonerudom,$domcloner,$codetitles, |
|
$cc_clone,$reqcrsdom,$reqinstcode) = @_; |
my (%courses,%showcourses,$cloner); |
my (%courses,%showcourses,$cloner); |
if (($filter->{'ownerfilter'} ne '') || |
if (($filter->{'ownerfilter'} ne '') || |
($filter->{'ownerdomfilter'} ne '')) { |
($filter->{'ownerdomfilter'} ne '')) { |
Line 15404 sub search_courses {
|
Line 15928 sub search_courses {
|
$filter->{'combownerfilter'}, |
$filter->{'combownerfilter'}, |
$filter->{'coursefilter'}, |
$filter->{'coursefilter'}, |
undef,undef,$type,$regexpok,undef,undef, |
undef,undef,$type,$regexpok,undef,undef, |
undef,undef,$cloner,$env{'form.cc_clone'}, |
undef,undef,$cloner,$cc_clone, |
$filter->{'cloneableonly'}, |
$filter->{'cloneableonly'}, |
$createdbefore,$createdafter,undef, |
$createdbefore,$createdafter,undef, |
$domcloner); |
$domcloner,undef,$reqcrsdom,$reqinstcode); |
if (($filter->{'personfilter'} ne '') && ($filter->{'persondomfilter'} ne '')) { |
if (($filter->{'personfilter'} ne '') && ($filter->{'persondomfilter'} ne '')) { |
my $ccrole; |
my $ccrole; |
if ($type eq 'Community') { |
if ($type eq 'Community') { |
Line 15827 sub symb_to_docspath {
|
Line 16351 sub symb_to_docspath {
|
sub captcha_display { |
sub captcha_display { |
my ($context,$lonhost) = @_; |
my ($context,$lonhost) = @_; |
my ($output,$error); |
my ($output,$error); |
my ($captcha,$pubkey,$privkey) = &get_captcha_config($context,$lonhost); |
my ($captcha,$pubkey,$privkey,$version) = |
|
&get_captcha_config($context,$lonhost); |
if ($captcha eq 'original') { |
if ($captcha eq 'original') { |
$output = &create_captcha(); |
$output = &create_captcha(); |
unless ($output) { |
unless ($output) { |
$error = 'captcha'; |
$error = 'captcha'; |
} |
} |
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
$output = &create_recaptcha($pubkey); |
$output = &create_recaptcha($pubkey,$version); |
unless ($output) { |
unless ($output) { |
$error = 'recaptcha'; |
$error = 'recaptcha'; |
} |
} |
} |
} |
return ($output,$error,$captcha); |
return ($output,$error,$captcha,$version); |
} |
} |
|
|
sub captcha_response { |
sub captcha_response { |
my ($context,$lonhost) = @_; |
my ($context,$lonhost) = @_; |
my ($captcha_chk,$captcha_error); |
my ($captcha_chk,$captcha_error); |
my ($captcha,$pubkey,$privkey) = &get_captcha_config($context,$lonhost); |
my ($captcha,$pubkey,$privkey,$version) = &get_captcha_config($context,$lonhost); |
if ($captcha eq 'original') { |
if ($captcha eq 'original') { |
($captcha_chk,$captcha_error) = &check_captcha(); |
($captcha_chk,$captcha_error) = &check_captcha(); |
} elsif ($captcha eq 'recaptcha') { |
} elsif ($captcha eq 'recaptcha') { |
$captcha_chk = &check_recaptcha($privkey); |
$captcha_chk = &check_recaptcha($privkey,$version); |
} else { |
} else { |
$captcha_chk = 1; |
$captcha_chk = 1; |
} |
} |
Line 15858 sub captcha_response {
|
Line 16383 sub captcha_response {
|
|
|
sub get_captcha_config { |
sub get_captcha_config { |
my ($context,$lonhost) = @_; |
my ($context,$lonhost) = @_; |
my ($captcha,$pubkey,$privkey,$hashtocheck); |
my ($captcha,$pubkey,$privkey,$version,$hashtocheck); |
my $hostname = &Apache::lonnet::hostname($lonhost); |
my $hostname = &Apache::lonnet::hostname($lonhost); |
my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname); |
my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname); |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
Line 15874 sub get_captcha_config {
|
Line 16399 sub get_captcha_config {
|
} |
} |
if ($privkey && $pubkey) { |
if ($privkey && $pubkey) { |
$captcha = 'recaptcha'; |
$captcha = 'recaptcha'; |
|
$version = $hashtocheck->{'recaptchaversion'}; |
|
if ($version ne '2') { |
|
$version = 1; |
|
} |
} else { |
} else { |
$captcha = 'original'; |
$captcha = 'original'; |
} |
} |
Line 15891 sub get_captcha_config {
|
Line 16420 sub get_captcha_config {
|
$privkey = $domconfhash{$serverhomedom.'.login.recaptchakeys_private'}; |
$privkey = $domconfhash{$serverhomedom.'.login.recaptchakeys_private'}; |
if ($privkey && $pubkey) { |
if ($privkey && $pubkey) { |
$captcha = 'recaptcha'; |
$captcha = 'recaptcha'; |
|
$version = $domconfhash{$serverhomedom.'.login.recaptchaversion'}; |
|
if ($version ne '2') { |
|
$version = 1; |
|
} |
} else { |
} else { |
$captcha = 'original'; |
$captcha = 'original'; |
} |
} |
Line 15898 sub get_captcha_config {
|
Line 16431 sub get_captcha_config {
|
$captcha = 'original'; |
$captcha = 'original'; |
} |
} |
} |
} |
return ($captcha,$pubkey,$privkey); |
return ($captcha,$pubkey,$privkey,$version); |
} |
} |
|
|
sub create_captcha { |
sub create_captcha { |
Line 15957 sub check_captcha {
|
Line 16490 sub check_captcha {
|
} |
} |
|
|
sub create_recaptcha { |
sub create_recaptcha { |
my ($pubkey) = @_; |
my ($pubkey,$version) = @_; |
my $use_ssl; |
if ($version >= 2) { |
if ($ENV{'SERVER_PORT'} == 443) { |
return '<div class="g-recaptcha" data-sitekey="'.$pubkey.'"></div>'; |
$use_ssl = 1; |
} else { |
} |
my $use_ssl; |
my $captcha = Captcha::reCAPTCHA->new; |
if ($ENV{'SERVER_PORT'} == 443) { |
return $captcha->get_options_setter({theme => 'white'})."\n". |
$use_ssl = 1; |
$captcha->get_html($pubkey,undef,$use_ssl). |
} |
&mt('If the text is hard to read, [_1] will replace them.', |
my $captcha = Captcha::reCAPTCHA->new; |
'<img src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />'). |
return $captcha->get_options_setter({theme => 'white'})."\n". |
'<br /><br />'; |
$captcha->get_html($pubkey,undef,$use_ssl). |
|
&mt('If the text is hard to read, [_1] will replace them.', |
|
'<img src="/res/adm/pages/refresh.gif" alt="reCAPTCHA refresh" />'). |
|
'<br /><br />'; |
|
} |
} |
} |
|
|
sub check_recaptcha { |
sub check_recaptcha { |
my ($privkey) = @_; |
my ($privkey,$version) = @_; |
my $captcha_chk; |
my $captcha_chk; |
my $captcha = Captcha::reCAPTCHA->new; |
if ($version >= 2) { |
my $captcha_result = |
my $ua = LWP::UserAgent->new; |
$captcha->check_answer( |
$ua->timeout(10); |
$privkey, |
my %info = ( |
$ENV{'REMOTE_ADDR'}, |
secret => $privkey, |
$env{'form.recaptcha_challenge_field'}, |
response => $env{'form.g-recaptcha-response'}, |
$env{'form.recaptcha_response_field'}, |
remoteip => $ENV{'REMOTE_ADDR'}, |
); |
); |
if ($captcha_result->{is_valid}) { |
my $response = $ua->post('https://www.google.com/recaptcha/api/siteverify',\%info); |
$captcha_chk = 1; |
if ($response->is_success) { |
|
my $data = JSON::DWIW->from_json($response->decoded_content); |
|
if (ref($data) eq 'HASH') { |
|
if ($data->{'success'}) { |
|
$captcha_chk = 1; |
|
} |
|
} |
|
} |
|
} else { |
|
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; |
return $captcha_chk; |
} |
} |
|
|
sub emailusername_info { |
sub emailusername_info { |
my @fields = ('firstname','lastname','institution','web','location','officialemail'); |
my @fields = ('firstname','lastname','institution','web','location','officialemail','id'); |
my %titles = &Apache::lonlocal::texthash ( |
my %titles = &Apache::lonlocal::texthash ( |
lastname => 'Last Name', |
lastname => 'Last Name', |
firstname => 'First Name', |
firstname => 'First Name', |
Line 15996 sub emailusername_info {
|
Line 16552 sub emailusername_info {
|
location => "School's city, state/province, country", |
location => "School's city, state/province, country", |
web => "School's web address", |
web => "School's web address", |
officialemail => 'E-mail address at institution (if different)', |
officialemail => 'E-mail address at institution (if different)', |
|
id => 'Student/Employee ID', |
); |
); |
return (\@fields,\%titles); |
return (\@fields,\%titles); |
} |
} |
Line 16076 sub des_decrypt {
|
Line 16633 sub des_decrypt {
|
} else { |
} else { |
$cypher=new DES $keybin; |
$cypher=new DES $keybin; |
} |
} |
my $plaintext= |
my $plaintext=''; |
$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16)))); |
my $cypherlength = length($cyphertext); |
$plaintext.= |
my $numchunks = int($cypherlength/32); |
$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16)))); |
for (my $j=0; $j<$numchunks; $j++) { |
$plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) ); |
my $start = $j*32; |
|
my $cypherblock = substr($cyphertext,$start,32); |
|
my $chunk = |
|
$cypher->decrypt(unpack("a8",pack("H16",substr($cypherblock,0,16)))); |
|
$chunk .= |
|
$cypher->decrypt(unpack("a8",pack("H16",substr($cypherblock,16,16)))); |
|
$chunk=substr($chunk,1,ord(substr($chunk,0,1)) ); |
|
$plaintext .= $chunk; |
|
} |
return $plaintext; |
return $plaintext; |
} |
} |
|
|