--- loncom/interface/loncommon.pm 2009/03/04 17:07:31 1.763
+++ loncom/interface/loncommon.pm 2010/09/27 01:16:22 1.948.2.11
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.763 2009/03/04 17:07:31 bisitz Exp $
+# $Id: loncommon.pm,v 1.948.2.11 2010/09/27 01:16:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -406,9 +406,10 @@ sub studentbrowser_javascript {
|| ($env{'request.role'}=~/^(au|dc|su)/)
) { return ''; }
return (<<'ENDSTDBRW');
-
ENDSTDBRW
}
sub selectstudent_link {
- my ($form,$unameele,$udomele)=@_;
+ my ($form,$unameele,$udomele,$courseadvonly)=@_;
+ my $callargs = "'".$form."','".$unameele."','".$udomele."'";
if ($env{'request.course.id'}) {
if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
&& !&Apache::lonnet::allowed('srm',$env{'request.course.id'}.
'/'.$env{'request.course.sec'})) {
return '';
}
- return "".&mt('Select User')."";
+ if ($courseadvonly) {
+ $callargs .= ",'',1,1";
+ }
+ return ''.
+ ''.
+ &mt('Select User').'';
}
if ($env{'request.role'}=~/^(au|dc|su)/) {
- return "".&mt('Select User')."";
+ $callargs .= ",1";
+ return ''.
+ ''.
+ &mt('Select User').'';
}
return '';
}
sub authorbrowser_javascript {
return <<"ENDAUTHORBRW";
-
ENDAUTHORBRW
}
sub coursebrowser_javascript {
- my ($domainfilter,$sec_element,$formname)=@_;
- my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Group - for which you wish to add/modify a user role');
- my $output = '
-';
+ return $output;
+}
- function getFormIdByName(formname) {
- for (var i=0;i -1) {
+ var domid = getIndexByName(formid,udom);
+ if (domid > -1) {
+ if (document.forms[formid].elements[domid].type == 'select-one') {
+ userdom=document.forms[formid].elements[domid].options[document.forms[formid].elements[domid].selectedIndex].value;
+ }
+ if (document.forms[formid].elements[domid].type == 'hidden') {
+ userdom=document.forms[formid].elements[domid].value;
}
}
- return -1;
}
-ENDSTDBRW
- if ($sec_element ne '') {
- $output .= &setsec_javascript($sec_element,$formname);
+ return userdom;
+}
+
+ENDJS
+
+}
+
+sub userbrowser_javascript {
+ my $id_functions = &javascript_index_functions();
+ return <<"ENDUSERBRW";
+
+function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom,caller) {
+ var url = '/adm/pickuser?';
+ var userdom = getDomainFromSelectbox(formname,udom);
+ if (userdom != null) {
+ if (userdom != '') {
+ url += 'srchdom='+userdom+'&';
+ }
}
- $output .= '
-';
- return $output;
+ url += 'form=' + formname + '&unameelement='+uname+
+ '&udomelement='+udom+
+ '&ulastelement='+ulast+
+ '&ufirstelement='+ufirst+
+ '&uemailelement='+uemail+
+ '&hideudomelement='+hideudom+
+ '&coursedom='+crsdom;
+ if ((caller != null) && (caller != undefined)) {
+ url += '&caller='+caller;
+ }
+ var title = 'User_Browser';
+ var options = 'scrollbars=1,resizable=1,menubar=0';
+ options += ',width=700,height=600';
+ var stdeditbrowser = open(url,title,options,'1');
+ stdeditbrowser.focus();
+}
+
+function fix_domain (formname,udom,origdom,uname) {
+ var formid = getFormIdByName(formname);
+ if (formid > -1) {
+ var unameid = getIndexByName(formid,uname);
+ var domid = getIndexByName(formid,udom);
+ var hidedomid = getIndexByName(formid,origdom);
+ if (hidedomid > -1) {
+ var fixeddom = document.forms[formid].elements[hidedomid].value;
+ var unameval = document.forms[formid].elements[unameid].value;
+ if ((fixeddom != '') && (fixeddom != undefined) && (fixeddom != null) && (unameval != '') && (unameval != undefined) && (unameval != null)) {
+ if (domid > -1) {
+ var slct = document.forms[formid].elements[domid];
+ if (slct.type == 'select-one') {
+ var i;
+ for (i=0;i".&mt('Select Course')."";
+ my ($form,$unameele,$udomele,$desc,$extra_element,$multflag,$selecttype,
+ $typeelement) = @_;
+ my $type = $selecttype;
+ my $linktext = &mt('Select Course');
+ if ($selecttype eq 'Community') {
+ $linktext = &mt('Select Community');
+ } elsif ($selecttype eq 'Course/Community') {
+ $linktext = &mt('Select Course/Community');
+ $type = '';
+ }
+ return ''
+ ."".$linktext.''
+ .'';
}
sub selectauthor_link {
@@ -612,6 +782,14 @@ sub selectauthor_link {
&mt('Select Author').'';
}
+sub selectuser_link {
+ my ($form,$unameelem,$domelem,$lastelem,$firstelem,$emailelem,$hdomelem,
+ $coursedom,$linktext,$caller) = @_;
+ return ''.$linktext.'';
+}
+
sub check_uncheck_jscript {
my $jscript = <<"ENDSCRT";
function checkAll(field) {
@@ -710,6 +888,21 @@ sub select_datelocale {
return $output;
}
+sub select_language {
+ my ($name,$selected,$includeempty) = @_;
+ my %langchoices;
+ if ($includeempty) {
+ %langchoices = ('' => 'No language preference');
+ }
+ foreach my $id (&languageids()) {
+ my $code = &supportedlanguagecode($id);
+ if ($code) {
+ $langchoices{$code} = &plainlanguagedescription($id);
+ }
+ }
+ return &select_form($selected,$name,\%langchoices);
+}
+
=pod
=item * &linked_select_forms(...)
@@ -796,7 +989,8 @@ sub linked_select_forms {
my $first = "document.$formname.$firstselectname";
# output the javascript to do the changing
my $result = '';
- $result.="
END
# output the initial values for the selection lists
@@ -877,7 +1072,7 @@ END
=pod
-=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height)
+=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height,$imgid)
Returns a string corresponding to an HTML link to the given help
$topic, where $topic corresponds to the name of a .tex file in
@@ -900,12 +1095,9 @@ be useful for certain help topics with b
=cut
sub help_open_topic {
- my ($topic, $text, $stayOnPage, $width, $height) = @_;
+ my ($topic, $text, $stayOnPage, $width, $height, $imgid) = @_;
$text = "" if (not defined $text);
$stayOnPage = 0 if (not defined $stayOnPage);
- if ($env{'browser.interface'} eq 'textual') {
- $stayOnPage=1;
- }
$width = 350 if (not defined $width);
$height = 400 if (not defined $height);
my $filename = $topic;
@@ -932,12 +1124,15 @@ sub help_open_topic {
# (Always) Add the graphic
my $title = &mt('Online Help');
my $helpicon=&lonhttpdurl("/adm/help/help.png");
+ if ($imgid ne '') {
+ $imgid = ' id="'.$imgid.'"';
+ }
$template.=' '
.'';
- if ($text ne "") {
+ if ($text ne "") {
$template.='';
}
return $template;
@@ -978,7 +1173,7 @@ sub general_help {
my $helptopic='Student_Intro';
if ($env{'request.role'}=~/^(ca|au)/) {
$helptopic='Authoring_Intro';
- } elsif ($env{'request.role'}=~/^cc/) {
+ } elsif ($env{'request.role'}=~/^(cc|co)/) {
$helptopic='Course_Coordination_Intro';
} elsif ($env{'request.role'}=~/^dc/) {
$helptopic='Domain_Coordination_Intro';
@@ -998,7 +1193,9 @@ sub update_help_link {
my $banner_link = "/adm/helpmenu?page=banner&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage";
my $output .= <<"ENDOUTPUT";
ENDOUTPUT
return $output;
@@ -1011,8 +1208,7 @@ sub help_open_menu {
$stayOnPage = 0 if (not defined $stayOnPage);
# only use pop-up help (stayOnPage == 0)
# if environment.remote is on (using remote control UI)
- if ($env{'browser.interface'} eq 'textual' ||
- $env{'environment.remote'} eq 'off' ) {
+ if ($env{'environment.remote'} eq 'off' ) {
$stayOnPage=1;
}
my $output;
@@ -1036,8 +1232,7 @@ sub top_nav_help {
my ($text) = @_;
$text = &mt($text);
my $stay_on_page =
- ($env{'browser.interface'} eq 'textual' ||
- $env{'environment.remote'} eq 'off' );
+ ($env{'environment.remote'} eq 'off' );
my $link = ($stay_on_page) ? "javascript:helpMenu('display')"
: "javascript:helpMenu('open')";
my $banner_link = &update_help_link(undef,undef,undef,undef,$stay_on_page);
@@ -1054,8 +1249,7 @@ sub help_menu_js {
my ($text) = @_;
my $stayOnPage =
- ($env{'browser.interface'} eq 'textual' ||
- $env{'environment.remote'} eq 'off' );
+ ($env{'environment.remote'} eq 'off' );
my $width = 620;
my $height = 600;
@@ -1075,8 +1269,8 @@ sub help_menu_js {
my $template .= <<"ENDTEMPLATE";
ENDTEMPLATE
return $template;
@@ -1114,8 +1308,7 @@ sub help_open_bug {
unless ($Apache::lonnet::perlvar{'BugzillaHost'}) { return ''; }
$text = "" if (not defined $text);
$stayOnPage = 0 if (not defined $stayOnPage);
- if ($env{'browser.interface'} eq 'textual' ||
- $env{'environment.remote'} eq 'off' ) {
+ if ($env{'environment.remote'} eq 'off' ) {
$stayOnPage=1;
}
$width = 600 if (not defined $width);
@@ -1159,8 +1352,7 @@ sub help_open_faq {
unless ($Apache::lonnet::perlvar{'FAQHost'}) { return ''; }
$text = "" if (not defined $text);
$stayOnPage = 0 if (not defined $stayOnPage);
- if ($env{'browser.interface'} eq 'textual' ||
- $env{'environment.remote'} eq 'off' ) {
+ if ($env{'environment.remote'} eq 'off' ) {
$stayOnPage=1;
}
$width = 350 if (not defined $width);
@@ -1370,6 +1562,7 @@ sub resize_textarea_js {
my $geometry = &viewport_geometry_js();
return <<"RESIZE";
RESIZE
@@ -1528,10 +1722,13 @@ sub create_workbook {
my $workbook = Spreadsheet::WriteExcel->new('/home/httpd'.$filename);
if (! defined($workbook)) {
$r->log_error("Error creating excel spreadsheet $filename: $!");
- $r->print('
'.&mt("Unable to create new Excel file. ".
- "This error has been logged. ".
- "Please alert your LON-CAPA administrator").
- '
');
+ $r->print(
+ '
'
+ .&mt('Problems occurred in creating the new Excel file.')
+ .' '.&mt('This error has been logged.')
+ .' '.&mt('Please alert your LON-CAPA administrator.')
+ .'
'
+ );
return (undef);
}
#
@@ -1571,9 +1768,13 @@ sub create_text_file {
$fh = Apache::File->new('>/home/httpd'.$filename);
if (! defined($fh)) {
$r->log_error("Couldn't open $filename for output $!");
- $r->print(&mt('Problems occurred in creating the output file. '
- .'This error has been logged. '
- .'Please alert your LON-CAPA administrator.'));
+ $r->print(
+ '
'
+ .&mt('Problems occurred in creating the output file.')
+ .' '.&mt('This error has been logged.')
+ .' '.&mt('Please alert your LON-CAPA administrator.')
+ .'