[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface loncommon.pm

raeburn raeburn@source.lon-capa.org
Thu, 21 May 2009 05:27:11 -0000


This is a MIME encoded message

--raeburn1242883631
Content-Type: text/plain

raeburn		Thu May 21 05:27:11 2009 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	loncommon.pm 
  Log:
  - Backport 1.699, 1.707, 1.709, 1.711, 1.713, 1.714, 1.715, 1.716,
             1.718, 1.724, 1.725, 1.726, 1.727, 1.728, 1.730, 1.731,
             1.732, 1.734, 1.735, 1.740, 1.742, 1.743, 1.750, 1.751,
             1.758, 1.763 (part), 1.764, 1.765, 1.766, 1.772, 1.776,
             1.780, 1.781, 1.784, 1.787, 1.792, 1.793, 1.799, 1.800,
             1.802, 1.803, 1.804, 1.805 (part), 1.811, 1.820, 1.821
  
  
--raeburn1242883631
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090521052711.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.692.4.1 loncom/interface/loncommon.pm:1.692.4.2
--- loncom/interface/loncommon.pm:1.692.4.1	Tue May 19 00:16:11 2009
+++ loncom/interface/loncommon.pm	Thu May 21 05:27:10 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.692.4.1 2009/05/19 00:16:11 raeburn Exp $
+# $Id: loncommon.pm,v 1.692.4.2 2009/05/21 05:27:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -406,9 +406,9 @@
          || ($env{'request.role'}=~/^(au|dc|su)/)
           ) { return ''; }  
    return (<<'ENDSTDBRW');
-<script type="text/javascript" language="Javascript" >
+<script type="text/javascript" language="Javascript">
     var stdeditbrowser;
-    function openstdbrowser(formname,uname,udom,roleflag,ignorefilter) {
+    function openstdbrowser(formname,uname,udom,roleflag,ignorefilter,courseadvonly) {
         var url = '/adm/pickstudent?';
         var filter;
 	if (!ignorefilter) {
@@ -422,6 +422,7 @@
         url += 'form=' + formname + '&unameelement='+uname+
                                     '&udomelement='+udom;
 	if (roleflag) { url+="&roles=1"; }
+        if (courseadvonly) { url+="&courseadvonly=1"; }
         var title = 'Student_Browser';
         var options = 'scrollbars=1,resizable=1,menubar=0';
         options += ',width=700,height=600';
@@ -433,19 +434,26 @@
 }
 
 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 "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
-        '","'.$udomele.'");'."'>".&mt('Select User')."</a>";
+       if ($courseadvonly)  {
+           $callargs .= ",'',1,1";
+       }
+       return '<span class="LC_nobreak">'.
+              '<a href="javascript:openstdbrowser('.$callargs.');">'.
+              &mt('Select User').'</a></span>';
    }
    if ($env{'request.role'}=~/^(au|dc|su)/) {
-       return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
-        '","'.$udomele.'",1);'."'>".&mt('Select User')."</a>";
+       $callargs .= ",1";
+       return '<span class="LC_nobreak">'.
+              '<a href="javascript:openstdbrowser('.$callargs.');">'.
+              &mt('Select User').'</a></span>';
    }
    return '';
 }
@@ -473,7 +481,7 @@
     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 = '
-<script type="text/javascript">
+<script type="text/javascript" language="JavaScript">
     var stdeditbrowser;'."\n";
    $output .= <<"ENDSTDBRW";
     function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag,crstype) {
@@ -602,8 +610,13 @@
 
 sub selectcourse_link {
    my ($form,$unameele,$udomele,$desc,$extra_element,$multflag,$selecttype)=@_;
-   return "<a href='".'javascript:opencrsbrowser("'.$form.'","'.$unameele.
-        '","'.$udomele.'","'.$desc.'","'.$extra_element.'","'.$multflag.'","'.$selecttype.'");'."'>".&mt('Select Course')."</a>";
+   return '<span class="LC_nobreak">'
+         ."<a href='"
+         .'javascript:opencrsbrowser("'.$form.'","'.$unameele
+         .'","'.$udomele.'","'.$desc.'","'.$extra_element
+         .'","'.$multflag.'","'.$selecttype.'");'
+         ."'>".&mt('Select Course').'</a>'
+         .'</span>';
 }
 
 sub selectauthor_link {
@@ -710,6 +723,21 @@
     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 +824,7 @@
     my $first = "document.$formname.$firstselectname";
     # output the javascript to do the changing
     my $result = '';
-    $result.="<script type=\"text/javascript\">\n";
+    $result.='<script type="text/javascript" language="JavaScript">'."\n";
     $result.="var select2data = new Object();\n";
     $" = '","';
     my $debug = '';
@@ -932,10 +960,12 @@
     # Add the graphic
     my $title = &mt('Online Help');
     my $helpicon=&lonhttpdurl("/adm/help/help.png");
-    $template .= <<"ENDTEMPLATE";
- <a target="_top" href="$link" title="$title"><img src="$helpicon" border="0" alt="(Help: $topic)" /></a>
-ENDTEMPLATE
-    if ($text ne '') { $template.='</span></td></tr></table>' };
+    $template .= '<a target="_top" href="'.$link.'" title="'.$title.'">'.
+                 '<img src="'.$helpicon.'" border="0" alt="'.&mt('Help: [_1]',$topic).
+                 '" title="'.$title.'" /></a>';
+    if ($text ne '') {
+        $template.='</span></td></tr></table>';
+    }
     return $template;
 
 }
@@ -943,24 +973,30 @@
 # This is a quicky function for Latex cheatsheet editing, since it 
 # appears in at least four places
 sub helpLatexCheatsheet {
-    my $other = shift;
+    my ($topic,$text,$not_author) = @_;
+    my $out;
     my $addOther = '';
     if ($other) {
-	$addOther = Apache::loncommon::help_open_topic($other, shift,
+	$addOther = &Apache::loncommon::help_open_topic($topic,$text,
 						       undef, undef, 600) .
 							   '</td><td>';
     }
-    return '<table><tr><td>'.
-	$addOther .
-	&Apache::loncommon::help_open_topic("Greek_Symbols",&mt('Greek Symbols'),
-					    undef,undef,600)
-	.'</td><td>'.
-	&Apache::loncommon::help_open_topic("Other_Symbols",&mt('Other Symbols'),
-					    undef,undef,600)
-	.'</td><td>'.
-	&Apache::loncommon::help_open_topic("Authoring_Output_Tags",&mt('Output Tags'),
-	                                    undef,undef,600)
-	.'</td></tr></table>';
+    $out = '<table><tr><td>'.
+           $addOther .
+           &Apache::loncommon::help_open_topic("Greek_Symbols",&mt('Greek Symbols'),
+                                               undef,undef,600).
+           '</td><td>'.
+           &Apache::loncommon::help_open_topic("Other_Symbols",&mt('Other Symbols'),
+                                               undef,undef,600).
+           '</td>';
+    unless ($not_author) {
+        $out .= '<td>'.
+                &Apache::loncommon::help_open_topic("Authoring_Output_Tags",&mt('Output Tags'),
+                                                    undef,undef,600).
+                '</td>';
+    }
+    $out .= '</tr></table>';
+    return $out;
 }
 
 sub general_help {
@@ -1629,7 +1665,7 @@
             $size = scalar(keys(%$hash));
         }
     }
-    $output.="\n<select name='$name' size='$size' multiple='1'>";
+    $output.="\n".'<select name="'.$name.'" size="'.$size.'" multiple="multiple">';
     my @order;
     if (ref($order) eq 'ARRAY')  {
         @order = @{$order};
@@ -1686,17 +1722,17 @@
 sub display_filter {
     if (!$env{'form.show'}) { $env{'form.show'}=10; }
     if (!$env{'form.displayfilter'}) { $env{'form.displayfilter'}='currentfolder'; }
-    return '<nobr><label>'.&mt('Records [_1]',
+    return '<span class="LC_nobreak"><label>'.&mt('Records [_1]',
 			       &Apache::lonmeta::selectbox('show',$env{'form.show'},undef,
 							   (&mt('all'),10,20,50,100,1000,10000))).
-	   '</label></nobr> <nobr>'.
+	   '</label></span> <span class="LC_nobreak">'.
            &mt('Filter [_1]',
 	   &select_form($env{'form.displayfilter'},
 			'displayfilter',
 			('currentfolder' => 'Current folder/page',
 			 'containing' => 'Containing phrase',
 			 'none' => 'None'))).
-			 '<input type="text" name="containingphrase" size="30" value="'.&HTML::Entities::encode($env{'form.containingphrase'}).'" /></nobr>';
+			 '<input type="text" name="containingphrase" size="30" value="'.&HTML::Entities::encode($env{'form.containingphrase'}).'" /></span>';
 }
 
 sub gradeleveldescription {
@@ -1740,7 +1776,7 @@
 
 =pod
 
-=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc)
+=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$autosubmit)
 
 Returns a string containing a <select name='$name' size='1'> form to 
 allow a user to select the domain to preform an operation in.  
@@ -1749,16 +1785,22 @@
 If the $includeempty flag is set, it also includes an empty choice ("no domain
 selected");
 
-If the $showdomdesc flag is set, the domain name is followed by the domain description. 
+If the $showdomdesc flag is set, the domain name is followed by the domain description.
+
+If the $autosubmit flag is set, the form containing the domain selector will be auto-submitted by an onchange action.
 
 =cut
 
 #-------------------------------------------
 sub select_dom_form {
-    my ($defdom,$name,$includeempty,$showdomdesc) = @_;
+    my ($defdom,$name,$includeempty,$showdomdesc,$autosubmit) = @_;
+    my $onchange;
+    if ($autosubmit) {
+        $onchange = ' onchange="this.form.submit()"';
+    }
     my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
     if ($includeempty) { @domains=('',@domains); }
-    my $selectdomain = "<select name=\"$name\" size=\"1\">\n";
+    my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n";
     foreach my $dom (@domains) {
         $selectdomain.="<option value=\"$dom\" ".
             ($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom;
@@ -1814,7 +1856,7 @@
     if ($numlib > 1) {
         $result .= '<select name="'.$name.'" />'."\n";
         if ($default) {
-            $result .= '<option value="default" selected>'.&mt('default').
+            $result .= '<option value="default" selected="selected">'.&mt('default').
                        '</option>'."\n";
         }
         foreach my $hostid (sort(keys(%servers))) {
@@ -2109,14 +2151,14 @@
         $autharg,$jscall);
     my ($authnum,%can_assign) =  &get_assignable_auth($in{'domain'});
     if ($in{'kerb_def_auth'} eq 'krb5') {
-       $check5 = ' checked="on"';
+       $check5 = ' checked="checked"';
     } else {
-       $check4 = ' checked="on"';
+       $check4 = ' checked="checked"';
     }
     $krbarg = $in{'kerb_def_dom'};
     if (defined($in{'curr_authtype'})) {
         if ($in{'curr_authtype'} eq 'krb') {
-            $krbcheck = ' checked="on"';
+            $krbcheck = ' checked="checked"';
             if (defined($in{'mode'})) {
                 if ($in{'mode'} eq 'modifyuser') {
                     $krbcheck = '';
@@ -2124,10 +2166,10 @@
             }
             if (defined($in{'curr_kerb_ver'})) {
                 if ($in{'curr_krb_ver'} eq '5') {
-                    $check5 = ' checked="on"';
+                    $check5 = ' checked="checked"';
                     $check4 = '';
                 } else {
-                    $check4 = ' checked="on"';
+                    $check4 = ' checked="checked"';
                     $check5 = '';
                 }
             }
@@ -2148,7 +2190,7 @@
         }
     } else {
         if ($authnum == 1) {
-            $authtype = '<input type="hidden" name="login" value="krb">';
+            $authtype = '<input type="hidden" name="login" value="krb" />';
         }
     }
     if (!$can_assign{'krb4'} && !$can_assign{'krb5'}) {
@@ -2157,7 +2199,7 @@
         if (defined($in{'mode'})) {
             if ($in{'mode'} eq 'modifycourse') {
                 if ($authnum == 1) {
-                    $authtype = '<input type="hidden" name="login" value="krb">';
+                    $authtype = '<input type="hidden" name="login" value="krb" />';
                 }
             }
         }
@@ -2218,7 +2260,7 @@
     if (defined($in{'curr_authtype'})) {
         if ($in{'curr_authtype'} eq 'int') {
             if ($can_assign{'int'}) {
-                $intcheck = 'checked="on" ';
+                $intcheck = 'checked="checked" ';
                 if (defined($in{'mode'})) {
                     if ($in{'mode'} eq 'modifyuser') {
                         $intcheck = '';
@@ -2234,7 +2276,7 @@
         }
     } else {
         if ($authnum == 1) {
-            $authtype = '<input type="hidden" name="login" value="int">';
+            $authtype = '<input type="hidden" name="login" value="int" />';
         }
     }
     if (!$can_assign{'int'}) {
@@ -2243,7 +2285,7 @@
         if (defined($in{'mode'})) {
             if ($in{'mode'} eq 'modifycourse') {
                 if ($authnum == 1) {
-                    $authtype = '<input type="hidden" name="login" value="int">';
+                    $authtype = '<input type="hidden" name="login" value="int" />';
                 }
             }
         }
@@ -2273,7 +2315,7 @@
     if (defined($in{'curr_authtype'})) {
         if ($in{'curr_authtype'} eq 'loc') {
             if ($can_assign{'loc'}) {
-                $loccheck = 'checked="on" ';
+                $loccheck = 'checked="checked" ';
                 if (defined($in{'mode'})) {
                     if ($in{'mode'} eq 'modifyuser') {
                         $loccheck = '';
@@ -2289,7 +2331,7 @@
         }
     } else {
         if ($authnum == 1) {
-            $authtype = '<input type="hidden" name="login" value="loc">';
+            $authtype = '<input type="hidden" name="login" value="loc" />';
         }
     }
     if (!$can_assign{'loc'}) {
@@ -2298,7 +2340,7 @@
         if (defined($in{'mode'})) {
             if ($in{'mode'} eq 'modifycourse') {
                 if ($authnum == 1) {
-                    $authtype = '<input type="hidden" name="login" value="loc">';
+                    $authtype = '<input type="hidden" name="login" value="loc" />';
                 }
             }
         }
@@ -2327,7 +2369,7 @@
     if (defined($in{'curr_authtype'})) {
         if ($in{'curr_authtype'} eq 'fsys') {
             if ($can_assign{'fsys'}) {
-                $fsyscheck = 'checked="on" ';
+                $fsyscheck = 'checked="checked" ';
                 if (defined($in{'mode'})) {
                     if ($in{'mode'} eq 'modifyuser') {
                         $fsyscheck = '';
@@ -2340,7 +2382,7 @@
         }
     } else {
         if ($authnum == 1) {
-            $authtype = '<input type="hidden" name="login" value="fsys">';
+            $authtype = '<input type="hidden" name="login" value="fsys" />';
         }
     }
     if (!$can_assign{'fsys'}) {
@@ -2349,7 +2391,7 @@
         if (defined($in{'mode'})) {
             if ($in{'mode'} eq 'modifycourse') {
                 if ($authnum == 1) {
-                    $authtype = '<input type="hidden" name="login" value="fsys">';
+                    $authtype = '<input type="hidden" name="login" value="fsys" />';
                 }
             }
         }
@@ -2717,6 +2759,43 @@
     &Apache::lonnet::devalidate_cache_new('emailscache',$id);
 }
 
+# -------------------------------------------------------------------- getlangs
+
+=pod
+
+=item * &getlangs($uname,$udom)
+
+Gets a user's language preference and returns it as a hash with key:
+language.
+
+=cut
+
+
+sub getlangs {
+    my ($uname,$udom) = @_;
+    if (!$udom)  { $udom =$env{'user.domain'}; }
+    if (!$uname) { $uname=$env{'user.name'};   }
+    my $id=$uname.':'.$udom;
+    my ($langs,$cached)=&Apache::lonnet::is_cached_new('userlangs',$id);
+    if ($cached) {
+        return %{$langs};
+    } else {
+        my %loadlangs=&Apache::lonnet::get('environment',['languages'],
+                                           $udom,$uname);
+        &Apache::lonnet::do_cache_new('userlangs',$id,\%loadlangs);
+        return %loadlangs;
+    }
+}
+
+sub flush_langs_cache {
+    my ($uname,$udom)=@_;
+    if (!$udom)  { $udom =$env{'user.domain'}; }
+    if (!$uname) { $uname=$env{'user.name'};   }
+    return if ($udom eq 'public' && $uname eq 'public');
+    my $id=$uname.':'.$udom;
+    &Apache::lonnet::devalidate_cache_new('userlangs',$id);
+}
+
 # ------------------------------------------------------------------ Screenname
 
 =pod
@@ -2735,6 +2814,25 @@
     return $names{'screenname'};
 }
 
+# ------------------------------------------------------------- Confirm Wrapper
+=pod
+
+=item confirmwrapper
+
+Wrap messages about completion of operation in box
+
+=cut
+
+sub confirmwrapper {
+    my ($message)=@_;
+    if ($message) {
+        return "\n".'<div class="LC_confirm_box">'."\n"
+               .$message."\n"
+               .'</div>'."\n";
+    } else {
+        return $message;
+    }
+}
 
 # ------------------------------------------------------------- Message Wrapper
 
@@ -2761,7 +2859,7 @@
         return;
     }
     return '<a href="/adm/'.$domain.'/'.$username.'/aboutme"'.
-	($target?' target="$target"':'').' title="'.&mt("View this user's personal page").'">'.$link.'</a>';
+	($target?' target="$target"':'').' title="'.&mt("View this user's personal information page").'">'.$link.'</a>';
 }
 
 # ------------------------------------------------------------ Syllabus Wrapper
@@ -2796,6 +2894,27 @@
 	&help_open_topic('View_recent_activity');
 }
 
+sub slot_reservations_link {
+    my ($linktext,$sname,$sdom,$target) = @_;
+    my $link ="/adm/slotrequest?command=showresv&amp;origin=aboutme";
+    my $title = 'View slot reservation history';
+    if (defined($sname) && $sname !~ /^\s*$/ &&
+        defined($sdom)  && $sdom  !~ /^\s*$/) {
+        $link .= "&amp;uname=$sname&amp;udom=$sdom";
+        $title .= ' of this student';
+    }
+    if (defined($target) && $target !~ /^\s*$/) {
+        $target = qq{target="$target"};
+    } else {
+        $target = '';
+    }
+    $title = &mt($title);
+    $linktext = &mt($linktext);
+    return qq{<a href="$link" title="$title" $target>$linktext</a>};
+# FIXME uncomment when help item created: &help_open_topic('Slot_Reservation_History');
+
+}
+
 # ===================================================== Display a student photo
 
 
@@ -3033,6 +3152,28 @@
     return $preferred_possibilities[0];
 }
 
+sub user_lang {
+    my ($touname,$toudom,$fromcid) = @_;
+    my @userlangs;
+    if (($fromcid ne '') && ($env{'course.'.$fromcid.'.languages'} ne '')) {
+        @userlangs=(@userlangs,split(/\s*(\,|\;|\:)\s*/,
+                    $env{'course.'.$fromcid.'.languages'}));
+    } else {
+        my %langhash = &getlangs($touname,$toudom);
+        if ($langhash{'languages'} ne '') {
+            @userlangs = split(/\s*(\,|\;|\:)\s*/,$langhash{'languages'});
+        } else {
+            my %domdefs = &Apache::lonnet::get_domain_defaults($toudom);
+            if ($domdefs{'lang_def'} ne '') {
+                @userlangs = ($domdefs{'lang_def'});
+            }
+        }
+    }
+    my @languages=&Apache::lonlocal::get_genlanguages(@userlangs);
+    my $user_lh = Apache::localize->get_handle(@languages);
+    return $user_lh;
+}
+
 ###############################################################
 ##               Student Answer Attempts                     ##
 ###############################################################
@@ -3171,7 +3312,7 @@
     }
     $thisdir=~s-/[^/]*$--;
     foreach my $link (@rlinks) {
-	unless (($link=~/^http:\/\//i) ||
+	unless (($link=~/^https?\:\/\//i) ||
 		($link=~/^\//) ||
 		($link=~/^javascript:/i) ||
 		($link=~/^mailto:/i) ||
@@ -3748,7 +3889,7 @@
                              &Apache::lonnet::coursedescription($course);
                         $coursedesc = $courseinfo{'description'};
                     }
-                    $category = "Group files in the course '$coursedesc'";
+                    $category = "Group portfolio files in the course '$coursedesc'";
                 } else {
                     $category = 'Portfolio files belonging to ';
                     if ($env{'user.name'} eq 'public' && 
@@ -3880,7 +4021,14 @@
         if (ref($domconfig{'login'}) eq 'HASH') {
             if (keys(%{$domconfig{'login'}})) {
                 foreach my $key (keys(%{$domconfig{'login'}})) {
-                    $designhash{$udom.'.login.'.$key}=$domconfig{'login'}{$key};
+                    if (ref($domconfig{'login'}{$key}) eq 'HASH') {
+                        foreach my $img (keys(%{$domconfig{'login'}{$key}})) {
+                            $designhash{$udom.'.login.'.$key.'_'.$img} =
+                                $domconfig{'login'}{$key}{$img};
+                        }
+                    } else {
+                        $designhash{$udom.'.login.'.$key}=$domconfig{'login'}{$key};
+                    }
                 }
             } else {
                 $legacy{'login'} = 1;
@@ -4102,7 +4250,7 @@
     my $font =   &designparm($function.'.font',$domain);
     my $pgbg   = $bgcolor || &designparm($function.'.pgbg',$domain);
 
-    my %design = ( 'style'   => 'margin-top: 0px',
+    my %design = ( 'style'   => 'margin-top: 0',
 		   'bgcolor' => $pgbg,
 		   'text'    => $font,
                    'alink'   => &designparm($function.'.alink',$domain),
@@ -4406,8 +4554,8 @@
     my $feedback_link_bg     = '#BBBBBB';
 
     my $border = ($env{'browser.type'} eq 'explorer' ||
-		  $env{'browser.type'} eq 'safari'     ) ? '0px 2px 0px 2px'
-	                                                 : '0px 3px 0px 4px';
+		  $env{'browser.type'} eq 'safari'     ) ? '0 2px 0 2px'
+	                                                 : '0 3px 0 4px';
 
 
     return <<END;
@@ -4442,25 +4590,34 @@
 .LC_diff_added {
   color: green;
 }
-.LC_unknown {
-  color: yellow;
+
+div.LC_confirm_box {
+  background-color: #FAFAFA;
+  border: 1px solid $lg_border_color;
+  margin-right: 0;
+  padding: 5px;
+}
+
+div.LC_confirm_box .LC_error img,
+div.LC_confirm_box .LC_success img {
+  vertical-align: middle;
 }
 
 .LC_icon {
-  border: 0px;
+  border: none;
 }
 .LC_indexer_icon {
-  border: 0px;
+  border: 0;
   height: 22px;
 }
 .LC_docs_spacer {
   width: 25px;
   height: 1px;
-  border: 0px;
+  border: none;
 }
 
 .LC_internal_info {
-  color: #999;
+  color: #999999;
 }
 
 table.LC_pastsubmission {
@@ -4473,7 +4630,7 @@
   background: $pgbg;
   border: 2px;
   border-collapse: separate;
-  padding: 0px;
+  padding: 0;
 }
 
 table#LC_title_bar, table.LC_breadcrumbs, 
@@ -4486,7 +4643,7 @@
   background: $pgbg;
   font-family: $sans;
   border-collapse: collapse;
-  padding: 0px;
+  padding: 0;
 }
 
 table.LC_docs_path {
@@ -4495,7 +4652,7 @@
   background: $pgbg;
   font-family: $sans;
   border-collapse: collapse;
-  padding: 0px;
+  padding: 0;
 }
 
 table#LC_title_bar td {
@@ -4516,27 +4673,27 @@
 table#LC_title_bar td.LC_title_bar_domain_logo {
   background: $sidebg;
   text-align: right;
-  padding: 0px;
+  padding: 0;
 }
 table#LC_title_bar td.LC_title_bar_role_logo {
   background: $sidebg;
-  padding: 0px;
+  padding: 0;
 }
 
 table#LC_menubuttons_mainmenu {
   width: 100%;
-  border: 0px;
+  border: 0;
   border-spacing: 1px;
-  padding: 0px 1px;
-  margin: 0px;
+  padding: 0 1px;
+  margin: 0;
   border-collapse: separate;
 }
 table#LC_menubuttons img, table#LC_menubuttons_mainmenu img {
-  border: 0px;
+  border: none;
 }
 table#LC_top_nav td {
   background: $tabbg;
-  border: 0px;
+  border: none;
   font-size: small;
 }
 table#LC_top_nav td a, div#LC_top_nav a {
@@ -4550,7 +4707,7 @@
   width: 31px;
 }
 table#LC_top_nav td.LC_top_nav_logo img {
-  border: 0px;
+  border: none;
   vertical-align: bottom;
 }
 table#LC_top_nav td.LC_top_nav_exit,
@@ -4591,7 +4748,7 @@
 .LC_menubuttons_link {
   text-decoration: none;
 }
-#2008--9-5: new menu style sheet.Changed category
+/*2008--9-5: new menu style sheet.Changed category*/
 .LC_menubuttons_category {
   color: $font;
   background: $pgbg;
@@ -4619,35 +4776,6 @@
   font-weight: bold;
 }
 
-.LC_rolesmenu_is {
-  font-family: $sans;
-}
-
-.LC_rolesmenu_selected {
-  font-family: $sans;
-}
-
-.LC_rolesmenu_future {
-  font-family: $sans;
-}
-
-
-.LC_rolesmenu_will {
-  font-family: $sans;
-}
-
-.LC_rolesmenu_will_not {
-  font-family: $sans;
-}
-
-.LC_rolesmenu_expired {
-  font-family: $sans;
-}
-
-.LC_rolesinfo {
-  font-family: $sans;
-}
-
 .LC_dropadd_labeltext {
   font-family: $sans;
   text-align: right;
@@ -4662,10 +4790,14 @@
   font-size: smaller;
 }
 
+.LC_mail_functions {
+    font-weight: bold;
+}
+
 table.LC_aboutme_port {
-  border: 0px;
+  border: none;
   border-collapse: collapse;
-  border-spacing: 0px;
+  border-spacing: 0;
 }
 table.LC_data_table, table.LC_mail_list {
   border: 1px solid #000000;
@@ -4679,13 +4811,13 @@
 table.LC_nested_outer {
   border: 1px solid #000000;
   border-collapse: collapse;
-  border-spacing: 0px;
+  border-spacing: 0;
   width: 100%;
 }
 table.LC_nested {
-  border: 0px;
+  border: none;
   border-collapse: collapse;
-  border-spacing: 0px;
+  border-spacing: 0;
   width: 100%;
 }
 table.LC_data_table tr th, table.LC_calendar tr th, table.LC_mail_list tr th,
@@ -4694,14 +4826,22 @@
   background-color: $data_table_head;
   font-size: smaller;
 }
+table.LC_data_table tr.LC_info_row > td {
+  background-color: #CCCCCC;
+  font-weight: bold;
+  text-align: left;
+}
 table.LC_data_table tr.LC_odd_row > td, 
+table.LC_pick_box tr > td.LC_odd_row,
 table.LC_aboutme_port tr td {
   background-color: $data_table_light;
   padding: 2px;
 }
 table.LC_data_table tr.LC_even_row > td,
+table.LC_pick_box tr > td.LC_even_row,
 table.LC_aboutme_port tr.LC_even_row td {
   background-color: $data_table_dark;
+  padding: 2px;
 }
 table.LC_data_table tr.LC_data_table_highlight td {
   background-color: $data_table_darker;
@@ -4735,7 +4875,7 @@
   text-align: right;
 }
 table.LC_nested tr.LC_info_row td {
-  background-color: #CCC;
+  background-color: #CCCCCC;
   font-weight: bold;
   font-size: small;
   text-align: center;
@@ -4745,7 +4885,7 @@
   text-align: left;
 }
 table.LC_nested td {
-  background-color: #FFF;
+  background-color: #FFFFFF;
   font-size: small;
 }
 table.LC_nested_outer tr th.LC_right_item,
@@ -4756,7 +4896,7 @@
 }
 
 table.LC_nested tr.LC_odd_row td {
-  background-color: #EEE;
+  background-color: #EEEEEE;
 }
 
 table.LC_createuser {
@@ -4767,7 +4907,7 @@
 }
 
 table.LC_createuser tr.LC_info_row td  {
-  background-color: #CCC;
+  background-color: #CCCCCC;
   font-weight: bold;
   text-align: center;
 }
@@ -4823,10 +4963,10 @@
 table#LC_portfolio_actions {
   width: auto;
   background: $pgbg;
-  border: 0px;
+  border: none;
   border-spacing: 2px 2px;
-  padding: 0px;
-  margin: 0px;
+  padding: 0;
+  margin: 0;
   border-collapse: separate;
 }
 table#LC_portfolio_actions td.LC_label {
@@ -4882,6 +5022,26 @@
 table#LC_browser tr.LC_browser_folder {
   background: #CCCCFF;
 }
+
+table.LC_data_table tr > td.LC_roles_is {
+/*  background: #77FF77; */
+}
+table.LC_data_table tr > td.LC_roles_future {
+  background: #FFFF77;
+}
+table.LC_data_table tr > td.LC_roles_will {
+  background: #FFAA77;
+}
+table.LC_data_table tr > td.LC_roles_expired {
+  background: #FF7777;
+}
+table.LC_data_table tr > td.LC_roles_will_not {
+  background: #AAFF77;
+}
+table.LC_data_table tr > td.LC_roles_selected {
+  background: #11CC55;
+}
+
 span.LC_current_location {
   font-size: x-large;
   background: $pgbg;
@@ -4927,9 +5087,9 @@
   border-color: $pgbg;
 }
 table#LC_helpmenu {
-  border: 0px;
+  border: none;
   height: 55px;
-  border-spacing: 0px;
+  border-spacing: 0;
 }
 
 table#LC_helpmenu fieldset legend {
@@ -4940,7 +5100,7 @@
   width: 100%;
   border: 1px solid black;
   background: $pgbg;
-  padding: 0px;
+  padding: 0;
   border-spacing: 1px;
 }
 table#LC_helpmenu_links tr td {
@@ -4982,6 +5142,7 @@
   background: $tabbg;
   font-weight: bold;
   text-align: right;
+  vertical-align: top;
   width: 184px;
   padding: 8px;
 }
@@ -5002,7 +5163,7 @@
   padding: 8px;
 }
 table.LC_pick_box td.LC_pick_box_separator {
-  padding: 0px;
+  padding: 0;
   height: 1px;
   background: black;
 }
@@ -5044,7 +5205,7 @@
   background-color: $data_table_light;
 }
 table.LC_helpform_receipt td.LC_pick_box_separator {
-  padding: 0px;
+  padding: 0;
   height: 1px;
   background: black;
 }
@@ -5077,7 +5238,7 @@
 }
 table.LC_group_priv td {
   text-align: left;
-  padding: 0px;
+  padding: 0;
 }
 
 table.LC_notify_front_page {
@@ -5098,6 +5259,7 @@
   background: $tabbg;
   vertical-align: middle;
   margin: 2ex 0ex 2ex 0ex;
+  padding: 3px;
 }
 .LC_topic_bar span {
   vertical-align: middle;
@@ -5214,7 +5376,7 @@
 
 table.LC_docs_documents {
   background: #BBBBBB;
-  border-width: 0px;
+  border-width: 0;
   border-collapse: collapse;
 }
 
@@ -5231,7 +5393,7 @@
 }
 
 .LC_docs_entry_move {
-  border: 0px;
+  border: none;
   border-collapse: collapse;
 }
 
@@ -5287,7 +5449,7 @@
 }
 
 table.LC_double_column {
-  border-width: 0px;
+  border-width: 0;
   border-collapse: collapse;
   width: 100%;
   padding: 2px;
@@ -5426,7 +5588,7 @@
 
   background: $tabbg;
   border-collapse: collapse;
-  padding: 0px
+  padding: 0;
 }
 
 div.LC_edit_problem_discards {
@@ -5442,7 +5604,7 @@
   color: $tabbg;
   background-color: $tabbg;
   height: 3px;
-  border: 0px;
+  border: none;
 }
 img.stift{
   border-width:0;
@@ -5467,9 +5629,14 @@
   font-weight: bold;
 }
 fieldset#LC_mainmenu_fieldset {
-  margin:0px 10px 10px 0px;
+  margin:0 10px 10px 0;
+
+}
 
+div.LC_createcourse {
+    margin: 10px 10px 10px 10px;
 }
+
 END
 }
 
@@ -5738,9 +5905,24 @@
     if ($args->{'html_encode'}) {
 	$result = &html_encode($result);
     }
-    return $result;
-}
+    #Breadcrumbs
+    if (exists($args->{'bread_crumbs'}) or exists($args->{'bread_crumbs_component'})) {
+        &Apache::lonhtmlcommon::clear_breadcrumbs();
+        #if any br links exists, add them to the breadcrumbs
+        if (exists($args->{'bread_crumbs'}) and ref($args->{'bread_crumbs'}) eq 'ARRAY') {
+            foreach my $crumb (@{$args->{'bread_crumbs'}}){
+                &Apache::lonhtmlcommon::add_breadcrumb($crumb);
+            }
+        }
 
+        #if bread_crumbs_component exists show it as headline else show only the breadcrumbs
+        if (exists($args->{'bread_crumbs_component'})){
+            $result .= &Apache::lonhtmlcommon::breadcrumbs($args->{'bread_crumbs_component'});
+        } else {
+            $result .= &Apache::lonhtmlcommon::breadcrumbs();
+        }
+    }
+    return $result;
 
 =pod
 
@@ -5983,6 +6165,37 @@
 
 =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
@@ -6498,21 +6711,37 @@
                                             ['quotas'],$udom);
     if (ref($quotahash{'quotas'}) eq 'HASH') {
         if ($inststatus ne '') {
-            my @statuses = split(/:/,$inststatus);
+            my @statuses = map { &unescape($_); } split(/:/,$inststatus);
             foreach my $item (@statuses) {
-                if ($quotahash{'quotas'}{$item} ne '') {
-                    if ($defquota eq '') {
-                        $defquota = $quotahash{'quotas'}{$item};
-                        $settingstatus = $item;
-                    } elsif ($quotahash{'quotas'}{$item} > $defquota) {
-                        $defquota = $quotahash{'quotas'}{$item};
-                        $settingstatus = $item;
+                if (ref($quotahash{'quotas'}{'defaultquota'}) eq 'HASH') {
+                    if ($quotahash{'quotas'}{'defaultquota'}{$item} ne '') {
+                        if ($defquota eq '') {
+                            $defquota = $quotahash{'quotas'}{'defaultquota'}{$item};
+                            $settingstatus = $item;
+                        } elsif ($quotahash{'quotas'}{'defaultquota'}{$item} > $defquota) {
+                            $defquota = $quotahash{'quotas'}{'defaultquota'}{$item};
+                            $settingstatus = $item;
+                        }
+                    }
+                } else {
+                    if ($quotahash{'quotas'}{$item} ne '') {
+                        if ($defquota eq '') {
+                            $defquota = $quotahash{'quotas'}{$item};
+                            $settingstatus = $item;
+                        } elsif ($quotahash{'quotas'}{$item} > $defquota) {
+                            $defquota = $quotahash{'quotas'}{$item};
+                            $settingstatus = $item;
+                        }
                     }
                 }
             }
         }
         if ($defquota eq '') {
-            $defquota = $quotahash{'quotas'}{'default'};
+            if (ref($quotahash{'quotas'}{'defaultquota'}) eq 'HASH') {
+                $defquota = $quotahash{'quotas'}{'defaultquota'}{'default'};
+            } else {
+                $defquota = $quotahash{'quotas'}{'default'};
+            }
             $settingstatus = 'default';
         }
     } else {
@@ -6661,12 +6890,14 @@
                 if ($cancreate) {
                     $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>';
                 } else {
-                    my $helplink = ' href="javascript:helpMenu('."'display'".')"';
+                    my $helplink = 'javascript:helpMenu('."'display'".')';
                     my %usertypetext = (
                         official   => 'institutional',
                         unofficial => 'non-institutional',
                     );
-                    $new_user_create = '<br /><span class="LC_warning">'.&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.").' '.&mt('Contact the <a[_1]>helpdesk</a> for assistance.',$helplink).'</span><br /><br />';
+                    $new_user_create = '<p class="LC_warning">'.
+                                       &mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.").' '.
+                                       &mt('Please contact the [_1]helpdesk[_2] for assistance.','<a href="'.$helplink.'">','</a>').'</p><br />';
                 }
             }
         }
@@ -6948,6 +7179,7 @@
                         middlename => 'Middle Name',
                         generation => 'Generation',
                         gen => 'Generation',
+                        inststatus => 'Affiliation',
                    );
     return %fieldtitles;
 }
@@ -7017,6 +7249,56 @@
 
 =pod
 
+=head1 Slot Helpers
+
+=over 4
+
+=item * sorted_slots()
+
+Sorts an array of slot names in order of slot start time (earliest first).
+
+Inputs:
+
+=over 4
+
+slotsarr  - Reference to array of unsorted slot names.
+
+slots     - Reference to hash of hash, where outer hash keys are slot names.
+
+=back
+
+Returns:
+
+=over 4
+
+sorted   - An array of slot names sorted by the start time of the slot.
+
+=back
+
+=back
+
+=cut
+
+
+sub sorted_slots {
+    my ($slotsarr,$slots) = @_;
+    my @sorted;
+    if ((ref($slotsarr) eq 'ARRAY') && (ref($slots) eq 'HASH')) {
+        @sorted =
+            sort {
+                     if (ref($slots->{$a}) && ref($slots->{$b})) {
+                         return $slots->{$a}{'starttime'} <=> $slots->{$b}{'starttime'}
+                     }
+                     if (ref($slots->{$a})) { return -1;}
+                     if (ref($slots->{$b})) { return 1;}
+                     return 0;
+                 } @{$slotsarr};
+    }
+    return @sorted;
+}
+
+=pod
+
 =back
 
 =head1 HTTP Helpers
@@ -7569,7 +7851,7 @@
 #                 xml   => &mt('HTML/XML'),
                  );
     my $Str = '<input type="file" name="upfile" size="50" />'.
-        '<br />Type: <select name="upfiletype">';
+        '<br />'.&mt('Type').': <select name="upfiletype">';
     foreach my $type (sort(keys(%Types))) {
         $Str .= '<option value="'.$type.'" >'.$Types{$type}."</option>\n";
     }
@@ -8313,9 +8595,10 @@
 
 =item * &build_recipient_list()
 
-Build recipient lists for three types of e-mail:
-(a) Error Reports, (b) Package Updates, (c) Help requests, generated by
-lonerrorhandler.pm, CHECKRPMS and lonsupportreq.pm respectively.
+Build recipient lists for four 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.
 
 Inputs:
 defmail (scalar - email address of default recipient), 
@@ -8339,17 +8622,21 @@
     my %domconfig =
          &Apache::lonnet::get_dom('configuration',['contacts'],$defdom);
     if (ref($domconfig{'contacts'}) eq 'HASH') {
-        if (ref($domconfig{'contacts'}{$mailing}) eq 'HASH') {
-            my @contacts = ('adminemail','supportemail');
-            foreach my $item (@contacts) {
-                if ($domconfig{'contacts'}{$mailing}{$item}) {
-                    my $addr = $domconfig{'contacts'}{$item}; 
-                    if (!grep(/^\Q$addr\E$/,@recipients)) {
-                        push(@recipients,$addr);
+        if (exists($domconfig{'contacts'}{$mailing})) {
+            if (ref($domconfig{'contacts'}{$mailing}) eq 'HASH') {
+                my @contacts = ('adminemail','supportemail');
+                foreach my $item (@contacts) {
+                    if ($domconfig{'contacts'}{$mailing}{$item}) {
+                        my $addr = $domconfig{'contacts'}{$item};
+                        if (!grep(/^\Q$addr\E$/,@recipients)) {
+                            push(@recipients,$addr);
+                        }
                     }
+                    $otheremails = $domconfig{'contacts'}{$mailing}{'others'};
                 }
-                $otheremails = $domconfig{'contacts'}{$mailing}{'others'};
             }
+        } elsif ($origmail ne '') {
+            push(@recipients,$origmail);
         }
     } elsif ($origmail ne '') {
         push(@recipients,$origmail);
@@ -8993,7 +9280,9 @@
                    'policy.email',
                    'comment.email',
                    'pch.users.denied',
-                   'plc.users.denied'],
+                   'plc.users.denied',
+                   'hidefromcat',
+                   'categories'],
                    $$crsudom,$$crsunum);
     }
 
@@ -9321,6 +9610,22 @@
     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;
+}
+
 # -------------------------------------------------------- Initliaze user login
 sub init_user_environment {
     my ($r, $username, $domain, $authhost, $form, $args) = @_;
@@ -9451,6 +9756,17 @@
 	    }
 	}
 
+        foreach my $tool ('aboutme','blog','portfolio') {
+            $userenv{'availabletools.'.$tool} =
+                &Apache::lonnet::usertools_access($username,$domain,$tool,'reload');
+        }
+
+        foreach my $crstype ('official','unofficial') {
+            $userenv{'canrequest.'.$crstype} =
+                &Apache::lonnet::usertools_access($username,$domain,$crstype,
+                                                  'reload','requestcourses');
+        }
+
 	$env{'user.environment'} = "$lonids/$cookie.id";
 	
 	if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id",
@@ -9489,7 +9805,7 @@
 # --- Get the symbolic name of a problem and the url
 sub get_symb {
     my ($request,$silent) = @_;
-    (my $url=$env{'form.url'}) =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
+    (my $url=$env{'form.url'}) =~ s-^https?\://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
     my $symb=($env{'form.symb'} ne '' ? $env{'form.symb'} : (&Apache::lonnet::symbread($url)));
     if ($symb eq '') {
         if (!$silent) {
@@ -9516,11 +9832,13 @@
 }
 
 sub clean_symb {
-    my ($symb) = @_;
+    my ($symb,$delete_enc) = @_;
 
     &Apache::lonenc::check_decrypt(\$symb);
     my $enc = $env{'request.enc'};
-    delete($env{'request.enc'});
+    if ($delete_enc) {
+        delete($env{'request.enc'});
+    }
 
     return ($symb,$enc);
 }

--raeburn1242883631--