version 1.564.2.7, 2007/09/04 23:59:53
|
version 1.566, 2007/08/23 21:54:40
|
Line 1084 sub changable_area {
|
Line 1084 sub changable_area {
|
|
|
=pod |
=pod |
|
|
|
=item * resize_textarea_js |
|
|
|
emits the needed javascript to resize a textarea to be as big as possible |
|
|
|
creates a function resize_textrea that takes two IDs first should be |
|
the id of the element to resize, second should be the id of a div that |
|
surrounds everything that comes after the textarea, this routine needs |
|
to be attached to the <body> for the onload and onresize events. |
|
|
|
|
|
=cut |
|
|
|
sub resize_textarea_js { |
|
return <<"RESIZE"; |
|
<script type="text/javascript"> |
|
function myHandleEvent (event) { |
|
alert(event.type); |
|
} |
|
|
|
var Geometry = {}; |
|
function init_geometry() { |
|
if (Geometry.init) { return }; |
|
Geometry.init=1; |
|
if (window.innerHeight) { |
|
Geometry.getViewportHeight = function() { return window.innerHeight; }; |
|
} |
|
else if (document.documentElement && document.documentElement.clientHeight) { |
|
Geometry.getViewportHeight = |
|
function() { return document.documentElement.clientHeight; }; |
|
} |
|
else if (document.body.clientHeight) { |
|
Geometry.getViewportHeight = |
|
function() { return document.body.clientHeight; }; |
|
} |
|
} |
|
|
|
function resize_textarea(textarea_id,bottom_id) { |
|
init_geometry(); |
|
var textarea = document.getElementById(textarea_id); |
|
//alert(textarea); |
|
|
|
var textarea_top = textarea.offsetTop; |
|
var textarea_height = textarea.offsetHeight; |
|
var bottom = document.getElementById(bottom_id); |
|
var bottom_top = bottom.offsetTop; |
|
var bottom_height = bottom.offsetHeight; |
|
var window_height = Geometry.getViewportHeight(); |
|
var fudge = 23; |
|
var new_height = window_height-fudge-textarea_top-bottom_height; |
|
if (new_height < 300) { |
|
new_height = 300; |
|
} |
|
textarea.style.height=new_height+'px'; |
|
} |
|
</script> |
|
RESIZE |
|
|
|
} |
|
|
|
=pod |
|
|
=back |
=back |
|
|
=head1 Excel and CSV file utility routines |
=head1 Excel and CSV file utility routines |
Line 3458 sub bodytag {
|
Line 3519 sub bodytag {
|
if (!$realm) { $realm=' '; } |
if (!$realm) { $realm=' '; } |
# Set messages |
# Set messages |
my $messages=&domainlogo($domain); |
my $messages=&domainlogo($domain); |
|
# Port for miniserver |
|
my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'}; |
|
if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; } |
|
|
my $extra_body_attr = &make_attr_string($forcereg,\%design); |
my $extra_body_attr = &make_attr_string($forcereg,\%design); |
|
|
Line 3575 ENDROLE
|
Line 3639 ENDROLE
|
|
|
my $imgsrc = $img; |
my $imgsrc = $img; |
if ($img =~ /^\/adm/) { |
if ($img =~ /^\/adm/) { |
$imgsrc = &lonhttpdurl($img); |
$imgsrc = 'http://'.$ENV{'HTTP_HOST'}.':'.$lonhttpdPort.$img; |
} |
} |
my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />'; |
my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />'; |
|
|
Line 5549 sub get_secgrprole_info {
|
Line 5613 sub get_secgrprole_info {
|
} |
} |
|
|
sub user_picker { |
sub user_picker { |
my ($dom,$srch,$forcenewuser,$caller) = @_; |
my ($dom,$srch,$forcenewuser) = @_; |
my $currdom = $dom; |
my $currdom = $dom; |
my %curr_selected = ( |
my %curr_selected = ( |
srchin => 'dom', |
srchin => 'dom', |
Line 5572 sub user_picker {
|
Line 5636 sub user_picker {
|
$srchterm = $srch->{'srchterm'}; |
$srchterm = $srch->{'srchterm'}; |
} |
} |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'usr' => 'Search criteria', |
|
'doma' => 'Domain/institution to search', |
'doma' => 'Domain/institution to search', |
'uname' => 'username', |
'uname' => 'username', |
'lastname' => 'last name', |
'lastname' => 'last name', |
'lastfirst' => 'last name, first name', |
'lastfirst' => 'last name, first name', |
'crs' => 'in this course', |
'crs' => 'in this course', |
'dom' => 'in selected domain', |
'dom' => 'in this domain', |
'alc' => 'all LON-CAPA', |
'alc' => 'all LON-CAPA', |
'instd' => 'in institutional directory for selected domain', |
'instd' => 'in institutional directory', |
'exact' => 'is', |
'exact' => 'is', |
'contains' => 'contains', |
'contains' => 'contains', |
'begins' => 'begins with', |
|
'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.", |
|
'thet' => "The text you are searching for must contain at least three characters when using a 'contains' type search.", |
|
'yomc' => "You must choose a domain when using an institutional directory search.", |
|
'ymcd' => "You must choose a domain when using a domain search.", |
|
'whus' => "When using searching by last,first you must include a comma as separator between last name and 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:", |
|
); |
); |
my $domform = &select_dom_form($currdom,'srchdomain',1,1); |
my $domform = &select_dom_form($currdom,'srchdomain',1,1); |
my $srchinsel = ' <select name="srchin">'; |
my $srchinsel = ' <select name="srchin">'; |
Line 5627 sub user_picker {
|
Line 5681 sub user_picker {
|
$srchbysel .= "\n </select>\n"; |
$srchbysel .= "\n </select>\n"; |
|
|
my $srchtypesel = ' <select name="srchtype">'; |
my $srchtypesel = ' <select name="srchtype">'; |
foreach my $option ('exact','begins','contains') { |
foreach my $option ('exact','contains') { |
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">'.$lt{$option}.'</option>'; |
Line 5641 sub user_picker {
|
Line 5695 sub user_picker {
|
my ($newuserscript,$new_user_create); |
my ($newuserscript,$new_user_create); |
|
|
if ($forcenewuser) { |
if ($forcenewuser) { |
$new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" /> </p>'; |
$new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\');" /> </p>'; |
$newuserscript = <<"ENDSCRIPT"; |
$newuserscript = <<"ENDSCRIPT"; |
|
|
function setSearch(createnew,callingForm) { |
function setSearch(createnew) { |
if (createnew == 1) { |
if (createnew == 1) { |
for (var i=0; i<callingForm.srchby.length; i++) { |
for (var i=0; i<document.crtuser.srchby.length; i++) { |
if (callingForm.srchby.options[i].value == 'uname') { |
if (document.crtuser.srchby.options[i].value == 'uname') { |
callingForm.srchby.selectedIndex = i; |
document.crtuser.srchby.selectedIndex = i; |
} |
} |
} |
} |
for (var i=0; i<callingForm.srchin.length; i++) { |
for (var i=0; i<document.crtuser.srchin.length; i++) { |
if ( callingForm.srchin.options[i].value == 'dom') { |
if ( document.crtuser.srchin.options[i].value == 'dom') { |
callingForm.srchin.selectedIndex = i; |
document.crtuser.srchin.selectedIndex = i; |
} |
} |
} |
} |
for (var i=0; i<callingForm.srchtype.length; i++) { |
for (var i=0; i<document.crtuser.srchtype.length; i++) { |
if (callingForm.srchtype.options[i].value == 'exact') { |
if (document.crtuser.srchtype.options[i].value == 'exact') { |
callingForm.srchtype.selectedIndex = i; |
document.crtuser.srchtype.selectedIndex = i; |
} |
} |
} |
} |
for (var i=0; i<callingForm.srchdomain.length; i++) { |
for (var i=0; i<document.crtuser.srchdomain.length; i++) { |
if (callingForm.srchdomain.options[i].value == '$env{'request.role.domain'}') { |
if (document.crtuser.srchdomain.options[i].value == '$env{'request.role.domain'}') { |
callingForm.srchdomain.selectedIndex = i; |
document.crtuser.srchdomain.selectedIndex = i; |
} |
} |
} |
} |
} |
} |
Line 5674 ENDSCRIPT
|
Line 5728 ENDSCRIPT
|
|
|
my $output = <<"END_BLOCK"; |
my $output = <<"END_BLOCK"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
function validateEntry(callingForm) { |
function validateEntry() { |
|
|
var checkok = 1; |
var checkok = 1; |
var srchin; |
var srchin; |
for (var i=0; i<callingForm.srchin.length; i++) { |
for (var i=0; i<document.crtuser.srchin.length; i++) { |
if ( callingForm.srchin[i].checked ) { |
if ( document.crtuser.srchin[i].checked ) { |
srchin = callingForm.srchin[i].value; |
srchin = document.crtuser.srchin[i].value; |
} |
} |
} |
} |
|
|
var srchtype = callingForm.srchtype.options[callingForm.srchtype.selectedIndex].value; |
var srchtype = document.crtuser.srchtype.options[document.crtuser.srchtype.selectedIndex].value; |
var srchby = callingForm.srchby.options[callingForm.srchby.selectedIndex].value; |
var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value; |
var srchdomain = callingForm.srchdomain.options[callingForm.srchdomain.selectedIndex].value; |
var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value; |
var srchterm = callingForm.srchterm.value; |
var srchterm = document.crtuser.srchterm.value; |
var srchin = callingForm.srchin.options[callingForm.srchin.selectedIndex].value; |
var srchin = document.crtuser.srchin.options[document.crtuser.srchin.selectedIndex].value; |
var msg = ""; |
var msg = ""; |
|
|
if (srchterm == "") { |
if (srchterm == "") { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'youm'}\\n"; |
msg += "You must include some text to search for.\\n"; |
} |
|
|
|
if (srchtype== 'begins') { |
|
if (srchterm.length < 2) { |
|
checkok = 0; |
|
msg += "$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 += "The text you are searching for must contain at least three characters when using a 'contains' type search.\\n"; |
} |
} |
} |
} |
if (srchin == 'instd') { |
if (srchin == 'instd') { |
if (srchdomain == '') { |
if (srchdomain == '') { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'yomc'}\\n"; |
msg += "You must choose a domain when using an institutional directory search.\\n"; |
} |
} |
} |
} |
if (srchin == 'dom') { |
if (srchin == 'dom') { |
if (srchdomain == '') { |
if (srchdomain == '') { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'ymcd'}\\n"; |
msg += "You must choose a domain when using a domain search.\\n"; |
} |
} |
} |
} |
if (srchby == 'lastfirst') { |
if (srchby == 'lastfirst') { |
if (srchterm.indexOf(",") == -1) { |
if (srchterm.indexOf(",") == -1) { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'whus'}\\n"; |
msg += "When using searching by last,first you must include a comma as separator between last name and first name.\\n"; |
} |
} |
if (srchterm.indexOf(",") == srchterm.length -1) { |
if (srchterm.indexOf(",") == srchterm.length -1) { |
checkok = 0; |
checkok = 0; |
msg += "$lt{'whse'}\\n"; |
msg += "When searching by last,first you must include at least one character in the first name.\\n"; |
} |
} |
} |
} |
if (checkok == 0) { |
if (checkok == 0) { |
alert("$lt{'thfo'}\\n"+msg); |
alert("The following need to be corrected before the search can be run:\\n"+msg); |
return; |
return; |
} |
} |
if (checkok == 1) { |
if (checkok == 1) { |
callingForm.submit(); |
document.crtuser.submit(); |
} |
} |
} |
} |
|
|
Line 5748 $new_user_create
|
Line 5795 $new_user_create
|
|
|
<table> |
<table> |
<tr> |
<tr> |
<td>$lt{'doma'}:</td> |
|
<td>$domform</td> |
|
</td> |
|
</tr> |
|
<tr> |
|
<td>$lt{'usr'}:</td> |
|
<td>$srchbysel |
<td>$srchbysel |
$srchtypesel |
$srchtypesel |
<input type="text" size="15" name="srchterm" value="$srchterm" /> |
<input type="text" size="15" name="srchterm" value="$srchterm" /> |
$srchinsel |
$srchinsel |
</td> |
</td> |
</tr> |
</tr> |
|
<tr> |
|
<td>$lt{'doma'}: $domform</td> |
|
</td> |
|
</tr> |
</table> |
</table> |
<br /> |
<br /> |
END_BLOCK |
END_BLOCK |
Line 6941 sub check_clone {
|
Line 6986 sub check_clone {
|
$args->{'crstype'}); |
$args->{'crstype'}); |
} else { |
} else { |
my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1}); |
my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1}); |
if ($env{'request.role.domain'} eq $args->{'clonedomain'}) { |
if ($env{'request.role.domain'} eq $args->{'form.clonedomain'}) { |
$can_clone = 1; |
$can_clone = 1; |
} else { |
} else { |
my %clonehash = &Apache::lonnet::get('environment',['cloners'], |
my %clonehash = &Apache::lonnet::get('environment',['cloners'], |
Line 7321 sub icon {
|
Line 7366 sub icon {
|
return &lonhttpdurl($iconname); |
return &lonhttpdurl($iconname); |
} |
} |
|
|
sub lonhttpd_port { |
|
my $lonhttpd_port=$Apache::lonnet::perlvar{'lonhttpdPort'}; |
|
if (!defined($lonhttpd_port)) { $lonhttpd_port='8080'; } |
|
# IE doesn't like a secure page getting images from a non-secure |
|
# port (when logging we haven't parsed the browser type so default |
|
# back to secure |
|
if ((!exists($env{'browser.type'}) || $env{'browser.type'} eq 'explorer') |
|
&& $ENV{'SERVER_PORT'} == 443) { |
|
return 443; |
|
} |
|
return $lonhttpd_port; |
|
|
|
} |
|
|
|
sub lonhttpdurl { |
sub lonhttpdurl { |
my ($url)=@_; |
my ($url)=@_; |
|
my $lonhttpd_port=$Apache::lonnet::perlvar{'lonhttpdPort'}; |
my $lonhttpd_port = &lonhttpd_port(); |
if (!defined($lonhttpd_port)) { $lonhttpd_port='8080'; } |
if ($lonhttpd_port == 443) { |
|
return 'https://'.$ENV{'SERVER_NAME'}.$url; |
|
} |
|
return 'http://'.$ENV{'SERVER_NAME'}.':'.$lonhttpd_port.$url; |
return 'http://'.$ENV{'SERVER_NAME'}.':'.$lonhttpd_port.$url; |
} |
} |
|
|