--- loncom/interface/loncommon.pm 2009/05/16 07:59:09 1.818 +++ loncom/interface/loncommon.pm 2009/05/27 13:36:46 1.825 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.818 2009/05/16 07:59:09 tempelho Exp $ +# $Id: loncommon.pm,v 1.825 2009/05/27 13:36:46 bisitz 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 } @@ -482,6 +486,7 @@ sub coursebrowser_javascript { 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; } @@ -829,6 +835,7 @@ sub linked_select_forms { # output the javascript to do the changing my $result = ''; $result.=' END # output the initial values for the selection lists @@ -1027,7 +1035,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; @@ -1394,6 +1404,7 @@ sub resize_textarea_js { my $geometry = &viewport_geometry_js(); return <<"RESIZE"; RESIZE @@ -2299,7 +2311,7 @@ sub authform_internal{ $result = &mt ('[_1] Internally authenticated (with initial password [_2])', ''.$autharg); - $result.="'; + $result.="'; return $result; } @@ -4168,6 +4180,68 @@ sub designparm { return $output; } +############################################## +=pod + +=item * &head_subbox() + +Inputs: $content (contains HTML code with page functions, etc.) + +Returns: HTML div with $content + To be included in page header + +=cut + +sub head_subbox { + my ($content)=@_; + my $output = + '
' #FIXME: solve conflicts with lonhtmlcommon:breadcrumbs LC_head_subbox + .$content + .'
' +} + +############################################## +=pod + +=item * &CSTR_pageheader() + +Inputs: ./. + +Returns: HTML div with CSTR path and recent box + To be included on Construction Space pages + +=cut + +sub CSTR_pageheader { + # this is for resources; directories have customtitle, and crumbs + # and select recent are created in lonpubdir.pm + my ($uname,$thisdisfn)= + ($env{'request.filename'} =~ m|^/home/([^/]+)/public_html/(.*)|); + my $formaction='/priv/'.$uname.'/'.$thisdisfn; + $formaction=~s/\/+/\//g; + + my $parentpath = ''; + my $lastitem = ''; + if ($thisdisfn =~ m-(.+/)([^/]*)$-) { + $parentpath = $1; + $lastitem = $2; + } else { + $lastitem = $thisdisfn; + } + return + '
' + .&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it? + .''.&mt('Construction Space:').' ' + .'
' #FIXME lonpubdir: target="_parent" + .&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv','','+1',1)."$lastitem
" + #FIXME lonpubdir: &Apache::lonhtmlcommon::crumbs($uname.$thisdisfn.'/','_top','/priv','','+1',1)."
" + .&Apache::lonhtmlcommon::select_recent('construct','recent','this.form.action=this.form.recent.value;this.form.submit()') + .'
' + .&Apache::lonmenu::constspaceform() + .'
'; +} + ############################################### ############################################### @@ -4320,32 +4394,9 @@ ENDROLE $forcereg=1; } - if (!$customtitle && $env{'request.state'} eq 'construct') { - # this is for resources; directories have customtitle, and crumbs - # and select recent are created in lonpubdir.pm - my ($uname,$thisdisfn)= - ($env{'request.filename'} =~ m|^/home/([^/]+)/public_html/(.*)|); - my $formaction='/priv/'.$uname.'/'.$thisdisfn; - $formaction=~s/\/+/\//g; - - my $parentpath = ''; - my $lastitem = ''; - if ($thisdisfn =~ m-(.+/)([^/]*)$-) { - $parentpath = $1; - $lastitem = $2; - } else { - $lastitem = $thisdisfn; - } - $titleinfo = - &Apache::loncommon::help_open_menu('','',3,'Authoring') - .''.&mt('Construction Space').': ' - .'
' - .&Apache::lonhtmlcommon::crumbs($uname.'/'.$parentpath,'_top','/priv','','+1',1)."$lastitem
" - .&Apache::lonhtmlcommon::select_recent('construct','recent','this.form.action=this.form.recent.value;this.form.submit()') - .'
' - .&Apache::lonmenu::constspaceform(); - } + if (!$customtitle && $env{'request.state'} eq 'construct') { + $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls + } my $titletable = '' ."".$roleinfo @@ -4674,6 +4725,7 @@ table#LC_title_bar a { } table#LC_title_bar { + clear: both; /*display: none;*/ } @@ -4689,6 +4741,7 @@ table#LC_title_bar.LC_with_remote { font-family: $sans; border-collapse: collapse; padding: 0; + margin: 0; } table.LC_docs_path { @@ -4712,22 +4765,18 @@ table#LC_title_bar .LC_title_bar_who { margin: 0; } -table#LC_title_bar .LC_title_bar_name { +table#LC_title_bar div.LC_title_bar_name { margin: 0; } -table#LC_title_bar .LC_title_bar_role { +table#LC_title_bar div.LC_title_bar_role { margin: 0; } -table#LC_title_bar .LC_title_bar_realm { +table#LC_title_bar div.LC_title_bar_realm { margin: 0; } -span.LC_metadata { - font-family: $sans; -} - table#LC_menubuttons img{ border: none; } @@ -4797,6 +4846,24 @@ table#LC_mainmenu td.LC_mainmenu_column font-size: 70%; } +#LC_head_subbox { + clear:both; + background: $sidebg; + border-bottom: 1px solid $lg_border_color; + height: 32px; + line-height: 32px; + margin: 0; + padding: 0; +} + +#LC_head_subbox2 { /* FIXME: replace by LC_head_subbox once lonhtmlcommon::breadcrumbs has been fixed */ + clear:both; + background: #F8F8F8; /* $sidebg; */ + border-bottom: 1px solid $lg_border_color; + margin: 0 0 10px 0; + padding: 5px; +} + .LC_fontsize_medium { font-size: 85%; } @@ -5940,30 +6007,22 @@ ul.LC_TabContentBigger li a { ol#LC_MenuBreadcrumbs, ol#LC_PathBreadcrumbs, -ul.LC_CourseBreadcrumbs { - border-top: solid 1px RGB(255, 255, 255); - height: 20px; - line-height: 20px; - vertical-align: bottom; - margin: 0 0 30px 0; +ul#LC_CourseBreadcrumbs { padding-left: 10px; + margin: 0; list-style-position: inside; - background: url(/adm/lonIcons/lightGreyBG.png) repeat-x left top; } ol#LC_MenuBreadcrumbs li, ol#LC_PathBreadcrumbs li, -ul.LC_CourseBreadcrumbs li { -/* - background: url(/adm/lonIcons/arrow_white.png) no-repeat left center; -*/ +ul#LC_CourseBreadcrumbs li { display: inline; padding: 0 0 0 10px; -/* vertical-align: bottom; */ overflow:hidden; } -ol#LC_MenuBreadcrumbs li a, ul.LC_CourseBreadcrumbs li a { +ol#LC_MenuBreadcrumbs li a, +ul#LC_CourseBreadcrumbs li a { text-decoration: none; font-size:90%; } @@ -6791,6 +6850,38 @@ sub get_users_function { =pod +=item * &show_course() + +Used by lonmenu.pm and lonroles.pm to determine whether to use the word +'Courses' or 'Roles' in inline navigation and on screen displaying user's roles. + +Inputs: +None + +Outputs: +Scalar: 1 if 'Course' to be used, 0 otherwise. + +=cut + +############################################### +sub show_course { + my $course = !$env{'user.adv'}; + if (!$env{'user.adv'}) { + foreach my $env (keys(%env)) { + next if ($env !~ m/^user\.priv\./); + if ($env !~ m/^user\.priv\.(?:st|cm)/) { + $course = 0; + last; + } + } + } + return $course; +} + +############################################### + +=pod + =item * &check_user_status() Determines current status of supplied role for a @@ -7534,6 +7625,7 @@ ENDSCRIPT my $output = <<"END_BLOCK"; $new_user_create @@ -10209,6 +10302,22 @@ sub escape_url { return join('/',@urlslices).'/'.$lastitem; } +sub compare_arrays { + my ($arrayref1,$arrayref2) = @_; + my (@difference,%count); + @difference = (); + %count = (); + if ((ref($arrayref1) eq 'ARRAY') && (ref($arrayref2) eq 'ARRAY')) { + foreach my $element (@{$arrayref1}, @{$arrayref2}) { $count{$element}++; } + foreach my $element (keys(%count)) { + if ($count{$element} == 1) { + push(@difference,$element); + } + } + } + return @difference; +} + # -------------------------------------------------------- Initialize user login sub init_user_environment { my ($r, $username, $domain, $authhost, $form, $args) = @_;
$titleinfo $dc_info