version 1.59, 2006/07/29 00:31:58
|
version 1.81, 2008/12/03 21:59:37
|
Line 29 package Apache::loncoursegroups;
|
Line 29 package Apache::loncoursegroups;
|
|
|
use strict; |
use strict; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon; |
use Apache::loncommon(); |
use Apache::lonhtmlcommon; |
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::portfolio(); |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
|
use LONCAPA::map(); |
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA; |
use LONCAPA; |
|
|
Line 75 sub handler {
|
Line 76 sub handler {
|
|
|
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 => $ucgpterm.' home page', |
homepage => $ucgpterm.' home page', |
); |
); |
|
|
Line 91 sub handler {
|
Line 92 sub handler {
|
|
|
my $action = $env{'form.action'}; |
my $action = $env{'form.action'}; |
my $state = $env{'form.state'}; |
my $state = $env{'form.state'}; |
if ((!defined($action)) || ($action eq 'view') || ($action eq 'modify')) { |
if ((!defined($action)) || ($action eq 'view') || ($action eq 'modify') || ($action eq 'delete') || ($action eq 'reenable')) { |
if (!defined($state)) { |
if (!defined($state)) { |
$state = 'view'; |
$state = 'view'; |
} |
} |
} |
} |
if ($action eq 'create' || $action eq 'modify' || $action eq 'view') { |
if ($action eq 'create' || $action eq 'modify' || $action eq 'view' || |
|
$action eq 'delete' || $action eq 'reenable') { |
if ($view_permission || $manage_permission) { |
if ($view_permission || $manage_permission) { |
if ($state eq 'view') { |
if ($state eq 'view') { |
&print_main_menu($r,$cdom,$cnum,\%functions,\%idx, |
&print_main_menu($r,$cdom,$cnum,\%functions,\%idx, |
Line 109 sub handler {
|
Line 111 sub handler {
|
$crstype); |
$crstype); |
} |
} |
} else { |
} else { |
$r->print(&mt('You do not have [_1] administration '. |
$r->print('<div class="LC_warning">' |
'privileges in this [_2]',$gpterm,lc($crstype))); |
.&mt('You do not have '.$gpterm.' administration ' |
|
.'privileges in this '.lc($crstype).'.') |
|
.'</div>'); |
} |
} |
} else { |
} else { |
&print_main_menu($r,$cdom,$cnum,\%functions,\%idx,$view_permission, |
&print_main_menu($r,$cdom,$cnum,\%functions,\%idx,$view_permission, |
Line 127 sub print_main_menu {
|
Line 131 sub print_main_menu {
|
function changeSort(caller) { |
function changeSort(caller) { |
document.$state.sortby.value = caller; |
document.$state.sortby.value = caller; |
document.$state.submit(); |
document.$state.submit(); |
|
} |
|
function openGroupRoster(group,status) { |
|
var url = '/adm/grouproster?'; |
|
url += 'group='+group+'&status='+status+'&ref=popup'; |
|
var title = 'Group Membership'; |
|
var options = 'scrollbars=1,resizable=1,menubar=0'; |
|
options += ',width=700,height=600'; |
|
rosterbrowser = open(url,title,options,'1'); |
|
rosterbrowser.focus(); |
}\n|; |
}\n|; |
$r->print(&header('Groups',$jscript,$action,$state)); |
$r->print(&header('Groups',$jscript,$action,$state)); |
if ($env{'form.refpage'} eq 'enrl') { |
if ($env{'form.refpage'} eq 'cusr') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/dropadd", |
({href=>"/adm/createuser", |
text=>"Enrollment Manager"}); |
text=>"User Management"}); |
} |
} |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/coursegroups", |
({href=>"/adm/coursegroups", |
text=>"Groups"}); |
text=>"Groups"}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Groups')); |
my $helpitem; |
|
if ($manage_permission) { |
|
$helpitem = 'Creating_Groups'; |
|
} |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Groups',$helpitem)); |
&display_groups($r,$cdom,$cnum,$functions,$idx,$view_permission, |
&display_groups($r,$cdom,$cnum,$functions,$idx,$view_permission, |
$manage_permission,$action,$state,$gpterm,$ucgpterm, |
$manage_permission,$action,$state,$gpterm,$ucgpterm, |
$crstype); |
$crstype); |
Line 155 sub display_groups {
|
Line 172 sub display_groups {
|
$env{'form.refpage'}.'&state=pick_task&groupname=', |
$env{'form.refpage'}.'&state=pick_task&groupname=', |
view => '<a href="/adm/'.$cdom.'/'.$cnum.'/', |
view => '<a href="/adm/'.$cdom.'/'.$cnum.'/', |
delete => '<a href="/adm/coursegroups?action=delete&refpage='. |
delete => '<a href="/adm/coursegroups?action=delete&refpage='. |
$env{'form.refpage'}.'&groupname=', |
$env{'form.refpage'}.'&state=verify&groupname=', |
|
reenable => '<a href="/adm/coursegroups?action=reenable&refpage='. |
|
$env{'form.refpage'}.'&state=verify&groupname=', |
); |
); |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
modify => 'Modify', |
modify => 'Modify', |
view => 'View', |
view => 'View', |
delete => 'Delete', |
delete => 'Delete', |
|
reenable => 'Re-enable', |
act => 'Action', |
act => 'Action', |
gname => 'Group Name', |
gname => 'Group Name', |
desc => 'Group Title', |
desc => 'Group Title', |
Line 175 sub display_groups {
|
Line 195 sub display_groups {
|
dius => 'Disk Use (%)', |
dius => 'Disk Use (%)', |
nogr => 'No groups exist.', |
nogr => 'No groups exist.', |
crng => 'Create a new group', |
crng => 'Create a new group', |
|
redg => 'Re-enable a deleted group', |
alth => 'Although your current role has privileges'. |
alth => 'Although your current role has privileges'. |
' to view any existing groups in this'. |
' to view any existing groups in this '. |
lc($crstype).', you do not have privileges'. |
lc($crstype).', you do not have privileges '. |
'to create new groups.', |
'to create new groups.', |
); |
); |
if ($view_permission) { |
if ($view_permission) { |
if (!defined($action)) { |
if (!defined($action)) { |
$action = 'view'; |
$action = 'view'; |
} |
} |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum); |
my ($status,$reenable_link); |
|
if ($action eq 'reenable') { |
|
$status = 'deleted_groups'; |
|
} else { |
|
if ($manage_permission) { |
|
my %deleted_groups = |
|
&Apache::longroup::coursegroups($cdom,$cnum,undef,'deleted_groups'); |
|
if (keys(%deleted_groups) > 0) { |
|
$reenable_link = ' <a href="/adm/coursegroups?action=reenable&refpage='.$env{'form.refpage'}.'">'.$lt{'redg'}.'</a>'; |
|
} |
|
} |
|
} |
|
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,undef, |
|
$status); |
|
|
if (%curr_groups) { |
if (%curr_groups) { |
if ($manage_permission) { |
if ($manage_permission) { |
if (!exists($env{'form.refpage'})) { |
if ($action ne 'reenable') { |
$r->print('<br /><a href="/adm/coursegroups?action=create">'.$lt{'crng'}.'</a>'); |
$r->print('<br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>'); |
|
} |
|
if ($reenable_link) { |
|
$r->print($reenable_link); |
} |
} |
} |
} |
$r->print('<br /><br />'); |
$r->print('<br /><br />'); |
Line 218 END
|
Line 256 END
|
my $members_result = &group_members($cdom,$cnum,$group, |
my $members_result = &group_members($cdom,$cnum,$group, |
\%grp_info); |
\%grp_info); |
my $port_path = '/userfiles/groups/'.$group.'/portfolio'; |
my $port_path = '/userfiles/groups/'.$group.'/portfolio'; |
my $port_dir = &Apache::loncommon::propath($cdom,$cnum).$port_path; |
|
my $totaldirs = 0; |
my $totaldirs = 0; |
my $totalfiles = 0; |
my $totalfiles = 0; |
&group_files($group,$port_dir,\$totalfiles,\$totaldirs); |
&group_files($group,$port_path,\$totalfiles,\$totaldirs); |
$grp_info{$group}{'totalfiles'} = $totalfiles; |
$grp_info{$group}{'totalfiles'} = $totalfiles; |
$grp_info{$group}{'totaldirs'} = $totaldirs; |
$grp_info{$group}{'totaldirs'} = $totaldirs; |
my $diskuse = &Apache::lonnet::diskusage($cdom,$cnum,$port_dir); |
my $getpropath = 1; |
|
my $diskuse = &Apache::lonnet::diskusage($cdom,$cnum,$port_path, $getpropath); |
if ($grp_info{$group}{'quota'} > 0) { |
if ($grp_info{$group}{'quota'} > 0) { |
my $pct_use = 0.1 * $diskuse/$grp_info{$group}{'quota'}; |
my $pct_use = 0.1 * $diskuse/$grp_info{$group}{'quota'}; |
$grp_info{$group}{'diskuse'} = sprintf("%.0f",$pct_use); |
$grp_info{$group}{'diskuse'} = sprintf("%.0f",$pct_use); |
Line 282 END
|
Line 320 END
|
$functionality = &mt('None available'); |
$functionality = &mt('None available'); |
} |
} |
my $link = $actionlinks{$action}; |
my $link = $actionlinks{$action}; |
if ($action eq 'modify' || $action eq 'delete') { |
if ($action eq 'modify' || $action eq 'delete' || |
|
$action eq 'reenable') { |
$link .= $group; |
$link .= $group; |
} else { |
} else { |
$link .= $group.'/smppg?ref=grouplist'; |
$link .= $group.'/smppg?ref=grouplist'; |
Line 292 END
|
Line 331 END
|
} |
} |
$link .= '">'.$lt{$action}.'</a>'; |
$link .= '">'.$lt{$action}.'</a>'; |
if ($action eq 'view') { |
if ($action eq 'view') { |
if (($manage_permission) && |
if ($manage_permission) { |
($env{'form.refpage'} ne 'enrl')) { |
|
$link .= ' '.$actionlinks{'modify'}. |
$link .= ' '.$actionlinks{'modify'}. |
$group.'">'.$lt{'modify'}.'</a>'; |
$group.'">'.$lt{'modify'}.'</a>'. |
|
' '.$actionlinks{'delete'}. |
|
$group.'">'.$lt{'delete'}.'</a>'; |
} |
} |
} |
} |
$r->print(&Apache::loncommon::start_data_table_row('LC_data_table_dense'). |
$r->print(&Apache::loncommon::start_data_table_row('LC_data_table_dense'). |
Line 308 END
|
Line 348 END
|
'<td>'.$functionality.'</td>'. |
'<td>'.$functionality.'</td>'. |
'<td align="right">'.$quota.'</td>'. |
'<td align="right">'.$quota.'</td>'. |
'<td align="right">'.$totalmembers.'</td>'. |
'<td align="right">'.$totalmembers.'</td>'. |
'<td align="right"><nobr>'.&mt('Files: ').$totalfiles.'</nobr><br /><nobr>'.&mt('Folders: ').$totaldirs.'</nobr></td>'. |
'<td align="right">'. |
|
'<div class="LC_nobreak">'.&mt('Files: [_1]',$totalfiles).'</div>'. |
|
'<div class="LC_nobreak">'.&mt('Folders: [_1]',$totaldirs).'</div>'. |
|
'</td>'. |
'<td align="right">'.$boards.'</td>'. |
'<td align="right">'.$boards.'</td>'. |
'<td align="right">'.$diskuse.'</td>'. |
'<td align="right">'.$diskuse.'</td>'. |
&Apache::loncommon::end_data_table_row()); |
&Apache::loncommon::end_data_table_row()); |
Line 327 END
|
Line 370 END
|
} else { |
} else { |
$r->print($lt{'nogr'}); |
$r->print($lt{'nogr'}); |
if ($manage_permission) { |
if ($manage_permission) { |
if (!exists($env{'form.refpage'})) { |
$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">'.$lt{'crng'}.'</a>'); |
if ($action ne 'reenable') { |
|
if ($reenable_link) { |
|
$r->print($reenable_link); |
|
} |
} |
} |
} else { |
} else { |
$r->print('<br /><br />'.$lt{'alth'}); |
$r->print('<br /><br />'.$lt{'alth'}); |
|
|
} |
} |
} |
} |
} else { |
} else { |
Line 350 END
|
Line 395 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 '.$gpterm.'s in this '.lc($crstype).'.')); |
'active [_1]s in this [_2]',$gpterm, |
|
lc($crstype))); |
|
} |
} |
} |
} |
return; |
return; |
Line 366 sub group_administration {
|
Line 409 sub group_administration {
|
my @types = (); |
my @types = (); |
my @roles = (); |
my @roles = (); |
my @sections = (); |
my @sections = (); |
my @buildsections = (); |
|
my %users = (); |
my %users = (); |
my %userdata = (); |
my %userdata = (); |
my @members = (); |
my @members = (); |
Line 420 sub group_administration {
|
Line 462 sub group_administration {
|
$state = 'pick_task'; |
$state = 'pick_task'; |
} |
} |
} else { |
} else { |
%stored = &retrieve_settings($cdom,$cnum,$groupname); |
%stored = &retrieve_settings($cdom,$cnum,$groupname,$action); |
if (ref($stored{'types'}) eq 'ARRAY') { |
if (ref($stored{'types'}) eq 'ARRAY') { |
@types = @{$stored{'types'}}; |
@types = @{$stored{'types'}}; |
} |
} |
Line 526 sub group_administration {
|
Line 568 sub group_administration {
|
} |
} |
if (defined($env{'form.sectionpick'})) { |
if (defined($env{'form.sectionpick'})) { |
@sections=&Apache::loncommon::get_env_multiple('form.sectionpick'); |
@sections=&Apache::loncommon::get_env_multiple('form.sectionpick'); |
if (grep/^all$/,@sections) { |
|
@buildsections = sort {$a cmp $b} keys(%sectioncount); |
|
} else { |
|
@buildsections = @sections; |
|
} |
|
} |
} |
} |
} |
|
|
if (($state eq 'pick_members') || ($state eq 'pick_privs') || ($state eq 'change_privs')) { |
if (($state eq 'pick_members') || ($state eq 'pick_privs') || ($state eq 'change_privs')) { |
&build_members_list($cdom,$cnum,\@types,\@roles,\@buildsections,\%users, |
&build_members_list($cdom,$cnum,\@types,\@roles,\@sections,\%users, |
\%userdata); |
\%userdata); |
} |
} |
if ($state eq 'pick_members') { |
if ($state eq 'pick_members') { |
Line 798 function changeSort(caller) {
|
Line 835 function changeSort(caller) {
|
my %branchstates = (); |
my %branchstates = (); |
@{$states{'create'}} = ('pick_name','pick_members','pick_privs','result'); |
@{$states{'create'}} = ('pick_name','pick_members','pick_privs','result'); |
@{$states{'modify'}} = ('pick_task'); |
@{$states{'modify'}} = ('pick_task'); |
|
@{$states{'delete'}} = ('verify','result'); |
|
@{$states{'reenable'}} = ('verify','result'); |
@{$branchstates{'noprivs'}} = ('result'); |
@{$branchstates{'noprivs'}} = ('result'); |
@{$branchstates{'settings'}} = ('change_settings','chgresult'); |
@{$branchstates{'settings'}} = ('change_settings','chgresult'); |
@{$branchstates{'members'}} = ('change_members','change_privs','memresult'); |
@{$branchstates{'members'}} = ('change_members','change_privs','memresult'); |
Line 808 function changeSort(caller) {
|
Line 847 function changeSort(caller) {
|
push (@{$states{$action}},@{$branchstates{$env{'form.branch'}}}); |
push (@{$states{$action}},@{$branchstates{$env{'form.branch'}}}); |
} |
} |
|
|
if (($action eq 'create') || ($action eq 'modify')) { |
if (($action eq 'create') || ($action eq 'modify') || ($action eq 'delete') || ($action eq 'reenable')) { |
my $done = 0; |
my $done = 0; |
my $i=0; |
my $i=0; |
while ($i<@{$states{$action}} && !$done) { |
while ($i<@{$states{$action}} && !$done) { |
Line 824 function changeSort(caller) {
|
Line 863 function changeSort(caller) {
|
$r->print(&header("Groups Manager", |
$r->print(&header("Groups Manager", |
$jscript,$action,$state,$page,$loaditems)); |
$jscript,$action,$state,$page,$loaditems)); |
|
|
if ($env{'form.refpage'} eq 'enrl') { |
if ($env{'form.refpage'} eq 'cusr') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/dropadd", |
({href=>"/adm/createuser", |
text=>"Enrollment Manager", |
text=>"User Management", |
faq=>9,bug=>'Instructor Interface',}); |
faq=>9,bug=>'Instructor Interface',}); |
if ($action eq 'modify') { |
if ($action eq 'modify' || $action eq 'delete') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"/adm/coursegroups?refpage=enrl&action=modify", |
({href=>"/adm/coursegroups?refpage=cusr&action=$action", |
text=>"Groups", |
text=>"Groups", |
faq=>9,bug=>'Instructor Interface',}); |
faq=>9,bug=>'Instructor Interface',}); |
} |
} |
Line 867 function changeSort(caller) {
|
Line 906 function changeSort(caller) {
|
memresult => 'Modifications Complete', |
memresult => 'Modifications Complete', |
addresult => 'Additions Complete', |
addresult => 'Additions Complete', |
); |
); |
|
%{$trail{'delete'}} = &Apache::lonlocal::texthash( |
|
verify => 'Verify deletion', |
|
result => 'Deletion Complete' |
|
); |
|
%{$trail{'reenable'}} = &Apache::lonlocal::texthash( |
|
verify => 'Verify Re-enable', |
|
result => 'Re-enabled' |
|
); |
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', |
Line 875 function changeSort(caller) {
|
Line 922 function changeSort(caller) {
|
gtpp => 'Go to previous page', |
gtpp => 'Go to previous page', |
adme => 'Add members', |
adme => 'Add members', |
); |
); |
if ((($action eq 'create') || ($action eq 'modify')) && |
if ((($action eq 'create') || ($action eq 'modify') || ($action eq 'delete') || ($action eq 'reenable')) && |
($manage_permission)) { |
($manage_permission)) { |
for (my $i=0; $i<@{$states{$action}}; $i++) { |
for (my $i=0; $i<@{$states{$action}}; $i++) { |
if ($state eq $states{$action}[$i]) { |
if ($state eq $states{$action}[$i]) { |
&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 |
("Groups Manager")); |
("Groups Manager","Creating_Groups")); |
&display_control($r,$cdom,$cnum,$action,$state,$page, |
&display_control($r,$cdom,$cnum,$action,$state,$page, |
\%sectioncount,$groupname,$description,$functions, |
\%sectioncount,$groupname,$description,$functions, |
\@tools,$toolprivs,$fixedprivs,$startdate,$enddate, |
\@tools,$toolprivs,$fixedprivs,$startdate,$enddate, |
Line 893 function changeSort(caller) {
|
Line 940 function changeSort(caller) {
|
$crstype); |
$crstype); |
last; |
last; |
} else { |
} else { |
if (($state eq 'result') && ($i > 0)) { |
if (($action eq 'create') || ($action eq 'modify')) { |
&Apache::lonhtmlcommon::add_breadcrumb( |
if (($state eq 'result') && ($i > 0)) { |
|
&Apache::lonhtmlcommon::add_breadcrumb( |
{href=>"javascript:backPage(document.$state,'$states{$action}[0]')", |
{href=>"javascript:backPage(document.$state,'$states{$action}[0]')", |
text=>"$trail{$action}{$states{$action}[$i]}"}); |
text=>"$trail{$action}{$states{$action}[$i]}"}); |
} else { |
} else { |
&Apache::lonhtmlcommon::add_breadcrumb( |
&Apache::lonhtmlcommon::add_breadcrumb( |
{href=>"javascript:backPage(document.$state,'$states{$action}[$i]')", |
{href=>"javascript:backPage(document.$state,'$states{$action}[$i]')", |
text=>"$trail{$action}{$states{$action}[$i]}"}); |
text=>"$trail{$action}{$states{$action}[$i]}"}); |
|
} |
} |
} |
} |
} |
} |
} |
} elsif (($action eq 'view') && ($view_permission)) { |
} elsif (($action eq 'view') && ($view_permission)) { |
&Apache::lonhtmlcommon::add_breadcrumb( |
&Apache::lonhtmlcommon::add_breadcrumb( |
Line 912 function changeSort(caller) {
|
Line 961 function changeSort(caller) {
|
&display_groups($r,$cdom,$cnum,$functions,$idx,$view_permission, |
&display_groups($r,$cdom,$cnum,$functions,$idx,$view_permission, |
$manage_permission,$action,$state,$gpterm,$ucgpterm, |
$manage_permission,$action,$state,$gpterm,$ucgpterm, |
$crstype); |
$crstype); |
|
|
} |
} |
$r->print(&footer()); |
$r->print(&footer()); |
return; |
return; |
} |
} |
|
|
sub retrieve_settings { |
sub retrieve_settings { |
my ($cdom,$cnum,$groupname) = @_; |
my ($cdom,$cnum,$groupname,$action) = @_; |
my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$groupname); |
my %curr_groups; |
|
my $namespace; |
|
if ($action eq 'reenable') { |
|
$namespace = 'deleted_groups'; |
|
} else { |
|
$namespace = 'coursegroups'; |
|
} |
|
%curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$groupname, |
|
$namespace); |
|
|
return if (!%curr_groups); |
return if (!%curr_groups); |
|
|
Line 1059 sub display_control {
|
Line 1115 sub display_control {
|
$sections,$states,$navbuttons,$memchg, |
$sections,$states,$navbuttons,$memchg, |
$sectioncount,$stored,$gpterm,$ucgpterm,$crstype); |
$sectioncount,$stored,$gpterm,$ucgpterm,$crstype); |
} |
} |
|
} elsif ($action eq 'delete') { |
|
my %stored = &retrieve_settings($cdom,$cnum,$groupname,$action); |
|
if ($state eq 'verify') { |
|
&verify_delete($r,$groupname,$state,$action,$page,$states, |
|
\%stored); |
|
} elsif ($state eq 'result') { |
|
&delete_group($r,$cdom,$cnum,$groupname); |
|
} |
|
} elsif ($action eq 'reenable') { |
|
my %stored = &retrieve_settings($cdom,$cnum,$groupname,$action); |
|
if ($state eq 'verify') { |
|
&verify_reenable($r,$groupname,$state,$action,$page,$states, |
|
\%stored); |
|
} elsif ($state eq 'result') { |
|
&reenable_group($r,$cdom,$cnum,$groupname); |
|
} |
|
} |
|
} |
|
|
|
sub verify_delete { |
|
my ($r,$groupname,$formname,$action,$page,$states,$stored) = @_; |
|
$r->print(&Apache::lonhtmlcommon::echo_form_input([])); |
|
$r->print(&mt('You have requested deletion of the group [_1].' |
|
,'<i>'.$stored->{'description'}.'</i>'). |
|
'<br /><br />'.&mt('When a group is deleted the following occurs:').'<ul>'. |
|
'<li>'.&mt('All group membership is terminated.').'</li>'. |
|
'<li>'.&mt('The group ceases to be available either for viewing or for modification of group settings and membership.').'</li>'. |
|
'<li>'.&mt('The group folder is removed from the folder containing it - normally this is the "Course Groups" folder which contains folders for all groups in the course.').'</li>'. |
|
'</ul>'.&mt('Although a deleted group is no longer accessible, the group name used for the group will be reserved, and will not be available for assignment to a new group in the same course in the future.')); |
|
my $prevtext = &mt('Go back'); |
|
my $nexttext = &mt('Delete group'); |
|
my $prev; |
|
if ($env{'form.refpage'} eq 'cusr') { |
|
$prev = 'view'; |
|
} |
|
&display_navbuttons($r,$formname,$prev,$prevtext, |
|
$$states{$action}[$page+1],$nexttext); |
|
return; |
|
} |
|
|
|
sub delete_group { |
|
my ($r,$cdom,$cnum,$groupname) = @_; |
|
my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum, |
|
$groupname); |
|
my $now = time; |
|
my $num_users = 0; |
|
my $num_fail = 0; |
|
my $num_ok = 0; |
|
my @deleted; |
|
my @undeleted; |
|
my %usersettings; |
|
my $context = 'deletegroup'; |
|
foreach my $key (sort(keys(%membership))) { |
|
if ($key =~ /^\Q$groupname\E:([^:]+:[^:]+)$/) { |
|
my $user = $1; |
|
my($end,$start,$userprivs) = split(/:/,$membership{$key},3); |
|
if ($start != -1) { |
|
$num_users ++; |
|
$usersettings{$groupname.':'.$user} = $now.':-1:'.$userprivs; |
|
if (&Apache::lonnet::modify_group_roles($cdom,$cnum, |
|
$groupname,$user, |
|
$now,'-1',$userprivs, |
|
'',$context) |
|
eq 'ok') { |
|
$num_ok ++; |
|
push(@deleted,$user); |
|
} else { |
|
push(@undeleted,$user); |
|
$num_fail ++; |
|
} |
|
} |
|
} |
|
} |
|
if ($num_ok > 0) { |
|
my $roster_result = |
|
&Apache::lonnet::modify_coursegroup_membership($cdom,$cnum, |
|
\%usersettings); |
|
} |
|
if ($num_fail > 0) { |
|
$r->print('<div class="LC_error">' |
|
.&mt('Group deletion failed because deletion of [_1] out of [_2] members failed.' |
|
,$num_fail,$num_users) |
|
.'</div>'); |
|
|
|
} else { |
|
my ($result,$message) = |
|
&Apache::lonnet::toggle_coursegroup_status($cdom,$cnum, |
|
$groupname,'delete'); |
|
if ($result eq 'ok') { |
|
my $outcome = &modify_folders($cdom,$cnum,$groupname); |
|
if ($outcome eq '') { |
|
$r->print('<div class="LC_success">' |
|
.&mt('Group successfully deleted.') |
|
.'</div>'); |
|
} else { |
|
$r->print('<div class="LC_error">' |
|
.&mt("Although the group was deleted, an error occurred when removing" |
|
." the group's folder from the 'Course Groups' folder: [_1]",$outcome) |
|
.'</div>'); |
|
} |
|
} else { |
|
$r->print('<div class="LC_error">' |
|
.&mt('Group deletion failed.') |
|
.'</div>'); |
|
} |
|
} |
|
return; |
|
} |
|
|
|
sub reenable_folder { |
|
my ($cdom,$cnum,$groupname,$description) = @_; |
|
my $outcome; |
|
my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/'; |
|
my $allgrpsmap = $crspath.'group_allfolders.sequence'; |
|
my $foldertitle = &mt('Course Folder -[_1]',$description); |
|
my $mapurl = $crspath.'group_folder_'. |
|
$groupname.'.sequence'; |
|
my ($errtext,$fatal)=&LONCAPA::map::mapread($allgrpsmap); |
|
if ($fatal) { |
|
$outcome='<div class="LC_error">' |
|
.&mt('An error occurred when reading contents of parent folder to group:') |
|
."<br />($allgrpsmap): $errtext" |
|
.'</div>'; |
|
} else { |
|
my $idx=&LONCAPA::map::getresidx($mapurl); |
|
$LONCAPA::map::resources[$idx] = $foldertitle.':'.$mapurl. |
|
':false:normal:res'; |
|
$LONCAPA::map::order[1+$#LONCAPA::map::order]=$idx; |
|
my ($outtext,$errtext) = &LONCAPA::map::storemap($allgrpsmap,1); |
|
if ($errtext) { |
|
$outcome='<div class="LC_error">' |
|
.&mt('An error occurred when saving updated parent folder to group:' |
|
,"<br />$allgrpsmap - $errtext") |
|
.'</div>'; |
|
} else { |
|
my ($furl,$ferr) = |
|
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
|
} |
|
} |
|
return $outcome; |
|
} |
|
|
|
sub modify_folders { |
|
my ($cdom,$cnum,$groupname) = @_; |
|
my $outcome; |
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
my $groupmap = '/uploaded/'.$cdom.'/'.$cnum.'/'.'group_folder_'. |
|
$groupname.'.sequence'; |
|
my $groupmapres = $navmap->getResourceByUrl($groupmap); |
|
my ($map,$id,$src); |
|
if ($groupmapres) { |
|
($map,$id,$src)=&Apache::lonnet::decode_symb($groupmapres->symb()); |
|
} |
|
undef($navmap); |
|
if ($map) { |
|
$map = '/'.$map; |
|
my ($errtext,$fatal) = &LONCAPA::map::mapread($map); |
|
if ($fatal) { |
|
$outcome='<div class="LC_error">' |
|
.&mt('An error occurred when reading contents of parent folder to group:') |
|
."<br />($map): $errtext" |
|
.'</div>'; |
|
} else { |
|
my $idx = 0; |
|
my $grpidx; |
|
foreach my $item (@LONCAPA::map::order) { |
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$item]); |
|
$url=&LONCAPA::map::qtescape($url); |
|
if ($url eq $groupmap) { |
|
$grpidx = $idx; |
|
last; |
|
} else { |
|
$idx++; |
|
} |
|
} |
|
|
|
if ($grpidx ne '') { |
|
&LONCAPA::map::makezombie($LONCAPA::map::order[$grpidx]); |
|
for (my $i=$grpidx;$i<$#LONCAPA::map::order;$i++) { |
|
$LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1]; |
|
} |
|
$#LONCAPA::map::order--; |
|
my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1); |
|
if ($errtext) { |
|
$outcome='<div class="LC_error">' |
|
.&mt('An error occurred when saving updated parent folder to group:') |
|
."<br />$map - $errtext" |
|
.'</div>'; |
|
} else { |
|
my ($furl,$ferr) = |
|
&Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
|
} |
|
} |
|
} |
|
} |
|
return $outcome; |
|
} |
|
|
|
sub verify_reenable { |
|
my ($r,$groupname,$formname,$action,$page,$states,$stored) = @_; |
|
$r->print(&Apache::lonhtmlcommon::echo_form_input([])); |
|
$r->print(&mt('You have requested enabling the previously deleted group [_1].' |
|
,'<i>'.$stored->{'description'}.'</i>'). |
|
'<br /><br />'.&mt('When a deleted group is re-enabled the following occurs:').'<ul>'. |
|
'<li>'.&mt('Group settings and membership at the time the group was deleted are reinstated.').'</li>'. |
|
'<li>'.&mt('A group folder is added to the "Course Groups" folder which contains folders for all groups in the course.').'</li></ul>'); |
|
my $prevtext = &mt('Go back'); |
|
my $nexttext = &mt('Reenable group'); |
|
my $prev; |
|
if ($env{'form.refpage'} eq 'cusr') { |
|
$prev = 'view'; |
|
} |
|
&display_navbuttons($r,$formname,$prev,$prevtext, |
|
$$states{$action}[$page+1],$nexttext); |
|
return; |
|
} |
|
|
|
sub reenable_group { |
|
my ($r,$cdom,$cnum,$groupname) = @_; |
|
my %groups = |
|
&Apache::longroup::coursegroups($cdom,$cnum,$groupname, |
|
'deleted_groups'); |
|
if (keys(%groups) == 0) { |
|
$r->print(&mt('The group [_1] was not re-enabled, because it is not a deleted group.[_2]Perhaps it has already been re-enabled?','<i>'.$groupname.'</i>'),'<br />'); |
|
return; |
|
} |
|
my %groupinfo = |
|
&Apache::longroup::get_group_settings($groups{$groupname}); |
|
my $defstart = $groupinfo{'startdate'}; |
|
my $defend = $groupinfo{'enddate'}; |
|
my $showstart = &Apache::lonlocal::locallocaltime($defstart); |
|
my $showend; |
|
if ($defend == 0) { |
|
$showend = &mt('No end date set'); |
|
} else { |
|
$showend = &Apache::lonlocal::locallocaltime($defend); |
|
} |
|
my $description = &unescape($groupinfo{'description'}); |
|
my $num_users = 0; |
|
my $num_ok = 0; |
|
my $num_fail = 0; |
|
my $context = 'reenablegroup'; |
|
my (%usersettings,@enabled,@unenabled); |
|
my ($result,$message) = |
|
&Apache::lonnet::toggle_coursegroup_status($cdom,$cnum,$groupname, |
|
'reenable'); |
|
if ($result eq 'ok') { |
|
my %membership = &Apache::lonnet::get_group_membership($cdom,$cnum, |
|
$groupname); |
|
foreach my $key (sort(keys(%membership))) { |
|
if ($key =~ /^\Q$groupname\E:([^:]+:[^:]+)$/) { |
|
my $user = $1; |
|
my($end,$start,$userprivs) = split(/:/,$membership{$key},3); |
|
if (($start == -1) && ($end == $groupinfo{'modified'})) { |
|
$num_users ++; |
|
$usersettings{$groupname.':'.$user} = $defend.':'. |
|
$defstart.':'. |
|
$userprivs; |
|
if (&Apache::lonnet::modify_group_roles($cdom,$cnum, |
|
$groupname,$user, |
|
$defend,$defstart, |
|
$userprivs,'', |
|
$context) eq 'ok') { |
|
$num_ok ++; |
|
push(@enabled,$user); |
|
} else { |
|
push(@unenabled,$user); |
|
$num_fail ++; |
|
} |
|
} |
|
} |
|
} |
|
if ($num_users > 0) { |
|
if ($num_ok > 0) { |
|
my $roster_result = |
|
&Apache::lonnet::modify_coursegroup_membership($cdom,$cnum, |
|
\%usersettings); |
|
if ($roster_result eq 'ok') { |
|
$r->print('<div class="LC_success">' |
|
.&mt('Membership reinstated for [quant,_1,user], each with start and end dates for group access set to defaults: [_2] and [_3]',$num_ok,$showstart,$showend) |
|
.'</div>'); |
|
} |
|
} else { |
|
$r->print('<div class="LC_error">' |
|
.&mt('A problem occurred when trying to reinstate [_1] of the [_2] members of the pre-existing group.',$num_fail,$num_users) |
|
.'</div>'); |
|
} |
|
} else { |
|
$r->print('<div class="LC_info">' |
|
.&mt('There were no group members to reinstate, as none were removed when the group was deleted.') |
|
.'</div>'); |
|
} |
|
my $outcome = &reenable_folder($cdom,$cnum,$groupname,$description); |
|
if ($outcome eq '') { |
|
$r->print('<div class="LC_success">' |
|
.&mt('Group successfully re-enabled.') |
|
.'</div>'); |
|
} else { |
|
$r->print('<div class="LC_error">' |
|
.&mt("Although the group was re-enabled, an error occurred when adding the group's folder to the 'Course Groups' folder: [_1]",$outcome) |
|
.'</div>'); |
|
} |
|
} else { |
|
$r->print('<div class="LC_error">' |
|
.&mt('Re-enabling group failed.') |
|
.'</div>'); |
} |
} |
|
return; |
} |
} |
|
|
sub header { |
sub header { |
Line 1129 sub build_members_list {
|
Line 1492 sub build_members_list {
|
} |
} |
|
|
sub group_files { |
sub group_files { |
my ($group,$currdir,$numfiles,$numdirs) = @_; |
my ($group,$portpath,$numfiles,$numdirs) = @_; |
my $dirptr=16384; |
my $dirptr=16384; |
my @dir_list=&Apache::portfolio::get_dir_list($currdir,$group); |
my @dir_list=&Apache::portfolio::get_dir_list($portpath,undef,$group); |
foreach my $line (@dir_list) { |
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); |
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 (($filename !~ /^\.\.?$/) && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/) && ($filename ne 'no_such_dir')) { |
if ($dirptr&$testdir) { |
if ($dirptr&$testdir) { |
$currdir .= '/'.$filename; |
$portpath .= '/'.$filename; |
$$numdirs ++; |
$$numdirs ++; |
&group_files($numfiles,$numdirs) |
&group_files($group,$portpath,$numfiles,$numdirs) |
} else { |
} else { |
$$numfiles ++; |
$$numfiles ++; |
} |
} |
Line 1151 sub group_members {
|
Line 1514 sub group_members {
|
my ($cdom,$cnum,$group,$group_info) = @_; |
my ($cdom,$cnum,$group,$group_info) = @_; |
my %memberhash = &Apache::lonnet::get_group_membership($cdom,$cnum,$group); |
my %memberhash = &Apache::lonnet::get_group_membership($cdom,$cnum,$group); |
my $now = time; |
my $now = time; |
my ($tmp)=keys(%memberhash); |
my %lt = &Apache::lonlocal::texthash ( |
if ($tmp=~/^error:/) { |
active => 'active', |
$$group_info{'totalmembers'} = 'Unknown - an error occurred'; |
previous => 'previous', |
return $tmp; |
future => 'future', |
} |
); |
|
my %membercounts = ( |
|
active => 0, |
|
previous => 0, |
|
future => 0, |
|
); |
my $totalmembers = 0; |
my $totalmembers = 0; |
my $active = 0; |
|
my $previous = 0; |
|
my $future = 0; |
|
foreach my $member (keys %memberhash) { |
foreach my $member (keys %memberhash) { |
$totalmembers ++; |
$totalmembers ++; |
my ($end,$start) = split(/:/,$memberhash{$member}); |
my ($end,$start) = split(/:/,$memberhash{$member}); |
unless ($start == -1) { |
unless ($start == -1) { |
if (($end!=0) && ($end<$now)) { |
if (($end!=0) && ($end<$now)) { |
$previous ++; |
$membercounts{previous} ++; |
} elsif (($start!=0) && ($start>$now)) { |
} elsif (($start!=0) && ($start>$now)) { |
$future ++; |
$membercounts{future} ++; |
} else { |
} else { |
$active ++; |
$membercounts{active} ++; |
} |
} |
} |
} |
} |
} |
if ($totalmembers == 0) { |
if ($totalmembers == 0) { |
$$group_info{$group}{'totalmembers'} = 'None'; |
$$group_info{$group}{'totalmembers'} = 'None'; |
} else { |
} else { |
$$group_info{$group}{'totalmembers'} = '<nobr>'.$active. |
foreach my $type ('active','previous','future') { |
' - active</nobr><br /><nobr>'.$previous. |
$$group_info{$group}{'totalmembers'} .= |
' - previous</nobr><br /><nobr>'.$future. |
&open_list_window($group,$type,$membercounts{$type},$lt{$type}); |
' - future</nobr>'; |
} |
} |
} |
return 'ok'; |
return 'ok'; |
} |
} |
|
|
|
sub open_list_window { |
|
my ($group,$status,$count,$text) = @_; |
|
my $entry; |
|
if ($count > 0) { |
|
$entry = '<nobr><a href="javascript:openGroupRoster('. |
|
"'$group','$status'".')">'.$text.'</a> - '.$count. |
|
'</nobr><br />'; |
|
} else { |
|
$entry = '<nobr>'.$text.' - '.$count.'</nobr><br />'; |
|
} |
|
return $entry; |
|
} |
|
|
|
|
sub general_settings_form { |
sub general_settings_form { |
my ($r,$cdom,$cnum,$action,$formname,$page,$functions,$tools, |
my ($r,$cdom,$cnum,$action,$formname,$page,$functions,$tools, |
Line 1230 sub groupsettings_options {
|
Line 1608 sub groupsettings_options {
|
'for different group members?', |
'for different group members?', |
); |
); |
my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,$stored); |
my ($crsquota,$freespace,$maxposs) = &get_quota_constraints($action,$stored); |
&topic_bar($r,$image,$lt{'gnde'}); |
$r->print(&Apache::lonhtmlcommon::topic_bar($image,$lt{'gnde'}).' |
$r->print(' |
|
<table class="LC_descriptive_input"> |
<table class="LC_descriptive_input"> |
<tr> |
<tr> |
<td class="LC_description">'.$lt{'gnam'}.':</td> |
<td class="LC_description">'.$lt{'gnam'}.':</td> |
Line 1269 END
|
Line 1646 END
|
$$functions{$allfunctions[$i]}.'</label></td> |
$$functions{$allfunctions[$i]}.'</label></td> |
<td> </td><td> </td>'); |
<td> </td><td> </td>'); |
} |
} |
$r->print('<td><input type="button" value="check all" '. |
$r->print('<td><input type="button" value="'.&mt('check all').'" '. |
'onclick="javascript:checkAll(document.'.$formname.'.tool)" />'. |
'onclick="javascript:checkAll(document.'.$formname.'.tool)" />'. |
'</td></tr><tr><td> </td>'); |
'</td></tr><tr><td> </td>'); |
for (my $j=$halfnum; $j<@allfunctions; $j++) { |
for (my $j=$halfnum; $j<@allfunctions; $j++) { |
Line 1283 END
|
Line 1660 END
|
} |
} |
$r->print(' |
$r->print(' |
<td> |
<td> |
<input type="button" value="uncheck all" |
<input type="button" value="'.&mt('uncheck all').'" |
onclick="javascript:uncheckAll(document.'.$formname.'.tool)" /> |
onclick="javascript:uncheckAll(document.'.$formname.'.tool)" /> |
</td> |
</td> |
</tr> |
</tr> |
Line 1292 END
|
Line 1669 END
|
<td colspan="10">'.$lt{'doyo'}.' <label><input type="radio" name="granularity" value="Yes" />'.&mt('Yes').'</label> <label><input type="radio" name="granularity" value="No" checked="checked" />'.&mt('No').'</label>'); |
<td colspan="10">'.$lt{'doyo'}.' <label><input type="radio" name="granularity" value="Yes" />'.&mt('Yes').'</label> <label><input type="radio" name="granularity" value="No" checked="checked" />'.&mt('No').'</label>'); |
if ($action eq 'modify') { |
if ($action eq 'modify') { |
$r->print(' ('.&mt('Currently set to "[_1]"', |
$r->print(' ('.&mt('Currently set to "[_1]"', |
$$stored{'granularity'}).')'); |
&mt($$stored{'granularity'})).')'); |
} |
} |
$r->print(' |
$r->print(' |
</td> |
</td> |
Line 1300 END
|
Line 1677 END
|
<tr> |
<tr> |
<td class="LC_description">'.&mt('Disk quota: ').'</td><td colspan="10">'); |
<td class="LC_description">'.&mt('Disk quota: ').'</td><td colspan="10">'); |
if ($action eq 'create') { |
if ($action eq 'create') { |
$r->print(&mt('If you enable the file repository for the [_1], allocate a disk quota.',$gpterm)); |
$r->print(&mt('If you enable the file repository for the '.$gpterm.', allocate a disk quota.')); |
} else { |
} else { |
$r->print(&mt('Quota allocated to file repository:')); |
$r->print(&mt('Quota allocated to file repository:')); |
} |
} |
$r->print(' <input type="text" name="quota" size="4" />Mb'); |
$r->print(' '.&mt('[_1] Mb','<input type="text" name="quota" size="4" />')); |
if ($action eq 'create') { |
if ($action eq 'create') { |
$r->print('<br />'. |
$r->print('<br />' |
&mt('A total of [_1] Mb can be divided amongst all [_2]s in the '. |
.&mt('A total of [_1] Mb can be divided amongst all '.$gpterm.'s in the ' |
'[_3], and [_4] Mb are currently unallocated.',$crsquota, |
.lc($crstype).', and [_2] Mb are currently unallocated.' |
$gpterm,lc($crstype),sprintf("%.2f",$freespace))); |
,$crsquota,sprintf("%.2f",$freespace)) |
|
); |
} else { |
} else { |
$r->print(' ('.&mt('The quota is currently [_1] Mb', |
$r->print(' ('.&mt('The quota is currently [_1] Mb', |
$$stored{'quota'}).').'); |
$$stored{'quota'}).').'); |
|
|
$r->print('<br />'.&mt('The quota can be increased to [_1] Mb, '. |
$r->print('<br />' |
'by adding all unallocated space for [_2]s in the [_3].', |
.&mt('The quota can be increased to [_1] Mb, ' |
sprintf("%.2f",$maxposs),$gpterm,lc($crstype))); |
.'by adding all unallocated space for '.$gpterm.'s in the '.lc($crstype).'.' |
|
,sprintf("%.2f",$maxposs))); |
} |
} |
$r->print(' |
$r->print(' |
</td> |
</td> |
Line 1369 sub membership_options {
|
Line 1748 sub membership_options {
|
|
|
my @sections = keys(%{$sectioncount}); |
my @sections = keys(%{$sectioncount}); |
|
|
&topic_bar($r,$image,$lt{'pipa'}); |
$r->print(&Apache::lonhtmlcommon::topic_bar($image,$lt{'pipa'}).' |
$r->print(' |
|
<b>'.$lt{'gmem'}.'</b><br />'.$lt{'picr'}); |
<b>'.$lt{'gmem'}.'</b><br />'.$lt{'picr'}); |
if ($action eq 'create') { |
if ($action eq 'create') { |
$r->print($lt{'meof'}.'<br />'.$lt{'ifno'}.'<br />'.$lt{'asub'}); |
$r->print($lt{'meof'}.'<br />'.$lt{'ifno'}.'<br />'.$lt{'asub'}); |
Line 1428 sub sections_selection {
|
Line 1806 sub sections_selection {
|
|
|
sub access_date_settings { |
sub access_date_settings { |
my ($r,$action,$formname,$stored,$image,$gpterm,$ucgpterm) = @_; |
my ($r,$action,$formname,$stored,$image,$gpterm,$ucgpterm) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my $sten = &mt("Default start and end dates for $gpterm 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 |
if ($action eq 'modify') { |
if ($action eq 'modify') { |
Line 1440 sub access_date_settings {
|
Line 1816 sub access_date_settings {
|
} |
} |
} |
} |
my ($table) = &date_setting_table($starttime,$endtime,$formname); |
my ($table) = &date_setting_table($starttime,$endtime,$formname); |
&topic_bar($r,$image,$lt{'sten'}); |
$r->print(&Apache::lonhtmlcommon::topic_bar($image,$sten).' |
$r->print(' |
|
'.$table.' |
'.$table.' |
'); |
'); |
return; |
return; |
Line 1518 sub display_navbuttons {
|
Line 1893 sub display_navbuttons {
|
<input type="button" name="previous" value = "'.$prevtext.'" |
<input type="button" name="previous" value = "'.$prevtext.'" |
onclick="javascript:backPage(document.'.$formname.','."'".$prev."'".')"/> |
onclick="javascript:backPage(document.'.$formname.','."'".$prev."'".')"/> |
'); |
'); |
|
} elsif ($prevtext) { |
|
$r->print(' |
|
<input type="button" name="previous" value = "'.$prevtext.'" |
|
onclick="javascript:history.back()"/> |
|
'); |
} |
} |
if ($next) { |
if ($next) { |
$r->print(' |
$r->print(' |
Line 1553 sub print_current_settings {
|
Line 1933 sub print_current_settings {
|
ygrs => "Your group selections - ", |
ygrs => "Your group selections - ", |
tfwa => "The following settings will apply to the group:", |
tfwa => "The following settings will apply to the group:", |
difn => 'Different collaborative tools<br />for different members:', |
difn => 'Different collaborative tools<br />for different members:', |
stda => 'Start date', |
stda => 'Start date:', |
enda => 'End date:', |
enda => 'End date:', |
); |
); |
my $showstart = &Apache::lonlocal::locallocaltime($startdate); |
my $showstart = &Apache::lonlocal::locallocaltime($startdate); |
Line 1587 sub print_current_settings {
|
Line 1967 sub print_current_settings {
|
<td> |
<td> |
'); |
'); |
if (@{$available} > 0) { |
if (@{$available} > 0) { |
$r->print(&mt('<b>Available for assignment to members:</b>'). |
$r->print('<b>'.&mt('Available for assignment to members:').'</b>'. |
'<table class="LC_group_priv"><tr>'); |
'<table class="LC_group_priv"><tr>'); |
my $rowcell = int(@{$available}/2) + @{$available}%2; |
my $rowcell = int(@{$available}/2) + @{$available}%2; |
for (my $i=0; $i<@{$available}; $i++) { |
for (my $i=0; $i<@{$available}; $i++) { |
Line 1605 sub print_current_settings {
|
Line 1985 sub print_current_settings {
|
$r->print('</tr></table><br />'); |
$r->print('</tr></table><br />'); |
} |
} |
if (@{$unavailable} > 0) { |
if (@{$unavailable} > 0) { |
$r->print(&mt('<b>Unavailable for assignment:</b>'). |
$r->print('<b>'.&mt('Unavailable for assignment:').'</b>'. |
'<table class="LC_group_priv"><tr>'); |
'<table class="LC_group_priv"><tr>'); |
my $rowcell = int(@{$unavailable}/2) + @{$unavailable}%2; |
my $rowcell = int(@{$unavailable}/2) + @{$unavailable}%2; |
for (my $j=0; $j<@{$unavailable}; $j++) { |
for (my $j=0; $j<@{$unavailable}; $j++) { |
Line 1622 sub print_current_settings {
|
Line 2002 sub print_current_settings {
|
} |
} |
$r->print('</tr></table>'); |
$r->print('</tr></table>'); |
} |
} |
|
my $quota_text=&mt('[_1] Mb',$quota); |
|
my $granu_text=&mt($granularity); |
$r->print(<<"END"); |
$r->print(<<"END"); |
</td> |
</td> |
<td valign="top"><b>$lt{'difn'}</b> $granularity</td> |
<td valign="top"><b>$lt{'difn'}</b> $granu_text</td> |
<td valign="top">$quota Mb</td> |
<td valign="top">$quota_text</td> |
<td valign="top"><b>$lt{'stda'}</b> $showstart<br /> |
<td valign="top"><b>$lt{'stda'}</b> $showstart<br /> |
<b>$lt{'enda'}</b> $showend |
<b>$lt{'enda'}</b> $showend |
</td> |
</td> |
Line 1648 sub pick_new_members {
|
Line 2030 sub pick_new_members {
|
'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 ". |
" matching the specified type(s), role(s), and ". |
"section(s) are already affiliated with this group.", |
"section(s) are already affiliated with this group.", |
'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.", |
); |
); |
my %members; |
my %members; |
my $totalusers = 0; |
my $totalusers = 0; |
Line 1674 sub pick_new_members {
|
Line 2056 sub pick_new_members {
|
$r->print(&check_uncheck_tools($r,$available)); |
$r->print(&check_uncheck_tools($r,$available)); |
} |
} |
} |
} |
&topic_bar($r,$img,$lt{'gpme'}); |
$r->print(&Apache::lonhtmlcommon::topic_bar($img,$lt{'gpme'})); |
if (keys(%members) > 0) { |
if (keys(%members) > 0) { |
$r->print(' |
$r->print(' |
<table> |
<table> |
Line 1684 sub pick_new_members {
|
Line 2066 sub pick_new_members {
|
$r->print('<td> |
$r->print('<td> |
<fieldset><legend><b>'.$lt{'setf'}.'</b></legend> |
<fieldset><legend><b>'.$lt{'setf'}.'</b></legend> |
<nobr> |
<nobr> |
<input type="button" value="check all" |
<input type="button" value="'.&mt('check all').'" |
onclick="javascript:checkAllTools(document.'.$formname.')" /> |
onclick="javascript:checkAllTools(document.'.$formname.')" /> |
|
|
<input type="button" value="uncheck all" |
<input type="button" value="'.&mt('uncheck all').'" |
onclick="javascript:uncheckAllTools(document.'.$formname.')" /> |
onclick="javascript:uncheckAllTools(document.'.$formname.')" /> |
</nobr> |
</nobr> |
</fieldset></td>'); |
</fieldset></td>'); |
Line 1823 sub privilege_specificity {
|
Line 2205 sub privilege_specificity {
|
} |
} |
} |
} |
} |
} |
&topic_bar($r,$img,$lt{'uprv'}); |
$r->print(&Apache::lonhtmlcommon::topic_bar($img,$lt{'uprv'})); |
if ((($action eq 'create') && (@{$available} > 0)) || |
if ((($action eq 'create') && (@{$available} > 0)) || |
(($action eq 'modify') && ($formname eq 'change_settings'))) { |
(($action eq 'modify') && ($formname eq 'change_settings'))) { |
my %specific = ( |
my %specific = ( |
Line 1927 sub default_privileges {
|
Line 2309 sub default_privileges {
|
if ($fixed ne '') { |
if ($fixed ne '') { |
$fixed .= '</td><td class="LC_groups_fixed">'; |
$fixed .= '</td><td class="LC_groups_fixed">'; |
} |
} |
$fixed .= '<input type="hidden" name="defpriv" value="'.$priv.'" /><nobr>'.$$toolprivs{$tool}{$priv}.' '; |
$fixed .= '<input type="hidden" name="defpriv" value="'.$priv.'" />' |
|
.'<span class="LC_nobreak">'.$$toolprivs{$tool}{$priv}.' '; |
if ($action eq 'modify') { |
if ($action eq 'modify') { |
if (grep(/^$tool$/,@{$available})) { |
if (grep(/^$tool$/,@{$available})) { |
$fixed .= '<small>'.&mt('(on)').'<small> '; |
$fixed .= '<small>'.&mt('(on)').'<small> '; |
Line 1935 sub default_privileges {
|
Line 2318 sub default_privileges {
|
$fixed .= '<small>'.&mt('(off)').'<small> '; |
$fixed .= '<small>'.&mt('(off)').'<small> '; |
} |
} |
} |
} |
$fixed .= '</nobr>'; |
$fixed .= '</span>'; |
} else { |
} else { |
$privcount++; |
$privcount++; |
if ($privcount == 3) { |
if ($privcount == 3) { |
$dynamic .= '</tr> |
$dynamic .= '</tr> |
<tr>'."\n"; |
<tr>'."\n"; |
} |
} |
$dynamic .= '<td><nobr><label><input type="checkbox" name="defpriv" value="'.$priv.'" />'.$$toolprivs{$tool}{$priv}.'</label></nobr></td>'."\n"; |
$dynamic .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="defpriv" value="'.$priv.'" />'.$$toolprivs{$tool}{$priv}.'</label></span></td>'."\n"; |
} |
} |
} |
} |
if ($privcount == 0) { |
if ($privcount == 0) { |
$dynamic .= '<td>None</td>'."\n"; |
$dynamic .= '<td>'.&mt('None').'</td>'."\n"; |
} |
} |
if ($privcount < 3) { |
if ($privcount < 3) { |
$dynamic .= '<td> </td>'."\n"; |
$dynamic .= '<td> </td>'."\n"; |
Line 2064 sub change_members_form {
|
Line 2447 sub change_members_form {
|
$r->print(' |
$r->print(' |
<br /> |
<br /> |
'); |
'); |
&topic_bar($r,1,$lt{'grse'}); |
$r->print(&Apache::lonhtmlcommon::topic_bar(1,$lt{'grse'})); |
&print_current_settings($r,$action,$functions,$startdate,$enddate, |
&print_current_settings($r,$action,$functions,$startdate,$enddate, |
$groupname,$description,$granularity,$quota, |
$groupname,$description,$granularity,$quota, |
\@available,\@unavailable,$gpterm,$ucgpterm); |
\@available,\@unavailable,$gpterm,$ucgpterm); |
&topic_bar($r,2,$lt{'mogm'}); |
$r->print(&Apache::lonhtmlcommon::topic_bar(2,$lt{'mogm'})); |
my $numcurrent = ¤t_membership($r,$cdom,$cnum,$formname,$groupname, |
my $numcurrent = ¤t_membership($r,$cdom,$cnum,$formname,$groupname, |
\@available,\@unavailable,$fixedprivs, |
\@available,\@unavailable,$fixedprivs, |
$granularity,$specificity); |
$granularity,$specificity); |
Line 2128 sub current_membership {
|
Line 2511 sub current_membership {
|
<td> |
<td> |
<nobr> |
<nobr> |
<fieldset><legend><b>'.$lt{'curf'}.'</b></legend> |
<fieldset><legend><b>'.$lt{'curf'}.'</b></legend> |
<input type="button" value="check all" |
<input type="button" value="'.&mt('check all').'" |
onclick="javascript:checkAllTools(document.'.$formname.')" /> |
onclick="javascript:checkAllTools(document.'.$formname.')" /> |
|
|
<input type="button" value="uncheck all" |
<input type="button" value="'.&mt('uncheck all').'" |
onclick="javascript:uncheckAllTools(document.'.$formname.')" /> |
onclick="javascript:uncheckAllTools(document.'.$formname.')" /> |
</fieldset> |
</fieldset> |
</nobr> |
</nobr> |
Line 2287 sub check_uncheck_buttons {
|
Line 2670 sub check_uncheck_buttons {
|
<fieldset> |
<fieldset> |
<legend><b>'.$title.'</b></legend> |
<legend><b>'.$title.'</b></legend> |
<nobr> |
<nobr> |
<input type="button" value="check all" |
<input type="button" value="'.&mt('check all').'" |
onclick="javascript:checkAll(document.'.$formname.'.'.$field.')" /> |
onclick="javascript:checkAll(document.'.$formname.'.'.$field.')" /> |
|
|
<input type="button" value="uncheck all" |
<input type="button" value="'.&mt('uncheck all').'" |
onclick="javascript:uncheckAll(document.'.$formname.'.'.$field.')" /> |
onclick="javascript:uncheckAll(document.'.$formname.'.'.$field.')" /> |
</nobr> |
</nobr> |
</fieldset> |
</fieldset> |
Line 2318 sub change_privs_form {
|
Line 2701 sub change_privs_form {
|
} else { |
} else { |
$nexttext = $$navbuttons{'mose'}; |
$nexttext = $$navbuttons{'mose'}; |
} |
} |
&topic_bar($r,3,&mt('Members to delete or expire')); |
$r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('Members to delete or expire'))); |
my $exp_or_del = 0; |
my $exp_or_del = 0; |
if (ref($$memchg{'deletion'}) eq 'ARRAY') { |
if (ref($$memchg{'deletion'}) eq 'ARRAY') { |
if (@{$$memchg{'deletion'}} > 0) { |
if (@{$$memchg{'deletion'}} > 0) { |
Line 2346 sub change_privs_form {
|
Line 2729 sub change_privs_form {
|
$r->print($lt{'nome'}.'<br />'); |
$r->print($lt{'nome'}.'<br />'); |
} |
} |
|
|
&topic_bar($r,4,&mt('Setting optional privileges for specific group members')); |
$r->print(&Apache::lonhtmlcommon::topic_bar(4,&mt('Setting optional privileges for specific group members'))); |
|
|
my $numchgs = &member_privileges_form($r,$action,$formname,$tools, |
my $numchgs = &member_privileges_form($r,$action,$formname,$tools, |
$toolprivs,$fixedprivs,$userdata, |
$toolprivs,$fixedprivs,$userdata, |
Line 2403 sub choose_privs_form {
|
Line 2786 sub choose_privs_form {
|
$nexttext = $$navbuttons{'adme'}; |
$nexttext = $$navbuttons{'adme'}; |
} |
} |
|
|
&topic_bar($r,6,&mt('Setting optional privileges for specific group members')); |
$r->print(&Apache::lonhtmlcommon::topic_bar(6,&mt('Setting optional privileges for specific group members'))); |
|
|
&member_privileges_form($r,$action,$formname,$tools,$toolprivs, |
&member_privileges_form($r,$action,$formname,$tools,$toolprivs, |
$fixedprivs,$userdata,$usertools,$idx,undef, |
$fixedprivs,$userdata,$usertools,$idx,undef, |
Line 2492 sub member_privileges_form {
|
Line 2875 sub member_privileges_form {
|
'members being added or modified, '. |
'members being added or modified, '. |
'there are no optional privileges to set '. |
'there are no optional privileges to set '. |
'for specific members.', |
'for specific members.', |
'algr' => 'All new group members will receive the same privileges.', 'ifex' => 'If previously expired members are being re-enabled, or '. |
'algr' => 'All new group members will receive the same privileges.', |
|
'ifex' => 'If previously expired members are being re-enabled, or '. |
'if access for future members is being activated now, '. |
'if access for future members is being activated now, '. |
'previously set privileges will be preserved.', |
'previously set privileges will be preserved.', |
'asno' => 'As no group members are being added, '. |
'asno' => 'As no group members are being added, '. |
Line 2570 sub member_privileges_form {
|
Line 2954 sub member_privileges_form {
|
$r->print('<td valign="top">'); |
$r->print('<td valign="top">'); |
$r->print('<table class="thinborder"><tr>'. |
$r->print('<table class="thinborder"><tr>'. |
'<th colspan="'.$colspan.'">'. |
'<th colspan="'.$colspan.'">'. |
$tool.'</th></tr><tr>'); |
&mt($tool).'</th></tr><tr>'); |
my $privcount = 0; |
my $privcount = 0; |
foreach my $priv (@{$showboxes{$tool}}) { |
foreach my $priv (@{$showboxes{$tool}}) { |
$privcount ++; |
$privcount ++; |
Line 2584 sub member_privileges_form {
|
Line 2968 sub member_privileges_form {
|
} else { |
} else { |
$r->print('<td>'); |
$r->print('<td>'); |
} |
} |
$r->print(qq| |
$r->print( |
<fieldset><legend><b>$$toolprivs{$tool}{$priv}</b></legend> |
'<fieldset><legend><b>'.&mt($$toolprivs{$tool}{$priv}).'</b></legend>' |
<nobr> |
.'<span class="LC_nobreak">' |
<input type="button" value="check all" |
.' <input type="button" value="'.&mt('check all').'"' |
onclick="javascript:checkAll(document.$formname.userpriv_$priv)" /> |
.' onclick="javascript:checkAll(document.'.$formname.'.userpriv_'.$priv.')" />' |
|
.' ' |
<input type="button" value="uncheck all" |
.'<input type="button" value="'.&mt('uncheck all').'"' |
onclick="javascript:uncheckAll(document.$formname.userpriv_$priv)" /> |
.' onclick="javascript:uncheckAll(document.'.$formname.'.userpriv_'.$priv.')" />' |
</nobr></fieldset><br />|); |
.'</span></fieldset><br />' |
|
); |
$r->print('</td>'); |
$r->print('</td>'); |
if ($privcount < @{$showboxes{$tool}}) { |
if ($privcount < @{$showboxes{$tool}}) { |
if (@{$showboxes{$tool}} > 2) { |
if (@{$showboxes{$tool}} > 2) { |
Line 2736 sub write_group_data {
|
Line 3121 sub write_group_data {
|
} |
} |
if ($quota !~ /^\d*\.?\d*$/) { |
if ($quota !~ /^\d*\.?\d*$/) { |
$quota = 0; |
$quota = 0; |
$r->print(&mt('The value you entered for the quota for the file repository in this [_1] contained invalid characters, so it has been set to 0 Mb. You can change this by modifying the [_1] settings.<br />',$gpterm)); |
$r->print('<div class="LC_warning">' |
|
.&mt('The value you entered for the quota for the file repository in this '.$gpterm |
|
.' contained invalid characters, so it has been set to 0 Mb. You can change this by' |
|
.' modifying the '.$gpterm.' settings.') |
|
.'</div>'); |
} |
} |
if ($quota > $maxposs) { |
if ($quota > $maxposs) { |
$quota = $maxposs; |
$quota = $maxposs; |
$r->print(&mt('The value you entered for the quota for the file repository in this [_1] exceeded the maximum possible value, so it has been set to [_2] Mb (the maximum possible value).<br />',$gpterm,sprintf("%.2f",$maxposs))); |
$r->print('<div class="LC_warning">' |
|
.&mt('The value you entered for the quota for the file repository in this '.$gpterm |
|
.' exceeded the maximum possible value, so it has been set to [_1] Mb ' |
|
.'(the maximum possible value).',sprintf("%.2f",$maxposs)) |
|
.'</div>'); |
} |
} |
my %groupinfo = ( |
my %groupinfo = ( |
description => $esc_description, |
description => $esc_description, |
Line 2805 sub write_group_data {
|
Line 3198 sub write_group_data {
|
my $result = &add_group_folder($cdom,$cnum,$now,$groupname,$action, |
my $result = &add_group_folder($cdom,$cnum,$now,$groupname,$action, |
$description,$tools,\%groupinfo, |
$description,$tools,\%groupinfo, |
$gpterm,$ucgpterm,$crstype); |
$gpterm,$ucgpterm,$crstype); |
if ($result ne 'ok') { |
if ($result eq 'ok') { |
$r->print(&mt('A problem occurred when creating folders for the new [_1]. [_2].<br />',$gpterm,$result)); |
$r->print('<div class="LC_success">' |
|
.&mt($ucgpterm.' [_1] was created.','<i>'.$groupname.'</i>') |
|
.'</div>'); |
|
} else { |
|
$r->print('<div class="LC_error">' |
|
.&mt('A problem occurred when creating folders for the new '.$gpterm.' [_1]:' |
|
,'<i>'.$groupname.'</i>') |
|
.'<br />'.$result |
|
.'</div>'); |
} |
} |
$r->print(&mt('[_1] [_2] was created.<br />',$ucgpterm,$groupname)); |
|
} elsif ($action eq 'modify') { |
} elsif ($action eq 'modify') { |
my (@oldtools,@newtools); |
my (@oldtools,@newtools); |
if (ref($$stored{'tool'}) eq 'ARRAY') { |
if (ref($$stored{'tool'}) eq 'ARRAY') { |
Line 2838 sub write_group_data {
|
Line 3238 sub write_group_data {
|
my $parm_result = &parm_setter($navmap,$cdom,$boardsmap, |
my $parm_result = &parm_setter($navmap,$cdom,$boardsmap, |
$groupname); |
$groupname); |
if ($parm_result) { |
if ($parm_result) { |
$r->print(&mt('Error while setting parameters '. |
$r->print('<div class="LC_error">' |
'for Discussion Boards folder: '. |
.&mt('An error occurred while setting parameters ' |
'[_1]<br />.',$parm_result)); |
.'for Discussion Boards folder: ' |
|
.'[_1]',$parm_result) |
|
.'</div>'); |
} else { |
} else { |
$r->print(&mt('Discussion Boards Folder created.<br />')); |
$r->print('<div class="LC_success">' |
|
.&mt('Discussion Boards Folder created.') |
|
.'</div>'); |
} |
} |
} else { |
} else { |
$r->print($outcome); |
$r->print($outcome); |
Line 2850 sub write_group_data {
|
Line 3254 sub write_group_data {
|
undef($navmap); |
undef($navmap); |
} |
} |
} |
} |
$r->print(&mt('[_1] [_2] was updated.<br />',$ucgpterm,$groupname)); |
$r->print('<div class="LC_success">' |
|
.&mt($ucgpterm.' [_1] was updated.','<i>'.$groupname.'</i>') |
|
.'</div>'); |
} |
} |
} else { |
} else { |
my %actiontype = ( |
my %actiontype = ( |
Line 2860 sub write_group_data {
|
Line 3266 sub write_group_data {
|
&Apache::lonnet::logthis("Failed to store $gpterm $groupname ". |
&Apache::lonnet::logthis("Failed to store $gpterm $groupname ". |
'in '.lc($crstype).': '.$cnum. |
'in '.lc($crstype).': '.$cnum. |
' in domain: '.$cdom); |
' in domain: '.$cdom); |
$r->print(&mt('An error occurred when [_1] the [_2]. '. |
$r->print('<div class="LC_error">' |
'Please try again.',$actiontype{$action},$gpterm)); |
.&mt('An error occurred when [_1] the '.$gpterm.'. ' |
|
.'Please try again.',$actiontype{$action}) |
|
.'</div>'); |
} |
} |
return $result; |
return $result; |
} |
} |
Line 2880 sub process_membership {
|
Line 3288 sub process_membership {
|
my %curr_start = (); |
my %curr_start = (); |
my %curr_end = (); |
my %curr_end = (); |
my %tooltype = (); |
my %tooltype = (); |
|
my $context = 'processgroupmembership'; |
|
|
foreach my $tool (@{$tools}) { |
foreach my $tool (@{$tools}) { |
foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) { |
foreach my $priv (sort(keys(%{$$toolprivs{$tool}}))) { |
Line 2949 sub process_membership {
|
Line 3358 sub process_membership {
|
$curr_privs{$user}; |
$curr_privs{$user}; |
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname, |
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname, |
$user,$now,$savestart, |
$user,$now,$savestart, |
$curr_privs{$user}) eq 'ok') { |
$curr_privs{$user},'',$context) eq 'ok') { |
push(@{$added{'expired'}},$user); |
push(@{$added{'expired'}},$user); |
$num_ok ++; |
$num_ok ++; |
} else { |
} else { |
Line 2960 sub process_membership {
|
Line 3369 sub process_membership {
|
foreach my $user (@deletion) { |
foreach my $user (@deletion) { |
$usersettings{$groupname.':'.$user} = $now.':-1:'; |
$usersettings{$groupname.':'.$user} = $now.':-1:'; |
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname, |
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname, |
$user,$now,'-1','') |
$user,$now,'-1','','',$context) |
eq 'ok') { |
eq 'ok') { |
push(@{$added{'deleted'}},$user); |
push(@{$added{'deleted'}},$user); |
$num_ok ++; |
$num_ok ++; |
Line 3014 sub process_membership {
|
Line 3423 sub process_membership {
|
$group_privs{$user}; |
$group_privs{$user}; |
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname, |
if (&Apache::lonnet::modify_group_roles($cdom,$cnum,$groupname, |
$user,$end,$start, |
$user,$end,$start, |
$group_privs{$user}) eq 'ok') { |
$group_privs{$user},'',$context) eq 'ok') { |
push(@{$added{$type}},$user); |
push(@{$added{$type}},$user); |
$num_ok ++; |
$num_ok ++; |
} else { |
} else { |
Line 3053 sub process_membership {
|
Line 3462 sub process_membership {
|
} |
} |
if ($num_fail) { |
if ($num_fail) { |
foreach my $type (sort(keys(%failed))) { |
foreach my $type (sort(keys(%failed))) { |
$r->print(&mt('The following users could not be [_1], because an error occurred:<br />',$type)); |
$r->print('<div class="LC_error">' |
|
.&mt("The following users could not be $type, because an error occurred:") |
|
.'</div>'); |
foreach my $user (@{$failed{$type}}) { |
foreach my $user (@{$failed{$type}}) { |
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />'); |
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />'); |
} |
} |
Line 3061 sub process_membership {
|
Line 3472 sub process_membership {
|
$r->print('<br />'); |
$r->print('<br />'); |
} |
} |
if (@unchanged > 0) { |
if (@unchanged > 0) { |
$r->print(&mt('No change occurred for the following users:<br />')); |
$r->print(&mt('No change occurred for the following users:').'<br />'); |
foreach my $user (sort(@unchanged)) { |
foreach my $user (sort(@unchanged)) { |
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />'); |
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />'); |
} |
} |
$r->print('<br />'); |
$r->print('<br />'); |
} |
} |
if ($roster_result eq 'ok') { |
if ($roster_result eq 'ok') { |
$r->print('<br />'.&mt('[_1] membership list updated.',$ucgpterm)); |
$r->print('<div class="LC_success">' |
$r->print('<p>'.&mt("Any currently logged in course users affected by the changes you made to group membership or privileges for the [_1] group will need to log out and log back in for their LON-CAPA sessions to reflect these changes.",$groupname).'</p>'); |
.&mt($ucgpterm.' membership list updated.') |
} else { |
.'</div>'); |
$r->print('<br />'.&mt('An error occurred while updating the [_1] membership list -',$gpterm).$roster_result.'<br />'); |
$r->print('<p class="LC_info">' |
|
.&mt('Any currently logged in course users affected by the changes you made' |
|
.' to group membership or privileges for the [_1] group will need to log out' |
|
.' and log back in for their LON-CAPA sessions to reflect these changes.' |
|
,'<i>'.$groupname.'</i>') |
|
.'</p>' |
|
); |
|
} else { |
|
$r->print('<div class="LC_error">' |
|
.&mt("An error occurred while updating the $gpterm membership list:") |
|
.'<br />'.$roster_result |
|
.'</div>'); |
} |
} |
return; |
return; |
} |
} |
Line 3110 sub automapping {
|
Line 3532 sub automapping {
|
if (exists($$stored{'autodrop'})) { |
if (exists($$stored{'autodrop'})) { |
$drop = $$stored{'autodrop'}; |
$drop = $$stored{'autodrop'}; |
} |
} |
&topic_bar($r,$image,$$lt{'endi'}); |
$r->print(&Apache::lonhtmlcommon::topic_bar($image,$$lt{'endi'}).' |
$r->print(' |
|
<b>'.$$lt{'gmma'}.':</b><br />'.$$lt{'adds'}.'<br />'.$$lt{'drops'}.'<br /><br /> |
<b>'.$$lt{'gmma'}.':</b><br />'.$$lt{'adds'}.'<br />'.$$lt{'drops'}.'<br /><br /> |
<nobr>'.$$lt{'auad'}.': |
<nobr>'.$$lt{'auad'}.': |
<label><input type="radio" name="autoadd" value="on" />on </label><label><input type="radio" name="autoadd" value="off" checked="checked" />off</label>'); |
<label><input type="radio" name="autoadd" value="on" />'.&mt('on').' </label><label><input type="radio" name="autoadd" value="off" checked="checked" />'.&mt('off').'</label>'); |
if ($action eq 'modify') { |
if ($action eq 'modify') { |
$r->print(' ('.$$lt{'curr'}.' <b>'.$$lt{$add}.'</b>)'); |
$r->print(' ('.$$lt{'curr'}.' <b>'.$$lt{$add}.'</b>)'); |
} |
} |
$r->print(' |
$r->print(' |
</nobr><br /> |
</nobr><br /> |
<nobr>'.$$lt{'auex'}.': |
<nobr>'.$$lt{'auex'}.': |
<label><input type="radio" name="autodrop" value="on" />on </label><label><input type="radio" name="autodrop" value="off" checked="checked" />off</label>'); |
<label><input type="radio" name="autodrop" value="on" />'.&mt('on').' </label><label><input type="radio" name="autodrop" value="off" checked="checked" />'.&mt('off').'</label>'); |
if ($action eq 'modify') { |
if ($action eq 'modify') { |
$r->print(' ('.$$lt{'curr'}.' <b>'.$$lt{$drop}.'</b>)'); |
$r->print(' ('.$$lt{'curr'}.' <b>'.$$lt{$drop}.'</b>)'); |
} |
} |
Line 3138 sub mapping_settings {
|
Line 3559 sub mapping_settings {
|
} else { |
} else { |
@sections = ('all','none'); |
@sections = ('all','none'); |
} |
} |
&topic_bar($r,$image,$$lt{'pirs'}); |
$r->print(&Apache::lonhtmlcommon::topic_bar($image,$$lt{'pirs'})); |
my @roles = &standard_roles(); |
my @roles = &standard_roles(); |
my %customroles = &Apache::lonhtmlcommon::course_custom_roles($cdom,$cnum); |
my %customroles = &Apache::lonhtmlcommon::course_custom_roles($cdom,$cnum); |
$r->print(&Apache::loncommon::start_data_table(). |
$r->print(&Apache::loncommon::start_data_table(). |
Line 3338 sub add_group_folder {
|
Line 3759 sub add_group_folder {
|
my ($cdom,$cnum,$now,$groupname,$action,$description,$tools,$groupinfo, |
my ($cdom,$cnum,$now,$groupname,$action,$description,$tools,$groupinfo, |
$gpterm,$ucgpterm,$crstype) = @_; |
$gpterm,$ucgpterm,$crstype) = @_; |
if ($cdom eq '' || $cnum eq '') { |
if ($cdom eq '' || $cnum eq '') { |
return &mt('Error: invalid course domain or number - group folder creation failed'); |
return '<span class="LC_error">' |
|
.&mt('Error: invalid course domain or number - group folder creation failed.') |
|
.'</span>'; |
} |
} |
my ($outcome,$allgrpsmap,$grpmap,$boardsmap,$grppage); |
my ($outcome,$allgrpsmap,$grpmap,$boardsmap,$grppage,$warning); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
|
my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/'; |
my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/'; |
$allgrpsmap = $crspath.'group_allfolders.sequence'; |
$allgrpsmap = $crspath.'group_allfolders.sequence'; |
my $topmap = $navmap->getResourceByUrl($allgrpsmap); |
|
undef($navmap); |
|
if ($action eq 'create') { |
if ($action eq 'create') { |
# check if group_allfolders.sequence exists. |
if (&get_folder_lock($cdom,$cnum,'group_allfolders',$now) eq 'ok') { |
if (!$topmap) { |
# check if group_allfolders.sequence exists. |
my $grpstitle = &mt('[_1] [_2]s',$crstype,$ucgpterm); |
my $mapcontents = &Apache::lonnet::getfile($allgrpsmap); |
my $topmap_url = '/'.$env{'course.'.$env{'request.course.id'}.'.url'}; |
if ($mapcontents eq '-1') { #file does not exist; |
$topmap_url =~ s|/+|/|g; |
my $grpstitle = &mt("$crstype $ucgpterm".'s'); |
if ($topmap_url =~ m|^/uploaded|) { |
my $topmap_url = '/'.$env{'course.'.$env{'request.course.id'}.'.url'}; |
$outcome = &map_updater($cdom,$cnum,'group_allfolders.sequence', |
$topmap_url =~ s|/+|/|g; |
'toplevelgroup',$grpstitle,$topmap_url); |
if ($topmap_url =~ m|^/uploaded|) { |
|
$outcome = &map_updater($cdom,$cnum,'group_allfolders.sequence', |
|
'toplevelgroup',$grpstitle,$topmap_url); |
|
} else { |
|
$outcome = '<span class="LC_warning">' |
|
.&mt('Non-standard course - folder for all groups not added.') |
|
.'</span>'; |
|
} |
if ($outcome ne 'ok') { |
if ($outcome ne 'ok') { |
|
my $delresult = &release_folder_lock($cdom,$cnum,'group_allfolders'); |
|
if ($delresult ne 'ok') { |
|
$warning = $delresult; |
|
} |
return $outcome; |
return $outcome; |
} |
} |
} else { |
|
$outcome = &mt('Non-standard course - folder for all groups not added.'); |
|
return $outcome; |
|
} |
} |
|
my $delresult = &release_folder_lock($cdom,$cnum,'group_allfolders'); |
|
if ($delresult ne 'ok') { |
|
$warning = $delresult ; |
|
} |
|
} else { |
|
$outcome = '<span class="LC_error">' |
|
.&mt('Could not obtain exclusive lock to check status of the folder for all groups. No group folder added.') |
|
.'</div>'; |
|
return $outcome; |
} |
} |
my $grpfolder = &mt('[_1] Folder -',$ucgpterm,).$description; |
my $grpfolder = &mt($ucgpterm.' Folder - [_1]',$description); |
$grppage='/adm/'.$cdom.'/'.$cnum.'/'.$groupname.'/smppg'; |
$grppage='/adm/'.$cdom.'/'.$cnum.'/'.$groupname.'/smppg'; |
my $grptitle = &mt('Group homepage').' - '.$description; |
my $grptitle = &mt('Group homepage - [_1]',$description); |
my ($discussions,$disctitle); |
my ($discussions,$disctitle); |
my $outcome = &map_updater($cdom,$cnum,'group_folder_'.$groupname.'.sequence', |
my $outcome = &map_updater($cdom,$cnum,'group_folder_'.$groupname.'.sequence', |
'grpseq',$grpfolder,$allgrpsmap,$grppage, |
'grpseq',$grpfolder,$allgrpsmap,$grppage, |
$grptitle); |
$grptitle); |
if ($outcome ne 'ok') { |
if ($outcome ne 'ok') { |
return $outcome; |
return $outcome.$warning; |
} |
} |
my $pageout = &create_homepage($cdom,$cnum,$groupname,$groupinfo, |
my $pageout = &create_homepage($cdom,$cnum,$groupname,$groupinfo, |
$tools,$gpterm,$ucgpterm,$now); |
$tools,$gpterm,$ucgpterm,$now); |
Line 3382 sub add_group_folder {
|
Line 3819 sub add_group_folder {
|
my $outcome = &map_updater($cdom,$cnum,'group_boards_'.$groupname. |
my $outcome = &map_updater($cdom,$cnum,'group_boards_'.$groupname. |
'.sequence','bbseq',$disctitle,$grpmap); |
'.sequence','bbseq',$disctitle,$grpmap); |
if ($outcome ne 'ok') { |
if ($outcome ne 'ok') { |
return $outcome; |
return $outcome.$warning; |
} |
} |
$boardsmap = $crspath.'group_boards_'.$groupname.'.sequence'; |
$boardsmap = $crspath.'group_boards_'.$groupname.'.sequence'; |
} |
} |
Line 3390 sub add_group_folder {
|
Line 3827 sub add_group_folder {
|
#modify group folder if status of discussions tools is changed |
#modify group folder if status of discussions tools is changed |
} |
} |
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); |
$navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
# modify parameters |
# modify parameters |
my $parm_result; |
my $parm_result; |
if ($action eq 'create') { |
if ($action eq 'create') { |
Line 3404 sub add_group_folder {
|
Line 3841 sub add_group_folder {
|
$parm_result .= &parm_setter($navmap,$cdom,$boardsmap,$groupname); |
$parm_result .= &parm_setter($navmap,$cdom,$boardsmap,$groupname); |
} |
} |
} |
} |
|
undef($navmap); |
if ($parm_result) { |
if ($parm_result) { |
return $parm_result; |
return $warning.$parm_result; |
|
} else { |
|
return 'ok'; |
|
} |
|
} |
|
|
|
sub get_folder_lock { |
|
my ($cdom,$cnum,$folder_name,$now) = @_; |
|
# get lock for folder being edited. |
|
my $lockhash = { |
|
$folder_name."\0".'locked_folder' => $now.':'.$env{'user.name'}. |
|
':'.$env{'user.domain'}, |
|
}; |
|
my $tries = 0; |
|
my $gotlock = &Apache::lonnet::newput('coursegroups',$lockhash,$cdom,$cnum); |
|
|
|
while (($gotlock ne 'ok') && $tries <3) { |
|
$tries ++; |
|
sleep(1); |
|
$gotlock = &Apache::lonnet::newput('coursegroups',$lockhash,$cdom,$cnum); |
|
} |
|
return $gotlock; |
|
} |
|
|
|
sub release_folder_lock { |
|
my ($cdom,$cnum,$folder_name) = @_; |
|
# remove lock |
|
my @del_lock = ($folder_name."\0".'locked_folder'); |
|
my $dellockoutcome=&Apache::lonnet::del('coursegroups',\@del_lock,$cdom,$cnum); |
|
if ($dellockoutcome ne 'ok') { |
|
return ('<div class="LC_error">' |
|
.&mt('Warning: failed to release lock for folder: [_1].','<tt>'.$folder_name.'</tt>') |
|
.'</div>' |
|
); |
} else { |
} else { |
return 'ok'; |
return 'ok'; |
} |
} |
Line 3420 sub map_updater {
|
Line 3891 sub map_updater {
|
my $newmapurl=&Apache::lonnet::finishuserfileupload($cnum,$cdom,$itemname, |
my $newmapurl=&Apache::lonnet::finishuserfileupload($cnum,$cdom,$itemname, |
$newfile); |
$newfile); |
if ($newmapurl !~ m|^/uploaded|) { |
if ($newmapurl !~ m|^/uploaded|) { |
$outcome = &mt('Error uploading new folder.')." ($newfile): $newmapurl".'<br />'; |
$outcome = '<div class="LC_error">' |
|
.&mt('Error uploading new folder.')." ($newfile): $newmapurl" |
|
.'</div>'; |
return $outcome; |
return $outcome; |
} |
} |
my ($errtext,$fatal)=&Apache::lonratedt::mapread($parentmap); |
my ($errtext,$fatal)=&LONCAPA::map::mapread($parentmap); |
if ($fatal) { |
if ($fatal) { |
$outcome = &mt('Error reading contents of parent folder')." ($parentmap): $errtext".'<br />'; |
$outcome = '<div class="LC_error">' |
|
.&mt('Error reading contents of parent folder.')." ($parentmap): $errtext" |
|
.'</div>'; |
return $outcome; |
return $outcome; |
} else { |
} else { |
my $newidx=&Apache::lonratedt::getresidx($newmapurl); |
my $newidx=&LONCAPA::map::getresidx($newmapurl); |
$Apache::lonratedt::resources[$newidx] = $itemtitle.':'.$newmapurl. |
$LONCAPA::map::resources[$newidx] = $itemtitle.':'.$newmapurl. |
':false:normal:res'; |
':false:normal:res'; |
$Apache::lonratedt::order[1+$#Apache::lonratedt::order]=$newidx; |
$LONCAPA::map::order[1+$#LONCAPA::map::order]=$newidx; |
my ($outtext,$errtext) = &Apache::lonratedt::storemap($parentmap,1); |
my ($outtext,$errtext) = &LONCAPA::map::storemap($parentmap,1); |
if ($errtext) { |
if ($errtext) { |
$outcome = &mt('Error storing updated parent folder')." ($parentmap): $errtext".'<br />'; |
$outcome = '<div class="LC_error">' |
|
.&mt('Error saving updated parent folder.')." ($parentmap): $errtext" |
|
.'</div>'; |
return $outcome; |
return $outcome; |
} |
} |
} |
} |
Line 3468 sub parm_setter {
|
Line 3945 sub parm_setter {
|
}, |
}, |
); |
); |
my $res = $navmap->getResourceByUrl($url); |
my $res = $navmap->getResourceByUrl($url); |
my $symb = $res->symb(); |
if ($res) { |
foreach my $level (keys(%hide_settings)) { |
my $symb = $res->symb(); |
my $parmresult = &Apache::lonparmset::storeparm_by_symb($symb, |
foreach my $level (keys(%hide_settings)) { |
|
my $parmresult = |
|
&Apache::lonparmset::storeparm_by_symb($symb, |
'0_hiddenresource', |
'0_hiddenresource', |
$hide_settings{$level}{'num'}, |
$hide_settings{$level}{'num'}, |
$hide_settings{$level}{'set'}, |
$hide_settings{$level}{'set'}, |
'string_yesno',undef,$cdom, |
'string_yesno',undef,$cdom, |
undef,undef, |
undef,undef, |
$hide_settings{$level}{'extra'}); |
$hide_settings{$level}{'extra'}); |
if ($parmresult) { |
if ($parmresult) { |
$allresults .= $level.': '.$parmresult; |
$allresults .= $level.': '.$parmresult; |
|
} |
} |
} |
|
} else { |
|
$allresults = '<div class="LC_warning">' |
|
.&mt('Parameters not set for [_1] because the resource was not recognized' |
|
.' as part of the course.','<tt>'.$url.'</tt>') |
|
.'</div>'; |
} |
} |
return $allresults; |
return $allresults; |
} |
} |
Line 3543 sub validate_groupname {
|
Line 4028 sub validate_groupname {
|
my ($groupname,$action,$cdom,$cnum,$gpterm,$ucgpterm,$crstype) = @_; |
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 %deleted_groups = &Apache::longroup::coursegroups($cdom,$cnum,undef, |
|
'deleted_groups'); |
|
if (my $tmp = &Apache::lonnet::error(%deleted_groups)) { |
|
undef(%deleted_groups); |
|
&Apache::lonnet::logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom); |
|
} |
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
igna => "Invalid $gpterm name", |
igna => "Invalid $gpterm name", |
tgne => "The $gpterm name entered ", |
tgne => "The $gpterm name entered ", |
Line 3570 sub validate_groupname {
|
Line 4060 sub validate_groupname {
|
return $exitmsg.$lt{'cnnb'}.&mt('a section').$lt{'inth'}. |
return $exitmsg.$lt{'cnnb'}.&mt('a section').$lt{'inth'}. |
'<br />'.$lt{'grna'}; |
'<br />'.$lt{'grna'}; |
} |
} |
if ($action eq 'create' |
if ($action eq 'create') { |
&& exists($curr_groups{$groupname})) { |
if (exists($curr_groups{$groupname})) { |
|
return $exitmsg.$lt{'cnnb'}.&mt('an existing [_1]',$gpterm). |
return $exitmsg.$lt{'cnnb'}.&mt('an existing [_1]',$gpterm). |
$lt{'inth'}.'.<br />'.$lt{'grna'}; |
$lt{'inth'}.'<br />'.$lt{'grna'}; |
} elsif (exists($deleted_groups{$groupname})) { |
|
return $exitmsg.$lt{'cnnb'}.&mt('a [_1] which previously existed',$gpterm). |
|
$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('[_1] name:',$ucgpterm).' '.$groupname.$lt{'thgr'}. |
$earlyout = &mt('[_1] name:',$ucgpterm).' '.$groupname.$lt{'thgr'}. |
Line 3586 sub validate_groupname {
|
Line 4078 sub validate_groupname {
|
return; |
return; |
} |
} |
|
|
sub topic_bar { |
|
my ($r,$imgnum,$title) = @_; |
|
$r->print(' |
|
<div class="LC_topic_bar"> |
|
<img alt="'.&mt('Step [_1]',$imgnum). |
|
'"src="/res/adm/pages/bl_step'.$imgnum.'.gif" /> |
|
<span>'.$title.'</span> |
|
</div> |
|
'); |
|
return; |
|
} |
|
|
|
sub check_changes { |
sub check_changes { |
my ($member_changes,$memchg) = @_; |
my ($member_changes,$memchg) = @_; |
my %exclusions; |
my %exclusions; |