--- loncom/interface/loncommon.pm 2009/05/21 15:43:52 1.692.4.3 +++ loncom/interface/loncommon.pm 2010/01/19 06:01:09 1.692.4.21 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.692.4.3 2009/05/21 15:43:52 raeburn Exp $ +# $Id: loncommon.pm,v 1.692.4.21 2010/01/19 06:01:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -407,6 +407,7 @@ sub studentbrowser_javascript { ) { return ''; } return (<<'ENDSTDBRW'); ENDSTDBRW } @@ -461,6 +463,7 @@ sub selectstudent_link { 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 = ' + my ($domainfilter,$sec_element,$formname,$role_element)=@_; + my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Community - for which you wish to add/modify a user role.'); + my $id_functions = &javascript_index_functions(); + my $output = ' '; + return $output; +} + +sub javascript_index_functions { + return <<"ENDJS"; + +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').'' + ."'>".$linktext.'' .''; } @@ -625,6 +776,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) { @@ -825,6 +984,7 @@ sub linked_select_forms { # output the javascript to do the changing my $result = ''; $result.=' END # output the initial values for the selection lists @@ -1023,7 +1184,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; @@ -1100,8 +1263,8 @@ sub help_menu_js { my $template .= <<"ENDTEMPLATE"; ENDTEMPLATE return $template; @@ -1395,6 +1558,7 @@ sub resize_textarea_js { my $geometry = &viewport_geometry_js(); return <<"RESIZE"; RESIZE @@ -1776,7 +1941,7 @@ sub select_level_form { =pod -=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$autosubmit) +=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$onchange) Returns a string containing a ".&mt('Visible input').''; + $result.="'; return $result; } @@ -2874,7 +3038,7 @@ sub syllabuswrapper { } sub track_student_link { - my ($linktext,$sname,$sdom,$target,$start) = @_; + my ($linktext,$sname,$sdom,$target,$start,$only_body) = @_; my $link ="/adm/trackstudent?"; my $title = 'View recent activity'; if (defined($sname) && $sname !~ /^\s*$/ && @@ -2888,6 +3052,7 @@ sub track_student_link { $target = ''; } if ($start) { $link.='&start='.$start; } + if ($only_body) { $link .= '&only_body=1'; } $title = &mt($title); $linktext = &mt($linktext); return qq{$linktext}. @@ -3992,7 +4157,7 @@ sub determinedomain { my $domain=shift; if (! $domain) { # Determine domain if we have not been given one - $domain = $Apache::lonnet::perlvar{'lonDefDomain'}; + $domain = &Apache::lonnet::default_login_domain(); if ($env{'user.domain'}) { $domain=$env{'user.domain'}; } if ($env{'request.role.domain'}) { $domain=$env{'request.role.domain'}; @@ -4538,8 +4703,8 @@ sub standard_css { my $sans = 'Verdana,Arial,Helvetica,sans-serif'; my $mono = 'monospace'; my $data_table_head = $tabbg; - my $data_table_light = '#EEEEEE'; - my $data_table_dark = '#DDDDDD'; + my $data_table_light = '#FAFAFA'; + my $data_table_dark = '#F0F0F0'; my $data_table_darker = '#CCCCCC'; my $data_table_highlight = '#FFFF00'; my $mail_new = '#FFBB77'; @@ -4562,6 +4727,15 @@ sub standard_css { return < td { background-color: #CCCCCC; font-weight: bold; @@ -5765,7 +5977,8 @@ sub xml_begin { .''; } else { - $output=''; + $output=''. + ''; } return $output; } @@ -6156,7 +6369,7 @@ sub get_users_function { if ($env{'request.role'}=~/^(su|dc|ad|li)/) { $function='admin'; } - if (($env{'request.role'}=~/^(au|ca)/) || + if (($env{'request.role'}=~/^(au|ca|aa)/) || ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) { $function='author'; } @@ -6701,6 +6914,8 @@ If the user's status includes multiple t the largest default quota which applies to the user determines the default quota returned. +=back + =cut ############################################### @@ -6849,6 +7064,7 @@ sub user_picker { # loncreateuser::print_user_query_page() # has been completed. next if ($option eq 'alc'); + next if (($option eq 'crs') && ($env{'form.form'} eq 'requestcrs')); next if ($option eq 'crs' && !$env{'request.course.id'}); if ($curr_selected{'srchin'} eq $option) { $srchinsel .= ' @@ -6936,6 +7152,7 @@ ENDSCRIPT my $output = <<"END_BLOCK"; $new_user_create - - - - - - - - - - -
$lt{'doma'}:$domform
$lt{'usr'}:$srchbysel - $srchtypesel - - $srchinsel -
-
END_BLOCK + $output .= &Apache::lonhtmlcommon::start_pick_box(). + &Apache::lonhtmlcommon::row_title($lt{'doma'}). + $domform. + &Apache::lonhtmlcommon::row_closure(). + &Apache::lonhtmlcommon::row_title($lt{'usr'}). + $srchbysel. + $srchtypesel. + ''. + $srchinsel. + &Apache::lonhtmlcommon::row_closure(1). + &Apache::lonhtmlcommon::end_pick_box(). + '
'; return $output; } @@ -7301,8 +7515,6 @@ sub sorted_slots { =pod -=back - =head1 HTTP Helpers =over 4 @@ -7899,7 +8111,8 @@ sub csv_print_samples { $r->print(&mt('Samples').'
'.&start_data_table(). &start_data_table_header_row()); foreach my $sample (sort({$a <=> $b} keys(%{ $samples->[0] }))) { - $r->print(''.&mt('Column [_1]',($sample+1)).''); } + $r->print(''.&mt('Column [_1]',($sample+1)).''); + } $r->print(&end_data_table_header_row()); foreach my $hash (@$samples) { $r->print(&start_data_table_row()); @@ -7943,7 +8156,7 @@ sub csv_print_select_table { my ($value,$display,$defaultcol)=@{ $array_ref }; $r->print(&start_data_table_row().''.$display.''); - $r->print(''); $r->print(''); foreach my $sample (sort({$a <=> $b} keys(%{ $samples->[0] }))) { @@ -8597,10 +8810,11 @@ sub restore_settings { =item * &build_recipient_list() -Build recipient lists for four types of e-mail: +Build recipient lists for five types of e-mail: (a) Error Reports, (b) Package Updates, (c) lonstatus warnings/errors -(d) Help requests, generated by -lonerrorhandler.pm, CHECKRPMS, loncron, and lonsupportreq.pm respectively. +(d) Help requests, (e) Course requests needing approval, generated by +lonerrorhandler.pm, CHECKRPMS, loncron, lonsupportreq.pm and +loncoursequeueadmin.pm respectively. Inputs: defmail (scalar - email address of default recipient), @@ -9173,8 +9387,9 @@ sub check_clone { $clonemsg = &mt('No new course created.').$linefeed.&mt('A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',$args->{'clonecourse'}.':'.$args->{'clonedomain'}); } else { my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1}); - if ($env{'request.role.domain'} eq $args->{'clonedomain'}) { - $can_clone = 1; + if (($env{'request.role.domain'} eq $args->{'clonedomain'}) && + (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) { + $can_clone = 1; } else { my %clonehash = &Apache::lonnet::get('environment',['cloners'], $args->{'clonedomain'},$args->{'clonecourse'}); @@ -9201,7 +9416,7 @@ sub check_clone { } sub construct_course { - my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context) = @_; + my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context,$cnum,$category) = @_; my $outcome; my $linefeed = '
'."\n"; if ($context eq 'auto') { @@ -9239,7 +9454,9 @@ sub construct_course { $args->{'crscode'}, $args->{'ccuname'}.':'. $args->{'ccdomain'}, - $args->{'crstype'}); + $args->{'crstype'}, + $cnum,$context,$category); + # Note: The testing routines depend on this being output; see # Utils::Course. This needs to at least be output as a comment @@ -9547,12 +9764,22 @@ sub course_type { sub group_term { my $crstype = &course_type(); my %names = ( - 'Course' => 'group', - 'Group' => 'team', + 'Course' => 'group', + 'Community' => 'group', ); return $names{$crstype}; } +sub course_types { + my @types = ('official','unofficial','community'); + my %typename = ( + official => 'Official course', + unofficial => 'Unofficial course', + community => 'Community', + ); + return (\@types,\%typename); +} + sub icon { my ($file)=@_; my $curfext = lc((split(/\./,$file))[-1]); @@ -9763,7 +9990,7 @@ sub init_user_environment { &Apache::lonnet::usertools_access($username,$domain,$tool,'reload'); } - foreach my $crstype ('official','unofficial') { + foreach my $crstype ('official','unofficial','community') { $userenv{'canrequest.'.$crstype} = &Apache::lonnet::usertools_access($username,$domain,$crstype, 'reload','requestcourses');