--- loncom/interface/loncreateuser.pm 2007/12/21 15:33:32 1.217 +++ loncom/interface/loncreateuser.pm 2007/12/21 16:23:54 1.218 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.217 2007/12/21 15:33:32 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.218 2007/12/21 16:23:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -809,141 +809,44 @@ ENDNOPORTPRIV &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses); } } ## End of new user/old user logic - my $addrolesdisplay = 0; - $r->print('

'.&mt('Add Roles').'

'); -# -# Co-Author -# - if (&Apache::lonuserutils::authorpriv($env{'user.name'}, - $env{'request.role.domain'}) && - ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { - # No sense in assigning co-author role to yourself - $addrolesdisplay = 1; - my $cuname=$env{'user.name'}; - my $cudom=$env{'request.role.domain'}; - my %lt=&Apache::lonlocal::texthash( - 'cs' => "Construction Space", - 'act' => "Activate", - 'rol' => "Role", - 'ext' => "Extent", - 'sta' => "Start", - 'end' => "End", - 'cau' => "Co-Author", - 'caa' => "Assistant Co-Author", - 'ssd' => "Set Start Date", - 'sed' => "Set End Date" - ); - $r->print('

'.$lt{'cs'}.'

'."\n". - &Apache::loncommon::start_data_table()."\n". - &Apache::loncommon::start_data_table_header_row()."\n". - ''.$lt{'act'}.''.$lt{'rol'}.''. - ''.$lt{'ext'}.''.$lt{'sta'}.''. - ''.$lt{'end'}.''."\n". - &Apache::loncommon::end_data_table_header_row()."\n". - &Apache::loncommon::start_data_table_row()."\n". - ' - - - '.$lt{'cau'}.' - '.$cudom.'_'.$cuname.' - - '.$lt{'ssd'}.' - -'.$lt{'sed'}.''."\n". - &Apache::loncommon::end_data_table_row()."\n". - &Apache::loncommon::start_data_table_row()."\n". -' -'.$lt{'caa'}.' -'.$cudom.'_'.$cuname.' - -'.$lt{'ssd'}.' - -'.$lt{'sed'}.''."\n". - &Apache::loncommon::end_data_table_row()."\n". - &Apache::loncommon::end_data_table()); - } elsif ($env{'request.role'} =~ /^au\./) { - if (!(&Apache::lonuserutils::authorpriv($env{'user.name'}, - $env{'request.role.domain'}))) { - $r->print(''. - &mt('You do not have privileges to assign co-author roles.'). - ''); - } elsif (($env{'user.name'} eq $ccuname) && - ($env{'user.domain'} eq $ccdomain)) { - $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted')); - } - } -# -# Domain level -# - my $num_domain_level = 0; - my $domaintext = - '

'.&mt('Domain Level').'

'. - &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(). - ''.&mt('Activate').''.&mt('Role').''. - &mt('Extent').''. - ''.&mt('Start').''.&mt('End').''. - &Apache::loncommon::end_data_table_header_row(); - foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) { - foreach my $role ('dc','li','dg','au','sc') { - if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) { - my $plrole=&Apache::lonnet::plaintext($role); - my %lt=&Apache::lonlocal::texthash( - 'ssd' => "Set Start Date", - 'sed' => "Set End Date" - ); - $num_domain_level ++; - $domaintext .= -&Apache::loncommon::start_data_table_row(). -' -'.$plrole.' -'.$thisdomain.' - -'.$lt{'ssd'}.' - -'.$lt{'sed'}.''. -&Apache::loncommon::end_data_table_row(); - } - } - } - $domaintext.= &Apache::loncommon::end_data_table(); - if ($num_domain_level > 0) { - $r->print($domaintext); - $addrolesdisplay = 1; - } -# -# Course level -# - if ($env{'request.role'} =~ m{^dc\./($match_domain)/$}) { - $r->print(&course_level_dc($1,'Course')); - $r->print('
'."\n"); - } elsif ($env{'request.role'} =~ m{^au\./($match_domain)/$}) { - if ($addrolesdisplay) { - $r->print('
print(' onClick="verify_message(this.form)" \>'."\n"); + if ($env{'form.action'} eq 'singlestudent') { + $r->print('
'."\n"); + } else { + $r->print('

'.&mt('Add Roles').'

'); + my $addrolesdisplay = 0; + if ($context eq 'domain' || $context eq 'author') { + $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain); + } + if ($context eq 'domain') { + my $add_domainroles = &new_domain_roles($r); + if (!$addrolesdisplay) { + $addrolesdisplay = $add_domainroles; + } + $r->print(&course_level_dc($env{'request.role.domain'},'Course')); + $r->print('
'."\n"); + } elsif ($context eq 'author') { + if ($addrolesdisplay) { + $r->print('
print(' onClick="verify_message(this.form)" \>'."\n"); + } else { + $r->print('onClick="this.form.submit()" \>'."\n"); + } } else { - $r->print('onClick="this.form.submit()" \>'."\n"); + $r->print('
'. + &mt('Back to previous page').''); } } else { - $r->print('
'. - &mt('Back to previous page').''); + $r->print(&course_level_table(%inccourses)); + $r->print('
'."\n"); } - } else { - $r->print(&course_level_table(%inccourses)); - $r->print('
'."\n"); } $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain'])); $r->print(''); $r->print(''); $r->print("".&Apache::loncommon::end_page()); + return; } sub singleuser_breadcrumb { @@ -1208,6 +1111,124 @@ sub display_existing_roles { return; } +sub new_coauthor_roles { + my ($r,$ccuname,$ccdomain) = @_; + my $addrolesdisplay = 0; + # + # Co-Author + # + if (&Apache::lonuserutils::authorpriv($env{'user.name'}, + $env{'request.role.domain'}) && + ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { + # No sense in assigning co-author role to yourself + $addrolesdisplay = 1; + my $cuname=$env{'user.name'}; + my $cudom=$env{'request.role.domain'}; + my %lt=&Apache::lonlocal::texthash( + 'cs' => "Construction Space", + 'act' => "Activate", + 'rol' => "Role", + 'ext' => "Extent", + 'sta' => "Start", + 'end' => "End", + 'cau' => "Co-Author", + 'caa' => "Assistant Co-Author", + 'ssd' => "Set Start Date", + 'sed' => "Set End Date" + ); + $r->print('

'.$lt{'cs'}.'

'."\n". + &Apache::loncommon::start_data_table()."\n". + &Apache::loncommon::start_data_table_header_row()."\n". + ''.$lt{'act'}.''.$lt{'rol'}.''. + ''.$lt{'ext'}.''.$lt{'sta'}.''. + ''.$lt{'end'}.''."\n". + &Apache::loncommon::end_data_table_header_row()."\n". + &Apache::loncommon::start_data_table_row().' + + + + '.$lt{'cau'}.' + '.$cudom.'_'.$cuname.' + + '.$lt{'ssd'}.' + +'.$lt{'sed'}.''."\n". + &Apache::loncommon::end_data_table_row()."\n". + &Apache::loncommon::start_data_table_row()."\n". +' +'.$lt{'caa'}.' +'.$cudom.'_'.$cuname.' + +'.$lt{'ssd'}.' + +'.$lt{'sed'}.''."\n". + &Apache::loncommon::end_data_table_row()."\n". + &Apache::loncommon::end_data_table()); + } elsif ($env{'request.role'} =~ /^au\./) { + if (!(&Apache::lonuserutils::authorpriv($env{'user.name'}, + $env{'request.role.domain'}))) { + $r->print(''. + &mt('You do not have privileges to assign co-author roles.'). + ''); + } elsif (($env{'user.name'} eq $ccuname) && + ($env{'user.domain'} eq $ccdomain)) { + $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted')); + } + } + return $addrolesdisplay;; +} + +sub new_domain_roles { + my ($r) = @_; + my $addrolesdisplay = 0; + # + # Domain level + # + my $num_domain_level = 0; + my $domaintext = + '

'.&mt('Domain Level').'

'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Activate').''.&mt('Role').''. + &mt('Extent').''. + ''.&mt('Start').''.&mt('End').''. + &Apache::loncommon::end_data_table_header_row(); + foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) { + foreach my $role ('dc','li','dg','au','sc') { + if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) { + my $plrole=&Apache::lonnet::plaintext($role); + my %lt=&Apache::lonlocal::texthash( + 'ssd' => "Set Start Date", + 'sed' => "Set End Date" + ); + $num_domain_level ++; + $domaintext .= +&Apache::loncommon::start_data_table_row(). +' +'.$plrole.' +'.$thisdomain.' + +'.$lt{'ssd'}.' + +'.$lt{'sed'}.''. +&Apache::loncommon::end_data_table_row(); + } + } + } + $domaintext.= &Apache::loncommon::end_data_table(); + if ($num_domain_level > 0) { + $r->print($domaintext); + $addrolesdisplay = 1; + } + return $addrolesdisplay; +} + sub user_authentication { my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_; my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);