Diff for /loncom/interface/longroup.pm between versions 1.7 and 1.8

version 1.7, 2006/06/30 18:27:19 version 1.8, 2006/07/02 17:08:42
Line 415  sub group_changes { Line 415  sub group_changes {
   
 ###############################################  ###############################################
   
   sub get_fixed_privs {
       my $fixedprivs = {
                         email      => {sgm => 1},
                         discussion => {vgb => 1},
                         chat       => {pgc => 1},
                         files      => {rgf => 1},
                         roster     => {vgm => 1},
                         homepage   => {vgh => 1},
                        };
       return $fixedprivs;
   }
   
   ###############################################
   
   sub get_tool_privs {
       my ($gpterm) = @_;
       my $toolprivs = {
           email      => {
               sgm => 'Send '.$gpterm.' mail',
               sgb => 'Broadcast mail',
           },
           discussion => {
               cgb => 'Create boards',
               pgd => 'Post',
               pag => 'Anon. posts',
               rgi => 'Get identities',
               vgb => 'View boards',
           },
           chat       => {
               pgc => 'Chat',
           },
           files      => {
               rgf => 'Retrieve',
               ugf => 'Upload',
               mgf => 'Modify',
               dgf => 'Delete',
               agf => 'Control Access',
           },
           roster     => {
               vgm => 'View',
           },
           homepage   => {
               vgh => 'View page',
               mgh => 'Modify page',
           },
       };
       return $toolprivs;
   }
   
   ###############################################
   
   
   sub group_memberlist {
       my ($cdom,$cnum,$groupname,$fixedprivs,$available) = @_;
       my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum,
                                                              $groupname);
       my %current = ();
       my $hastools = 0;
       my $addtools = 0;
       my $num_previous = 0;
       my $num_future = 0;
       my $num_active = 0;
       my $now = time;
       if (keys(%membership) > 0) {
           my %allnames = ();
           foreach my $key (sort(keys(%membership))) {
               if ($key =~ /^\Q$groupname\E:([^:]+):([^:]+)$/) {
                   my $uname = $1;
                   my $udom = $2;
                   my $user = $uname.':'.$udom;
                   my($end,$start,@userprivs) = split(/:/,$membership{$key});
                   unless ($start == -1) {
                       $allnames{$udom}{$uname} = 1;
                       $current{$user} = {
                           uname     => $uname,
                           udom      => $udom,
                           start     => &Apache::lonlocal::locallocaltime($start),
                           currtools => [],
                           newtools  => [],
                           privs     => \@userprivs,
                       };
   
                       if ($end == 0) {
                           $current{$user}{end} =  'No end date';
                       } else {
                           $current{$user}{end} =
                                        &Apache::lonlocal::locallocaltime($end);
                       }
                       my $now = time;
                       if (($end > 0) && ($end < $now)) {
                           $current{$user}{changestate} = 'reenable';
                           $current{$user}{'status'} = 'previous';
                           $num_previous++;
                       } elsif (($start > $now)) {
                           $current{$user}{changestate} = 'activate';
                           $current{$user}{'status'} = 'future';
                           $num_future ++;
                       } else {
                           $current{$user}{changestate} = 'expire';
                           $current{$user}{'status'} = 'active';
                           $num_active ++;
                       }
                       if (@userprivs > 0) {
                           foreach my $tool (sort(keys(%{$fixedprivs}))) {
                               foreach my $priv (keys(%{$$fixedprivs{$tool}})) {
                                   if (grep/^$priv$/,@userprivs) {
                                       push(@{$current{$user}{currtools}},$tool);
                                       last;
                                   }
                               }
                           }
                           $hastools = 1;
                       }
                       if (@{$available} > 0) {
                           if (@{$current{$user}{currtools}} > 0) {
                               if ("@{$available}" ne "@{$current{$user}{currtools}}") {
                                   foreach my $tool (@{$available}) {
                                       unless (grep/^$tool$/,@{$current{$user}{currtools}}) {
                                           push(@{$current{$user}{newtools}},$tool);                                    }
                                   }
                               }
                           } else {
                               @{$current{$user}{newtools}} = @{$available};
   
                           }
                           if (@{$current{$user}{newtools}} > 0) {
                               $addtools = 1;
                           }
                       }
                   }
               }
           }
           if (keys(%current) > 0) {
               my %idhash;
               foreach my $udom (keys(%allnames)) {
                   %{$idhash{$udom}} = &Apache::lonnet::idrget($udom,
                                                   keys(%{$allnames{$udom}}));
                   foreach my $uname (keys(%{$idhash{$udom}})) {
                       $current{$uname.':'.$udom}{'id'} = $idhash{$udom}{$uname};
                   }
                   foreach my $uname (keys(%{$allnames{$udom}})) {
                       $current{$uname.':'.$udom}{'fullname'} =
                                   &Apache::loncommon::plainname($uname,$udom,
                                                                     'lastname');
                   }
               }
           }
       }
       return (\%current,$hastools,$addtools,$num_previous,$num_future,
               $num_active);
   }
   
   ###############################################
   
 sub sum_quotas {  sub sum_quotas {
     my ($courseid) = @_;      my ($courseid) = @_;
     my $totalquotas = 0;      my $totalquotas = 0;

Removed from v.1.7  
changed lines
  Added in v.1.8


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