$lt{'rev'} $lt{'ren'} $lt{'del'} $lt{'rol'} $lt{'e
xt'} $lt{'sta'} $lt{'end'}
END
- foreach my $type ('Construction Space','Course','Domain','System','Unknown') {
+ foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') {
if ($output{$type}) {
$r->print($output{$type}."\n");
}
@@ -678,7 +781,7 @@ END
$currentauth=~/^internal:/ or
$currentauth=~/^localauth:/
) { # bad authentication scheme
- if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
+ if (&Apache::lonnet::allowed('mau',$ccdomain)) {
&initialize_authen_forms();
my %lt=&Apache::lonlocal::texthash(
'err' => "ERROR",
@@ -701,7 +804,7 @@ $lt{'uuas'} ($currentauth). $lt{'sldb'}.
$authformloc
ENDBADAUTH
} else {
- # This user is not allowed to modify the users
+ # This user is not allowed to modify the user's
# authentication scheme, so just notify them of the problem
my %lt=&Apache::lonlocal::texthash(
'err' => "ERROR",
@@ -710,9 +813,6 @@ ENDBADAUTH
);
$r->print(<
-
$lt{'err'}:
$lt{'uuas'} ($currentauth). $lt{'adcs'}.
@@ -743,7 +843,7 @@ ENDBADAUTH
"$authformint
$authformfsys
";
}
$authformcurrent.=' (will override current values) ';
- if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
+ if (&Apache::lonnet::allowed('mau',$ccdomain)) {
# Current user has login modification privileges
my %lt=&Apache::lonlocal::texthash(
'ccld' => "Change Current Login Data",
@@ -761,6 +861,19 @@ $loginscript
$lt{'enld'}
$authform_other
ENDOTHERAUTHS
+ } else {
+ if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
+ my %lt=&Apache::lonlocal::texthash(
+ 'ccld' => "Change Current Login Data",
+ 'yodo' => "You do not have privileges to modify the authentication configuration for this user.",
+ 'ifch' => "If a change is required, contact a domain coordinator for the domain",
+ );
+ $r->print(<
+$lt{'ccld'}
+$lt{'yodo'} $lt{'ifch'}: $ccdomain
+ENDNOPRIV
+ }
}
} ## End of "check for bad authentication type" logic
} ## End of new user/old user logic
@@ -853,12 +966,11 @@ ENDDROW
$r->print($domaintext);
}
#
-# Course level
+# Course and group levels
#
- my $num_sections;
if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
- $r->print(&course_level_dc($1));
+ $r->print(&course_level_dc($1,'Course'));
$r->print(' '."\n");
} else {
$r->print(&course_level_table(%inccourses));
@@ -883,6 +995,7 @@ sub update_user_data {
$title='Modify User Privileges';
}
$r->print(&Apache::loncommon::start_page($title));
+ my %disallowed;
# Check Inputs
if (! $env{'form.ccuname'} ) {
$r->print($error.&mt('No login name specified').'.'.$end);
@@ -1104,22 +1217,23 @@ END
&Apache::lonnet::critical('put:'.
$env{'course.'.$cid.'.domain'}.':'.
$env{'course.'.$cid.'.num'}.':classlist:'.
- &Apache::lonnet::escape($env{'form.ccuname'}.':'.
+ &escape($env{'form.ccuname'}.':'.
$env{'form.ccdomain'}).'='.
- &Apache::lonnet::escape($now.':'),
+ &escape($now.':'),
$env{'course.'.$cid.'.home'}).' ');
}
}
if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
# Revoke custom role
- $r->print(&mt('Revoking custom role').
+ $r->print(&mt('Revoking custom role:').
' '.$4.' by '.$3.'@'.$2.' in '.$1.': '.
&Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
$env{'form.ccuname'},$1,$2,$3,$4).
' ');
}
} elsif ($_=~/^form\.del/) {
- if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
+ if ($_=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
+# Delete standard role
$r->print(&mt('Deleting').' '.$2.' in '.$1.': '.
&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$1,$2,$now,0,1).' ');
@@ -1130,23 +1244,33 @@ END
&Apache::lonnet::critical('put:'.
$env{'course.'.$cid.'.domain'}.':'.
$env{'course.'.$cid.'.num'}.':classlist:'.
- &Apache::lonnet::escape($env{'form.ccuname'}.':'.
+ &escape($env{'form.ccuname'}.':'.
$env{'form.ccdomain'}).'='.
- &Apache::lonnet::escape($now.':'),
+ &escape($now.':'),
$env{'course.'.$cid.'.home'}).' ');
}
- }
+ }
+ if ($_=~/^form\.del\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
+# Delete custom role
+ $r->print(&mt('Deleting custom role [_1] by [_2]@[_3] in [_4]',
+ $rolename,$rnam,$rdom,$url).': '.
+ &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
+ $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
+ 0,1).' ');
+ }
} elsif ($_=~/^form\.ren/) {
my $udom = $env{'form.ccdomain'};
my $uname = $env{'form.ccuname'};
- if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) {
+# Re-enable standard role
+ if ($_=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {
my $url = $1;
my $role = $2;
my $logmsg;
my $output;
if ($role eq 'st') {
if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) {
- my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
+ my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
$output = "Error: $result\n";
} else {
@@ -1159,11 +1283,20 @@ END
} else {
my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$role,0,$now);
- $output = &mt('Re-Enabling [_1] in [_2]: [_3]',
+ $output = &mt('Re-enabling [_1] in [_2]: [_3] ',
$role,$url,$result).' ';
}
$r->print($output);
- }
+ }
+# Re-enable custom role
+ if ($_=~/^form\.ren\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
+ my $result = &Apache::lonnet::assigncustomrole(
+ $env{'form.ccdomain'}, $env{'form.ccuname'},
+ $url,$rdom,$rnam,$rolename,0,$now);
+ $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : [_5] ',
+ $rolename,$rnam,$rdom,$url,$result).' ');
+ }
} elsif ($_=~/^form\.act/) {
my $udom = $env{'form.ccdomain'};
my $uname = $env{'form.ccuname'};
@@ -1184,11 +1317,18 @@ END
my %sections = ();
my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5);
if ($num_sections == 0) {
- $r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
+ $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
} else {
- foreach (sort {$a cmp $b} keys %sections) {
- my $securl = $url.'/'.$_;
- $r->print(&commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
+ my %curr_groups =
+ &Apache::longroup::coursegroups($one,$two);
+ foreach my $sec (sort {$a cmp $b} keys %sections) {
+ if (($sec eq 'none') || ($sec eq 'all') ||
+ exists($curr_groups{$sec})) {
+ $disallowed{$sec} = $url;
+ next;
+ }
+ my $securl = $url.'/'.$sec;
+ $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
}
}
} elsif ($_=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) {
@@ -1207,20 +1347,27 @@ END
my %sections = ();
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
if ($num_sections == 0) {
- $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
} else {
+ my %curr_groups =
+ &Apache::longroup::coursegroups($one,$two);
my $emptysec = 0;
foreach my $sec (sort {$a cmp $b} keys %sections) {
$sec =~ s/\W//g;
- if ($sec ne '') {
+ if ($sec ne '') {
+ if (($sec eq 'none') || ($sec eq 'all') ||
+ exists($curr_groups{$sec})) {
+ $disallowed{$sec} = $url;
+ next;
+ }
my $securl = $url.'/'.$sec;
- $r->print(&commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec));
} else {
$emptysec = 1;
}
}
if ($emptysec) {
- $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
}
}
} elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
@@ -1237,25 +1384,33 @@ END
my %sections = ();
my $num_sections = &build_roles($env{'form.sec_'.$1.'_'.$2},\%sections,$2);
if ($num_sections == 0) {
- $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
} else {
my $emptysec = 0;
foreach my $sec (sort {$a cmp $b} keys %sections) {
if ($sec ne '') {
my $securl = $url.'/'.$sec;
- $r->print(&commit_standardrole($udom,$uname,$securl,$2,$start,$end,$1,undef,$sec));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$2,$start,$end,$1,undef,$sec));
} else {
$emptysec = 1;
}
}
if ($emptysec) {
- $r->print(&commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$2,$start,$end,$1,undef,''));
}
}
} else {
$r->print(''.&mt('ERROR').': '.&mt('Unknown command').' '.$_.'
');
}
- }
+ foreach my $key (sort(keys(%disallowed))) {
+ if (($key eq 'none') || ($key eq 'all')) {
+ $r->print(''.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key));
+ } else {
+ $r->print('
'.&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',$key));
+ }
+ $r->print(' '.&mt('Please go back and choose a different section name.').'
');
+ }
+ }
} # End of foreach (keys(%env))
# Flush the course logs so reverse user roles immediately updated
&Apache::lonnet::flushcourselogs();
@@ -1263,89 +1418,6 @@ END
$r->print(&Apache::loncommon::end_page());
}
-sub commit_customrole {
- my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_;
- my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url.
- ($start?', '.&mt('starting').' '.localtime($start):'').
- ($end?', ending '.localtime($end):'').': '.
- &Apache::lonnet::assigncustomrole(
- $udom,$uname,$url,$three,$four,$five,$end,$start).
- ' ';
- return $output;
-}
-
-sub commit_standardrole {
- my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
- my $output;
- my $logmsg;
- if ($three eq 'st') {
- my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec);
- if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
- $output = "Error: $result\n";
- } else {
- $output = &mt('Assigning').' '.$three.' in '.$url.
- ($start?', '.&mt('starting').' '.localtime($start):'').
- ($end?', '.&mt('ending').' '.localtime($end):'').
- ': '.$result.' '.
- &mt('Add to classlist').': ok ';
- }
- } else {
- $output = &mt('Assigning').' '.$three.' in '.$url.
- ($start?', '.&mt('starting').' '.localtime($start):'').
- ($end?', '.&mt('ending').' '.localtime($end):'').': '.
- &Apache::lonnet::assignrole(
- $udom,$uname,$url,$three,$end,$start).
- ' ';
- }
- return $output;
-}
-
-sub commit_studentrole {
- my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;
- my $linefeed = ' '."\n";
- my $result;
- if (defined($one) && defined($two)) {
- my $cid=$one.'_'.$two;
- my $oldsec=&Apache::lonnet::getsection($udom,$uname,$cid);
- my $secchange = 0;
- my $expire_role_result;
- my $modify_section_result;
- unless ($oldsec eq '-1') {
- unless ($sec eq $oldsec) {
- $secchange = 1;
- my $uurl='/'.$cid;
- $uurl=~s/\_/\//g;
- if ($oldsec) {
- $uurl.='/'.$oldsec;
- }
- $expire_role_result = &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',time);
- $result = $expire_role_result;
- }
- }
- if (($expire_role_result eq 'ok') || ($secchange == 0)) {
- $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid);
- if ($modify_section_result =~ /^ok/) {
- if ($secchange == 1) {
- $$logmsg .= "Section for $uname switched from old section: $oldsec to new section: $sec".$linefeed;
- } elsif ($oldsec eq '-1') {
- $$logmsg .= "New student role for $uname in section $sec in course $cid".$linefeed;
- } else {
- $$logmsg .= "Student $uname assigned to unchanged section $sec in course $cid".$linefeed;
- }
- } else {
- $$logmsg .= "Error when attempting section change for $uname from old section $oldsec to new section: $sec in course $cid -error: $modify_section_result".$linefeed;
- }
- $result = $modify_section_result;
- } elsif ($secchange == 1) {
- $$logmsg .= "Error when attempting to expire role for $uname in old section $oldsec in course $cid -error: $expire_role_result".$linefeed;
- }
- } else {
- $$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed";
- $result = "Error: incomplete course id\n";
- }
- return $result;
-}
-
sub build_roles {
my ($sectionstr,$sections,$role) = @_;
my $num_sections = 0;
@@ -1375,7 +1447,7 @@ sub build_roles {
$num_sections ++;
}
}
-
+
return $num_sections;
}
@@ -1462,16 +1534,17 @@ sub custom_role_editor {
$area Domain: $domain
ENDEXTENT
if ($_ ne 'cc') {
- if ($num_sections > 0) {
- my $currsec = &course_sections($num_sections,\%sections_count,$protectedcourse.'_'.$_);
+ if (%sections_count) {
+ my $currsec = &course_sections(\%sections_count,$protectedcourse.'_'.$_);
$table .=
''.
''.$lt{'exs'}.' '.
@@ -1677,8 +1751,8 @@ ENDTIMEENTRY
$plrole
$area
END
- if ($num_sections > 0) {
- my $currsec = &course_sections($num_sections,\%sections_count,$customrole);
+ if (%sections_count) {
+ my $currsec = &course_sections(\%sections_count,$customrole);
$table.=
''.
''.$lt{'exs'}.' '.
@@ -1717,10 +1791,10 @@ ENDTABLE
}
sub course_sections {
- my ($num_sections,$sections_count,$role) = @_;
+ my ($sections_count,$role) = @_;
my $output = '';
my @sections = (sort {$a <=> $b} keys %{$sections_count});
- if ($num_sections == 1) {
+ if (scalar(@sections) == 1) {
$output = ''."\n".
' Select '."\n".
' No section '."\n".
@@ -1728,7 +1802,7 @@ sub course_sections {
} else {
$output = ''."\n";
foreach (@sections) {
$output .= ''.$_." \n";
@@ -1743,16 +1817,14 @@ sub course_level_dc {
my %customroles=&my_custom_roles();
my $hiddenitems = ' '.
' '.
- ' ';
+ ' ';
my $courseform=''.&Apache::loncommon::selectcourse_link
- ('cu','dccourse','dcdomain','coursedesc').' ';
-
- my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,$dcdom);
+ ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course').'';
+ my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu');
my %lt=&Apache::lonlocal::texthash(
- 'crl' => "Course Level",
- 'crt' => "Course Title",
+ 'typ' => "Type",
'rol' => "Role",
- 'grs' => "Group/Section",
+ 'grs' => "Section",
'exs' => "Existing sections",
'new' => "Define new section",
'sta' => "Start",
@@ -1760,11 +1832,16 @@ sub course_level_dc {
'ssd' => "Set Start Date",
'sed' => "Set End Date"
);
- my $header = ''.$lt{'crl'}.' '.
- ''.$courseform.' '.$lt{'rol'}.' '.$lt{'grs'}.' '.$lt{'sta'}.' '.$lt{'end'}.' ';
- my $otheritems = ' '.
+ my $header = ''.&mt('Course Level').' '.
+ ''.$lt{'typ'}.' '.$courseform.' '.$lt{'rol'}.' '.$lt{'grs'}.' '.$lt{'sta'}.' '.$lt{'end'}.' ';
+ my $otheritems = ''."\n".
+ ' '.&mt('Please select')."\n".
+ ' '.&mt('Course')."\n".
+ ' '.&mt('Non-standard course')."\n".
+ ' '."\n".
+ ' '."\n".
''."\n";
- foreach ('st','ta','ep','ad','in','cc') {
+ foreach ('st','ta','ep','in','cc') {
my $plrole=&Apache::lonnet::plaintext($_);
$otheritems .= ' '.$plrole;
}
@@ -1781,7 +1858,8 @@ sub course_level_dc {
' <--'.&mt('Pick course first').' '.
' '.
' '.$lt{'new'}.' '.
- ' '.
+ ' '.
+ ' '.
'
';
$otheritems .= <