Diff for /loncom/interface/loncoursegroups.pm between versions 1.28 and 1.29

version 1.28, 2006/06/28 16:01:01 version 1.29, 2006/06/28 23:38:09
Line 34  use Apache::lonhtmlcommon; Line 34  use Apache::lonhtmlcommon;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonnavmaps;  use Apache::lonnavmaps;
 use Apache::longroup;  use Apache::longroup;
   use Apache::portfolio;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA;  use LONCAPA;
Line 69  sub handler { Line 70  sub handler {
           &Apache::lonnet::allowed('mdg',$env{'request.course.id'});            &Apache::lonnet::allowed('mdg',$env{'request.course.id'});
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
   
       my $gpterm = &Apache::loncommon::group_term();
       my $ucgpterm = $gpterm;
       $ucgpterm =~ s/^(\w)/uc($1)/e;
       my $crstype = &Apache::loncommon::course_type();
   
     my %functions = (      my %functions = (
                       email => 'E-mail',                        email => 'E-mail',
                       discussion => 'Discussion boards',                        discussion => 'Discussion boards',
                       chat => 'Chat',                        chat => 'Chat',
                       files => 'File repository',                        files => 'File repository',
                       roster => 'Membership roster',                        roster => 'Membership roster',
                       homepage => 'Group home page',                        homepage => $ucgpterm.' home page',
                     );                      );
   
     my %idx = ();      my %idx = ();
Line 98  sub handler { Line 104  sub handler {
         if ($view_permission || $manage_permission) {          if ($view_permission || $manage_permission) {
             &group_administration($r,$action,$state,$cdom,$cnum,$function,              &group_administration($r,$action,$state,$cdom,$cnum,$function,
                                   $tabcol,\%functions,\%idx,$view_permission,                                    $tabcol,\%functions,\%idx,$view_permission,
                                   $manage_permission,$rowColor1,$rowColor2);                                    $manage_permission,$rowColor1,$rowColor2,
                                     $gpterm,$ucgpterm,$crstype);
         } else {          } else {
             $r->print(&mt('You do not have group administration '.              $r->print(&mt('You do not have [_1] administration '.
                           'privileges in this course'));                            'privileges in this [_2]',$gpterm,lc($crstype)));
         }          }
     } else {      } else {
         &print_main_menu($r,$cdom,$cnum,$function,$tabcol,\%functions,\%idx,          &print_main_menu($r,$cdom,$cnum,$function,$tabcol,\%functions,\%idx,
                          $view_permission,$manage_permission,$action,$state,                           $view_permission,$manage_permission,$action,$state,
                          $rowColor1,$rowColor2);                           $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype);
     }      }
     return OK;      return OK;
 }  }
   
 sub print_main_menu {  sub print_main_menu {
     my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission,      my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission,
         $manage_permission,$action,$state,$rowColor1,$rowColor2) = @_;          $manage_permission,$action,$state,$rowColor1,$rowColor2,$gpterm,
           $ucgpterm,$crstype) = @_;
       my $pagename = "$crstype $ucgpterm".'s';
     my $jscript = qq|      my $jscript = qq|
 function changeSort(caller) {  function changeSort(caller) {
     document.$state.sortby.value = caller;      document.$state.sortby.value = caller;
     document.$state.submit();      document.$state.submit();
 }\n|;  }\n|;
     $r->print(&header('Course Groups',$jscript,$action,$state,      $r->print(&header($pagename,$jscript,$action,$state,
                       undef,$function));                        undef,$function));
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
         ({href=>"/adm/coursegroups",          ({href=>"/adm/coursegroups",
           text=>"Course Groups",});            text=>"$pagename"});
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Groups'));      $r->print(&Apache::lonhtmlcommon::breadcrumbs($pagename));
     &display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,      &display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,
                     $view_permission,$manage_permission,$action,$state,                      $view_permission,$manage_permission,$action,$state,
                     $rowColor1,$rowColor2);                      $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype);
     $r->print(&footer());      $r->print(&footer());
     return;      return;
 }  }
   
 sub display_groups {  sub display_groups {
     my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission,      my ($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,$view_permission,
         $manage_permission,$action,$state,$rowColor1,$rowColor2) = @_;          $manage_permission,$action,$state,$rowColor1,$rowColor2,$gpterm,
           $ucgpterm,$crstype) = @_;
     my %curr_groups = ();      my %curr_groups = ();
     my %grp_info = ();      my %grp_info = ();
     my %actionlinks = (      my %actionlinks = (
Line 149  sub display_groups { Line 159  sub display_groups {
                           view   => 'View',                            view   => 'View',
                           delete => 'Delete',                            delete => 'Delete',
                           act    => 'Action',                            act    => 'Action',
                           gname  => 'Group Name',                            gname  => "$ucgpterm Name",
                           desc   => 'Description',                            desc   => 'Description',
                           crea   => 'Creator',                            crea   => 'Creator',
                           crtd   => 'Created',                            crtd   => 'Created',
Line 159  sub display_groups { Line 169  sub display_groups {
                           memb   => 'Members',                            memb   => 'Members',
                           file   => 'Files',                            file   => 'Files',
                           dibd   => 'Discussion Boards',                            dibd   => 'Discussion Boards',
                           dius   => 'Disk Use',                            dius   => 'Disk Use (%)',
                           nogr   => 'No groups exist.',                            nogr   => 'No '.$gpterm.'s exist.',
                           crng   => 'Create a new group',                            crng   => 'Create a new '.$gpterm,
                           alth   => 'Although your current role has privileges'.                            alth   => 'Although your current role has privileges'.
                                     ' to view any existing groups in this course,'.                                      ' to view any existing '.$gpterm.'s in this'.
                                     ' you do not have privileges to create new'.                                      lc($crstype).', you do not have privileges'.
                                     ' groups.',                                      'to create new '.$gpterm.'s.',
                      );                       );
     if ($view_permission) {      if ($view_permission) {
         if (!defined($action)) {          if (!defined($action)) {
Line 173  sub display_groups { Line 183  sub display_groups {
         }          }
         my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);          my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
         if (%curr_groups) {          if (%curr_groups) {
               if ($manage_permission) {
                   $r->print('<br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>');
               }
             $r->print('<br /><br />');              $r->print('<br /><br />');
             $r->print(&Apache::lonhtmlcommon::start_pick_box());              $r->print(&Apache::lonhtmlcommon::start_pick_box());
             $r->print(<<"END");              $r->print(<<"END");
Line 203  END Line 216  END
                                                          $curr_groups{$group});                                                           $curr_groups{$group});
                 my $members_result = &group_members($cdom,$cnum,$group,                  my $members_result = &group_members($cdom,$cnum,$group,
                                                     \%grp_info);                                                      \%grp_info);
                 my $files_result = &group_files($group,\%grp_info);                   my $port_path = '/userfiles/groups/'.$group.'/portfolio';
                   my $port_dir = &Apache::loncommon::propath($cdom,$cnum).$port_path;
                   my $totaldirs = 0;
                   my $totalfiles = 0;
                   &group_files($group,$port_dir,\$totalfiles,\$totaldirs);
                   $grp_info{$group}{'totalfiles'} = $totalfiles;
                   $grp_info{$group}{'totaldirs'} = $totaldirs;
                   my $diskuse = &Apache::lonnet::diskusage($cdom,$cnum,$port_dir);
                   if ($grp_info{$group}{'quota'} > 0) {
                       my $pct_use = 0.1 * $diskuse/$grp_info{$group}{'quota'};
                       $grp_info{$group}{'diskuse'} = sprintf("%.0f",$pct_use);
                   } else {
                       $grp_info{$group}{'diskuse'} = 'N/A';
                   }     
                 if ($env{'form.sortby'} eq 'groupname') {                  if ($env{'form.sortby'} eq 'groupname') {
                     push(@{$Sortby{$group}},$group);                      push(@{$Sortby{$group}},$group);
                 } elsif ($env{'form.sortby'} eq 'description') {                  } elsif ($env{'form.sortby'} eq 'description') {
                     push(@{$Sortby{$grp_info{$group}{'description'}}},                      push(@{$Sortby{$grp_info{$group}{'description'}}},$group);
                                                                      $group);  
                 } elsif ($env{'form.sortby'} eq 'creator') {                  } elsif ($env{'form.sortby'} eq 'creator') {
                     push(@{$Sortby{$grp_info{$group}{'creator'}}},$group);                      push(@{$Sortby{$grp_info{$group}{'creator'}}},$group);
                 } elsif ($env{'form.sortby'} eq 'creation') {                  } elsif ($env{'form.sortby'} eq 'creation') {
Line 247  END Line 272  END
                     my $quota = $grp_info{$group}{'quota'};                      my $quota = $grp_info{$group}{'quota'};
                     my $totalmembers = $grp_info{$group}{'totalmembers'};                      my $totalmembers = $grp_info{$group}{'totalmembers'};
                     my $totalfiles = $grp_info{$group}{'totalfiles'};                      my $totalfiles = $grp_info{$group}{'totalfiles'};
                       my $totaldirs = $grp_info{$group}{'totaldirs'};
                     my $boards = $grp_info{$group}{'boards'};                      my $boards = $grp_info{$group}{'boards'};
                     my $diskuse = $grp_info{$group}{'diskuse'};                      my $diskuse = $grp_info{$group}{'diskuse'};
                     my $functionality;                      my $functionality;
Line 272  END Line 298  END
                                       $group.'">'.$lt{'modify'}.'</a>';                                        $group.'">'.$lt{'modify'}.'</a>';
                         }                          }
                     }                      }
                     $r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$link.'</small></td><td><small>'.$group.'</small></td><td><small>'.$description.'</small></td><td><small>'.$creator.'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($creation).'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($modified).'</small></td><td><small>'.$functionality.'</small></td><td><small>'.$quota.'</small></td><td><small>'.$totalmembers.'</small></td><td><small>'.$totalfiles.'</small></td><td><small>'.$boards.'</small></td><td><small>'.$diskuse.'</small></td></tr>');                      $r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$link.'</small></td><td><small>'.$group.'</small></td><td><small>'.$description.'</small></td><td><small>'.$creator.'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($creation).'</small></td><td><small>'. &Apache::lonnavmaps::timeToHumanString($modified).'</small></td><td><small>'.$functionality.'</small></td><td><small>'.$quota.'</small></td><td><small>'.$totalmembers.'</small></td><td><small><nobr>'.&mt('Files: ').$totalfiles.'</nobr><br /><nobr>'.&mt('Folders: ').$totaldirs.'</nobr></small></td><td><small>'.$boards.'</small></td><td><small>'.$diskuse.'</small></td></tr>');
                     $rowNum ++;                      $rowNum ++;
                 }                  }
             }              }
Line 292  END Line 318  END
             if ($manage_permission) {              if ($manage_permission) {
                 $r->print('<br /><br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>');                  $r->print('<br /><br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>');
             } else {              } else {
                 $r->print('<br /><br />'.$lt{'crng'});                  $r->print('<br /><br />'.$lt{'alth'});
   
             }              }
         }          }
Line 313  END Line 339  END
             }              }
         } else {          } else {
             $r->print(&mt('You are not currently a member of any '.              $r->print(&mt('You are not currently a member of any '.
                           'active groups in this course'));                            'active [_1]s in this [_2]',$gpterm,
                             lc($crstype)));
         }          }
     }      }
     return;      return;
Line 321  END Line 348  END
   
 sub group_administration {  sub group_administration {
     my ($r,$action,$state,$cdom,$cnum,$function,$tabcol,$functions,$idx,      my ($r,$action,$state,$cdom,$cnum,$function,$tabcol,$functions,$idx,
         $view_permission,$manage_permission,$rowColor1,$rowColor2) = @_;          $view_permission,$manage_permission,$rowColor1,$rowColor2,$gpterm,
           $ucgpterm,$crstype) = @_;
     my %sectioncount = ();      my %sectioncount = ();
     my @tools = ();      my @tools = ();
     my @types = ();      my @types = ();
Line 335  sub group_administration { Line 363  sub group_administration {
     my %memchg;      my %memchg;
     my @member_changes = ('deletion','expire','activate','reenable',      my @member_changes = ('deletion','expire','activate','reenable',
                           'changefunc','changepriv');                            'changefunc','changepriv');
     my ($groupname,$description,$startdate,$enddate,$granularity,$specificity);      my ($groupname,$description,$startdate,$enddate,$granularity,$specificity,
           $quota);
   
     if (defined($env{'form.groupname'})) {      if (defined($env{'form.groupname'})) {
         $groupname = $env{'form.groupname'};          $groupname = $env{'form.groupname'};
Line 359  sub group_administration { Line 388  sub group_administration {
         if (defined($env{'form.specificity'})) {          if (defined($env{'form.specificity'})) {
             $specificity=$env{'form.specificity'};              $specificity=$env{'form.specificity'};
         }          }
           if (defined($env{'form.quota'})) {
               $quota=$env{'form.quota'};
           }
     }      }
     if (($action eq 'create') || (($action eq 'modify')       if (($action eq 'create') || (($action eq 'modify') 
         && (($state eq 'pick_privs') || ($state eq 'addresult')))) {          && (($state eq 'pick_privs') || ($state eq 'addresult')))) {
Line 398  sub group_administration { Line 429  sub group_administration {
                 $description = $stored{'description'};                  $description = $stored{'description'};
                 $granularity = $stored{'granularity'};                  $granularity = $stored{'granularity'};
                 $specificity =  $stored{'specificity'};                  $specificity =  $stored{'specificity'};
                   $quota = $stored{'quota'};
             }              }
         }          }
     }      }
Line 405  sub group_administration { Line 437  sub group_administration {
     my %toolprivs =      my %toolprivs =
  (   (
  email      => {   email      => {
      sgm => 'Send group mail',       sgm => 'Send '.$gpterm.' mail',
      sgb => 'Broadcast mail',       sgb => 'Broadcast mail',
  },   },
  discussion => {   discussion => {
Line 462  sub group_administration { Line 494  sub group_administration {
  enddate_second   => 'text',   enddate_second   => 'text',
  groupname        => 'text',   groupname        => 'text',
  description      => 'text',   description      => 'text',
                    quota            => 'text',
  tool             => 'checkbox',   tool             => 'checkbox',
  granularity      => 'radio',   granularity      => 'radio',
  no_end_date      => 'checkbox',   no_end_date      => 'checkbox',
Line 776  function changeSort(caller) { Line 809  function changeSort(caller) {
     }      }
   
     my $loaditems =  &onload_action($action,$state);      my $loaditems =  &onload_action($action,$state);
     $r->print(&header('Course Groups Manager',      my $crumbtitle = "$crstype $ucgpterm".'s'; 
       $r->print(&header("$crumbtitle Manager",
       $jscript,$action,$state,$page,$function,$loaditems));        $jscript,$action,$state,$page,$function,$loaditems));
   
     if ($env{'form.refpage'} eq 'enrl') {      if ($env{'form.refpage'} eq 'enrl') {
Line 787  function changeSort(caller) { Line 821  function changeSort(caller) {
     } else {      } else {
         &Apache::lonhtmlcommon::add_breadcrumb          &Apache::lonhtmlcommon::add_breadcrumb
        ({href=>"/adm/coursegroups",         ({href=>"/adm/coursegroups",
           text=>"Course Groups",            text=>"$crumbtitle",
           faq=>9,bug=>'Instructor Interface',});            faq=>9,bug=>'Instructor Interface',});
     }      }
   
     my %trail = ();      my %trail = ();
     %{$trail{'create'}} = &Apache::lonlocal::texthash (      %{$trail{'create'}} = &Apache::lonlocal::texthash (
                             pick_name => 'Group Settings',                              pick_name => $ucgpterm.' Settings',
                             pick_members => 'Select Members',                              pick_members => 'Select Members',
                             pick_privs => 'Choose Privileges',                              pick_privs => 'Choose Privileges',
                             result => 'Creation Complete',                              result => 'Creation Complete',
                           );                            );
     %{$trail{'modify'}} = &Apache::lonlocal::texthash(      %{$trail{'modify'}} = &Apache::lonlocal::texthash(
                             pick_group => 'Groups',                              pick_group => $ucgpterm.'s',
                             pick_task => 'Choose Task',                              pick_task => 'Choose Task',
                             change_settings => 'Group Settings',                              change_settings => "$ucgpterm Settings",
                             change_members => 'Modify/Delete Members',                              change_members => 'Modify/Delete Members',
                             change_privs => 'Change Privileges',                              change_privs => 'Change Privileges',
                             change_mapping => 'Membership Mapping',                              change_mapping => 'Membership Mapping',
Line 815  function changeSort(caller) { Line 849  function changeSort(caller) {
     my %navbuttons = &Apache::lonlocal::texthash(      my %navbuttons = &Apache::lonlocal::texthash(
                              gtns => 'Go to next step',                               gtns => 'Go to next step',
                              gtps => 'Go to previous step',                               gtps => 'Go to previous step',
                              crgr => 'Create group',                               crgr => 'Create '.$gpterm,
                              mose => 'Modify settings',                               mose => 'Modify settings',
                              gtpp => 'Go to previous page',                               gtpp => 'Go to previous page',
                              adme => 'Add members',                               adme => 'Add members',
Line 827  function changeSort(caller) { Line 861  function changeSort(caller) {
                 &Apache::lonhtmlcommon::add_breadcrumb(                  &Apache::lonhtmlcommon::add_breadcrumb(
                    {text=>"$trail{$action}{$state}"});                     {text=>"$trail{$action}{$state}"});
                 $r->print(&Apache::lonhtmlcommon::breadcrumbs                  $r->print(&Apache::lonhtmlcommon::breadcrumbs
   ('Course Groups Manager'));    ("$crumbtitle Manager"));
                 &display_control($r,$cdom,$cnum,$tabcol,$action,$state,$page,                  &display_control($r,$cdom,$cnum,$tabcol,$action,$state,$page,
                        \%sectioncount,$groupname,$description,$functions,                         \%sectioncount,$groupname,$description,$functions,
                        \@tools,\%toolprivs,\%fixedprivs,$startdate,$enddate,                         \@tools,\%toolprivs,\%fixedprivs,$startdate,$enddate,
                        \%users,\%userdata,$idx,\%memchg,\%usertools,                         \%users,\%userdata,$idx,\%memchg,\%usertools,
                        $function,$view_permission,$manage_permission,                         $function,$view_permission,$manage_permission,
                        \%stored,$granularity,$specificity,\@types,\@roles,                         \%stored,$granularity,$quota,$specificity,\@types,\@roles,
                        \@sections,\%states,\%navbuttons,$rowColor1,$rowColor2);                         \@sections,\%states,\%navbuttons,$rowColor1,$rowColor2,
                          $gpterm,$ucgpterm,$crstype);
                 last;                  last;
             } else {              } else {
                 if (($state eq 'result') && ($i > 0)) {                  if (($state eq 'result') && ($i > 0)) {
Line 850  function changeSort(caller) { Line 885  function changeSort(caller) {
         }          }
     } elsif (($action eq 'view') && ($view_permission)) {      } elsif (($action eq 'view') && ($view_permission)) {
                         &Apache::lonhtmlcommon::add_breadcrumb(                          &Apache::lonhtmlcommon::add_breadcrumb(
                    {text=>"View groups"});                     {text=>"View $gpterm".'s'});
           my $crumbtitle = "$crstype $ucgpterm".'s Manager';
         $r->print(&Apache::lonhtmlcommon::breadcrumbs          $r->print(&Apache::lonhtmlcommon::breadcrumbs
   ('Course Groups Manager'));    (&mt($crumbtitle)));
         &display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,          &display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,
                         $view_permission,$manage_permission,$action,$state,                          $view_permission,$manage_permission,$action,$state,
                         $rowColor1,$rowColor2);                          $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype);
   
     }      }
     $r->print(&footer());      $r->print(&footer());
Line 884  sub retrieve_settings { Line 920  sub retrieve_settings {
     $stored{'specificity'} = $groupinfo{'specificity'};      $stored{'specificity'} = $groupinfo{'specificity'};
     $stored{'creation'} = $groupinfo{'creation'};      $stored{'creation'} = $groupinfo{'creation'};
     $stored{'creator'} = $groupinfo{'creator'};      $stored{'creator'} = $groupinfo{'creator'};
       $stored{'quota'} = $groupinfo{'quota'};
   
     foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) {      foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) {
  if ($groupinfo{functions}{$tool} eq 'on') {   if ($groupinfo{functions}{$tool} eq 'on') {
Line 923  sub display_control { Line 960  sub display_control {
     my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$sectioncount,$groupname,      my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$sectioncount,$groupname,
         $description,$functions,$tools,$toolprivs,$fixedprivs,$startdate,          $description,$functions,$tools,$toolprivs,$fixedprivs,$startdate,
         $enddate,$users,$userdata,$idx,$memchg,$usertools,$function,          $enddate,$users,$userdata,$idx,$memchg,$usertools,$function,
         $view_permission,$manage_permission,$stored,$granularity,$specificity,          $view_permission,$manage_permission,$stored,$granularity,$quota,
         $types,$roles,$sections,$states,$navbuttons,$rowColor1,$rowColor2)=@_;          $specificity,$types,$roles,$sections,$states,$navbuttons,$rowColor1,
           $rowColor2,$gpterm,$ucgpterm,$crstype) = @_;
     if ($action eq 'create') {      if ($action eq 'create') {
         if ($state eq 'pick_name') {          if ($state eq 'pick_name') {
             &general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page,              &general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page,
                                    $functions,$tools,$toolprivs,$fixedprivs,                                     $functions,$tools,$toolprivs,$fixedprivs,
                                    $sectioncount,$stored,$states,$navbuttons,                                     $sectioncount,$stored,$states,$navbuttons,
                                    $rowColor1,$rowColor2);                                     $rowColor1,$rowColor2,$gpterm,$ucgpterm,
                                      $crstype);
         } elsif ($state eq 'pick_members') {          } elsif ($state eq 'pick_members') {
             &choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,              &choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
                                  $groupname,$description,$granularity,                                   $groupname,$description,$granularity,$quota,
                                  $startdate,$enddate,$tools,$fixedprivs,                                   $startdate,$enddate,$tools,$fixedprivs,
                                  $toolprivs,$functions,$users,$userdata,$idx,                                   $toolprivs,$functions,$users,$userdata,$idx,
                                  $stored,$states,$navbuttons,$rowColor1,                                   $stored,$states,$navbuttons,$rowColor1,
                                  $rowColor2);                                   $rowColor2,$gpterm,$ucgpterm,$crstype);
         } elsif ($state eq 'pick_privs') {          } elsif ($state eq 'pick_privs') {
             &choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,              &choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
                                $startdate,$enddate,$tools,$functions,                                 $startdate,$enddate,$tools,$functions,
                                $toolprivs,$fixedprivs,$userdata,$usertools,                                 $toolprivs,$fixedprivs,$userdata,$usertools,
                                $idx,$states,$stored,$sectioncount,$navbuttons,                                 $idx,$states,$stored,$sectioncount,$navbuttons,
                                $rowColor1,$rowColor2);                                 $rowColor1,$rowColor2,$gpterm,$ucgpterm,
                                  $crstype);
         } elsif ($state eq 'result') {          } elsif ($state eq 'result') {
             &process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page,              &process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page,
                              $groupname,$description,$specificity,$userdata,                               $groupname,$description,$specificity,$userdata,
                              $startdate,$enddate,$tools,$functions,                               $startdate,$enddate,$tools,$functions,
                              $toolprivs,$usertools,$idx,$types,$roles,                               $toolprivs,$usertools,$idx,$types,$roles,
                              $sections,$states,$navbuttons,$memchg,                               $sections,$states,$navbuttons,$memchg,
                              $sectioncount,$stored,$rowColor1,$rowColor2);                               $sectioncount,$stored,$rowColor1,$rowColor2,
                                $gpterm,$ucgpterm,$crstype);
         }          }
     } elsif ($action eq 'modify') {      } elsif ($action eq 'modify') {
         my $groupname = $env{'form.groupname'};          my $groupname = $env{'form.groupname'};
         if ($state eq 'pick_group') {          if ($state eq 'pick_group') {
             &display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,              &display_groups($r,$cdom,$cnum,$function,$tabcol,$functions,$idx,
                             $view_permission,$manage_permission,$action,$state,                              $view_permission,$manage_permission,$action,$state,
                             $rowColor1,$rowColor2);                              $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype);
         } elsif ($state eq 'pick_task') {          } elsif ($state eq 'pick_task') {
             &modify_menu($r,$groupname,$page);              &modify_menu($r,$groupname,$page,$gpterm);
         } elsif ($state eq 'change_settings') {          } elsif ($state eq 'change_settings') {
             &general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page,              &general_settings_form($r,$cdom,$cnum,$action,$tabcol,$state,$page,
                                    $functions,$tools,$toolprivs,$fixedprivs,                                     $functions,$tools,$toolprivs,$fixedprivs,
                                    $sectioncount,$stored,$states,$navbuttons,                                     $sectioncount,$stored,$states,$navbuttons,
                                    $rowColor1,$rowColor2);                                     $rowColor1,$rowColor2,$gpterm,$ucgpterm,
                                      $crstype);
         } elsif ($state eq 'change_members') {          } elsif ($state eq 'change_members') {
             &change_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,              &change_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
                                  $groupname,$description,$startdate,$enddate,                                   $groupname,$description,$startdate,$enddate,
                                  $tools,$fixedprivs,$functions,$users,                                   $tools,$fixedprivs,$functions,$users,
                                  $userdata,$granularity,$specificity,$idx,                                   $userdata,$granularity,$quota,$specificity,
                                  $states,$navbuttons,$rowColor1,$rowColor2);                                   $idx,$states,$navbuttons,$rowColor1,$rowColor2,
                                    $gpterm,$ucgpterm);
         } elsif ($state eq 'add_members') {          } elsif ($state eq 'add_members') {
             &add_members_form($r,$tabcol,$action,$state,$page,$startdate,              &add_members_form($r,$tabcol,$action,$state,$page,$startdate,
                               $enddate,$groupname,$description,$granularity,                                $enddate,$groupname,$description,$granularity,
                               $sectioncount,$tools,$functions,$stored,$states,                                $quota,$sectioncount,$tools,$functions,$stored,
                               $navbuttons,$rowColor1,$rowColor2);                                $states,$navbuttons,$rowColor1,$rowColor2,$gpterm,
                                 $ucgpterm);
         } elsif ($state eq 'pick_members') {          } elsif ($state eq 'pick_members') {
             &choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,              &choose_members_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
                                  $groupname,$description,$granularity,                                   $groupname,$description,$granularity,$quota,
                                  $startdate,$enddate,$tools,$fixedprivs,                                   $startdate,$enddate,$tools,$fixedprivs,
                                  $toolprivs,$functions,$users,$userdata,$idx,                                   $toolprivs,$functions,$users,$userdata,$idx,
                                  $stored,$states,$navbuttons,$rowColor1,                                   $stored,$states,$navbuttons,$rowColor1,
                                  $rowColor2);                                   $rowColor2,$gpterm,$ucgpterm,$crstype);
         } elsif ($state eq 'pick_privs') {          } elsif ($state eq 'pick_privs') {
             &choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,              &choose_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
                                $startdate,$enddate,$tools,$functions,                                 $startdate,$enddate,$tools,$functions,
                                $toolprivs,$fixedprivs,$userdata,$usertools,                                 $toolprivs,$fixedprivs,$userdata,$usertools,
                                $idx,$states,$stored,$sectioncount,$navbuttons,                                 $idx,$states,$stored,$sectioncount,$navbuttons,
                                $rowColor1,$rowColor2);                                 $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype);
         } elsif ($state eq 'change_privs') {          } elsif ($state eq 'change_privs') {
             &change_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,              &change_privs_form($r,$cdom,$cnum,$tabcol,$action,$state,$page,
                                $startdate,$enddate,$tools,$functions,                                 $startdate,$enddate,$tools,$functions,
                                $toolprivs,$fixedprivs,$userdata,$usertools,                                 $toolprivs,$fixedprivs,$userdata,$usertools,
                                $memchg,$idx,$states,$stored,$sectioncount,                                 $memchg,$idx,$states,$stored,$sectioncount,
                                $navbuttons,$rowColor1,$rowColor2);                                 $navbuttons,$rowColor1,$rowColor2,$gpterm,
                                  $ucgpterm);
         } elsif ($state eq 'chgresult' || $state eq 'memresult' ||           } elsif ($state eq 'chgresult' || $state eq 'memresult' || 
                  $state eq 'addresult') {                   $state eq 'addresult') {
             &process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page,              &process_request($r,$cdom,$cnum,$tabcol,$action,$state,$page,
Line 1002  sub display_control { Line 1047  sub display_control {
                              $startdate,$enddate,$tools,$functions,                               $startdate,$enddate,$tools,$functions,
                              $toolprivs,$usertools,$idx,$types,$roles,                               $toolprivs,$usertools,$idx,$types,$roles,
                              $sections,$states,$navbuttons,$memchg,                               $sections,$states,$navbuttons,$memchg,
                              $sectioncount,$stored,$rowColor1,$rowColor2);                               $sectioncount,$stored,$rowColor1,$rowColor2,
                                $gpterm,$ucgpterm,$crstype);
         }          }
     }      }
 }  }
Line 1076  sub build_members_list { Line 1122  sub build_members_list {
 }  }
   
 sub group_files {  sub group_files {
       my ($group,$currdir,$numfiles,$numdirs) = @_;
       my $dirptr=16384;
       my @dir_list=&Apache::portfolio::get_dir_list($currdir,$group);
       foreach my $line (@dir_list) {
           my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
           if (($filename !~ /^\.\.?$/) && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/) && ($filename ne 'no_such_dir')) { 
               if ($dirptr&$testdir) {
                   $currdir .= '/'.$filename;
                   $$numdirs ++;
                   &group_files($numfiles,$numdirs)
               } else {
                   $$numfiles ++;
               }
           }
       }
     return;      return;
 }  }
   
Line 1117  sub group_members { Line 1178  sub group_members {
 sub general_settings_form {  sub general_settings_form {
     my ($r,$cdom,$cnum,$action,$tabcol,$formname,$page,$functions,$tools,      my ($r,$cdom,$cnum,$action,$tabcol,$formname,$page,$functions,$tools,
         $toolprivs,$fixedprivs,$sectioncount,$stored,$states,$navbuttons,          $toolprivs,$fixedprivs,$sectioncount,$stored,$states,$navbuttons,
         $rowColor1,$rowColor2) = @_;          $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype) = @_;
     my ($nexttext,$prevtext);      my ($nexttext,$prevtext);
     $r->print(' <br />      $r->print(' <br />
  <table width="100%" cellpadding="0" cellspacing="0" border="0">   <table width="100%" cellpadding="0" cellspacing="0" border="0">
 ');  ');
     &groupsettings_options($r,$tabcol,$functions,$action,$formname,$stored,1);      &groupsettings_options($r,$tabcol,$functions,$action,$formname,$stored,1,
                              $gpterm,$ucgpterm,$crstype);
     $r->print('       $r->print(' 
   <tr>    <tr>
    <td colspan="4">&nbsp;</td>     <td colspan="4">&nbsp;</td>
   </tr>');    </tr>');
     &access_date_settings($r,$tabcol,$action,$formname,$stored,2);      &access_date_settings($r,$tabcol,$action,$formname,$stored,2,$gpterm,
                             $ucgpterm);
     $r->print('      $r->print('
   <tr>    <tr>
    <td colspan="4">&nbsp;</td>     <td colspan="4">&nbsp;</td>
   </tr>');    </tr>');
     if ($action eq 'create') {      if ($action eq 'create') {
         &membership_options($r,$action,$formname,$tabcol,$sectioncount,3);          &membership_options($r,$action,$formname,$tabcol,$sectioncount,3,
                               $gpterm,$ucgpterm);
         $nexttext = $$navbuttons{'gtns'};          $nexttext = $$navbuttons{'gtns'};
     } else {      } else {
         my @available = ();          my @available = ();
Line 1142  sub general_settings_form { Line 1206  sub general_settings_form {
         @{$tools} = sort(keys(%{$functions}));          @{$tools} = sort(keys(%{$functions}));
         &privilege_specificity($r,$tabcol,$rowColor1,$rowColor2,$action,          &privilege_specificity($r,$tabcol,$rowColor1,$rowColor2,$action,
                                3,$tools,$stored,$toolprivs,$fixedprivs,                                 3,$tools,$stored,$toolprivs,$fixedprivs,
                                \@available,$formname);                                 \@available,$formname,$gpterm,$ucgpterm);
         $r->print('          $r->print('
   <tr>    <tr>
    <td colspan="4">&nbsp;</td>     <td colspan="4">&nbsp;</td>
   </tr>');    </tr>');
         &mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount,          &mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount,
                          $states,$stored,$navbuttons,4,5,$rowColor1,                           $states,$stored,$navbuttons,4,5,$rowColor1,
                          $rowColor2);                           $rowColor2,$gpterm,$ucgpterm,$crstype);
         $nexttext = $$navbuttons{'mose'};          $nexttext = $$navbuttons{'mose'};
     }      }
     $prevtext = $$navbuttons{'gtpp'};      $prevtext = $$navbuttons{'gtpp'};
Line 1161  sub general_settings_form { Line 1225  sub general_settings_form {
 }  }
   
 sub groupsettings_options {  sub groupsettings_options {
     my ($r,$tabcol,$functions,$action,$formname,$stored,$image) = @_;      my ($r,$tabcol,$functions,$action,$formname,$stored,$image,$gpterm,
           $ucgpterm,$crstype) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         'gdat' => 'Group open and close dates',          'gdat' => "$ucgpterm open and close dates",
         'sten' => 'Set a start date/time and end date/time for the group',          'sten' => "Set a start date/time and end date/time for the $gpterm",
         'gfun' => 'Group functionality',          'gfun' => "$ucgpterm functionality",
         'gnde' => 'Group name, description and available functionality',          'gnde' => "$ucgpterm name, description and available functionality",
         'desc' => 'Description',          'desc' => 'Description',
         'func' => 'Functionality',          'func' => 'Functionality',
         'gnam' => 'Group Name',          'gnam' => "$ucgpterm Name",
         'doyo' => 'Do you want to assign different functionality '.          'doyo' => "Do you want to assign different functionality ".
                   'to different group members?',                    "to different $gpterm members?",
     );      );
       my $crsquota = $env{'course.'.$env{'request.course.id'}.'.internal.coursequota'};
       if ($crsquota eq '') {
           $crsquota = 20;
       }
       my $freespace = $crsquota - &Apache::longroup::sum_quotas();
       my $maxposs = $$stored{'quota'} + $freespace;
     &topic_bar($r,$tabcol,$image,$lt{'gnde'});      &topic_bar($r,$tabcol,$image,$lt{'gnde'});
     $r->print('      $r->print('
    <tr>     <tr>
Line 1233  END Line 1304  END
        </td>         </td>
       </tr>        </tr>
       <tr>        <tr>
        <td><b>Granularity:</b></td>         <td><b>'.&mt('Granularity:').'</b></td>
        <td colspan="9">'.$lt{'doyo'}.'&nbsp;<label><input type="radio" name="granularity" value="Yes" />'.&mt('Yes').'</label>&nbsp;<label><input type="radio" name="granularity" value="No" checked="checked" />'.&mt('No').'</label>');         <td colspan="10">'.$lt{'doyo'}.'&nbsp;<label><input type="radio" name="granularity" value="Yes" />'.&mt('Yes').'</label>&nbsp;<label><input type="radio" name="granularity" value="No" checked="checked" />'.&mt('No').'</label>');
     if ($action eq 'modify') {      if ($action eq 'modify') {
         $r->print('&nbsp;&nbsp;('.&mt('Currently set to "[_1]"',          $r->print('&nbsp;&nbsp;('.&mt('Currently set to "[_1]"',
                                       $$stored{'granularity'}).')');                                        $$stored{'granularity'}).')');
Line 1242  END Line 1313  END
     $r->print('      $r->print('
        </td>         </td>
       </tr>        </tr>
         <tr>
          <td valign="top">'.&mt('<b>Disk quota:</b> ').'</td><td colspan="10">');
       if ($action eq 'create') {
           $r->print(&mt('If you enable the file repository for the [_1], allocate a disk quota.',$gpterm));
       } else {
           $r->print(&mt('Quota allocated to file repository:'));
       } 
       $r->print('&nbsp;<input type="text" name="quota" size="4" />Mb');
       if ($action eq 'create') {
           $r->print('<br />'.
                     &mt('A total of [_1] Mb is shared between all [_2]s in the '.
                     '[_3], and [_4] Mb are currently unallocated.',$crsquota,
                     $gpterm,lc($crstype),$freespace));
       } else {
           $r->print('&nbsp;&nbsp;('.&mt('The quota is currently [_1] Mb',
                                         $$stored{'quota'}).').');
   
           $r->print('<br />'.&mt('The quota can be increased to [_1] Mb, '.
                     'by adding all unallocated space for [_2]s in the [_3].',
                     $maxposs,$gpterm,lc($crstype)));
       }
       $r->print('
          </td>
         </tr>
      </table>       </table>
     </td>      </td>
    </tr>     </tr>
Line 1250  END Line 1345  END
 }  }
   
 sub membership_options {  sub membership_options {
     my ($r,$action,$state,$tabcol,$sectioncount,$image) = @_;      my ($r,$action,$state,$tabcol,$sectioncount,$image,$gpterm,$ucgpterm) = @_;
       my $crstype = &Apache::loncommon::course_type();
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                 'pipa' => 'Pick parameters to generate membership list',                  'pipa' => 'Pick parameters to generate membership list',
                 'gmem' => 'Group membership options',                  'gmem' => "$ucgpterm membership options",
                 'picr' => 'Pick the criteria to use to build a list of '.                  'picr' => 'Pick the criteria to use to build a list of '.
                           'course users from which you will select ',                            lc($crstype).' users from which you will select ',
                 'meof' => 'members of the new group.',                  'meof' => "members of the new $gpterm.",
                 'admg' => 'additional members of the group.',                  'admg' => "additional members of the $gpterm.",
                 'ifno' => 'If you do not wish to add members when you first '.                  'ifno' => "If you do not wish to add members when you first ".
                           'create the group, do not make any selections.',                            "create the $gpterm, do not make any selections.",
                 'asub' => 'A subsequent step will also allow you to specify automatic adding/dropping of group members triggered by specified role and section changes.',                  'asub' => "A subsequent step will also allow you to specify automatic adding/dropping of $gpterm members triggered by specified role and section changes.",
                 'acty' => 'Access types',                  'acty' => 'Access types',
                 'coro' => 'Course roles',                  'coro' => $crstype.' roles',
                 'cose' => 'Course sections',                  'cose' => $crstype.' sections',
              );               );
     my %status_types = (      my %status_types = (
                    active => &mt('Currently has access'),                     active => &mt('Currently has access'),
Line 1344  sub sections_selection { Line 1440  sub sections_selection {
 }  }
   
 sub access_date_settings {  sub access_date_settings {
     my ($r,$tabcol,$action,$formname,$stored,$image) = @_;      my ($r,$tabcol,$action,$formname,$stored,$image,$gpterm,$ucgpterm) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                 'sten' => 'Default start and end dates for group access',                  'sten' => "Default start and end dates for $gpterm access",
              );               );
     my $starttime = time;      my $starttime = time;
     my $endtime = time+(6*30*24*60*60); # 6 months from now, approx      my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
Line 1376  sub access_date_settings { Line 1472  sub access_date_settings {
   
 sub choose_members_form {  sub choose_members_form {
     my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description,      my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description,
         $granularity,$startdate,$enddate,$tools,$fixedprivs,$toolprivs,          $granularity,$quota,$startdate,$enddate,$tools,$fixedprivs,$toolprivs,
         $functions,$users,$userdata,$idx,$stored,$states,$navbuttons,          $functions,$users,$userdata,$idx,$stored,$states,$navbuttons,
         $rowColor1,$rowColor2) = @_;          $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype) = @_;
     my @regexps = ('user_','userpriv_','sec_');      my @regexps = ('user_','userpriv_','sec_');
     my %origmembers;      my %origmembers;
     $r->print(&Apache::lonhtmlcommon::echo_form_input(      $r->print(&Apache::lonhtmlcommon::echo_form_input(
          ['origin','action','state','page','member','specificity','branch',           ['origin','action','state','page','member','specificity','branch',
           'defpriv','autorole','autoadd','autodrop','sortby','togglefunc'],            'defpriv','autorole','autoadd','autodrop','sortby','togglefunc'],
          \@regexps));           \@regexps));
     my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum);      my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum,$gpterm,
                                          $ucgpterm,$crstype);
     $r->print('      $r->print('
 <table width="100%" cellpadding="0" cellspacing="0" border="0">  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr>   <tr>
Line 1406  sub choose_members_form { Line 1503  sub choose_members_form {
     if ($action eq 'create') {      if ($action eq 'create') {
         &print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2,          &print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2,
                                 $functions,$startdate,$enddate,$groupname,                                  $functions,$startdate,$enddate,$groupname,
                                 $description,$granularity,\@available,                                  $description,$granularity,$quota,\@available,
                                 \@unavailable);                                  \@unavailable,$gpterm,$ucgpterm);
         $specimg = 4;          $specimg = 4;
         $memimg = 5;          $memimg = 5;
     } else {      } else {
Line 1429  sub choose_members_form { Line 1526  sub choose_members_form {
     }      }
     &privilege_specificity($r,$tabcol,$rowColor1,$rowColor2,$action,      &privilege_specificity($r,$tabcol,$rowColor1,$rowColor2,$action,
                           $specimg,$tools,$stored,$toolprivs,                            $specimg,$tools,$stored,$toolprivs,
                           $fixedprivs,\@available,$formname);                            $fixedprivs,\@available,$formname,$gpterm,$ucgpterm);
     my $newusers = &pick_new_members($r,$action,$formname,$tabcol,$rowColor1,      my $newusers = &pick_new_members($r,$action,$formname,$tabcol,$rowColor1,
                                     $rowColor2,\@available,$idx,$stored,                                      $rowColor2,\@available,$idx,$stored,
                                     $memimg,$users,$userdata,$granularity,                                      $memimg,$users,$userdata,$granularity,
                                     \%origmembers);                                      \%origmembers,$gpterm,$ucgpterm);
     if ($newusers || $action eq 'create') {      if ($newusers || $action eq 'create') {
         &display_navbuttons($r,$formname,$$states{$action}[$page-1],          &display_navbuttons($r,$formname,$$states{$action}[$page-1],
                             $$navbuttons{'gtps'},$$states{$action}[$page+1],                              $$navbuttons{'gtps'},$$states{$action}[$page+1],
Line 1486  sub check_tools { Line 1583  sub check_tools {
   
 sub print_current_settings {  sub print_current_settings {
     my ($r,$action,$tabcol,$rowColor1,$rowColor2,$functions,$startdate,$enddate,      my ($r,$action,$tabcol,$rowColor1,$rowColor2,$functions,$startdate,$enddate,
            $groupname,$description,$granularity,$available,$unavailable) =@_;          $groupname,$description,$granularity,$quota,$available,$unavailable,
           $gpterm,$ucgpterm) = @_;
   
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         grna => 'Group Name',          grna => "$ucgpterm Name",
         desc => 'Description',          desc => 'Description',
         grfn => 'Group Functions',          grfn => "$ucgpterm Functions",
         gran => 'Granularity',          gran => 'Granularity',
           quot => 'File quota',
         dfac => 'Default access dates',          dfac => 'Default access dates',
         ygrs => 'Your group selections',          ygrs => "Your $gpterm selections",
         tfwa => 'The following settings will apply to the group:',          tfwa => "The following settings will apply to the $gpterm:",
         difn => 'Different functionality<br />for different users:',          difn => 'Different functionality<br />for different members:',
         stda => 'Start date',          stda => 'Start date',
         enda => 'End date:',          enda => 'End date:',
     );      );
Line 1527  sub print_current_settings { Line 1626  sub print_current_settings {
   <td><b>'.$lt{'desc'}.'</b></td>    <td><b>'.$lt{'desc'}.'</b></td>
   <td><b>'.$lt{'grfn'}.'</b></td>    <td><b>'.$lt{'grfn'}.'</b></td>
   <td><b>'.$lt{'gran'}.'</b></td>    <td><b>'.$lt{'gran'}.'</b></td>
     <td><b>'.$lt{'quot'}.'</b></td>
   <td><b>'.$lt{'dfac'}.'</b></td>    <td><b>'.$lt{'dfac'}.'</b></td>
  </tr>   </tr>
  <tr bgcolor="'.$rowColor2.'">   <tr bgcolor="'.$rowColor2.'">
Line 1573  sub print_current_settings { Line 1673  sub print_current_settings {
     $r->print(<<"END");      $r->print(<<"END");
   </td>    </td>
   <td valign="top"><small><b>$lt{'difn'}    <td valign="top"><small><b>$lt{'difn'}
   </b> $granularity</small>     </b> $granularity</small></td>
     <td valign="top"><small>$quota Mb</small></td> 
   <td valign="top"><small><b>$lt{'stda'}</b> $showstart<br />    <td valign="top"><small><b>$lt{'stda'}</b> $showstart<br />
       <b>$lt{'enda'}</b> $showend</small>        <b>$lt{'enda'}</b> $showend</small>
   </td>    </td>
Line 1589  END Line 1690  END
   
 sub pick_new_members {  sub pick_new_members {
     my ($r,$action,$formname,$tabcol,$rowColor1,$rowColor2,$available,$idx,      my ($r,$action,$formname,$tabcol,$rowColor1,$rowColor2,$available,$idx,
         $stored,$img,$users,$userdata,$granularity,$origmembers) = @_;          $stored,$img,$users,$userdata,$granularity,$origmembers,$gpterm,
           $ucgpterm) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
           'gpme' => 'Group membership',            'gpme' => "$ucgpterm membership",
           'addm' => 'Add members',            'addm' => 'Add members',
           'setf' => 'Set functionality',            'setf' => 'Set functionality',
           'func' => 'Functionality',            'func' => 'Functionality',
           'nome' => 'No members to add at this time.',            'nome' => 'No members to add at this time.',
           'nnew' => 'There are no users to add as new members, as all users'.            'nnew' => "There are no users to add as new members, as all users".
                     ' matching the specified type(s), role(s), and/or '.                      " matching the specified type(s), role(s), and/or ".
                     'section(s) are already affiliated with this group.',                      "section(s) are already affiliated with this $gpterm.",
           'yoma' =>  'You may need to use the '."'".'modify existing, past or '.            'yoma' =>  'You may need to use the '."'".'modify existing, past or '.
                      'future members'."'".' page if you need to re-enable '.                       'future members'."'".' page if you need to re-enable '.
                      'or activate access for previous or future members.',                       'or activate access for previous or future members.',
Line 1755  sub pick_new_members { Line 1857  sub pick_new_members {
   
 sub privilege_specificity {  sub privilege_specificity {
     my ($r,$tabcol,$rowColor1,$rowColor2,$action,$img,$tools,$stored,      my ($r,$tabcol,$rowColor1,$rowColor2,$action,$img,$tools,$stored,
         $toolprivs,$fixedprivs,$available,$formname) = @_;          $toolprivs,$fixedprivs,$available,$formname,$gpterm,$ucgpterm) = @_;
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
       'uprv' => 'User privileges',        'uprv' => 'User privileges',
       'frty' => 'For each type of functionality you have chosen to include, '.        'frty' => 'For each type of functionality you have chosen to include, '.
Line 1770  sub privilege_specificity { Line 1872  sub privilege_specificity {
                 'privileges which apply to members with access to that '.                  'privileges which apply to members with access to that '.
                 'functionality, and may also include additional privileges '.                  'functionality, and may also include additional privileges '.
                 'which can be set for specific members.',                  'which can be set for specific members.',
       'cutg' => 'Currently the group is configured ',        'cutg' => "Currently the $gpterm is configured ",
       'sdif' => 'so different group members can receive different privileges.',        'sdif' => "so different $gpterm members can receive different privileges.",
       'sall' => 'so all group members will receive the same privileges.',        'sall' => "so all $gpterm members will receive the same privileges.",
       'algm' => 'All group members will receive the same privileges.',        'algm' => "All $gpterm members will receive the same privileges.",
       'smgp' => 'Some group members will receive different privileges from '.        'smgp' => "Some $gpterm members will receive different privileges from ".
                 'others.',                  "others.",
       'thwi' => 'These will be the privileges all group members receive, '.         'thwi' => "These will be the privileges all $gpterm members receive, ". 
                 'if you selected the first option above.',                  "if you selected the first option above.",
       'thes' => 'These will be the privileges given to members assigned '.           'thes' => "These will be the privileges given to members assigned ".   
                 'in the future, including via automatic group assignment '.                  "in the future, including via automatic $gpterm assignment ".
                 'for specific sections/roles ',                  "for specific sections/roles ",
       'asyo' => 'As you have chosen not to include any functionality in the '.        'asyo' => "As you have chosen not to include any functionality in the ".
                 'group, no default user privileges settings need to be set.',                  "$gpterm, no default user privileges settings need to be set.",
       'plin' => 'Please indicate which <b>optional</b> privileges members '.        'plin' => 'Please indicate which <b>optional</b> privileges members '.
                 'will receive by default.',                  'will receive by default.',
       'oppr' => 'Optional privileges',        'oppr' => 'Optional privileges',
Line 2047  sub display_defprivs { Line 2149  sub display_defprivs {
 sub change_members_form {  sub change_members_form {
     my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description,      my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$groupname,$description,
         $startdate,$enddate,$tools,$fixedprivs,$functions,$users,$userdata,          $startdate,$enddate,$tools,$fixedprivs,$functions,$users,$userdata,
         $granularity,$specificity,$idx,$states,$navbuttons,$rowColor1,          $granularity,$quota,$specificity,$idx,$states,$navbuttons,$rowColor1,
         $rowColor2) = @_;          $rowColor2,$gpterm,$ucgpterm) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                                          grse => 'Group settings',                                           grse => "$ucgpterm settings",
                                          mogm => 'Modify group membership',                                           mogm => "Modify $gpterm membership",
                                         );                                          );
     my @regexps = ('user_','userpriv_');      my @regexps = ('user_','userpriv_');
     $r->print(&Apache::lonhtmlcommon::echo_form_input(      $r->print(&Apache::lonhtmlcommon::echo_form_input(
Line 2076  sub change_members_form { Line 2178  sub change_members_form {
 ');  ');
     &print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2,      &print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2,
                             $functions,$startdate,$enddate,$groupname,                              $functions,$startdate,$enddate,$groupname,
                           $description,$granularity,\@available,\@unavailable);                              $description,$granularity,$quota,\@available,
                               \@unavailable,$gpterm,$ucgpterm);
 $r->print('  $r->print('
 </td></tr><tr><td colspan="4">&nbsp;</td></tr>');  </td></tr><tr><td colspan="4">&nbsp;</td></tr>');
     &topic_bar($r,$tabcol,2,$lt{'mogm'});      &topic_bar($r,$tabcol,2,$lt{'mogm'});
Line 2418  sub change_privs_form { Line 2521  sub change_privs_form {
     my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate,      my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate,
        $tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,         $tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,
        $memchg,$idx,$states,$stored,$sectioncount,$navbuttons,$rowColor1,         $memchg,$idx,$states,$stored,$sectioncount,$navbuttons,$rowColor1,
        $rowColor2) = @_;         $rowColor2,$gpterm,$ucgpterm) = @_;
     my @regexps = ('userpriv_');      my @regexps = ('userpriv_');
     my $nexttext;      my $nexttext;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                'tode' => 'To be deleted',                 'tode' => 'To be deleted',
                'toex' => 'To be expired',                 'toex' => 'To be expired',
                'nome' => 'No members to be deleted or expired from the group.',                 'nome' => "No members to be deleted or expired from the $gpterm.",
     );      );
     $r->print(&Apache::lonhtmlcommon::echo_form_input(      $r->print(&Apache::lonhtmlcommon::echo_form_input(
          ['origin','action','state','page','sortby'],\@regexps));           ['origin','action','state','page','sortby'],\@regexps));
Line 2463  sub change_privs_form { Line 2566  sub change_privs_form {
                   '</td></tr><tr><td colspan="4">&nbsp;</td></tr>');                    '</td></tr><tr><td colspan="4">&nbsp;</td></tr>');
     }      }
           
     &topic_bar($r,$tabcol,4,&mt('Group member privileges'));      &topic_bar($r,$tabcol,4,&mt('[_1] member privileges',$ucgpterm));
   
     my $numchgs = &member_privileges_form($r,$tabcol,$action,$formname,$tools,      my $numchgs = &member_privileges_form($r,$tabcol,$action,$formname,$tools,
                                           $toolprivs,$fixedprivs,$userdata,                                            $toolprivs,$fixedprivs,$userdata,
                                           $usertools,$idx,$memchg,$states,                                            $usertools,$idx,$memchg,$states,
                                           $stored,$rowColor1,$rowColor2);                                            $stored,$rowColor1,$rowColor2,
                                             $gpterm);
     $r->print('</td></tr><tr><td colspan="4">&nbsp;</td></tr>');      $r->print('</td></tr><tr><td colspan="4">&nbsp;</td></tr>');
     my $prevtext = $$navbuttons{'gtps'};      my $prevtext = $$navbuttons{'gtps'};
     if ($numchgs || $exp_or_del) {      if ($numchgs || $exp_or_del) {
Line 2483  sub change_privs_form { Line 2587  sub change_privs_form {
   
 sub add_members_form {  sub add_members_form {
     my ($r,$tabcol,$action,$formname,$page,$startdate,$enddate,$groupname,      my ($r,$tabcol,$action,$formname,$page,$startdate,$enddate,$groupname,
         $description,$granularity,$sectioncount,$tools,$functions,$stored,          $description,$granularity,$quota,$sectioncount,$tools,$functions,
         $states,$navbuttons,$rowColor1,$rowColor2) = @_;           $stored,$states,$navbuttons,$rowColor1,$rowColor2,$gpterm,$ucgpterm)=@_; 
     $r->print(' <br />      $r->print(' <br />
 <table width="100%" cellpadding="0" cellspacing="0" border="0">  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr>   <tr>
Line 2496  sub add_members_form { Line 2600  sub add_members_form {
     &check_tools($functions,$tools,\@available,\@unavailable);      &check_tools($functions,$tools,\@available,\@unavailable);
     &print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2,      &print_current_settings($r,$action,$tabcol,$rowColor1,$rowColor2,
                             $functions,$startdate,$enddate,$groupname,                              $functions,$startdate,$enddate,$groupname,
                             $description,$granularity,\@available,\@unavailable);                              $description,$granularity,$quota,\@available,
                               \@unavailable,$gpterm,$ucgpterm);
     $r->print('      $r->print('
    </td>     </td>
   </tr>    </tr>
Line 2504  sub add_members_form { Line 2609  sub add_members_form {
    <td colspan="4">&nbsp;</td>     <td colspan="4">&nbsp;</td>
   </tr>');    </tr>');
   
     &membership_options($r,$action,$formname,$tabcol,$sectioncount,1);      &membership_options($r,$action,$formname,$tabcol,$sectioncount,1,$gpterm,
                           $ucgpterm);
     my $nexttext = $$navbuttons{'gtns'};      my $nexttext = $$navbuttons{'gtns'};
     my $prevtext = $$navbuttons{'gtpp'};      my $prevtext = $$navbuttons{'gtpp'};
     &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,      &display_navbuttons($r,$formname,$$states{$action}[$page-1],$prevtext,
Line 2517  sub add_members_form { Line 2623  sub add_members_form {
 sub choose_privs_form {  sub choose_privs_form {
     my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate,      my ($r,$cdom,$cnum,$tabcol,$action,$formname,$page,$startdate,$enddate,
        $tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,$idx,         $tools,$functions,$toolprivs,$fixedprivs,$userdata,$usertools,$idx,
        $states,$stored,$sectioncount,$navbuttons,$rowColor1,$rowColor2) = @_;         $states,$stored,$sectioncount,$navbuttons,$rowColor1,$rowColor2,
          $gpterm,$ucgpterm,$crstype) = @_;
   
     my @regexps = ('userpriv_');      my @regexps = ('userpriv_');
     my $nexttext;      my $nexttext;
Line 2535  sub choose_privs_form { Line 2642  sub choose_privs_form {
     }      }
   
     $r->print('<br /><table width="100%" cellpadding="0" cellspacing="0" border="0">');      $r->print('<br /><table width="100%" cellpadding="0" cellspacing="0" border="0">');
     &topic_bar($r,$tabcol,6,&mt('Group member privileges'));      &topic_bar($r,$tabcol,6,&mt('[_1] member privileges',$ucgpterm));
   
     &member_privileges_form($r,$tabcol,$action,$formname,$tools,$toolprivs,      &member_privileges_form($r,$tabcol,$action,$formname,$tools,$toolprivs,
                             $fixedprivs,$userdata,$usertools,$idx,undef,                              $fixedprivs,$userdata,$usertools,$idx,undef,
                             $states,$stored,$rowColor1,$rowColor2);                              $states,$stored,$rowColor1,$rowColor2,$gpterm);
   
     $r->print('</td></tr><tr><td colspan="4">&nbsp;</td></tr>');      $r->print('</td></tr><tr><td colspan="4">&nbsp;</td></tr>');
     if ($action eq 'create') {      if ($action eq 'create') {
Line 2548  sub choose_privs_form { Line 2655  sub choose_privs_form {
             my $img2 = 8;              my $img2 = 8;
             &mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount,              &mapping_options($r,$action,$formname,$page,$tabcol,$sectioncount,
                              $states,$stored,$navbuttons,$img1,$img2,                               $states,$stored,$navbuttons,$img1,$img2,
                              $rowColor1,$rowColor2);                               $rowColor1,$rowColor2,$gpterm,$ucgpterm,$crstype);
         }          }
     }      }
     my $prevtext = $$navbuttons{'gtps'};      my $prevtext = $$navbuttons{'gtps'};
Line 2618  function uncheckAllTools(formname) { Line 2725  function uncheckAllTools(formname) {
   
 sub member_privileges_form {  sub member_privileges_form {
     my ($r,$tabcol,$action,$formname,$tools,$toolprivs,$fixedprivs,$userdata,      my ($r,$tabcol,$action,$formname,$tools,$toolprivs,$fixedprivs,$userdata,
         $usertools,$idx,$memchg,$states,$stored,$rowColor1,$rowColor2) = @_;          $usertools,$idx,$memchg,$states,$stored,$rowColor1,$rowColor2,
           $gpterm) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
             'addp' => 'Additional privileges',              'addp' => 'Additional privileges',
             'fixp' => 'Fixed privileges',              'fixp' => 'Fixed privileges',
Line 2627  sub member_privileges_form { Line 2735  sub member_privileges_form {
             'forf' => 'For the functionality you have chosen to include '.              'forf' => 'For the functionality you have chosen to include '.
                       'there are no optional privileges to set besides '.                        'there are no optional privileges to set besides '.
                       'the standard privileges.',                        'the standard privileges.',
             'algr' => 'All group members will receive the same privileges.',              'algr' => "All $gpterm members will receive the same privileges.",
             'asno' => 'As no group members are being added, '.              'asno' => "As no $gpterm members are being added, ".
                       'there are no specific user privileges to set.',                        "there are no specific user privileges to set.",
             'asng' => 'As no group tools will be made available to users, '.              'asng' => "As no $gpterm tools will be made available to users, ".
                       'there are no specific user privileges to set.',                        "there are no specific user privileges to set.",
             'nogm' => 'No group member privileges to display or set, '.              'nogm' => "No $gpterm member privileges to display or set, ".
                       'as you have not indicated that you will be activating,'.                        "as you have not indicated that you will be activating,".
                       ' re-enabling, changing privileges, or adding/removing '.                        " re-enabling, changing privileges, or adding/removing ".
                       'functionality for any current members ',                        "functionality for any current members ",
             'full' => 'Fullname',              'full' => 'Fullname',
             'user' => 'Username',              'user' => 'Username',
             'doma' => 'Domain',              'doma' => 'Domain',
Line 2794  sub process_request { Line 2902  sub process_request {
     my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$groupname,$description,      my ($r,$cdom,$cnum,$tabcol,$action,$state,$page,$groupname,$description,
         $specificity,$userdata,$startdate,$enddate,$tools,$functions,$toolprivs,          $specificity,$userdata,$startdate,$enddate,$tools,$functions,$toolprivs,
         $usertools,$idx,$types,$roles,$sections,$states,$navbuttons,$memchg,          $usertools,$idx,$types,$roles,$sections,$states,$navbuttons,$memchg,
         $sectioncount,$stored,$rowColor1,$rowColor2) = @_;          $sectioncount,$stored,$rowColor1,$rowColor2,$gpterm,$ucgpterm,
           $crstype) = @_;
   
     $r->print(&Apache::lonhtmlcommon::echo_form_input(      $r->print(&Apache::lonhtmlcommon::echo_form_input(
                                  ['origin','action','state','page','sortby']));                                   ['origin','action','state','page','sortby']));
   
     my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum);      my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum,$gpterm,
                                          $ucgpterm,$crstype);
     if ($earlyout) {      if ($earlyout) {
         $r->print('          $r->print('
 <table width="100%" cellpadding="0" cellspacing="0" border="0">  <table width="100%" cellpadding="0" cellspacing="0" border="0">
Line 2845  sub process_request { Line 2955  sub process_request {
                                      $description,$startdate,$enddate,                                       $description,$startdate,$enddate,
                                      $specificity,$functions,$tools,                                       $specificity,$functions,$tools,
                                      $sectioncount,$roles,$types,$sections,                                       $sectioncount,$roles,$types,$sections,
                                      \@defprivs,$stored);                                        \@defprivs,$stored,$gpterm,$ucgpterm,
                                        $crstype); 
     }      }
     if (($action eq 'create' && $outcome eq 'ok') || (($action eq 'modify') &&       if (($action eq 'create' && $outcome eq 'ok') || (($action eq 'modify') && 
        (($state eq 'memresult') || ($state eq 'addresult')))) {         (($state eq 'memresult') || ($state eq 'addresult')))) {
         &process_membership($r,$cdom,$cnum,$action,$state,$groupname,$tools,          &process_membership($r,$cdom,$cnum,$action,$state,$groupname,$tools,
                             $enddate,$startdate,$userdata,$idx,$toolprivs,                              $enddate,$startdate,$userdata,$idx,$toolprivs,
                             $usertools,$specificity,\@defprivs,$memchg);                              $usertools,$specificity,\@defprivs,$memchg,$gpterm,
                               $ucgpterm);
     }      }
     return;      return;
 }  }
Line 2859  sub process_request { Line 2971  sub process_request {
 sub write_group_data {  sub write_group_data {
     my ($r,$cdom,$cnum,$action,$state,$groupname,$description,$startdate,      my ($r,$cdom,$cnum,$action,$state,$groupname,$description,$startdate,
         $enddate,$specificity,$functions,$tools,$sectioncount,$roles,$types,          $enddate,$specificity,$functions,$tools,$sectioncount,$roles,$types,
         $sections,$defprivs,$stored) = @_;          $sections,$defprivs,$stored,$gpterm,$ucgpterm,$crstype) = @_;
     my $now = time;      my $now = time;
     my $creation = $now;      my $creation = $now;
     my $creator = $env{'user.name'}.':'.$env{'user.domain'};      my $creator = $env{'user.name'}.':'.$env{'user.domain'};
Line 2870  sub write_group_data { Line 2982  sub write_group_data {
     my $esc_description = &escape($description);      my $esc_description = &escape($description);
     my @single_attributes = ('description','functions','startdate','enddate',      my @single_attributes = ('description','functions','startdate','enddate',
                              'creation','modified','creator','granularity',                               'creation','modified','creator','granularity',
                              'specificity','autoadd','autodrop');                               'specificity','autoadd','autodrop','quota');
     my @mult_attributes = ('roles','types','sectionpick','defpriv');      my @mult_attributes = ('roles','types','sectionpick','defpriv');
   
     my %groupinfo = (      my %groupinfo = (
Line 2884  sub write_group_data { Line 2996  sub write_group_data {
                      specificity => $specificity,                       specificity => $specificity,
                      autoadd => $env{'form.autoadd'},                       autoadd => $env{'form.autoadd'},
                      autodrop => $env{'form.autodrop'},                       autodrop => $env{'form.autodrop'},
                        quota => $env{'form.quota'},                
                    );                     );
     foreach my $func (keys(%{$functions})) {      foreach my $func (keys(%{$functions})) {
         my $status;          my $status;
Line 2932  sub write_group_data { Line 3045  sub write_group_data {
     if ($result eq 'ok') {      if ($result eq 'ok') {
         if ($action eq 'create') {          if ($action eq 'create') {
             my $put_result = &create_homepage($cdom,$cnum,$groupname,              my $put_result = &create_homepage($cdom,$cnum,$groupname,
                                               \%groupinfo,$tools);                                                \%groupinfo,$tools,$gpterm,
             $r->print('Group '.$groupname.' was created.<br />');                                                $ucgpterm);
               $r->print(&mt('[_1] [_2] was created.<br />',$ucgpterm,$groupname));
         } else {          } else {
             $r->print('Group '.$groupname.' was updated.<br />');              $r->print(&mt('[_1] [_2] was updated.<br />',$ucgpterm,$groupname));
         }          }
     } else {      } else {
         my %actiontype = (          my %actiontype = (
                           'create' => 'creating',                            'create' => 'creating',
                           'modify' => 'modifying',                            'modify' => 'modifying',
                          );                           );
         &Apache::lonnet::logthis('Failed to store group '.$groupname.          &Apache::lonnet::logthis("Failed to store $gpterm $groupname ".
                                  'in course: '.$cnum.' in domain: '.$cdom);                                   'in '.lc($crstype).': '.$cnum.
         $r->print(&mt('An error occurred when [_1] the new group. '.                                   ' in domain: '.$cdom);
                       'Please try again.',$actiontype{$action}));          $r->print(&mt('An error occurred when [_1] the new [_2]. '.
                         'Please try again.',$actiontype{$action},$gpterm));
     }      }
     return $result;      return $result;
 }  }
   
 sub process_membership {  sub process_membership {
     my ($r,$cdom,$cnum,$action,$state,$groupname,$tools,$enddate,$startdate,      my ($r,$cdom,$cnum,$action,$state,$groupname,$tools,$enddate,$startdate,
         $userdata,$idx,$toolprivs,$usertools,$specificity,$defprivs,$memchg)=@_;          $userdata,$idx,$toolprivs,$usertools,$specificity,$defprivs,$memchg,
           $gpterm,$ucgpterm)=@_;
     my %usersettings = ();      my %usersettings = ();
     my %added= ();      my %added= ();
     my %failed = ();      my %failed = ();
Line 3149  sub process_membership { Line 3265  sub process_membership {
         $r->print('<br />');          $r->print('<br />');
     }      }
     if ($roster_result eq 'ok') {      if ($roster_result eq 'ok') {
         $r->print('<br />'.&mt('Group membership list updated.'));          $r->print('<br />'.&mt('[_1] membership list updated.',$ucgpterm));
     } else {      } else {
         $r->print('<br />'.&mt('An error occurred while updating the group membership list -').$roster_result.'<br />');          $r->print('<br />'.&mt('An error occurred while updating the [_1] membership list -',$gpterm).$roster_result.'<br />');
     }      }
     return;      return;
 }  }
   
 sub mapping_options {  sub mapping_options {
     my ($r,$action,$formname,$page,$tabcol,$sectioncount,$states,$stored,      my ($r,$action,$formname,$page,$tabcol,$sectioncount,$states,$stored,
         $navbuttons,$img1,$img2,$rowColor1,$rowColor2) = @_;          $navbuttons,$img1,$img2,$rowColor1,$rowColor2,$gpterm,$ucgpterm,
           $crstype) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         'auto' => 'Settings for automatic group enrollment',          'auto' => "Settings for automatic $gpterm enrollment",
         'gmma' => 'Group membership mapping to specific sections/roles',          'gmma' => "$ucgpterm membership mapping to specific sections/roles",
         'endi' => 'Enable/disable automatic group enrollment for '.          'endi' => "Enable/disable automatic $gpterm enrollment for ".
                           'users in specified roles and sections',                            "users in specified roles and sections",
         'adds'  => 'If automatic group enrollment is enabled, when a user is assigned a course-wide or section-specific role, he/she will automatically be added as a member of the group, with start and end access dates defined by the default dates set for the group, unless he/she is already a group member, with access dates that permit either current or future group access.',          'adds'  => "If automatic $gpterm enrollment is enabled, when a user is assigned a ".lc($crstype)."-wide or section-specific role, he/she will automatically be added as a member of the $gpterm, with start and end access dates defined by the default dates set for the $gpterm, unless he/she is already a $gpterm member, with access dates that permit either current or future $gpterm access.",
         'drops'  => "If automatic group disenrollment is enabled, when a user's role is expired, access to the group will be terminated unless the user continues to have other course-wide or section-specific active or future roles which receive automatic membership in the group.",          'drops'  => "If automatic $gpterm disenrollment is enabled, when a user's role is expired, access to the $gpterm will be terminated unless the user continues to have other ".lc($crstype)."-wide or section-specific active or future roles which receive automatic membership in the $gpterm.",
         'pirs' => 'Pick roles and sections for automatic group enrollment',          'pirs' => "Pick roles and sections for automatic $gpterm enrollment",
         'curr' => 'Currently set to',          'curr' => 'Currently set to',
         'on' => 'on',          'on' => 'on',
         'off' => 'off',          'off' => 'off',
         'auad' => 'Automatically enable group membership when roles are added?',          'auad' => "Automatically enable $gpterm membership when roles are added?",
         'auex' => 'Automatically expire group membership when roles are removed?',          'auex' => "Automatically expire $gpterm membership when roles are removed?",
         'mapr' => 'Mapping of roles and sections affected by automatic group enrollment/disenrollment follows scheme chosen below.',          'mapr' => "Mapping of roles and sections affected by automatic $gpterm enrollment/disenrollment follows scheme chosen below.",
     );      );
     &automapping($r,$action,$tabcol,$stored,\%lt,$img1);      &automapping($r,$action,$tabcol,$stored,\%lt,$img1);
     $r->print('      $r->print('
Line 3180  sub mapping_options { Line 3297  sub mapping_options {
     <td colspan="4">&nbsp;</td>      <td colspan="4">&nbsp;</td>
    </tr>');     </tr>');
     &mapping_settings($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,\%lt,      &mapping_settings($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,\%lt,
                                                        $stored,$img2);                        $stored,$img2,$crstype);
     return;      return;
 }  }
   
Line 3240  sub automapping { Line 3357  sub automapping {
 }  }
   
 sub mapping_settings {  sub mapping_settings {
     my ($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,$lt,$stored,$image) = @_;      my ($r,$tabcol,$rowColor1,$rowColor2,$sectioncount,$lt,$stored,$image,
           $crstype) = @_;
     my @sections = keys(%{$sectioncount});      my @sections = keys(%{$sectioncount});
     if (@sections > 0) {      if (@sections > 0) {
         @sections = sort {$a cmp $b} @sections;          @sections = sort {$a cmp $b} @sections;
Line 3266  sub mapping_settings { Line 3384  sub mapping_settings {
     my $rowNum = 0;      my $rowNum = 0;
     my $rowColor;      my $rowColor;
     foreach my $role (@roles) {      foreach my $role (@roles) {
         my $plrole=&Apache::lonnet::plaintext($role);          my $plrole=&Apache::lonnet::plaintext($role,$crstype);
         my $sections_sel;          my $sections_sel;
         if (@sections > 0) {          if (@sections > 0) {
             if ($role eq 'cc') {              if ($role eq 'cc') {
Line 3326  sub my_custom_roles { Line 3444  sub my_custom_roles {
 }  }
   
 sub modify_menu {  sub modify_menu {
     my ($r,$groupname,$page) = @_;      my ($r,$groupname,$page,$gpterm) = @_;
     my @menu =      my @menu =
         (          (
           { text => 'Modify default group settings',            { text => "Modify default $gpterm settings",
             help => 'Course_Modify_Group',              help => 'Course_Modify_Group',
             state => 'change_settings',              state => 'change_settings',
             branch => 'settings',              branch => 'settings',
Line 3340  sub modify_menu { Line 3458  sub modify_menu {
             state => 'change_members',              state => 'change_members',
             branch => 'members',              branch => 'members',
             },              },
           { text => 'Add member(s) to the group',            { text => "Add member(s) to the $gpterm",
             help => 'Course_Group_Add_Members',              help => 'Course_Group_Add_Members',
             state => 'add_members',              state => 'add_members',
             branch => 'adds',              branch => 'adds',
Line 3454  sub date_setting_table { Line 3572  sub date_setting_table {
 }  }
   
 sub create_homepage {  sub create_homepage {
     my ($cdom,$cnum,$name,$groupinfo,$tools) = @_;      my ($cdom,$cnum,$name,$groupinfo,$tools,$gpterm,$ucgpterm) = @_;
     my $functionality = join(',',@{$tools});      my $functionality = join(',',@{$tools});
     my $content = &unescape($$groupinfo{description});      my $content = &unescape($$groupinfo{description});
     $content=~s/\s+$//s;      $content=~s/\s+$//s;
Line 3463  sub create_homepage { Line 3581  sub create_homepage {
     $content=&Apache::lonfeedback::clear_out_html($content,1);      $content=&Apache::lonfeedback::clear_out_html($content,1);
   
     my %pageinfo = (      my %pageinfo = (
                      'aaa_title' => 'Group: '.$name,                       'aaa_title' => "$ucgpterm: $name",
                      'abb_links' => $functionality,                       'abb_links' => $functionality,
                      'bbb_content' => $content,                       'bbb_content' => $content,
                      'ccc_webreferences' => '',                       'ccc_webreferences' => '',
Line 3509  function toggleTools(field,caller) { Line 3627  function toggleTools(field,caller) {
 }  }
   
 sub validate_groupname {  sub validate_groupname {
     my ($groupname,$action,$cdom,$cnum) = @_;      my ($groupname,$action,$cdom,$cnum,$gpterm,$ucgpterm,$crstype) = @_;
     my %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum);      my %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum);
     my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);      my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
   
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                       igna => 'Invalid group name',                        igna => "Invalid $gpterm name",
                       tgne => 'The group name entered ',                        tgne => "The $gpterm name entered ",
                       grna => 'Group names and section names used in a course '.                        grna => "$ucgpterm names and section names used in a ".
                               'must be unique.',                                 "$crstype must be unique.",
                       isno => 'is not a valid name.',                        isno => "is not a valid name.",
                       gnmo => 'Group names may only contain letters, numbers '.                        gnmo => "$ucgpterm names may only contain letters, ". 
                               'or underscores.',                                "numbers or underscores.",
                       cnnb => 'can not be used as it is the name of ',                        cnnb => "can not be used as it is the name of ",
                       inth => ' in this course.',                        inth => " in this $crstype", 
                       thgr => '- does not correspond to the name of an existing'.                          thgr => "- does not correspond to the name of an ".
                               ' group ',                                    "existing $gpterm",    
     );      );
   
     my $exitmsg = '<b>'.$lt{'igna'}.'</b><br /><br />'.$lt{'tgne'}.' "'.      my $exitmsg = '<b>'.$lt{'igna'}.'</b><br /><br />'.$lt{'tgne'}.' "'.
Line 3542  sub validate_groupname { Line 3660  sub validate_groupname {
     if ($action eq 'create'       if ($action eq 'create' 
  && exists($curr_groups{$groupname})) {   && exists($curr_groups{$groupname})) {
   
  return $exitmsg.$lt{'cnnb'}.&mt('an existing group').   return $exitmsg.$lt{'cnnb'}.&mt('an existing [_1]',$gpterm).
     $lt{'inth'}.'<br />'.$lt{'grna'};      $lt{'inth'}.'<br />'.$lt{'grna'};
   
     } elsif ($action eq 'modify') {      } elsif ($action eq 'modify') {
         unless(exists($curr_groups{$groupname})) {          unless(exists($curr_groups{$groupname})) {
             $earlyout = &mt('Group name:').' '.$groupname.$lt{'thgr'}.$lt{'inth'};              $earlyout = &mt('[_1] name:',$ucgpterm).' '.$groupname.$lt{'thgr'}.
                           $lt{'inth'};
             return $earlyout;              return $earlyout;
         }          }
     }      }

Removed from v.1.28  
changed lines
  Added in v.1.29


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