Diff for /loncom/interface/loncommon.pm between versions 1.518 and 1.537

version 1.518, 2007/04/04 00:10:01 version 1.537, 2007/06/18 23:19:12
Line 240  Inputs: formname, elementname Line 240  Inputs: formname, elementname
   
 formname and elementname specify the name of the html form and the name  formname and elementname specify the name of the html form and the name
 of the element the selection from the search results will be placed in.  of the element the selection from the search results will be placed in.
   =back
 =cut  =cut
   
 sub browser_and_searcher_javascript {  sub browser_and_searcher_javascript {
Line 1272  sub domain_select { Line 1272  sub domain_select {
   
 =pod  =pod
   
   =head1 Routines for form select boxes
   
   =over 4
   
   =cut
   
 =item * multiple_select_form($name,$value,$size,$hash,$order)  =item * multiple_select_form($name,$value,$size,$hash,$order)
   
 Returns a string containing a <select> element int multiple mode  Returns a string containing a <select> element int multiple mode
Line 1461  sub home_server_option_list { Line 1467  sub home_server_option_list {
   
 =pod  =pod
   
 =back  =back 
   
 =cut  =cut
   
Line 2048  if $first is set to 'lastname' then it r Line 2054  if $first is set to 'lastname' then it r
 ###############################################################  ###############################################################
 sub plainname {  sub plainname {
     my ($uname,$udom,$first)=@_;      my ($uname,$udom,$first)=@_;
       return if (!defined($uname) || !defined($udom));
     my %names=&getnames($uname,$udom);      my %names=&getnames($uname,$udom);
     my $name=&Apache::lonnet::format_name($names{'firstname'},      my $name=&Apache::lonnet::format_name($names{'firstname'},
   $names{'middlename'},    $names{'middlename'},
Line 2079  if the user does not Line 2086  if the user does not
   
 sub nickname {  sub nickname {
     my ($uname,$udom)=@_;      my ($uname,$udom)=@_;
       return if (!defined($uname) || !defined($udom));
     my %names=&getnames($uname,$udom);      my %names=&getnames($uname,$udom);
     my $name=$names{'nickname'};      my $name=$names{'nickname'};
     if ($name) {      if ($name) {
Line 2094  sub nickname { Line 2102  sub nickname {
   
 sub getnames {  sub getnames {
     my ($uname,$udom)=@_;      my ($uname,$udom)=@_;
       return if (!defined($uname) || !defined($udom));
     if ($udom eq 'public' && $uname eq 'public') {      if ($udom eq 'public' && $uname eq 'public') {
  return ('lastname' => &mt('Public'));   return ('lastname' => &mt('Public'));
     }      }
Line 2908  sub blockcheck { Line 2917  sub blockcheck {
         }          }
         my $no_ownblock = 0;          my $no_ownblock = 0;
         my $no_userblock = 0;          my $no_userblock = 0;
         if ($otheruser) {          if ($otheruser && $activity ne 'com') {
             # Check if current user has 'evb' priv for this              # Check if current user has 'evb' priv for this
             if (defined($own_courses{$course})) {              if (defined($own_courses{$course})) {
                 foreach my $sec (keys(%{$own_courses{$course}})) {                  foreach my $sec (keys(%{$own_courses{$course}})) {
Line 3161  Returns: Determines which domain should Line 3170  Returns: Determines which domain should
 ###############################################  ###############################################
 sub determinedomain {  sub determinedomain {
     my $domain=shift;      my $domain=shift;
    if (! $domain) {      if (! $domain) {
         # Determine domain if we have not been given one          # Determine domain if we have not been given one
         $domain = $Apache::lonnet::perlvar{'lonDefDomain'};          $domain = $Apache::lonnet::perlvar{'lonDefDomain'};
         if ($env{'user.domain'}) { $domain=$env{'user.domain'}; }          if ($env{'user.domain'}) { $domain=$env{'user.domain'}; }
Line 3218  sub get_domainconf { Line 3227  sub get_domainconf {
             }              }
         }          }
         if (-e '/home/httpd/html/adm/lonDomLogos/'.$udom.'.gif') {          if (-e '/home/httpd/html/adm/lonDomLogos/'.$udom.'.gif') {
             $designhash{$udom.'.login.domlogo'} =               $designhash{$udom.'.login.domlogo'} = "/adm/lonDomLogos/$udom.gif";
                 &lonhttpdurl("/adm/lonDomLogos/$udom.gif");   
         }          }
     }      }
     &Apache::lonnet::do_cache_new('domainconfig',$udom,\%designhash,      &Apache::lonnet::do_cache_new('domainconfig',$udom,\%designhash,
Line 3244  sub domainlogo { Line 3252  sub domainlogo {
     my %designhash = &get_domainconf($domain);          my %designhash = &get_domainconf($domain);    
     # See if there is a logo      # See if there is a logo
     if ($designhash{$domain.'.login.domlogo'} ne '') {      if ($designhash{$domain.'.login.domlogo'} ne '') {
         return '<img src="'.$designhash{$domain.'.login.domlogo'}.          my $imgsrc = $designhash{$domain.'.login.domlogo'};
                '" alt="'.$domain.'" />';          if ($imgsrc =~ /^\/(adm|res)/) {
               $imgsrc = &lonhttpdurl($imgsrc);
           } 
           return '<img src="'.$imgsrc.'" alt="'.$domain.'" />';
     } elsif (defined(&Apache::lonnet::domain($domain,'description'))) {      } elsif (defined(&Apache::lonnet::domain($domain,'description'))) {
         return &Apache::lonnet::domain($domain,'description');          return &Apache::lonnet::domain($domain,'description');
     } else {      } else {
Line 3284  sub designparm { Line 3295  sub designparm {
     }      }
     $domain=&determinedomain($domain);      $domain=&determinedomain($domain);
     my %domdesign = &get_domainconf($domain);      my %domdesign = &get_domainconf($domain);
       my $output;
     if ($domdesign{$domain.'.'.$which} ne '') {      if ($domdesign{$domain.'.'.$which} ne '') {
  return $domdesign{$domain.'.'.$which};   $output = $domdesign{$domain.'.'.$which};
     } else {      } else {
         return $defaultdesign{$which};          $output = $defaultdesign{$which};
     }      }
       if (($which =~ /^(student|coordinator|author|admin)\.img$/) ||
           ($which =~ /login\.(img|logo|domlogo)/)) {
           if ($output =~ /^\/(adm|res)\//) {
               $output = &lonhttpdurl($output);
           }
       }
       return $output;
 }  }
   
 ###############################################  ###############################################
Line 3397  sub bodytag { Line 3416  sub bodytag {
     my $bodytag = "<body $extra_body_attr>".      my $bodytag = "<body $extra_body_attr>".
  &Apache::lontexconvert::init_math_support();   &Apache::lontexconvert::init_math_support();
   
     if ($bodyonly       if ($bodyonly) {
  || ($env{'request.state'} eq 'construct'   
     && $env{'environment.remote'} ne 'off' )) {  
         return $bodytag;          return $bodytag;
     } elsif ($env{'browser.interface'} eq 'textual') {      } elsif ($env{'browser.interface'} eq 'textual') {
 # Accessibility  # Accessibility
Line 3676  sub standard_css { Line 3693  sub standard_css {
     my $border = ($env{'browser.type'} eq 'explorer') ? '0px 2px 0px 2px'      my $border = ($env{'browser.type'} eq 'explorer') ? '0px 2px 0px 2px'
                                               : '0px 3px 0px 4px';                                                : '0px 3px 0px 4px';
   
   
     return <<END;      return <<END;
 h1, h2, h3, th { font-family: $sans }  h1, h2, h3, th { font-family: $sans }
 a:focus { color: red; background: yellow }   a:focus { color: red; background: yellow } 
 table.thinborder,  table.thinborder,
 table.LC_optres_prior {  
   border-collapse: collapse;  
 }  
 table.thinborder tr th {  table.thinborder tr th {
   border-style: solid;    border-style: solid;
   border-width: 1px;    border-width: 1px;
   background: $tabbg;    background: $tabbg;
 }  }
 table.thinborder tr td,   table.thinborder tr td {
 table.LC_optres_prior tr td {  
   border-style: solid;    border-style: solid;
   border-width: 1px    border-width: 1px
 }  }
Line 3705  form, .inline { display: inline; } Line 3720  form, .inline { display: inline; }
 .LC_diff_removed {  .LC_diff_removed {
   color: red;    color: red;
 }  }
   
   .LC_info,
 .LC_success,  .LC_success,
 .LC_diff_added {  .LC_diff_added {
   color: green;    color: green;
Line 3713  form, .inline { display: inline; } Line 3730  form, .inline { display: inline; }
   border: 0px;    border: 0px;
 }  }
   
   .LC_internal_info {
     color: #999;
   }
   
 table.LC_pastsubmission {  table.LC_pastsubmission {
   border: 1px solid black;    border: 1px solid black;
   margin: 2px;    margin: 2px;
Line 3774  table#LC_title_bar td.LC_title_bar_role_ Line 3795  table#LC_title_bar td.LC_title_bar_role_
 }  }
   
 table#LC_menubuttons_mainmenu {  table#LC_menubuttons_mainmenu {
   background: $pgbg;    width: 100%;
   border: 0px;    border: 0px;
   border-spacing: 1px;    border-spacing: 1px;
   padding: 0px 1px;    padding: 0px 1px;
Line 3829  td.LC_table_cell_checkbox { Line 3850  td.LC_table_cell_checkbox {
   text-align: center;    text-align: center;
 }  }
   
   table#LC_mainmenu td.LC_mainmenu_column {
       vertical-align: top;
   }
   
 .LC_menubuttons_inline_text {  .LC_menubuttons_inline_text {
   color: $font;    color: $font;
   font-family: $sans;    font-family: $sans;
   font-size: smaller;    font-size: smaller;
 }  }
   
   .LC_menubuttons_link {
     text-decoration: none;
   }
   
   .LC_menubuttons_category {
     color: $font;
     background: $pgbg;
     font-family: $sans;
     font-size: larger;
     font-weight: bold;
   }
   
 td.LC_menubuttons_text {  td.LC_menubuttons_text {
     width: 90%;
   color: $font;    color: $font;
   font-family: $sans;    font-family: $sans;
 }  }
   
 td.LC_menubuttons_img {  td.LC_menubuttons_img {
   background: $tabbg;  
 }  }
   
 .LC_current_location {  .LC_current_location {
   font-family: $sans;    font-family: $sans;
   background: $tabbg;    background: $tabbg;
Line 3851  td.LC_menubuttons_img { Line 3890  td.LC_menubuttons_img {
   font-weight: bold;    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;
   }
   
   .LC_preferences_labeltext {
     font-family: $sans;
     text-align: right;
   }
   
 table.LC_aboutme_port {  table.LC_aboutme_port {
   border: 0px;    border: 0px;
   border-collapse: collapse;    border-collapse: collapse;
Line 3876  table.LC_nested { Line 3954  table.LC_nested {
   border-spacing: 0px;    border-spacing: 0px;
   width: 100%;    width: 100%;
 }  }
 table.LC_data_table tr th, table.LC_calendar tr th, table.LC_mail_list tr th {  table.LC_data_table tr th, table.LC_calendar tr th, table.LC_mail_list tr th,
   table.LC_prior_tries tr th {
   font-weight: bold;    font-weight: bold;
   background-color: $data_table_head;    background-color: $data_table_head;
   font-size: smaller;    font-size: smaller;
Line 4254  span.LC_feedback_link { Line 4333  span.LC_feedback_link {
 }  }
   
 table.LC_prior_tries {  table.LC_prior_tries {
     border-width: 1px;    border: 1px solid #000000;
     border-style: solid;    border-collapse: separate;
     border-color: gray;    border-spacing: 1px;
     border-collapse: collapse;  
 }  }
 table.LC_prior_tries th,  
 table.LC_prior_tries td {  table.LC_prior_tries td {
     border-width: 1px;    padding: 2px;
     border-style: solid;  }
     border-color: gray;  
     padding: 3px;  .LC_answer_correct {
 }    background: #AAFFAA;
 table.LC_prior_tries tr.LC_correct {    color: black;
     font-weight: bold;  }
     background: #aaffaa;  .LC_answer_charged_try {
 }    background: #FFAAAA ! important;
 span.LC_prior_numerical {    color: black;
     font-family: monospace;  }
     white-space: pre;  .LC_answer_not_charged_try, 
   .LC_answer_no_grade,
   .LC_answer_late {
     background: #FFFFAA;
     color: black;
   }
   .LC_answer_previous {
     background: #AAAAFF;
     color: black;
   }
   .LC_answer_no_message {
     background: #FFFFFF;
     color: black;
   }
   .LC_answer_unknown {
     background: orange;
     color: black;
   }
   
   
   span.LC_prior_numerical,
   span.LC_prior_string,
   span.LC_prior_custom,
   span.LC_prior_reaction,
   span.LC_prior_math {
     font-family: monospace;
     white-space: pre;
   }
   
   span.LC_prior_string {
     font-family: monospace;
     white-space: pre;
   }
   
   table.LC_prior_option {
     width: 100%;
     border-collapse: collapse;
   }
   table.LC_prior_rank, table.LC_prior_match {
     border-collapse: collapse;
   }
   table.LC_prior_option tr td,
   table.LC_prior_rank tr td,
   table.LC_prior_match tr td {
     border: 1px solid #000000;
   }
   
   span.LC_nobreak {
       white-space: nowrap;
 }  }
   
 END  END
Line 5104  Incoming parameters: Line 5230  Incoming parameters:
 2. user's domain  2. user's domain
   
 Returns:  Returns:
 1. Disk quota (in Mb) assigned to student.   1. Disk quota (in Mb) assigned to student.
   2. (Optional) Type of setting: custom or default
      (individually assigned or default for user's 
      institutional status).
   3. (Optional) - User's institutional status (e.g., faculty, staff
      or student - types as defined in localenroll::inst_usertypes 
      for user's domain, which determines default quota for user.
   4. (Optional) - Default quota which would apply to the user.
   
 If a value has been stored in the user's environment,   If a value has been stored in the user's environment, 
 it will return that, otherwise it returns the default  it will return that, otherwise it returns the maximal default
 for users in the domain.  defined for the user's instituional status(es) in the domain.
   
 =cut  =cut
   
Line 5117  for users in the domain. Line 5250  for users in the domain.
   
 sub get_user_quota {  sub get_user_quota {
     my ($uname,$udom) = @_;      my ($uname,$udom) = @_;
     my $quota;      my ($quota,$quotatype,$settingstatus,$defquota);
     if (!defined($udom)) {      if (!defined($udom)) {
         $udom = $env{'user.domain'};          $udom = $env{'user.domain'};
     }      }
Line 5127  sub get_user_quota { Line 5260  sub get_user_quota {
     if (($udom eq '' || $uname eq '') ||      if (($udom eq '' || $uname eq '') ||
         ($udom eq 'public') && ($uname eq 'public')) {          ($udom eq 'public') && ($uname eq 'public')) {
         $quota = 0;          $quota = 0;
           $quotatype = 'default';
           $defquota = 0; 
     } else {      } else {
           my $inststatus;
         if ($udom eq $env{'user.domain'} && $uname eq $env{'user.name'}) {          if ($udom eq $env{'user.domain'} && $uname eq $env{'user.name'}) {
             $quota = $env{'environment.portfolioquota'};              $quota = $env{'environment.portfolioquota'};
               $inststatus = $env{'environment.inststatus'};
         } else {          } else {
             my %userenv = &Apache::lonnet::dump('environment',$udom,$uname);              my %userenv = 
                   &Apache::lonnet::get('environment',['portfolioquota',
                                        'inststatus'],$udom,$uname);
             my ($tmp) = keys(%userenv);              my ($tmp) = keys(%userenv);
             if ($tmp !~ /^(con_lost|error|no_such_host)/i) {              if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
                 $quota = $userenv{'portfolioquota'};                  $quota = $userenv{'portfolioquota'};
                   $inststatus = $userenv{'inststatus'};
             } else {              } else {
                 undef(%userenv);                  undef(%userenv);
             }              }
         }          }
           ($defquota,$settingstatus) = &default_quota($udom,$inststatus);
         if ($quota eq '') {          if ($quota eq '') {
             $quota = &default_quota($udom);              $quota = $defquota;
               $quotatype = 'default';
           } else {
               $quotatype = 'custom';
         }          }
     }      }
     return $quota;      if (wantarray) {
           return ($quota,$quotatype,$settingstatus,$defquota);
       } else {
           return $quota;
       }
 }  }
   
 ###############################################  ###############################################
Line 5152  sub get_user_quota { Line 5300  sub get_user_quota {
   
 =item * &default_quota()  =item * &default_quota()
   
 Retrieves default quota assigned for storage of user portfolio files  Retrieves default quota assigned for storage of user portfolio files,
   given an (optional) user's institutional status.
   
 Incoming parameters:  Incoming parameters:
 1. domain  1. domain
   2. (Optional) institutional status(es).  This is a : separated list of 
      status types (e.g., faculty, staff, student etc.)
      which apply to the user for whom the default is being retrieved.
      If the institutional status string in undefined, the domain
      default quota will be returned. 
   
 Returns:  Returns:
 1. Default disk quota (in Mb) for user portfolios in the domain.  1. Default disk quota (in Mb) for user portfolios in the domain.
   2. (Optional) institutional type which determined the value of the
      default quota.
   
 If a value has been stored in the domain's configuration db,  If a value has been stored in the domain's configuration db,
 it will return that, otherwise it returns 20 (for backwards   it will return that, otherwise it returns 20 (for backwards 
 compatibility with domains which have not set up a configuration  compatibility with domains which have not set up a configuration
 db file; the original statically defined portfolio quota was 20 Mb).   db file; the original statically defined portfolio quota was 20 Mb). 
   
   If the user's status includes multiple types (e.g., staff and student),
   the largest default quota which applies to the user determines the
   default quota returned.
   
 =cut  =cut
   
 ###############################################  ###############################################
   
   
 sub default_quota {  sub default_quota {
     my ($udom) = @_;      my ($udom,$inststatus) = @_;
     my %defaults = &Apache::lonnet::get_dom('configuration',      my ($defquota,$settingstatus);
                                             ['portfolioquota'],$udom);      my %quotahash = &Apache::lonnet::get_dom('configuration',
     if ($defaults{'portfolioquota'} ne '') {                                              ['quota'],$udom);
         return $defaults{'portfolioquota'};      if (ref($quotahash{'quota'}) eq 'HASH') {
           if ($inststatus ne '') {
               my @statuses = split(/:/,$inststatus);
               foreach my $item (@statuses) {
                   if ($quotahash{'quota'}{$item} ne '') {
                       if ($defquota eq '') {
                           $defquota = $quotahash{'quota'}{$item};
                           $settingstatus = $item;
                       } elsif ($quotahash{'quota'}{$item} > $defquota) {
                           $defquota = $quotahash{'quota'}{$item};
                           $settingstatus = $item;
                       }
                   }
               }
           }
           if ($defquota eq '') {
               $defquota = $quotahash{'quota'}{'default'};
               $settingstatus = 'default';
           }
       } else {
           $settingstatus = 'default';
           $defquota = 20;
       }
       if (wantarray) {
           return ($defquota,$settingstatus);
     } else {      } else {
         return '20';          return $defquota;
     }      }
 }  }
   

Removed from v.1.518  
changed lines
  Added in v.1.537


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>