Diff for /loncom/interface/loncommon.pm between versions 1.398 and 1.425

version 1.398, 2006/06/26 22:06:19 version 1.425, 2006/07/07 19:34:20
Line 707  sub helpLatexCheatsheet { Line 707  sub helpLatexCheatsheet {
 }  }
   
 sub help_open_menu {  sub help_open_menu {
     my ($color,$topic,$component_help,$function,$faq,$bug,$stayOnPage,$width,$height,$text) = @_;      my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height,$text) = @_;
     $text = "" if (not defined $text);      $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);      $stayOnPage = 0 if (not defined $stayOnPage);
     if ($env{'browser.interface'} eq 'textual' ||      if ($env{'browser.interface'} eq 'textual' ||
Line 721  sub help_open_menu { Line 721  sub help_open_menu {
     my $origurl = $ENV{'REQUEST_URI'};      my $origurl = $ENV{'REQUEST_URI'};
     $origurl=~s|^/~|/priv/|;      $origurl=~s|^/~|/priv/|;
     my $timestamp = time;      my $timestamp = time;
     foreach my $datum (\$color,\$function,\$topic,\$component_help,\$faq,      foreach my $datum (\$topic,\$component_help,\$faq,\$bug,\$origurl) {
        \$bug,\$origurl) {  
         $$datum = &escape($$datum);          $$datum = &escape($$datum);
     }      }
     if (!$stayOnPage) {      if (!$stayOnPage) {
Line 730  sub help_open_menu { Line 729  sub help_open_menu {
     } else {      } else {
         $link = "javascript:helpMenu('display')";          $link = "javascript:helpMenu('display')";
     }      }
     my $banner_link = "/adm/helpmenu?page=banner&function=$function&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage";      my $banner_link = "/adm/helpmenu?page=banner&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage";
     my $details_link = "/adm/helpmenu?page=body&function=$function&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp";      my $details_link = "/adm/helpmenu?page=body&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp";
     my $template;      my $template;
     if ($text ne "") {      if ($text ne "") {
  $template .=    $template .= 
Line 2726  Returns: value of designparamter $which Line 2725  Returns: value of designparamter $which
 =cut  =cut
   
   
 sub designparm {  
     my ($which,$domain)=@_;  
     my $result = &designparm_real(@_);  
     &Apache::lonnet::logthis(" $which $domain reulted in $result");  
     return $result;  
 }  
   
   
 ##############################################  ##############################################
 sub designparm_real {  sub designparm {
     my ($which,$domain)=@_;      my ($which,$domain)=@_;
     if ($env{'browser.blackwhite'} eq 'on') {      if ($env{'browser.blackwhite'} eq 'on') {
  if ($which=~/\.(font|alink|vlink|link)$/) {   if ($which=~/\.(font|alink|vlink|link)$/) {
Line 2805  Inputs: Line 2796  Inputs:
 =item * $no_inline_link, if true and in remote mode, don't show the   =item * $no_inline_link, if true and in remote mode, don't show the 
          'Switch To Inline Menu' link           'Switch To Inline Menu' link
   
   
 =back  =back
   
 Returns: A uniform header for LON-CAPA web pages.    Returns: A uniform header for LON-CAPA web pages.  
Line 2876  sub bodytag { Line 2866  sub bodytag {
  return $bodytag;   return $bodytag;
     }      }
   
       my $name = &plainname($env{'user.name'},$env{'user.domain'});
           
     my $roleinfo=(<<ENDROLE);      my $roleinfo=(<<ENDROLE);
 <td class="LC_title_bar_who">  <td class="LC_title_bar_who">
 <div class="LC_title_bar_name">  <div class="LC_title_bar_name">
     $env{'environment.firstname'}      $name
     $env{'environment.middlename'}  
     $env{'environment.lastname'}  
     $env{'environment.generation'}  
     &nbsp;      &nbsp;
 </div>  </div>
 <div class="LC_title_bar_role">  <div class="LC_title_bar_role">
Line 2935  ENDROLE Line 2922  ENDROLE
  $lastitem = $thisdisfn;   $lastitem = $thisdisfn;
     }      }
     $titleinfo =       $titleinfo = 
  &Apache::loncommon::help_open_menu('','','','',3,'Authoring').   &Apache::loncommon::help_open_menu('','',3,'Authoring').
  '<b>Construction Space</b>:&nbsp;'.    '<b>Construction Space</b>:&nbsp;'. 
  '<form name="dirs" method="post" action="'.$formaction   '<form name="dirs" method="post" action="'.$formaction
  .'" target="_top"><tt><b>'   .'" target="_top"><tt><b>'
Line 3120  sub standard_css { Line 3107  sub standard_css {
     my $data_table_head      = $tabbg;      my $data_table_head      = $tabbg;
     my $data_table_light     = '#EEEEEE';      my $data_table_light     = '#EEEEEE';
     my $data_table_dark      = '#DDD';      my $data_table_dark      = '#DDD';
       my $data_table_darker    = '#CCC';
     my $data_table_highlight = '#FFFF00';      my $data_table_highlight = '#FFFF00';
     my $mail_new             = '#FFBB77';      my $mail_new             = '#FFBB77';
     my $mail_new_hover       = '#DD9955';      my $mail_new_hover       = '#DD9955';
Line 3156  table#LC_top_nav, table#LC_menubuttons { Line 3144  table#LC_top_nav, table#LC_menubuttons {
   width: 100%;    width: 100%;
   background: $pgbg;    background: $pgbg;
   border: 2px;    border: 2px;
   border-collapse: seperate;    border-collapse: separate;
     padding: 0px;
 }  }
   
 table#LC_title_bar, table#LC_breadcrumbs, table#LC_nav_location,  table#LC_title_bar, table.LC_breadcrumbs, table#LC_nav_location,
 table#LC_title_bar.LC_with_remote {  table#LC_title_bar.LC_with_remote {
   width: 100%;    width: 100%;
   border-color: $pgbg;    border-color: $pgbg;
Line 3169  table#LC_title_bar.LC_with_remote { Line 3158  table#LC_title_bar.LC_with_remote {
   background: $pgbg;    background: $pgbg;
   font-family: $sans;    font-family: $sans;
   border-collapse: collapse;    border-collapse: collapse;
     padding: 0px;
   }
   
   table.LC_docs_path {
     width: 100%;
     border: 0;
     background: $pgbg;
     font-family: $sans;
     border-collapse: collapse;
     padding: 0px;
 }  }
   
 table#LC_title_bar td {  table#LC_title_bar td {
   padding: 3px;  
   background: $tabbg;    background: $tabbg;
 }  }
 table#LC_title_bar td.LC_title_bar_who {  table#LC_title_bar td.LC_title_bar_who {
Line 3182  table#LC_title_bar td.LC_title_bar_who { Line 3180  table#LC_title_bar td.LC_title_bar_who {
   text-align: right;    text-align: right;
 }  }
 span.LC_title_bar_title {  span.LC_title_bar_title {
   font: bold xx-large $sans;    font: bold x-large $sans;
 }  }
 table#LC_title_bar td.LC_title_bar_domain_logo {  table#LC_title_bar td.LC_title_bar_domain_logo {
   background: $sidebg;    background: $sidebg;
Line 3208  table#LC_menubuttons img, table#LC_menub Line 3206  table#LC_menubuttons img, table#LC_menub
 table#LC_top_nav td {  table#LC_top_nav td {
   background: $tabbg;    background: $tabbg;
   border: 0px;    border: 0px;
     font-size: small;
 }  }
 table#LC_top_nav td a, div#LC_top_nav a {  table#LC_top_nav td a, div#LC_top_nav a {
   color: $font;    color: $font;
Line 3216  table#LC_top_nav td a, div#LC_top_nav a Line 3215  table#LC_top_nav td a, div#LC_top_nav a
 table#LC_top_nav td.LC_top_nav_logo {  table#LC_top_nav td.LC_top_nav_logo {
   background: $tabbg;    background: $tabbg;
   text-align: right;    text-align: right;
     white-space: nowrap;
     font-weight: bold;
   }
   table#LC_top_nav td.LC_top_nav_logo img {
     margin-left: 0.2em;
     vertical-align: bottom;
 }  }
 table#LC_breadcrumbs td {  table.LC_breadcrumbs td, table.LC_docs_path td  {
   background: $tabbg;    background: $tabbg;
   color: $font;    color: $font;
   font-family: $sans;    font-family: $sans;
   font-size: smaller;    font-size: smaller;
 }  }
 table#LC_breadcrumbs td.LC_breadcrumb_component {  table.LC_breadcrumbs td.LC_breadcrumbs_component,
   table.LC_docs_path td.LC_docs_path_component {
   background: $tabbg;    background: $tabbg;
   color: $font;    color: $font;
   font-family: $sans;    font-family: $sans;
Line 3258  td.LC_menubuttons_img { Line 3264  td.LC_menubuttons_img {
   
 table.LC_data_table, table.LC_mail_list {  table.LC_data_table, table.LC_mail_list {
   border: 1px solid #000000;    border: 1px solid #000000;
   border-collapse: seperate;    border-collapse: separate;
   }
   .LC_data_table_dense {
     font-size: small;
 }  }
 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 {
   font-weight: bold;    font-weight: bold;
   background-color: $data_table_head;    background-color: $data_table_head;
     font-size: smaller;
 }  }
 table.LC_data_table tr td {  table.LC_data_table tr td {
   background-color: $data_table_light;    background-color: $data_table_light;
     padding: 2px;
 }  }
 table.LC_data_table tr.LC_even_row td {  table.LC_data_table tr.LC_even_row td {
   background-color: $data_table_dark;    background-color: $data_table_dark;
 }  }
 table.LC_data_table tr.LC_empty td {  table.LC_data_table tr.LC_data_table_highlight td {
     background-color: $data_table_darker;
   }
   table.LC_data_table tr.LC_empty_row td {
   background-color: #FFFFFF;    background-color: #FFFFFF;
     font-weight: bold;
     font-style: italic;
     text-align: center;
     padding: 8px;
 }  }
   
 table.LC_calendar {  table.LC_calendar {
Line 3442  table#LC_helpmenu_links { Line 3460  table#LC_helpmenu_links {
 table#LC_helpmenu_links tr td {  table#LC_helpmenu_links tr td {
   padding: 1px;    padding: 1px;
   background: $tabbg;    background: $tabbg;
     text-align: center;
     font-weight: bold;
 }  }
   
 table#LC_helpmenu_links a:link, table#LC_helpmenu_links a:visited,  table#LC_helpmenu_links a:link, table#LC_helpmenu_links a:visited,
Line 3454  table#LC_helpmenu_links a:hover { Line 3474  table#LC_helpmenu_links a:hover {
   color: $vlink;    color: $vlink;
 }  }
   
   .LC_chrt_popup_exists {
     border: 1px solid #339933;
     margin: -1px;
   }
   .LC_chrt_popup_up {
     border: 1px solid yellow;
     margin: -1px;
   }
   .LC_chrt_popup {
     border: 1px solid #8888FF;
     background: #CCCCFF;
   }
   
   table.LC_pick_box {
     width: 100%;
     border-collapse: separate;
     background: white;
     border: 1px solid black;
     border-spacing: 1px;
   }
   table.LC_pick_box td.LC_pick_box_title {
     background: $tabbg;
     font-weight: bold;
     text-align: right;
     width: 184px;
     padding: 8px;
   }
   table.LC_pick_box td.LC_pick_box_separator {
     padding: 0px;
     height: 1px;
     background: black;
   }
   table.LC_pick_box td.LC_pick_box_submit {
     text-align: right;
   }
   
   table.LC_group_priv_box {
     background: white;
     border: 1px solid black;
     border-spacing: 1px;
   }
   table.LC_group_priv_box td.LC_pick_box_title {
     background: $tabbg;
     font-weight: bold;
     text-align: right;
     width: 184px;
   }
   table.LC_group_priv_box td.LC_groups_fixed {
     background: $data_table_light;
     text-align: center;
   }
   table.LC_group_priv_box td.LC_groups_optional {
     background: $data_table_dark;
     text-align: center;
   }
   table.LC_group_priv_box td.LC_groups_functionality {
     background: $data_table_darker;
     text-align: center;
     font-weight: bold;
   }
   table.LC_group_priv td {
     text-align: left;
     padding: 0px;
   }
   
   table.LC_notify_front_page {
     background: white;
     border: 1px solid black;
     padding: 8px;
   }
   table.LC_notify_front_page td {
     padding: 8px;
   }
   .LC_navbuttons {
     margin: 2ex 0ex 2ex 0ex;
   }
   .LC_topic_bar {
     font-family: $sans;
     font-weight: bold;
     width: 100%;
     background: $tabbg;
     vertical-align: middle;
     margin: 2ex 0ex 2ex 0ex;
   }
   .LC_topic_bar span {
     vertical-align: middle;
   }
   .LC_topic_bar img {
     vertical-align: bottom;
   }
   table.LC_course_group_status {
     margin: 20px;
   }
   table.LC_status_selector td {
     vertical-align: top;
     text-align: center;
     padding: 4px;
   }
   table.LC_descriptive_input td.LC_description {
     vertical-align: top;
     text-align: right;
     font-weight: bold;
   }
   
 END  END
 }  }
   
Line 3470  Inputs: $title - optional title for the Line 3594  Inputs: $title - optional title for the
         $args - optional arguments          $args - optional arguments
             force_register - if is true call registerurl so the remote is               force_register - if is true call registerurl so the remote is 
                              informed                               informed
             redirect       -> array ref of seconds before redirect occurs              redirect       -> array ref of
                                     url to redirect to                                     1- seconds before redirect occurs
                                      2- url to redirect to
                                      3- whether the side effect should occur
                            (side effect of setting                              (side effect of setting 
                                $env{'internal.head.redirect'} to the url                                  $env{'internal.head.redirect'} to the url 
                                redirected too)                                 redirected too)
Line 3490  sub headtag { Line 3616  sub headtag {
     my $function = $args->{'function'} || &get_users_function();      my $function = $args->{'function'} || &get_users_function();
     my $domain   = $args->{'domain'}   || &determinedomain();      my $domain   = $args->{'domain'}   || &determinedomain();
     my $bgcolor  = $args->{'bgcolor'}  || &designparm($function.'.pgbg',$domain);      my $bgcolor  = $args->{'bgcolor'}  || &designparm($function.'.pgbg',$domain);
     my $url = join(':',$env{'user.name'},$env{'user.domain'},time(),      my $url = join(':',$env{'user.name'},$env{'user.domain'},
    #$env{'environment.color.timestamp'},     #time(),
      $env{'environment.color.timestamp'},
    $function,$domain,$bgcolor);     $function,$domain,$bgcolor);
   
     $url = '/adm/css/'.&escape($url).'.css';      $url = '/adm/css/'.&escape($url).'.css';
   
     my $result =      my $result =
  '<head>'.   '<head>'.
  '<link rel="stylesheet" type="text/css" href="'.$url.'" />'.  
  &font_settings().   &font_settings().
  &Apache::lonhtmlcommon::htmlareaheaders();   &Apache::lonhtmlcommon::htmlareaheaders();
   
Line 3507  sub headtag { Line 3633  sub headtag {
     }      }
   
     if (ref($args->{'redirect'})) {      if (ref($args->{'redirect'})) {
  my ($time,$url) = @{$args->{'redirect'}};   my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}};
  $url = &Apache::lonenc::check_encrypt($url);   $url = &Apache::lonenc::check_encrypt($url);
  $env{'internal.head.redirect'} = $url;   if (!$inhibit_continue) {
       $env{'internal.head.redirect'} = $url;
    }
  $result.=<<ADDMETA   $result.=<<ADDMETA
 <meta http-equiv="pragma" content="no-cache" />  <meta http-equiv="pragma" content="no-cache" />
 <meta http-equiv="Refresh" content="$time; url=$url" />  <meta http-equiv="Refresh" content="$time; url=$url" />
Line 3519  ADDMETA Line 3647  ADDMETA
  $title = 'The LearningOnline Network with CAPA';   $title = 'The LearningOnline Network with CAPA';
     }      }
           
     $result .= '<title> LON-CAPA '.&mt($title).'</title>'.$head_extra;      $result .= '<title> LON-CAPA '.&mt($title).'</title>'
    .'<link rel="stylesheet" type="text/css" href="'.$url.'" />'
    .$head_extra;
     return $result;      return $result;
 }  }
   
Line 3611  Returns a uniform complete <head>..</hea Line 3741  Returns a uniform complete <head>..</hea
   
 Inputs: $title - optional title for the page  Inputs: $title - optional title for the page
         $head_extra - optional extra HTML to put inside the <head>          $head_extra - optional extra HTML to put inside the <head>
   
 =back  =back
   
 =cut  =cut
Line 3724  Inputs:         $args - additional optio Line 3855  Inputs:         $args - additional optio
                                  a html attribute                                   a html attribute
                  frameset     -> if true will start with a <frameset>                   frameset     -> if true will start with a <frameset>
                                  rather than <body>                                   rather than <body>
 =back  
   
 =cut  =cut
   
Line 3818  sub simple_error_page { Line 3948  sub simple_error_page {
 {  {
     my $row_count;      my $row_count;
     sub start_data_table {      sub start_data_table {
    my ($add_class) = @_;
    my $css_class = (join(' ','LC_data_table',$add_class));
  undef($row_count);   undef($row_count);
  return '<table class="LC_data_table">'."\n";   return '<table class="'.$css_class.'">'."\n";
     }      }
   
     sub end_data_table {      sub end_data_table {
Line 3828  sub simple_error_page { Line 3960  sub simple_error_page {
     }      }
   
     sub start_data_table_row {      sub start_data_table_row {
    my ($add_class) = @_;
  $row_count++;   $row_count++;
  return  '<tr '.(($row_count % 2)?'':'class="LC_even_row"').'>'."\n";;   my $css_class = ($row_count % 2)?'':'LC_even_row';
    my $css_class = (join(' ',$css_class,$add_class));
    return  '<tr class="'.$css_class.'">'."\n";;
     }      }
   
     sub end_data_table_row {      sub end_data_table_row {
  return '</tr>'."\n";;   return '</tr>'."\n";;
     }      }
   
       sub start_data_table_empty_row {
    $row_count++;
    return  '<tr class="LC_empty_row" >'."\n";;
       }
   
       sub end_data_table_empty_row {
    return '</tr>'."\n";;
       }
   
     sub start_data_table_header_row {      sub start_data_table_header_row {
  return  '<tr class="LC_header_row">'."\n";;   return  '<tr class="LC_header_row">'."\n";;
     }      }
Line 3849  sub simple_error_page { Line 3993  sub simple_error_page {
   
 =pod  =pod
   
 =over 4  =item * &get_users_function()
   
 =item get_users_function  
   
 Used by &bodytag to determine the current users primary role.  Used by &bodytag to determine the current users primary role.
 Returns either 'student','coordinator','admin', or 'author'.  Returns either 'student','coordinator','admin', or 'author'.
Line 3878  sub get_users_function { Line 4020  sub get_users_function {
   
 =pod  =pod
   
 =item check_user_status  =item * &check_user_status
   
 Determines current status of supplied role for a  Determines current status of supplied role for a
 specific user. Roles can be active, previous or future.  specific user. Roles can be active, previous or future.
Line 3893  role status: active, previous or future. Line 4035  role status: active, previous or future.
 =cut  =cut
   
 sub check_user_status {  sub check_user_status {
     my ($udom,$uname,$cdom,$crs,$role,$secgrp) = @_;      my ($udom,$uname,$cdom,$crs,$role,$sec) = @_;
     my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname);      my %userinfo = &Apache::lonnet::dump('roles',$udom,$uname);
     my @uroles = keys %userinfo;      my @uroles = keys %userinfo;
     my $srchstr;      my $srchstr;
     my $active_chk = 'none';      my $active_chk = 'none';
       my $now = time;
     if (@uroles > 0) {      if (@uroles > 0) {
         if (($role eq 'cc') || ($secgrp eq '') || (!defined($secgrp))) {          if (($role eq 'cc') || ($sec eq '') || (!defined($sec))) {
             $srchstr = '/'.$cdom.'/'.$crs.'_'.$role;              $srchstr = '/'.$cdom.'/'.$crs.'_'.$role;
         } else {          } else {
             $srchstr = '/'.$cdom.'/'.$crs.'/'.$secgrp.'_'.$role;         }              $srchstr = '/'.$cdom.'/'.$crs.'/'.$sec.'_'.$role;
         if (grep/^$srchstr$/,@uroles) {          }
           if (grep/^\Q$srchstr\E$/,@uroles) {
             my $role_end = 0;              my $role_end = 0;
             my $role_start = 0;              my $role_start = 0;
             $active_chk = 'active';              $active_chk = 'active';
             if ($userinfo{$srchstr} =~ m/^($role)_(\d+)/) {              if ($userinfo{$srchstr} =~ m/^\Q$role\E_(\d+)/) {
                 $role_end = $2;                  $role_end = $1;
                 if ($userinfo{$srchstr} =~ m/^($role)_($role_end)_(\d+)$/) {                  if ($userinfo{$srchstr} =~ m/^\Q$role\E_\Q$role_end\E_(\d+)$/) {
                     $role_start = $3;                      $role_start = $1;
                 }                  }
             }              }
             if ($role_start > 0) {              if ($role_start > 0) {
                 if (time < $role_start) {                  if ($now < $role_start) {
                     $active_chk = 'future';                      $active_chk = 'future';
                 }                  }
             }              }
             if ($role_end > 0) {              if ($role_end > 0) {
                 if (time > $role_end) {                  if ($now > $role_end) {
                     $active_chk = 'previous';                      $active_chk = 'previous';
                 }                  }
             }              }
Line 3932  sub check_user_status { Line 4076  sub check_user_status {
   
 =pod  =pod
   
 =item get_sections  =item * &get_sections()
   
 Determines all the sections for a course including  Determines all the sections for a course including
 sections with students and sections containing other roles.  sections with students and sections containing other roles.
 Incoming parameters: domain, course number,   Incoming parameters: 
 reference to array containing roles for which sections should   
 be gathered (optional). If the third argument is undefined,  1. domain
 sections are gathered for any role.  2. course number 
   3. reference to array containing roles for which sections should 
   be gathered (optional).
   4. reference to array containing status types for which sections 
   should be gathered (optional).
   
   If the third argument is undefined, sections are gathered for any role. 
   If the fourth argument is undefined, sections are gathered for any status.
   Permissible values are 'active' or 'future' or 'previous'.
     
 Returns section hash (keys are section IDs, values are  Returns section hash (keys are section IDs, values are
 number of users in each section), subject to the  number of users in each section), subject to the
 optional roles filter.  optional roles filter, optional status filter 
   
 =cut  =cut
   
 ###############################################  ###############################################
 sub get_sections {  sub get_sections {
     my ($cdom,$cnum,$possible_roles) = @_;      my ($cdom,$cnum,$possible_roles,$possible_status) = @_;
     if (!defined($cdom) || !defined($cnum)) {      if (!defined($cdom) || !defined($cnum)) {
         my $cid =  $env{'request.course.id'};          my $cid =  $env{'request.course.id'};
   
Line 3960  sub get_sections { Line 4112  sub get_sections {
     }      }
   
     my %sectioncount;      my %sectioncount;
       my $now = time;
   
     if (!defined($possible_roles) || (grep(/^st$/,@$possible_roles))) {      if (!defined($possible_roles) || (grep(/^st$/,@$possible_roles))) {
  my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum);   my ($classlist) = &Apache::loncoursedata::get_classlist($cdom,$cnum);
  my $sec_index = &Apache::loncoursedata::CL_SECTION();   my $sec_index = &Apache::loncoursedata::CL_SECTION();
  my $status_index = &Apache::loncoursedata::CL_STATUS();   my $status_index = &Apache::loncoursedata::CL_STATUS();
           my $start_index = &Apache::loncoursedata::CL_START();
           my $end_index = &Apache::loncoursedata::CL_END();
           my $status;
  while (my ($student,$data) = each(%$classlist)) {   while (my ($student,$data) = each(%$classlist)) {
     my ($section,$status) = ($data->[$sec_index],      my ($section,$stu_status,$start,$end) = ($data->[$sec_index],
      $data->[$status_index]);                       $data->[$status_index],
     unless ($section eq '-1' || $section =~ /^\s*$/) {                                                       $data->[$start_index],
  $sectioncount{$section}++;                                                       $data->[$end_index]);
               if ($stu_status eq 'Active') {
                   $status = 'active';
               } elsif ($end < $now) {
                   $status = 'previous';
               } elsif ($start > $now) {
                   $status = 'future';
               } 
       if ($section ne '-1' && $section !~ /^\s*$/) {
                   if ((!defined($possible_status)) || (($status ne '') && 
                       (grep/^\Q$status\E$/,@{$possible_status}))) { 
       $sectioncount{$section}++;
                   }
     }      }
  }   }
     }      }
Line 3978  sub get_sections { Line 4146  sub get_sections {
  if ($user !~ /^(\w{2})/) { next; }   if ($user !~ /^(\w{2})/) { next; }
  my ($role) = ($user =~ /^(\w{2})/);   my ($role) = ($user =~ /^(\w{2})/);
  if ($possible_roles && !(grep(/^$role$/,@$possible_roles))) { next; }   if ($possible_roles && !(grep(/^$role$/,@$possible_roles))) { next; }
  my $section;   my ($section,$status);
  if ($role eq 'cr' &&   if ($role eq 'cr' &&
     $user =~ m-^$role/[^/]*/[^/]*/[^/]*:[^:]*:[^:]*:(\w+)-) {      $user =~ m-^$role/[^/]*/[^/]*/[^/]*:[^:]*:[^:]*:(\w+)-) {
     $section=$1;      $section=$1;
  }   }
  if ($user =~ /^$role:[^:]*:[^:]*:(\w+)/) { $section=$1; }   if ($user =~ /^$role:[^:]*:[^:]*:(\w+)/) { $section=$1; }
  if (!defined($section) || $section eq '-1') { next; }   if (!defined($section) || $section eq '-1') { next; }
  $sectioncount{$section}++;          my ($end,$start) = ($courseroles{$user} =~ /^([^:]*):([^:]*)$/);
           if ($end == -1 && $start == -1) {
               next; #deleted role
           }
           if (!defined($possible_status)) { 
               $sectioncount{$section}++;
           } else {
               if ((!$end || $end >= $now) && (!$start || $start <= $now)) {
                   $status = 'active';
               } elsif ($end < $now) {
                   $status = 'future';
               } elsif ($start > $now) {
                   $status = 'previous';
               }
               if (($status ne '') && (grep/^\Q$status\E$/,@{$possible_status})) {
                   $sectioncount{$section}++;
               }
           }
     }      }
     return %sectioncount;      return %sectioncount;
 }  }
Line 3993  sub get_sections { Line 4178  sub get_sections {
 ###############################################  ###############################################
   
 =pod  =pod
                                                                                   
 =item get_course_users  =item * &get_course_users()
                                                                                   
 Retrieves usernames:domains for users in the specified course  Retrieves usernames:domains for users in the specified course
 with specific role(s), and access status.   with specific role(s), and access status. 
   
Line 4018  Entries for end, start, section and stat Line 4203  Entries for end, start, section and stat
 of the possibility of multiple values for non-student roles.  of the possibility of multiple values for non-student roles.
   
 =cut  =cut
                                                                                   
 ###############################################  ###############################################
                                                                                   
 sub get_course_users {  sub get_course_users {
     my ($cdom,$cnum,$types,$roles,$sections,$users,$userdata) = @_;      my ($cdom,$cnum,$types,$roles,$sections,$users,$userdata) = @_;
     my %idx = ();      my %idx = ();
       my %seclists;
   
     $idx{udom} = &Apache::loncoursedata::CL_SDOM();      $idx{udom} = &Apache::loncoursedata::CL_SDOM();
     $idx{uname} =  &Apache::loncoursedata::CL_SNAME();      $idx{uname} =  &Apache::loncoursedata::CL_SNAME();
Line 4039  sub get_course_users { Line 4225  sub get_course_users {
         my $now = time;          my $now = time;
         foreach my $student (keys(%{$classlist})) {          foreach my $student (keys(%{$classlist})) {
             my $match = 0;              my $match = 0;
               my $secmatch = 0;
               my $section = $$classlist{$student}[$idx{section}];
               if ($section eq '') {
                   $section = 'none';
               }
             if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {              if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
  unless(grep(/^\Q$$classlist{$student}[$idx{section}]\E$/,                  if (grep(/^all$/,@{$sections})) {
     @{$sections})) {                      $secmatch = 1;
     next;                  } elsif ($$classlist{$student}[$idx{section}] eq '') {
                       if (grep(/^none$/,@{$sections})) {
                           $secmatch = 1;
                       }
                   } else {  
       if (grep(/^\Q$section\E$/,@{$sections})) {
           $secmatch = 1;
                       }
  }   }
             }                   if (!$secmatch) {
                       next;
                   }
               }
               push(@{$seclists{$student}},$section); 
             if (defined($$types{'active'})) {              if (defined($$types{'active'})) {
                 if ($$classlist{$student}[$idx{status}] eq 'Active') {                  if ($$classlist{$student}[$idx{status}] eq 'Active') {
                     push(@{$$users{st}{$student}},'active');                      push(@{$$users{st}{$student}},'active');
Line 4063  sub get_course_users { Line 4265  sub get_course_users {
                     $match = 1;                      $match = 1;
                 }                  }
             }              }
             if ($match && defined($userdata)) {              if ($match && ref($userdata) eq 'HASH') {
                 $$userdata{$student} = $$classlist{$student};                  $$userdata{$student} = $$classlist{$student};
             }              }
         }          }
     }      }
     if ((@{$roles} > 0) && (@{$roles} ne "st")) {      if ((@{$roles} > 1) || ((@{$roles} == 1) && ($$roles[0] ne "st"))) {
         my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum);          my @coursepersonnel = &Apache::lonnet::getkeys('nohist_userroles',$cdom,$cnum);
         foreach my $person (@coursepersonnel) {          foreach my $person (@coursepersonnel) {
             my $match = 0;              my $match = 0;
             my ($role,$user) = ($person =~ /^([^:]*):([^:]+:[^:]+)/);              my $secmatch = 0;
               my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
             $user =~ s/:$//;              $user =~ s/:$//;
             if (($role) && (grep(/^\Q$role\E$/,@{$roles}))) {              if (($role) && (grep(/^\Q$role\E$/,@{$roles}))) {
                 my ($uname,$udom,$usec) = split(/:/,$user);                  my ($uname,$udom) = split(/:/,$user);
                 if ($usec ne '' && (ref($sections) eq 'ARRAY') &&                   if ((ref($sections) eq 'ARRAY') && (@{$sections} > 0)) {
     @{$sections} > 0) {                      if (grep(/^all$/,@{$sections})) {
     unless(grep(/^\Q$usec\E$/,@{$sections})) {                          $secmatch = 1;
  next;                      } elsif ($usec eq '') {
     }                          if (grep(/^none$/,@{$sections})) {
                               $secmatch = 1;
                           }
                       } else {
                           if (grep(/^\Q$usec\E$/,@{$sections})) {
                               $secmatch = 1;
                           }
                       }
                       if (!$secmatch) {
                           next;
                       }
                   }
                   if ($usec eq '') {
                       $usec = 'none';
                 }                  }
                 if ($uname ne '' && $udom ne '') {                  if ($uname ne '' && $udom ne '') {
                     my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role);                      my $status = &check_user_status($udom,$uname,$cdom,$cnum,$role,
                                                       $usec);
                     foreach my $type (keys(%{$types})) {                       foreach my $type (keys(%{$types})) { 
                         if ($status eq $type) {                          if ($status eq $type) {
                             @{$$users{$role}{$user}} = $type;                              if (!grep(/^\Q$type\E$/,@{$$users{$role}{$user}})) {
                                   push(@{$$users{$role}{$user}},$type);
                               }
                             $match = 1;                              $match = 1;
                         }                          }
                     }                      }
                     if ($match && defined($userdata) &&                      if (($match) && (ref($userdata) eq 'HASH')) {
                         !exists($$userdata{$uname.':'.$udom})) {                          if (!exists($$userdata{$uname.':'.$udom})) {
  &get_user_info($udom,$uname,\%idx,$userdata);      &get_user_info($udom,$uname,\%idx,$userdata);
                           }
                           if (!grep(/^\Q$usec\E$/,@{$seclists{$uname.':'.$udom}})) {
                               push(@{$seclists{$uname.':'.$udom}},$usec);
                           }
                     }                      }
                 }                  }
             }              }
Line 4106  sub get_course_users { Line 4329  sub get_course_users {
                     if (defined($userdata) &&                       if (defined($userdata) && 
  !exists($$userdata{$owner.':'.$cdom})) {   !exists($$userdata{$owner.':'.$cdom})) {
  &get_user_info($cdom,$owner,\%idx,$userdata);   &get_user_info($cdom,$owner,\%idx,$userdata);
                           if (!grep(/^none$/,@{$seclists{$owner.':'.$cdom}})) {
                               push(@{$seclists{$owner.':'.$cdom}},'none');
                           }
     }      }
                 }                  }
             }              }
         }          }
           foreach my $user (keys(%seclists)) {
               @{$seclists{$user}} = (sort {$a <=> $b} @{$seclists{$user}});
               $$userdata{$user}[$idx{section}] = join(',',@{$seclists{$user}});
           }
     }      }
     return;      return;
 }  }
Line 5180  sub course_type { Line 5410  sub course_type {
     if (!defined($cid)) {      if (!defined($cid)) {
         $cid = $env{'request.course.id'};          $cid = $env{'request.course.id'};
     }      }
     if (defined($env{'course.'.$cid.'type'})) {      if (defined($env{'course.'.$cid.'.type'})) {
         return $env{'course.'.$cid.'type'};          return $env{'course.'.$cid.'.type'};
     } else {      } else {
         return 'Course';          return 'Course';
     }      }
 }  }
   
   sub group_term {
       my $crstype = &course_type();
       my %names = (
                     'Course' => 'group',
                     'Group' => 'team',
                   );
       return $names{$crstype};
   }
   
 sub icon {  sub icon {
     my ($file)=@_;      my ($file)=@_;
     my $curfext = (split(/\./,$file))[-1];      my $curfext = (split(/\./,$file))[-1];

Removed from v.1.398  
changed lines
  Added in v.1.425


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