--- loncom/interface/loncommon.pm 2009/08/15 00:25:43 1.885 +++ loncom/interface/loncommon.pm 2009/10/16 00:17:25 1.898 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.885 2009/08/15 00:25:43 raeburn Exp $ +# $Id: loncommon.pm,v 1.898 2009/10/16 00:17:25 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -483,7 +483,7 @@ 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 Community - for which you wish to add/modify a user role'); + 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 = ' <script type="text/javascript" language="JavaScript"> @@ -493,6 +493,7 @@ sub coursebrowser_javascript { $output .= <<"ENDSTDBRW"; function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag,crstype) { var url = '/adm/pickcourse?'; + var formid = getFormIdByName(formname); var domainfilter = getDomainFromSelectbox(formname,udom); if (domainfilter != null) { if (domainfilter != '') { @@ -602,7 +603,7 @@ sub userbrowser_javascript { my $id_functions = &javascript_index_functions(); return <<"ENDUSERBRW"; -function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom) { +function openuserbrowser(formname,uname,udom,ulast,ufirst,uemail,hideudom,crsdom,caller) { var url = '/adm/pickuser?'; var userdom = getDomainFromSelectbox(formname,udom); if (userdom != null) { @@ -617,6 +618,9 @@ function openuserbrowser(formname,uname, '&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'; @@ -624,23 +628,27 @@ function openuserbrowser(formname,uname, stdeditbrowser.focus(); } -function fix_domain (formname,udom,origdom) { +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; - if (domid > -1) { - var slct = document.forms[formid].elements[domid]; - if (slct.type == 'select-one') { - var i; - for (i=0;i<slct.length;i++) { - if (slct.options[i].value==fixeddom) { slct.selectedIndex=i; } + 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<slct.length;i++) { + if (slct.options[i].value==fixeddom) { slct.selectedIndex=i; } + } + } + if (slct.type == 'hidden') { + slct.value = fixeddom; } - } - if (slct.type == 'hidden') { - slct.value = fixeddom; } } } @@ -715,9 +723,9 @@ sub selectauthor_link { sub selectuser_link { my ($form,$unameelem,$domelem,$lastelem,$firstelem,$emailelem,$hdomelem, - $coursedom,$linktext) = @_; + $coursedom,$linktext,$caller) = @_; return '<a href="javascript:openuserbrowser('."'$form','$unameelem','$domelem',". - "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom'". + "'$lastelem','$firstelem','$emailelem','$hdomelem','$coursedom','$caller'". ');">'.$linktext.'</a>'; } @@ -2947,7 +2955,7 @@ sub messagewrapper { sub noteswrapper { my ($link,$un,$do)=@_; return -"<a href='/adm/email?recordftf=retrieve&recname=$un&recdom=$do'>$link</a>"; +"<a href='/adm/email?recordftf=retrieve&recname=$un&recdom=$do'>$link</a>"; } # ------------------------------------------------------------- Aboutme Wrapper @@ -2957,7 +2965,7 @@ sub aboutmewrapper { if (!defined($username) && !defined($domain)) { return; } - return '<a href="/adm/'.$domain.'/'.$username.'/aboutme"'. + return '<a href="/adm/'.$domain.'/'.$username.'/aboutme?forcestudent=1"'. ($target?' target="$target"':'').' title="'.&mt("View this user's personal information page").'">'.$link.'</a>'; } @@ -2971,7 +2979,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*$/ && @@ -2985,6 +2993,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{<a href="$link" title="$title" $target>$linktext</a>}. @@ -3917,23 +3926,24 @@ sub parse_block_record { } sub blocking_status { - my $blocked; my ($activity,$uname,$udom) = @_; my %setters; + + # check for active blocking my ($startblock,$endblock)=&blockcheck(\%setters,$activity,$uname,$udom); - if ($startblock && $endblock) { - $blocked = 1; - } - if(!wantarray) { - return $blocked; - } - my $output; - my $querystring; - $querystring = "?activity=$activity"; - $output .= <<"END_MYBLOCK"; -<script type="text/javascript"> -// <![CDATA[ + my $blocked = $startblock && $endblock ? 1 : 0; + + # caller just wants to know whether a block is active + if (!wantarray) { return $blocked; } + + # build a link to a popup window containing the details + my $querystring = "?activity=$activity"; + # $uname and $udom decide whose portfolio the user is trying to look at + $querystring .= "&udom=$udom" if $udom; + $querystring .= "&uname=$uname" if $uname; + + my $output .= <<'END_MYBLOCK'; function openWindow(url, wdwName, w, h, toolbar,scrollbar) { var options = "width=" + w + ",height=" + h + ","; options += "resizable=yes,scrollbars="+scrollbar+",status=no,"; @@ -3941,18 +3951,20 @@ sub blocking_status { var newWin = window.open(url, wdwName, options); newWin.focus(); } - -// ]]> -</script> END_MYBLOCK + + $output = Apache::lonhtmlcommon::scripttag($output); + my $popupUrl = "/adm/blockingstatus/$querystring"; + my $text = mt('Communication Blocked'); + $output .= <<"END_BLOCK"; <div class='LC_comblock'> <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring' - title='Communication Blocked'> - <img class='LC_noBorder LC_middle' title='Communication Blocked' src='/res/adm/pages/comblock.png' alt='Communication Blocked'/></a> + title='$text'> + <img class='LC_noBorder LC_middle' title='$text' src='/res/adm/pages/comblock.png' alt='$text'/></a> <a onclick='openWindow("$popupUrl","Blocking Table",600,300,"no","no");return false;' href='/adm/blockingstatus/$querystring' - title='Communication Blocked'>Communication Blocked</a> + title='$text'>$text</a> </div> END_BLOCK @@ -4035,7 +4047,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'}; @@ -4385,6 +4397,9 @@ sub bodytag { if ($env{'request.role'} !~ /^cr/) { $role = &Apache::lonnet::plaintext($role,&course_type()); } + if ($env{'request.course.sec'}) { + $role .= (' 'x2).'- '.&mt('section:').' '.$env{'request.course.sec'}; + } $realm = $env{'course.'.$env{'request.course.id'}.'.description'}; } else { $role = &Apache::lonnet::plaintext($role); @@ -4424,34 +4439,52 @@ sub bodytag { $dc_info = '('.$dc_info.')'; } - $role = "($role)" if $role; + $role = '<span class="LC_nobreak">('.$role.')</span>' if $role; &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); if ($env{'environment.remote'} eq 'off') { # No Remote - if ($env{'request.state'} eq 'construct') { - $forcereg=1; - } + if ($env{'request.state'} eq 'construct') { + $forcereg=1; + } -# if ($env{'request.state'} eq 'construct') { -# $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls -# } + # if ($env{'request.state'} eq 'construct') { + # $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls + # } my $titletable = '<table id="LC_title_bar">' - ."<tr><td> $titleinfo $dc_info</td>" - .'</tr></table>'; + ."<tr><td> $titleinfo $dc_info</td>" + .'</tr></table>'; - if ($no_nav_bar) { - $bodytag .= $titletable; - } else { - $bodytag .= qq|<div id="LC_nav_bar">$name $role<br /> - <em>$realm</em> $dc_info</div>| unless $env{'form.inhibitmenu'}; + if ($no_nav_bar) { + $bodytag .= $titletable; + } else { + $bodytag .= qq|<div id="LC_nav_bar">$name $role<br /> + <em>$realm</em> $dc_info</div>| unless $env{'form.inhibitmenu'}; - if ($env{'request.state'} eq 'construct') { - $bodytag .= &Apache::lonmenu::menubuttons($forcereg,$titletable); - } else { - $bodytag .= &Apache::lonmenu::menubuttons($forcereg).$titletable; - } +#SD $titletable is obsolete +#SD if ($env{'request.state'} eq 'construct') { +#SD $bodytag .= &Apache::lonmenu::menubuttons($forcereg,$titletable); +#SD } else { +#SD $bodytag .= &Apache::lonmenu::menubuttons($forcereg).$titletable; +#SD } + if ( $env{'form.inhibitmenu'} eq 'yes' + || $ENV{'REQUEST_URI'} eq '/adm/logout' + || $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { + + return $bodytag; + } + + $bodytag .= Apache::lonhtmlcommon::scripttag( + Apache::lonmenu::utilityfunctions(), + 'start'); + $bodytag .= Apache::lonmenu::primary_menu(); + $bodytag .= Apache::lonmenu::secondary_menu(); + #SD remove next line + #$bodytag .= Apache::lonmenu::menubuttons($forcereg); + $bodytag .= Apache::lonmenu::serverform(); + $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); + $bodytag .= Apache::lonmenu::innerregister($forcereg) if $forcereg; } return $bodytag; } @@ -4471,7 +4504,7 @@ sub bodytag { :'<a href="/adm/remote?action=collapse" target="_top">'.&mt('Switch to Inline Menu Mode').'</a>'); $bodytag .= qq|<div id="LC_nav_bar">$name $role <em>$realm</em> $dc_info </div> - <ol class="LC_smallMenu LC_right"> + <ol class="LC_primary_menu LC_right"> <li>$menu</li> </ol>| unless $env{'form.inhibitmenu'}; # @@ -4642,14 +4675,6 @@ a:focus { background: yellow } -hr { - clear: both; - color: $tabbg; - background-color: $tabbg; - height: 3px; - border: none; -} - form, .inline { display: inline; } @@ -4994,6 +5019,9 @@ table.LC_nested tr.LC_empty_row td { padding: 8px; } +table.LC_caption { +} + table.LC_nested tr.LC_empty_row td { padding: 4ex } @@ -5805,10 +5833,10 @@ div.LC_createcourse { # --------------------------*/ a:hover, -ol.LC_smallMenu a:hover, +ol.LC_primary_menu a:hover, ol#LC_MenuBreadcrumbs a:hover, ol#LC_PathBreadcrumbs a:hover, -ul#LC_TabMainMenuContent a:hover, +ul#LC_secondary_menu a:hover, .LC_FormSectionClearButton input:hover ul.LC_TabContent li:hover a { color:#BF2317; @@ -5885,7 +5913,7 @@ fieldset > legend { font-style: normal; } -ol.LC_smallMenu { +ol.LC_primary_menu { float: right; margin: 0.2em 0 0 0; } @@ -5894,23 +5922,23 @@ ol#LC_PathBreadcrumbs { margin: 0; } -ol.LC_smallMenu li { +ol.LC_primary_menu li { display: inline; padding: 5px 5px 0 10px; vertical-align: top; } -ol.LC_smallMenu li img { +ol.LC_primary_menu li img { vertical-align: bottom; } -ol.LC_smallMenu a { +ol.LC_primary_menu a { font-size: 90%; color: RGB(80, 80, 80); text-decoration: none; } -ul#LC_TabMainMenuContent { +ul#LC_secondary_menu { clear: both; color: $fontmenu; background: $tabbg; @@ -5920,7 +5948,7 @@ ul#LC_TabMainMenuContent { width: 100%; } -ul#LC_TabMainMenuContent li { +ul#LC_secondary_menu li { font-weight: bold; line-height: 1.8em; padding: 0 0.8em; @@ -5943,7 +5971,7 @@ ul.LC_TabContentBigger li { float:left; } -ul#LC_TabMainMenuContent li a { +ul#LC_secondary_menu li a { color: $fontmenu; text-decoration: none; } @@ -6763,6 +6791,11 @@ sub simple_error_page { sub end_data_table_header_row { return '</tr>'."\n";; } + + sub data_table_caption { + my $caption = shift; + return "<caption class=\"LC_caption\">$caption</caption>"; + } } =pod