--- loncom/interface/loncoursegroups.pm 2006/07/02 12:46:06 1.35 +++ loncom/interface/loncoursegroups.pm 2006/07/02 17:08:42 1.36 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: loncoursegroups.pm,v 1.35 2006/07/02 12:46:06 raeburn Exp $ +# $Id: loncoursegroups.pm,v 1.36 2006/07/02 17:08:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -438,47 +438,9 @@ sub group_administration { } } - 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', - }, - ); + my $toolprivs = &Apache::longroup::get_tool_privs($gpterm); - my %fixedprivs = - ( - email => {sgm => 1}, - discussion => {vgb => 1}, - chat => {pgc => 1}, - files => {rgf => 1}, - roster => {vgm => 1}, - homepage => {vgh => 1}, - ); + my $fixedprivs = &Apache::longroup::get_fixed_privs(); my %elements = ( @@ -686,8 +648,8 @@ sub group_administration { } my @currtools = (); if (@userprivs > 0) { - foreach my $tool (sort(keys(%fixedprivs))) { - foreach my $priv (keys(%{$fixedprivs{$tool}})) { + foreach my $tool (sort(keys(%{$fixedprivs}))) { + foreach my $priv (keys(%{$$fixedprivs{$tool}})) { if (grep/^$priv$/,@userprivs) { push(@currtools,$tool); last; @@ -757,8 +719,8 @@ sub group_administration { && ($specificity eq 'Yes')) { foreach my $user (sort(keys(%usertools))) { foreach my $tool (keys(%{$usertools{$user}})) { - foreach my $priv (keys(%{$toolprivs{$tool}})) { - unless (exists($fixedprivs{$tool}{$priv})) { + foreach my $priv (keys(%{$$toolprivs{$tool}})) { + unless (exists($$fixedprivs{$tool}{$priv})) { $elements{$action}{$state}{'userpriv_'.$priv} = 'checkbox'; } } @@ -868,7 +830,7 @@ function changeSort(caller) { ("$crumbtitle Manager")); &display_control($r,$cdom,$cnum,$tabcol,$action,$state,$page, \%sectioncount,$groupname,$description,$functions, - \@tools,\%toolprivs,\%fixedprivs,$startdate,$enddate, + \@tools,$toolprivs,$fixedprivs,$startdate,$enddate, \%users,\%userdata,$idx,\%memchg,\%usertools, $function,$view_permission,$manage_permission, \%stored,$granularity,$quota,$specificity,\@types,\@roles, @@ -2227,114 +2189,33 @@ sub current_membership { 'curf' => 'Current Functionality', 'chpr' => 'Change Privileges' ); - if (keys(%membership) > 0) { - my %current = (); - my %allnames = (); - my $hastools = 0; - my $addtools = 0; - my $num_reenable = 0; - my $num_activate = 0; - my $num_expire = 0; - 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 => [], - }; - - 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'; - $num_reenable++; - } elsif (($start > $now)) { - $current{$user}{changestate} = 'activate'; - $num_activate ++; - } else { - $current{$user}{changestate} = 'expire'; - $num_expire ++; - } - 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'); - } - } - $r->print(' + my ($current,$hastools,$addtools,$num_reenable,$num_activate,$num_expire) = + &Apache::longroup::group_memberlist($cdom,$cnum,$groupname,$fixedprivs, + $available); + if (keys(%{$current}) > 0) { + $r->print('   '); - if ($num_expire) { - &check_uncheck_buttons($r,$formname,'expire',$lt{'expi'}); - } - if ($num_reenable) { - &check_uncheck_buttons($r,$formname,'reenable',$lt{'reen'}); - } - if ($num_activate) { - &check_uncheck_buttons($r,$formname,'activate',$lt{'acti'}); + if ($num_expire) { + &check_uncheck_buttons($r,$formname,'expire',$lt{'expi'}); + } + if ($num_reenable) { + &check_uncheck_buttons($r,$formname,'reenable',$lt{'reen'}); + } + if ($num_activate) { + &check_uncheck_buttons($r,$formname,'activate',$lt{'acti'}); + } + &check_uncheck_buttons($r,$formname,'deletion',$lt{'dele'}); + if (@{$available} > 0) { + if ($specificity eq 'Yes') { + &check_uncheck_buttons($r,$formname,'changepriv',$lt{'chpr'}); } - &check_uncheck_buttons($r,$formname,'deletion',$lt{'dele'}); - if (@{$available} > 0) { - if ($specificity eq 'Yes') { - &check_uncheck_buttons($r,$formname,'changepriv',$lt{'chpr'}); - } - if ($granularity eq 'Yes') { - $r->print(&check_uncheck_tools($r,$available)); - $r->print(' + if ($granularity eq 'Yes') { + $r->print(&check_uncheck_tools($r,$available)); + $r->print(' '); - } } - $r->print(<<"END"); + } + $r->print(<<"END");
'.$lt{'curf'}.' @@ -2347,9 +2228,9 @@ sub current_membership {
@@ -2362,8 +2243,8 @@ sub current_membership {   END - $r->print(&Apache::lonhtmlcommon::start_pick_box()); - $r->print(<<"END"); + $r->print(&Apache::lonhtmlcommon::start_pick_box()); + $r->print(<<"END"); @@ -2375,135 +2256,134 @@ END END - my $colspan = 0; - if ($hastools) { - $r->print(''); - $colspan ++; - } - if ($addtools) { - $r->print(''); - $colspan ++; - } - $r->print(''); - if ($colspan) { - if ($granularity eq 'Yes') { - $r->print(' + my $colspan = 0; + if ($hastools) { + $r->print(''); + $colspan ++; + } + if ($addtools) { + $r->print(''); + $colspan ++; + } + $r->print(''); + if ($colspan) { + if ($granularity eq 'Yes') { + $r->print(''); } + $r->print(''); } - my %Sortby = (); - foreach my $user (sort(keys(%current))) { - if ($env{'form.sortby'} eq 'fullname') { - push(@{$Sortby{$current{$user}{fullname}}},$user); - } elsif ($env{'form.sortby'} eq 'username') { - push(@{$Sortby{$current{$user}{uname}}},$user); - } elsif ($env{'form.sortby'} eq 'domain') { - push(@{$Sortby{$current{$user}{udom}}},$user); - } elsif ($env{'form.sortby'} eq 'id') { - push(@{$Sortby{$current{$user}{id}}},$user); + } + my %Sortby = (); + foreach my $user (sort(keys(%{$current}))) { + if ($env{'form.sortby'} eq 'fullname') { + push(@{$Sortby{$$current{$user}{fullname}}},$user); + } elsif ($env{'form.sortby'} eq 'username') { + push(@{$Sortby{$$current{$user}{uname}}},$user); + } elsif ($env{'form.sortby'} eq 'domain') { + push(@{$Sortby{$$current{$user}{udom}}},$user); + } elsif ($env{'form.sortby'} eq 'id') { + push(@{$Sortby{$$current{$user}{id}}},$user); + } else { + push(@{$Sortby{$$current{$user}{fullname}}},$user); + } + } + my $rowNum = 0; + my $rowColor; + foreach my $key (sort(keys(%Sortby))) { + foreach my $user (@{$Sortby{$key}}) { + if ($rowNum %2 == 1) { + $rowColor = $rowColor1; } else { - push(@{$Sortby{$current{$user}{fullname}}},$user); + $rowColor = $rowColor2; } - } - my $rowNum = 0; - my $rowColor; - foreach my $key (sort(keys(%Sortby))) { - foreach my $user (@{$Sortby{$key}}) { - if ($rowNum %2 == 1) { - $rowColor = $rowColor1; - } else { - $rowColor = $rowColor2; - } - my $id = $current{$user}{id}; - my $fullname = $current{$user}{fullname}; - my $udom = $current{$user}{udom}; - my $uname = $current{$user}{uname}; - my $start = $current{$user}{start}; - my $end = $current{$user}{end}; - $r->print(' - + '); - if ($hastools) { - $r->print(''); + } + $r->print('   '); } - if ($addtools) { - $r->print(''); + } + if ($addtools) { + $r->print(''); } - $r->print(''."\n"); - $rowNum ++; + $r->print(''); } + $r->print(''."\n"); + $rowNum ++; } - $r->print(&Apache::lonhtmlcommon::end_pick_box()); - $r->print(' + } + $r->print(&Apache::lonhtmlcommon::end_pick_box()); + $r->print(' '); - } } return; }
$lt{'actn'}$lt{'stda'} $lt{'enda'}'.$lt{'curf'}.'Additional Functionality
'.$lt{'curf'}.'Additional Functionality
  '.&mt('All:'). ' '); - foreach my $tool (@{$available}) { - $r->print('
'); - if ($current{$user}{changestate} eq 'reenable') { - $r->print('
'); + if ($$current{$user}{changestate} eq 'reenable') { + $r->print('
'); - } elsif ($current{$user}{changestate} eq 'expire') { - $r->print('
'); - } elsif ($current{$user}{changestate} eq 'activate') { - $r->print('
'); - } - $r->print(''); - if ($specificity eq 'Yes') { - $r->print('
'); - } - $r->print(' + } + $r->print('
'. $fullname.''.$uname.''. $udom.''.$id.''.$start. ''.$end.''. + if ($hastools) { + $r->print(''. '      '); - foreach my $tool (@{$current{$user}{currtools}}) { - if ($granularity eq 'Yes') { - $r->print(''); - if ($granularity eq 'Yes') { - foreach my $tool (@{$current{$user}{newtools}}) { - $r->print(''); + if ($granularity eq 'Yes') { + foreach my $tool (@{$$current{$user}{newtools}}) { + $r->print('   '); - } - } else { - foreach my $tool (@{$current{$user}{newtools}}) { - $r->print('print(''.$tool. '   '); - } } - $r->print('