--- loncom/interface/loncreateuser.pm 2012/10/02 18:08:12 1.366 +++ loncom/interface/loncreateuser.pm 2014/02/19 17:12:52 1.394 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.366 2012/10/02 18:08:12 bisitz Exp $ +# $Id: loncreateuser.pm,v 1.394 2014/02/19 17:12:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -111,77 +111,51 @@ sub initialize_authen_forms { sub auth_abbrev { my %abv_auth = ( - krb5 => 'krb', - krb4 => 'krb', - internal => 'int', - localuth => 'loc', - unix => 'fsys', + krb5 => 'krb', + krb4 => 'krb', + internal => 'int', + localauth => 'loc', + unix => 'fsys', ); return %abv_auth; } # ==================================================== -sub portfolio_quota { +sub user_quotas { my ($ccuname,$ccdomain) = @_; my %lt = &Apache::lonlocal::texthash( 'usrt' => "User Tools", - 'disk' => "Disk space allocated to user's portfolio files", - 'cuqu' => "Current quota", 'cust' => "Custom quota", - 'defa' => "Default", 'chqu' => "Change quota", ); - my ($currquota,$quotatype,$inststatus,$defquota) = - &Apache::loncommon::get_user_quota($ccuname,$ccdomain); - my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain); - my ($longinsttype,$showquota,$custom_on,$custom_off,$defaultinfo); - if ($inststatus ne '') { - if ($usertypes->{$inststatus} ne '') { - $longinsttype = $usertypes->{$inststatus}; - } - } - $custom_on = ' '; - $custom_off = ' checked="checked" '; + my $quota_javascript = <<"END_SCRIPT"; END_SCRIPT - if ($quotatype eq 'custom') { - $custom_on = $custom_off; - $custom_off = ' '; - $showquota = $currquota; - if ($longinsttype eq '') { - $defaultinfo = &mt('For this user, the default quota would be [_1]' - .' Mb.',$defquota); - } else { - $defaultinfo = &mt("For this user, the default quota would be [_1]". - " Mb, as determined by the user's institutional". - " affiliation ([_2]).",$defquota,$longinsttype); - } - } else { - if ($longinsttype eq '') { - $defaultinfo = &mt('For this user, the default quota is [_1]' - .' Mb.',$defquota); - } else { - $defaultinfo = &mt("For this user, the default quota of [_1]". - " Mb, is determined by the user's institutional". - " affiliation ([_2]).",$defquota,$longinsttype); - } - } - + my $longinsttype; + my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain); my $output = $quota_javascript."\n". '

'.$lt{'usrt'}.'

'."\n". &Apache::loncommon::start_data_table(); @@ -189,29 +163,72 @@ END_SCRIPT if (&Apache::lonnet::allowed('mut',$ccdomain)) { $output .= &build_tools_display($ccuname,$ccdomain,'tools'); } - if (&Apache::lonnet::allowed('mpq',$ccdomain)) { - $output .= ''."\n". - ' '.$lt{'disk'}.''."\n". - ' '."\n". - &Apache::loncommon::start_data_table_row()."\n". - ' '.$lt{'cuqu'}.': '. - $currquota.' Mb.  '. - $defaultinfo.''."\n". - &Apache::loncommon::end_data_table_row()."\n". - &Apache::loncommon::start_data_table_row()."\n". - ' '.$lt{'chqu'}. - ':  '. - '  '. - ' Mb'."\n". - &Apache::loncommon::end_data_table_row()."\n"; - } + + my %titles = &Apache::lonlocal::texthash ( + portfolio => "Disk space allocated to user's portfolio files", + author => "Disk space allocated to user's Authoring Space (if role assigned)", + ); + foreach my $name ('portfolio','author') { + my ($currquota,$quotatype,$inststatus,$defquota) = + &Apache::loncommon::get_user_quota($ccuname,$ccdomain,$name); + if ($longinsttype eq '') { + if ($inststatus ne '') { + if ($usertypes->{$inststatus} ne '') { + $longinsttype = $usertypes->{$inststatus}; + } + } + } + my ($showquota,$custom_on,$custom_off,$defaultinfo); + $custom_on = ' '; + $custom_off = ' checked="checked" '; + if ($quotatype eq 'custom') { + $custom_on = $custom_off; + $custom_off = ' '; + $showquota = $currquota; + if ($longinsttype eq '') { + $defaultinfo = &mt('For this user, the default quota would be [_1]' + .' MB.',$defquota); + } else { + $defaultinfo = &mt("For this user, the default quota would be [_1]". + " MB, as determined by the user's institutional". + " affiliation ([_2]).",$defquota,$longinsttype); + } + } else { + if ($longinsttype eq '') { + $defaultinfo = &mt('For this user, the default quota is [_1]' + .' MB.',$defquota); + } else { + $defaultinfo = &mt("For this user, the default quota of [_1]". + " MB, is determined by the user's institutional". + " affiliation ([_2]).",$defquota,$longinsttype); + } + } + + if (&Apache::lonnet::allowed('mpq',$ccdomain)) { + $output .= ''."\n". + ' '.$titles{$name}.''."\n". + ' '."\n". + &Apache::loncommon::start_data_table_row()."\n". + ' '. + &mt('Current quota: [_1] MB',$currquota).'  '. + $defaultinfo.''."\n". + &Apache::loncommon::end_data_table_row()."\n". + &Apache::loncommon::start_data_table_row()."\n". + ' '.$lt{'chqu'}. + ':  '. + '  '. + ' '.&mt('MB').''."\n". + &Apache::loncommon::end_data_table_row()."\n"; + } + } $output .= &Apache::loncommon::end_data_table(); return $output; } @@ -223,7 +240,7 @@ sub build_tools_display { my %lt = &Apache::lonlocal::texthash ( 'blog' => "Personal User Blog", 'aboutme' => "Personal Information Page", - 'webdav' => "WebDAV access to authoring spaces (if SSL and author/co-author)", + 'webdav' => "WebDAV access to Authoring Spaces (if SSL and author/co-author)", 'portfolio' => "Personal User Portfolio", 'avai' => "Available", 'cusa' => "availability", @@ -233,13 +250,14 @@ sub build_tools_display { 'official' => 'Can request creation of official courses', 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', + 'textbook' => 'Can request creation of textbook courses', 'requestauthor' => 'Can request author space', ); if ($context eq 'requestcourses') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'requestcourses.official','requestcourses.unofficial', - 'requestcourses.community'); - @usertools = ('official','unofficial','community'); + 'requestcourses.community','requestcourses.textbook'); + @usertools = ('official','unofficial','community','textbook'); @options =('norequest','approval','autolimit','validate'); %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain); %reqtitles = &courserequest_titles(); @@ -428,12 +446,13 @@ sub coursereq_externaluser { 'official' => 'Can request creation of official courses', 'unofficial' => 'Can request creation of unofficial courses', 'community' => 'Can request creation of communities', + 'textbook' => 'Can request creation of textbook courses', ); %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'reqcrsotherdom.official','reqcrsotherdom.unofficial', - 'reqcrsotherdom.community'); - @usertools = ('official','unofficial','community'); + 'reqcrsotherdom.community','reqcrsotherdom.textbook'); + @usertools = ('official','unofficial','community','textbook'); @options = ('approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($cdom); my $optregex = join('|',@options); @@ -513,6 +532,7 @@ sub courserequest_titles { official => 'Official', unofficial => 'Unofficial', community => 'Communities', + textbook => 'Textbook', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -550,6 +570,15 @@ sub requestauthor_display { return %titles; } +sub requestchange_display { + my %titles = &Apache::lonlocal::texthash ( + approval => "availability set to 'on' (approval required)", + automatic => "availability set to 'on' (automatic approval)", + norequest => "availability set to 'off'", + ); + return %titles; +} + sub curr_requestauthor { my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_; return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH')); @@ -970,7 +999,7 @@ ENDSCRIPT $r->print(''); } } - $r->print('
'. + $r->print(''. &Apache::loncommon::start_data_table()."\n". &Apache::loncommon::start_data_table_header_row()."\n". ' '."\n"); @@ -1042,7 +1071,8 @@ sub print_user_query_page { } sub print_user_modification_page { - my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype,$brcrum) = @_; + my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype, + $brcrum,$showcredits) = @_; if (($ccuname eq '') || ($ccdomain eq '')) { my $usermsg = &mt('No username and/or domain provided.'); $env{'form.phase'} = ''; @@ -1133,7 +1163,7 @@ sub print_user_modification_page { my $groupslist = &Apache::lonuserutils::get_groupslist(); - my $js = &validation_javascript($context,$ccdomain,$pjump_def, + my $js = &validation_javascript($context,$ccdomain,$pjump_def,$crstype, $groupslist,$newuser,$formname,\%loaditem); my %breadcrumb_text = &singleuser_breadcrumb($crstype); my $helpitem = 'Course_Change_Privileges'; @@ -1176,10 +1206,13 @@ sub print_user_modification_page { ENDFORMINFO - my (%inccourses,$roledom); + my (%inccourses,$roledom,$defaultcredits); if ($context eq 'course') { $inccourses{$env{'request.course.id'}}=1; $roledom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + if ($showcredits) { + $defaultcredits = &Apache::lonuserutils::get_defaultcredits(); + } } elsif ($context eq 'author') { $roledom = $env{'request.role.domain'}; } elsif ($context eq 'domain') { @@ -1196,22 +1229,20 @@ ENDFORMINFO } } } + my $title = ''; if ($newuser) { my ($portfolioform,$domroleform); if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) || (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) { # Current user has quota or user tools modification privileges - $portfolioform = '
'.&portfolio_quota($ccuname,$ccdomain); + $portfolioform = '
'.&user_quotas($ccuname,$ccdomain); } - if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) { + if ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) && + ($ccdomain eq $env{'request.role.domain'})) { $domroleform = '
'.&domainrole_req($ccuname,$ccdomain); } &initialize_authen_forms($ccdomain,$formname); my %lt=&Apache::lonlocal::texthash( - 'cnu' => 'Create New User', - 'ast' => 'as a student', - 'ame' => 'as a member', - 'ind' => 'in domain', 'lg' => 'Login Data', 'hs' => "Home Server", ); @@ -1225,20 +1256,24 @@ $loginscript // ]]> -

$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain ENDTITLE if ($env{'form.action'} eq 'singlestudent') { if ($crstype eq 'Community') { - $r->print(' ('.$lt{'ame'}.')'); + $title = &mt('Create New User [_1] in domain [_2] as a member', + '"'.$ccuname.'"','"'.$ccdomain.'"'); } else { - $r->print(' ('.$lt{'ast'}.')'); + $title = &mt('Create New User [_1] in domain [_2] as a student', + '"'.$ccuname.'"','"'.$ccdomain.'"'); } + } else { + $title = &mt('Create New User [_1] in domain [_2]', + '"'.$ccuname.'"','"'.$ccdomain.'"'); } - $r->print('

'."\n".'
'); - my $personal_table = - &personal_data_display($ccuname,$ccdomain,$newuser,$context, - $inst_results{$ccuname.':'.$ccdomain}); - $r->print($personal_table); + $r->print('

'.$title.'

'."\n"); + $r->print('
'); + $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context, + $inst_results{$ccuname.':'.$ccdomain})); + # Option to disable student/employee ID conflict checking not offerred for new users. my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($ccdomain,'hserver', 'default','hide'); @@ -1319,39 +1354,28 @@ ENDAUTH $r->print($portfolioform.$domroleform); if ($env{'form.action'} eq 'singlestudent') { $r->print(&date_sections_select($context,$newuser,$formname, - $permission)); + $permission,$crstype,$ccuname, + $ccdomain,$showcredits)); } $r->print('
'); } else { # user already exists - my %lt=&Apache::lonlocal::texthash( - 'cup' => "Modify existing user: ", - 'ens' => "Enroll one student: ", - 'enm' => "Enroll one member: ", - 'id' => "in domain", - ); - $r->print(< -ENDCHANGEUSER + $r->print($start_page.$forminfo); if ($env{'form.action'} eq 'singlestudent') { if ($crstype eq 'Community') { - $r->print($lt{'enm'}); + $title = &mt('Enroll one member: [_1] in domain [_2]', + '"'.$ccuname.'"','"'.$ccdomain.'"'); } else { - $r->print($lt{'ens'}); + $title = &mt('Enroll one student: [_1] in domain [_2]', + '"'.$ccuname.'"','"'.$ccdomain.'"'); } } else { - $r->print($lt{'cup'}); - } - $r->print(' "'.$ccuname.'" '.$lt{'id'}.' "'.$ccdomain.'"'. - "\n".'
'); - my ($personal_table,$showforceid) = - &personal_data_display($ccuname,$ccdomain,$newuser,$context, - $inst_results{$ccuname.':'.$ccdomain}); - $r->print($personal_table); - if ($showforceid) { - $r->print(''.&Apache::lonuserutils::forceid_change($context).'
'); + $title = &mt('Modify existing user: [_1] in domain [_2]', + '"'.$ccuname.'"','"'.$ccdomain.'"'); } + $r->print('

'.$title.'

'."\n"); + $r->print('
'); + $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context, + $inst_results{$ccuname.':'.$ccdomain})); if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { $r->print('

'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'

'. &Apache::loncommon::start_data_table()); @@ -1369,23 +1393,21 @@ ENDCHANGEUSER my ($isadv,$isauthor) = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain); if ((!$isauthor) && - (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) { + (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) + && ($env{'request.role.domain'} eq $ccdomain)) { $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain); } $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname); if ((&Apache::lonnet::allowed('mpq',$ccdomain)) || (&Apache::lonnet::allowed('mut',$ccdomain))) { # Current user has quota modification privileges - $user_text{'quota'} = &portfolio_quota($ccuname,$ccdomain); + $user_text{'quota'} = &user_quotas($ccuname,$ccdomain); } if (!&Apache::lonnet::allowed('mpq',$ccdomain)) { if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { - # Get the user's portfolio information - my %portq = &Apache::lonnet::get('environment',['portfolioquota'], - $ccdomain,$ccuname); my %lt=&Apache::lonlocal::texthash( - 'dska' => "Disk space allocated to user's portfolio files", - 'youd' => "You do not have privileges to modify the portfolio quota for this user.", + 'dska' => "Disk quotas for user's portfolio and Authoring Space", + 'youd' => "You do not have privileges to modify the portfolio and/or Authoring Space quotas for this user.", 'ichr' => "If a change is required, contact a domain coordinator for the domain", ); $user_text{'quota'} = <print('
'); } - $r->print(&date_sections_select($context,$newuser,$formname)); - } + my $credits; + if ($showcredits) { + $credits = &get_user_credits($ccuname,$ccdomain,$defaultcredits); + if ($credits eq '') { + $credits = $defaultcredits; + } + } + $r->print(&date_sections_select($context,$newuser,$formname, + $permission,$crstype,$ccuname, + $ccdomain,$showcredits)); + } if ($gotdiv) { $r->print('
'); } @@ -1440,7 +1471,8 @@ ENDNOTOOLSPRIV } $r->print('
'."\n"); } else { - $r->print('

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

'); + $r->print('
'. + '
'.&mt('Add Roles').''); my $addrolesdisplay = 0; if ($context eq 'domain' || $context eq 'author') { $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain); @@ -1450,28 +1482,33 @@ ENDNOTOOLSPRIV if (!$addrolesdisplay) { $addrolesdisplay = $add_domainroles; } - $r->print(&course_level_dc($env{'request.role.domain'},'Course')); - $r->print('
'."\n"); + $r->print(&course_level_dc($env{'request.role.domain'},$showcredits)); + $r->print('
'. + '
'."\n"); } elsif ($context eq 'author') { if ($addrolesdisplay) { - $r->print('
print('
'. + '
print(' onclick="auth_check()" \>'."\n"); } else { $r->print('onclick="this.form.submit()" \>'."\n"); } } else { - $r->print('
'. + $r->print('
'. + ''. + '
'. &mt('Back to previous page').''); } } else { - $r->print(&course_level_table(%inccourses)); - $r->print('
'."\n"); + $r->print(&course_level_table(\%inccourses,$showcredits,$defaultcredits)); + $r->print('
'. + '
'."\n"); } } $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain'])); $r->print(''); - $r->print('
'); + $r->print('

'); return; } @@ -1495,22 +1532,32 @@ sub singleuser_breadcrumb { } sub date_sections_select { - my ($context,$newuser,$formname,$permission) = @_; + my ($context,$newuser,$formname,$permission,$crstype,$ccuname,$ccdomain, + $showcredits) = @_; + my $credits; + if ($showcredits) { + my $defaultcredits = &Apache::lonuserutils::get_defaultcredits(); + $credits = &get_user_credits($ccuname,$ccdomain,$defaultcredits); + if ($credits eq '') { + $credits = $defaultcredits; + } + } my $cid = $env{'request.course.id'}; my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid); my $date_table = '

'.&mt('Starting and Ending Dates').'

'."\n". &Apache::lonuserutils::date_setting_table(undef,undef,$context, undef,$formname,$permission); my $rowtitle = 'Section'; - my $secbox = '

'.&mt('Section').'

'."\n". + my $secbox = '

'.&mt('Section and Credits').'

'."\n". &Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle, - $permission); + $permission,$context,'',$crstype, + $showcredits,$credits); my $output = $date_table.$secbox; return $output; } sub validation_javascript { - my ($context,$ccdomain,$pjump_def,$groupslist,$newuser,$formname, + my ($context,$ccdomain,$pjump_def,$crstype,$groupslist,$newuser,$formname, $loaditem) = @_; my $dc_setcourse_code = ''; my $nondc_setsection_code = ''; @@ -1527,7 +1574,8 @@ sub validation_javascript { if ($context eq 'course') { $nondc_setsection_code = &Apache::lonuserutils::setsections_javascript($formname,$groupslist, - undef,$checkauth); + undef,$checkauth, + $crstype); } if ($checkauth) { $nondc_setsection_code .= @@ -1547,7 +1595,8 @@ sub validation_javascript { } sub display_existing_roles { - my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype) = @_; + my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype, + $showcredits) = @_; my $now=time; my %lt=&Apache::lonlocal::texthash( 'rer' => "Existing Roles", @@ -1556,6 +1605,7 @@ sub display_existing_roles { 'ren' => "Re-Enable", 'rol' => "Role", 'ext' => "Extent", + 'crd' => "Credits", 'sta' => "Start", 'end' => "End", ); @@ -1618,6 +1668,7 @@ sub display_existing_roles { my $delallowed=0; my $sortkey=$role_code; my $class='Unknown'; + my $credits=''; if ($area =~ m{^/($match_domain)/($match_courseid)} ) { $class='Course'; my ($coursedom,$coursedir) = ($1,$2); @@ -1646,6 +1697,15 @@ sub display_existing_roles { } $sortkey.="\0$coursedir"; $inccourses->{$cid}=1; + if (($showcredits) && ($class eq 'Course') && ($role_code eq 'st')) { + my $defaultcredits = $coursedata{'internal.defaultcredits'}; + $credits = + &get_user_credits($ccuname,$ccdomain,$defaultcredits, + $coursedom,$coursedir); + if ($credits eq '') { + $credits = $defaultcredits; + } + } if ((&Apache::lonnet::allowed('c'.$role_code,$coursedom.'/'.$coursedir)) || (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) { $allowed=1; @@ -1672,7 +1732,7 @@ sub display_existing_roles { } } if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) { - $carea.='
Section: '.$3; + $carea.='
'.&mt('Section: [_1]',$3); $sortkey.="\0$3"; if (!$allowed) { if ($env{'request.course.sec'} eq $3) { @@ -1702,7 +1762,7 @@ sub display_existing_roles { } } if ($role_code eq 'ca' || $role_code eq 'au' || $role_code eq 'aa') { - $class='Construction Space'; + $class='Authoring Space'; } elsif ($role_code eq 'su') { $class='System'; } else { @@ -1744,7 +1804,13 @@ sub display_existing_roles { } my $plaintext=''; if (!$croletitle) { - $plaintext=&Apache::lonnet::plaintext($role_code,$class) + $plaintext=&Apache::lonnet::plaintext($role_code,$class); + if (($showcredits) && ($credits ne '')) { + $plaintext .= '
'. + ''. + &mt('Credits: [_1]',$credits). + ''; + } } else { $plaintext= &mt('Customrole [_1][_2]defined by [_3]', @@ -1767,7 +1833,7 @@ sub display_existing_roles { my $rolesdisplay = 0; my %output = (); - foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') { + foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') { $output{$type} = ''; foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) { @@ -1793,25 +1859,25 @@ sub display_existing_roles { $contextrole = &mt('Existing Roles in this Course'); } } elsif ($env{'request.role'} =~ /^au\./) { - $contextrole = &mt('Existing Co-Author Roles in your Construction Space'); + $contextrole = &mt('Existing Co-Author Roles in your Authoring Space'); } else { $contextrole = &mt('Existing Roles in this Domain'); } - $r->print(' -

'.$lt{'rer'}.'

'. -'
'.$contextrole.'
'. + $r->print('
'. +'
'.$contextrole.''. &Apache::loncommon::start_data_table("LC_createuser"). &Apache::loncommon::start_data_table_header_row(). ''.$lt{'rev'}.''.$lt{'ren'}.''.$lt{'del'}. ''.$lt{'rol'}.''.$lt{'ext'}. ''.$lt{'sta'}.''.$lt{'end'}.''. &Apache::loncommon::end_data_table_header_row()); - foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') { + foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') { if ($output{$type}) { $r->print($output{$type}."\n"); } } - $r->print(&Apache::loncommon::end_data_table()); + $r->print(&Apache::loncommon::end_data_table(). + '
'); } return; } @@ -1830,7 +1896,7 @@ sub new_coauthor_roles { my $cuname=$env{'user.name'}; my $cudom=$env{'request.role.domain'}; my %lt=&Apache::lonlocal::texthash( - 'cs' => "Construction Space", + 'cs' => "Authoring Space", 'act' => "Activate", 'rol' => "Role", 'ext' => "Extent", @@ -1881,7 +1947,7 @@ sub new_coauthor_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')); + $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Authoring Space is not permitted')); } } return $addrolesdisplay;; @@ -2097,13 +2163,37 @@ sub modify_login_block { } sub personal_data_display { - my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray) = @_; - my ($output,$showforceid,%userenv,%canmodify,%canmodify_status); + my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray, + $now,$captchaform,$emailusername) = @_; + my ($output,%userenv,%canmodify,%canmodify_status); my @userinfo = ('firstname','middlename','lastname','generation', 'permanentemail','id'); my $rowcount = 0; my $editable = 0; - %canmodify_status = + my %textboxsize = ( + firstname => '15', + middlename => '15', + lastname => '15', + generation => '5', + permanentemail => '25', + id => '15', + ); + + my %lt=&Apache::lonlocal::texthash( + 'pd' => "Personal Data", + 'firstname' => "First Name", + 'middlename' => "Middle Name", + 'lastname' => "Last Name", + 'generation' => "Generation", + 'permanentemail' => "Permanent e-mail address", + 'id' => "Student/Employee ID", + 'lg' => "Login Data", + 'inststatus' => "Affiliation", + 'email' => 'E-mail address', + 'valid' => 'Validation', + ); + + %canmodify_status = &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain, ['inststatus'],$rolesarray); if (!$newuser) { @@ -2115,31 +2205,53 @@ sub personal_data_display { &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain, \@userinfo,$rolesarray); } elsif ($context eq 'selfcreate') { - %canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo, - $inst_results,$rolesarray); + if ($newuser eq 'email') { + if (ref($emailusername) eq 'HASH') { + my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); + @userinfo = (); + if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) { + foreach my $field (@{$infofields}) { + if ($emailusername->{$field}) { + push(@userinfo,$field); + $canmodify{$field} = 1; + unless ($textboxsize{$field}) { + $textboxsize{$field} = 25; + } + unless ($lt{$field}) { + $lt{$field} = $infotitles->{$field}; + } + } + } + } + } + } else { + %canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo, + $inst_results,$rolesarray); + } } - my %lt=&Apache::lonlocal::texthash( - 'pd' => "Personal Data", - 'firstname' => "First Name", - 'middlename' => "Middle Name", - 'lastname' => "Last Name", - 'generation' => "Generation", - 'permanentemail' => "Permanent e-mail address", - 'id' => "Student/Employee ID", - 'lg' => "Login Data", - 'inststatus' => "Affiliation", - ); - my %textboxsize = ( - firstname => '15', - middlename => '15', - lastname => '15', - generation => '5', - permanentemail => '25', - id => '15', - ); + my $genhelp=&Apache::loncommon::help_open_topic('Generation'); $output = '

'.$lt{'pd'}.'

'. &Apache::lonhtmlcommon::start_pick_box(); + if (($context eq 'selfcreate') && ($newuser eq 'email')) { + $output .= &Apache::lonhtmlcommon::row_title($lt{'email'},undef, + 'LC_oddrow_value')."\n". + ''; + $rowcount ++; + $output .= &Apache::lonhtmlcommon::row_closure(1); + my $upassone = ''; + my $upasstwo = ''; + $output .= &Apache::lonhtmlcommon::row_title(&mt('Password'), + 'LC_pick_box_title', + 'LC_oddrow_value')."\n". + $upassone."\n". + &Apache::lonhtmlcommon::row_closure(1)."\n". + &Apache::lonhtmlcommon::row_title(&mt('Confirm password'), + 'LC_pick_box_title', + 'LC_oddrow_value')."\n". + $upasstwo. + &Apache::lonhtmlcommon::row_closure()."\n"; + } foreach my $item (@userinfo) { my $rowtitle = $lt{$item}; my $hiderow = 0; @@ -2153,8 +2265,8 @@ sub personal_data_display { $row .= ''.$inst_results->{$item}; } else { if ($context eq 'selfcreate') { - if ($canmodify{$item}) { - $row .= ''; + if ($canmodify{$item}) { + $row .= ''; $editable ++; } else { $hiderow = 1; @@ -2169,7 +2281,11 @@ sub personal_data_display { $row .= $ccuname; } else { if ($canmodify{$item}) { - $row .= ''; + if ($newuser eq 'email') { + $row .= ''; + } else { + $row .= ''; + } $editable ++; } else { $hiderow = 1; @@ -2182,12 +2298,12 @@ sub personal_data_display { } else { if ($canmodify{$item}) { $row .= ''; + if (($item eq 'id') && (!$newuser)) { + $row .= '
'.&Apache::lonuserutils::forceid_change($context); + } } else { $row .= $userenv{$item}; } - if ($item eq 'id') { - $showforceid = $canmodify{$item}; - } } $row .= &Apache::lonhtmlcommon::row_closure(1); if (!$hiderow) { @@ -2222,7 +2338,7 @@ sub personal_data_display { } } if (!$hiderow) { - my $row = &Apache::lonhtmlcommon::row_title(&mt('Affliations'),undef,'LC_oddrow_value')."\n". + my $row = &Apache::lonhtmlcommon::row_title(&mt('Affiliations'),undef,'LC_oddrow_value')."\n". $shown.&Apache::lonhtmlcommon::row_closure(1); if ($context eq 'selfcreate') { $rowcount ++; @@ -2232,12 +2348,26 @@ sub personal_data_display { } } } + if (($context eq 'selfcreate') && ($newuser eq 'email')) { + if ($captchaform) { + $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'}, + 'LC_pick_box_title')."\n". + $captchaform."\n".'

'. + &Apache::lonhtmlcommon::row_closure(1); + $rowcount ++; + } + my $submit_text = &mt('Create account'); + $output .= &Apache::lonhtmlcommon::row_title()."\n". + '
'. + &Apache::lonhtmlcommon::row_closure(1); + } $output .= &Apache::lonhtmlcommon::end_pick_box(); if (wantarray) { if ($context eq 'selfcreate') { return($output,$rowcount,$editable); } else { - return ($output,$showforceid); + return $output; } } else { return $output; @@ -2314,7 +2444,7 @@ sub get_inststatuses { # ================================================================= Phase Three sub update_user_data { - my ($r,$context,$crstype,$brcrum) = @_; + my ($r,$context,$crstype,$brcrum,$showcredits) = @_; my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'}, $env{'form.ccdomain'}); # Error messages @@ -2402,9 +2532,12 @@ sub update_user_data { if (! exists($env{'form.makeuser'})) { # Modifying an existing user, so check the validity of the name if ($uhome eq 'no_host') { - $r->print($error.&mt('Unable to determine home server for '). - $env{'form.ccuname'}.&mt(' in domain '). - $env{'form.ccdomain'}.'.'); + $r->print( + $error + .'

' + .&mt('Unable to determine home server for [_1] in domain [_2].', + '"'.$env{'form.ccuname'}.'"','"'.$env{'form.ccdomain'}.'"') + .'

'); return; } } @@ -2432,18 +2565,19 @@ sub update_user_data { # If they are creating a new user but have not specified login # information this will be caught below. } else { - $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink); - return; + $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink); + return; } $r->print('

'.&mt('User [_1] in domain [_2]', - $env{'form.ccuname'}, $env{'form.ccdomain'}).'

'); - $r->print('

'.&mt('Please be patient').'

'); + $env{'form.ccuname'}.' ('.&Apache::loncommon::plainname($env{'form.ccuname'}, + $env{'form.ccdomain'}).')', $env{'form.ccdomain'}).''); + my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,2); my (%alerts,%rulematch,%inst_results,%curr_rules); my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); my @usertools = ('aboutme','blog','webdav','portfolio'); - my @requestcourses = ('official','unofficial','community'); + my @requestcourses = ('official','unofficial','community','textbook'); my @requestauthor = ('requestauthor'); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'}); @@ -2499,6 +2633,7 @@ sub update_user_data { } } } + &Apache::lonhtmlcommon::Increment_PrgWin($r, \%prog_state); # Call modifyuser my $result = &Apache::lonnet::modifyuser ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'}, @@ -2512,14 +2647,18 @@ sub update_user_data { my (%changeHash,%newcustom,%changed,%changedinfo); if ($uhome ne 'no_host') { if ($context eq 'domain') { - if ($env{'form.customquota'} == 1) { - if ($env{'form.portfolioquota'} eq '') { - $newcustom{'quota'} = 0; - } else { - $newcustom{'quota'} = $env{'form.portfolioquota'}; - $newcustom{'quota'} =~ s/[^\d\.]//g; + foreach my $name ('portfolio','author') { + if ($env{'form.custom_'.$name.'quota'} == 1) { + if ($env{'form.'.$name.'quota'} eq '') { + $newcustom{$name.'quota'} = 0; + } else { + $newcustom{$name.'quota'} = $env{'form.'.$name.'quota'}; + $newcustom{$name.'quota'} =~ s/[^\d\.]//g; + } + if ("a_admin($newcustom{$name.'quota'},\%changeHash,$name)) { + $changed{$name.'quota'} = 1; + } } - $changed{'quota'} = "a_admin($newcustom{'quota'},\%changeHash); } foreach my $item (@usertools) { if ($env{'form.custom'.$item} == 1) { @@ -2533,7 +2672,8 @@ sub update_user_data { $newcustom{$item} = $env{'form.crsreq_'.$item}; if ($env{'form.crsreq_'.$item} eq 'autolimit') { $newcustom{$item} .= '='; - unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) { + $env{'form.crsreq_'.$item.'_limit'} =~ s/\D+//g; + if ($env{'form.crsreq_'.$item.'_limit'}) { $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'}; } } @@ -2588,24 +2728,28 @@ sub update_user_data { $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end); } } - $r->rflush(); # Finish display of header before time consuming actions start - + &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state); ## - my (@userroles,%userupdate,$cnum,$cdom,%namechanged); + my (@userroles,%userupdate,$cnum,$cdom,$defaultcredits,%namechanged); if ($context eq 'course') { - ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity(); + ($cnum,$cdom) = + &Apache::lonuserutils::get_course_identity(); $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum); + if ($showcredits) { + $defaultcredits = &Apache::lonuserutils::get_defaultcredits($cdom,$cnum); + } } if (! $env{'form.makeuser'} ) { # Check for need to change my %userenv = &Apache::lonnet::get ('environment',['firstname','middlename','lastname','generation', - 'id','permanentemail','portfolioquota','inststatus','tools.aboutme', - 'tools.blog','tools.webdav','tools.portfolio', + 'id','permanentemail','portfolioquota','authorquota','inststatus', + 'tools.aboutme','tools.blog','tools.webdav','tools.portfolio', 'requestcourses.official','requestcourses.unofficial', - 'requestcourses.community','reqcrsotherdom.official', - 'reqcrsotherdom.unofficial','reqcrsotherdom.community', + 'requestcourses.community','requestcourses.textbook', + 'reqcrsotherdom.official','reqcrsotherdom.unofficial', + 'reqcrsotherdom.community','reqcrsotherdom.textbook', 'requestauthor'], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); @@ -2728,10 +2872,10 @@ sub update_user_data { } } } - my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus, - $newinststatus,$oldisdefault,$newisdefault,%oldsettings, + my (%quotachanged,%oldquota,%newquota,%olddefquota,%newdefquota, + $oldinststatus,$newinststatus,%oldisdefault,%newisdefault,%oldsettings, %oldsettingstext,%newsettings,%newsettingstext,@disporder, - $olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus); + %oldsettingstatus,%newsettingstatus); @disporder = ('inststatus'); if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) { push(@disporder,'requestcourses','requestauthor'); @@ -2740,9 +2884,11 @@ sub update_user_data { } push(@disporder,('quota','tools')); $oldinststatus = $userenv{'inststatus'}; - ($olddefquota,$oldsettingstatus) = - &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus); - ($newdefquota,$newsettingstatus) = ($olddefquota,$oldsettingstatus); + foreach my $name ('portfolio','author') { + ($olddefquota{$name},$oldsettingstatus{$name}) = + &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name); + ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name}); + } my %canshow; if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) { $canshow{'quota'} = 1; @@ -2781,8 +2927,10 @@ sub update_user_data { $changeHash{'inststatus'} = $newinststatus; if ($newinststatus ne $oldinststatus) { $changed{'inststatus'} = $newinststatus; - ($newdefquota,$newsettingstatus) = - &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus); + foreach my $name ('portfolio','author') { + ($newdefquota{$name},$newsettingstatus{$name}) = + &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name); + } } if (ref($usertypes) eq 'HASH') { $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses)); @@ -2796,61 +2944,78 @@ sub update_user_data { $newsettings{'inststatus'} = $othertitle; if ($newinststatus ne $oldinststatus) { $changed{'inststatus'} = $changeHash{'inststatus'}; - ($newdefquota,$newsettingstatus) = - &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus); + foreach my $name ('portfolio','author') { + ($newdefquota{$name},$newsettingstatus{$name}) = + &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name); + } } } } elsif ($context ne 'selfcreate') { $canshow{'inststatus'} = 1; $newsettings{'inststatus'} = $oldsettings{'inststatus'}; } - $changeHash{'portfolioquota'} = $userenv{'portfolioquota'}; + foreach my $name ('portfolio','author') { + $changeHash{$name.'quota'} = $userenv{$name.'quota'}; + } if ($context eq 'domain') { - if ($userenv{'portfolioquota'} ne '') { - $oldportfolioquota = $userenv{'portfolioquota'}; - if ($env{'form.customquota'} == 1) { - if ($env{'form.portfolioquota'} eq '') { - $newportfolioquota = 0; + foreach my $name ('portfolio','author') { + if ($userenv{$name.'quota'} ne '') { + $oldquota{$name} = $userenv{$name.'quota'}; + if ($env{'form.custom_'.$name.'quota'} == 1) { + if ($env{'form.'.$name.'quota'} eq '') { + $newquota{$name} = 0; + } else { + $newquota{$name} = $env{'form.'.$name.'quota'}; + $newquota{$name} =~ s/[^\d\.]//g; + } + if ($newquota{$name} != $oldquota{$name}) { + if ("a_admin($newquota{$name},\%changeHash,$name)) { + $changed{$name.'quota'} = 1; + } + } } else { - $newportfolioquota = $env{'form.portfolioquota'}; - $newportfolioquota =~ s/[^\d\.]//g; - } - if ($newportfolioquota != $oldportfolioquota) { - $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash); + if ("a_admin('',\%changeHash,$name)) { + $changed{$name.'quota'} = 1; + $newquota{$name} = $newdefquota{$name}; + $newisdefault{$name} = 1; + } } } else { - $changed{'quota'} = "a_admin('',\%changeHash); - $newportfolioquota = $newdefquota; - $newisdefault = 1; - } - } else { - $oldisdefault = 1; - $oldportfolioquota = $olddefquota; - if ($env{'form.customquota'} == 1) { - if ($env{'form.portfolioquota'} eq '') { - $newportfolioquota = 0; + $oldisdefault{$name} = 1; + $oldquota{$name} = $olddefquota{$name}; + if ($env{'form.custom_'.$name.'quota'} == 1) { + if ($env{'form.'.$name.'quota'} eq '') { + $newquota{$name} = 0; + } else { + $newquota{$name} = $env{'form.'.$name.'quota'}; + $newquota{$name} =~ s/[^\d\.]//g; + } + if ("a_admin($newquota{$name},\%changeHash,$name)) { + $changed{$name.'quota'} = 1; + } } else { - $newportfolioquota = $env{'form.portfolioquota'}; - $newportfolioquota =~ s/[^\d\.]//g; + $newquota{$name} = $newdefquota{$name}; + $newisdefault{$name} = 1; } - $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash); + } + if ($oldisdefault{$name}) { + $oldsettingstext{'quota'}{$name} = &get_defaultquota_text($oldsettingstatus{$name}); + } else { + $oldsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$oldquota{$name}); + } + if ($newisdefault{$name}) { + $newsettingstext{'quota'}{$name} = &get_defaultquota_text($newsettingstatus{$name}); } else { - $newportfolioquota = $newdefquota; - $newisdefault = 1; + $newsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$newquota{$name}); } } - if ($oldisdefault) { - $oldsettingstext{'quota'} = &get_defaultquota_text($oldsettingstatus); - } - if ($newisdefault) { - $newsettingstext{'quota'} = &get_defaultquota_text($newsettingstatus); - } &tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv, \%changeHash,\%changed,\%newsettings,\%newsettingstext); if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) { &tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext, \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); - &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); + &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext, + \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); } else { &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext, \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext); @@ -2861,8 +3026,10 @@ sub update_user_data { $namechanged{$item} = 1; } } - $oldsettings{'quota'} = $oldportfolioquota.' Mb'; - $newsettings{'quota'} = $newportfolioquota.' Mb'; + foreach my $name ('portfolio','author') { + $oldsettings{'quota'}{$name} = &mt('[_1] MB',$oldquota{$name}); + $newsettings{'quota'}{$name} = &mt('[_1] MB',$newquota{$name}); + } if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) { my ($chgresult,$namechgresult); if (keys(%changed) > 0) { @@ -2902,7 +3069,8 @@ sub update_user_data { $changeHash{'tools.'.$key}; } else { $newenvhash{'environment.availabletools.'.$key} = - &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, $key,'reload','tools'); + &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, + $key,'reload','tools'); } } } @@ -2959,9 +3127,12 @@ sub update_user_data { &Apache::lonnet::appenv(\%newenvhash); } } else { # error occurred - $r->print(''.&mt('Unable to successfully change environment for').' '. - $env{'form.ccuname'}.' '.&mt('in domain').' '. - $env{'form.ccdomain'}.'
'); + $r->print( + '

' + .&mt('Unable to successfully change environment for [_1] in domain [_2].', + '"'.$env{'form.ccuname'}.'"', + '"'.$env{'form.ccdomain'}.'"') + .'

'); } } else { # End of if ($env ... ) logic # They did not want to change the users name, quota, tool availability, @@ -3005,17 +3176,20 @@ sub update_user_data { .&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts,\%curr_rules) .''); } + &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); if ($env{'form.action'} eq 'singlestudent') { - &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype); - $r->print('

'); - if ($crstype eq 'Community') { - $r->print(&mt('Enroll Another Member')); - } else { - $r->print(&mt('Enroll Another Student')); - } - $r->print('

'); + &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context, + $crstype,$showcredits,$defaultcredits); + my $linktext = ($crstype eq 'Community' ? + &mt('Enroll Another Member') : &mt('Enroll Another Student')); + $r->print( + &Apache::lonhtmlcommon::actionbox([ + '' + .($crstype eq 'Community' ? + &mt('Enroll Another Member') : &mt('Enroll Another Student')) + .''])); } else { - my @rolechanges = &update_roles($r,$context); + my @rolechanges = &update_roles($r,$context,$showcredits); if (keys(%namechanged) > 0) { if ($context eq 'course') { if (@userroles > 0) { @@ -3036,10 +3210,9 @@ sub update_user_data { if ($env{'form.popup'}) { $r->print('

'.&mt('Close window').'

'); } else { - $r->print('

' - .&mt('Modify this user: [_1]',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.')').'' - .(' 'x5).'' - .&mt('Create/Modify Another User').'

'); + $r->print('
'.&Apache::lonhtmlcommon::actionbox(['' + .&mt('Modify this user: [_1]',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.')').'', + ''.&mt('Create/Modify Another User').''])); } } } @@ -3060,7 +3233,7 @@ sub display_userinfo { ref($newsetting) eq 'HASH' && ref($newsettingtext) eq 'HASH'); my %lt=&Apache::lonlocal::texthash( - 'ui' => 'User Information (unchanged)', + 'ui' => 'User Information', 'uic' => 'User Information Changed', 'firstname' => 'First Name', 'middlename' => 'Middle Name', @@ -3068,7 +3241,8 @@ sub display_userinfo { 'generation' => 'Generation', 'id' => 'Student/Employee ID', 'permanentemail' => 'Permanent e-mail address', - 'quota' => 'Disk space allocated to portfolio files', + 'portfolioquota' => 'Disk space allocated to portfolio files', + 'authorquota' => 'Disk space allocated to Authoring Space', 'blog' => 'Blog Availability', 'webdav' => 'WebDAV Availability', 'aboutme' => 'Personal Information Page Availability', @@ -3076,104 +3250,105 @@ sub display_userinfo { 'official' => 'Can Request Official Courses', 'unofficial' => 'Can Request Unofficial Courses', 'community' => 'Can Request Communities', + 'textbook' => 'Can Request Textbook Courses', 'requestauthor' => 'Can Request Author Role', 'inststatus' => "Affiliation", 'prvs' => 'Previous Value:', 'chto' => 'Changed To:' ); - my $title = $lt{'ui'}; - if ($changed) { - $title = $lt{'uic'}; - } - $r->print('

'.$title.'

'. - &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row()); if ($changed) { + $r->print('

'.$lt{'uic'}.'

'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row()); $r->print(" \n"); - } - my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); - foreach my $item (@userinfo) { - $r->print("$lt{$item}\n"); - } - foreach my $entry (@{$order}) { - if ($canshow->{$entry}) { - if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) { - foreach my $item (@{$requestcourses}) { - $r->print("$lt{$item}\n"); - } - } elsif ($entry eq 'tools') { - foreach my $item (@{$usertools}) { - $r->print("$lt{$item}\n"); - } - } else { - $r->print("$lt{$entry}\n"); - } - } - } - $r->print(&Apache::loncommon::end_data_table_header_row(). - &Apache::loncommon::start_data_table_row()); - if ($changed) { - $r->print(''.$lt{'prvs'}.''."\n"); - } - foreach my $item (@userinfo) { - $r->print(''.$userenv->{$item}.' '."\n"); - } - foreach my $entry (@{$order}) { - if ($canshow->{$entry}) { - if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) { - foreach my $item (@{$requestcourses}) { - $r->print("$oldsetting->{$item} $oldsettingtext->{$item}\n"); - } - } elsif ($entry eq 'tools') { - foreach my $item (@{$usertools}) { - $r->print("$oldsetting->{$item} $oldsettingtext->{$item}\n"); - } - } else { - $r->print("$oldsetting->{$entry} $oldsettingtext->{$entry} \n"); - } - } - } - $r->print(&Apache::loncommon::end_data_table_row()); - if ($changed) { - $r->print(&Apache::loncommon::start_data_table_row(). - ''.$lt{'chto'}.''."\n"); + $r->print(''.$lt{'prvs'}.''); + $r->print(''.$lt{'chto'}.''); + $r->print(&Apache::loncommon::end_data_table_header_row()); + my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); + foreach my $item (@userinfo) { my $value = $env{'form.c'.$item}; - if ($namechangedhash->{$item}) { - $value = ''.$value.''; + #show changes only: + unless ($value eq $userenv->{$item}){ + $r->print(&Apache::loncommon::start_data_table_row()); + $r->print("$lt{$item}\n"); + $r->print("".$userenv->{$item}."\n"); + $r->print("$value \n"); + $r->print(&Apache::loncommon::end_data_table_row()); } - $r->print("$value \n"); } foreach my $entry (@{$order}) { if ($canshow->{$entry}) { - if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) { - foreach my $item (@{$requestcourses}) { - my $value = $newsetting->{$item}.' '.$newsettingtext->{$item}; - if ($changedhash->{$item}) { - $value = ''.$value.''; + if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom') || ($entry eq 'requestauthor')) { + my @items; + if ($entry eq 'requestauthor') { + @items = ($entry); + } else { + @items = @{$requestcourses}; + } + foreach my $item (@items) { + if (($newsetting->{$item} ne $oldsetting->{$item}) || + ($newsettingtext->{$item} ne $oldsettingtext->{$item})) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$item}\n"); + $r->print("".$oldsetting->{$item}); + if ($oldsettingtext->{$item}) { + if ($oldsetting->{$item}) { + $r->print(' -- '); + } + $r->print($oldsettingtext->{$item}); + } + $r->print("\n"); + $r->print("".$newsetting->{$item}); + if ($newsettingtext->{$item}) { + if ($newsetting->{$item}) { + $r->print(' -- '); + } + $r->print($newsettingtext->{$item}); + } + $r->print("\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); } - $r->print("$value \n"); } } elsif ($entry eq 'tools') { foreach my $item (@{$usertools}) { - my $value = $newsetting->{$item}.' '.$newsettingtext->{$item}; - if ($changedhash->{$item}) { - $value = ''.$value.''; + if ($newsetting->{$item} ne $oldsetting->{$item}) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$item}\n"); + $r->print("".$oldsetting->{$item}.' '.$oldsettingtext->{$item}."\n"); + $r->print("".$newsetting->{$item}.' '.$newsettingtext->{$item}."\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); + } + } + } elsif ($entry eq 'quota') { + if ((ref($oldsetting->{$entry}) eq 'HASH') && (ref($oldsettingtext->{$entry}) eq 'HASH') && + (ref($newsetting->{$entry}) eq 'HASH') && (ref($newsettingtext->{$entry}) eq 'HASH')) { + foreach my $name ('portfolio','author') { + if ($newsetting->{$entry}->{$name} ne $oldsetting->{$entry}->{$name}) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$name.$entry}\n"); + $r->print("".$oldsettingtext->{$entry}->{$name}."\n"); + $r->print("".$newsettingtext->{$entry}->{$name}."\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); + } } - $r->print("$value \n"); } } else { - my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry}; - if ($changedhash->{$entry}) { - $value = ''.$value.''; + if ($newsetting->{$entry} ne $oldsetting->{$entry}) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$entry}\n"); + $r->print("".$oldsetting->{$entry}.' '.$oldsettingtext->{$entry}."\n"); + $r->print("".$newsetting->{$entry}.' '.$newsettingtext->{$entry}."\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); } - $r->print("$value \n"); } } } - $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table().'
'); + } else { + $r->print('

'.$lt{'ui'}.'

'. + '

'.&mt('No changes made to user information').'

'); } - $r->print(&Apache::loncommon::end_data_table().'
'); return; } @@ -3186,20 +3361,20 @@ sub tool_changes { (ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) { return; } + my %reqdisplay = &requestchange_display(); if ($context eq 'reqcrsotherdom') { my @options = ('approval','validate','autolimit'); my $optregex = join('|',@options); - my %reqdisplay = &courserequest_display(); my $cdom = $env{'request.role.domain'}; foreach my $tool (@{$usertools}) { - $oldaccesstext->{$tool} = &mt('No'); + $oldaccesstext->{$tool} = &mt("availability set to 'off'"); $newaccesstext->{$tool} = $oldaccesstext->{$tool}; $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool}; - my $newop; + my ($newop,$limit); if ($env{'form.'.$context.'_'.$tool}) { $newop = $env{'form.'.$context.'_'.$tool}; if ($newop eq 'autolimit') { - my $limit = $env{'form.'.$context.'_'.$tool.'_limit'}; + $limit = $env{'form.'.$context.'_'.$tool.'_limit'}; $limit =~ s/\D+//g; $newop .= '='.$limit; } @@ -3209,7 +3384,15 @@ sub tool_changes { $changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop, $changeHash,$context); if ($changed->{$tool}) { - $newaccesstext->{$tool} = &mt('Yes'); + if ($newop =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } else { + $newaccesstext->{$tool} = $reqdisplay{$newop}; + } } else { $newaccesstext->{$tool} = $oldaccesstext->{$tool}; } @@ -3220,8 +3403,17 @@ sub tool_changes { my $changedoms; foreach my $req (@curr) { if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) { - $oldaccesstext->{$tool} = &mt('Yes'); my $oldop = $1; + if ($oldop =~ /^autolimit=(\d*)/) { + my $limit = $1; + if ($limit) { + $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } else { + $oldaccesstext->{$tool} = $reqdisplay{$oldop}; + } if ($oldop ne $newop) { $changedoms = 1; foreach my $item (@curr) { @@ -3255,15 +3447,15 @@ sub tool_changes { my $limit = $env{'form.'.$context.'_'.$tool.'_limit'}; $limit =~ s/\D+//g; if ($limit) { - $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user.',$limit); + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); } else { - $newaccesstext->{$tool} = &mt('Yes, processed automatically'); + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); } } else { $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}}; } } else { - $newaccesstext->{$tool} = &mt('No'); + $newaccesstext->{$tool} = &mt("availability set to 'off'"); } } } @@ -3272,12 +3464,14 @@ sub tool_changes { return; } foreach my $tool (@{$usertools}) { - my ($newval,$envkey); + my ($newval,$limit,$envkey); $envkey = $context.'.'.$tool; if ($context eq 'requestcourses') { $newval = $env{'form.crsreq_'.$tool}; if ($newval eq 'autolimit') { - $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'}; + $limit = $env{'form.crsreq_'.$tool.'_limit'}; + $limit =~ s/\D+//g; + $newval .= '='.$limit; } } elsif ($context eq 'requestauthor') { $newval = $env{'form.'.$context}; @@ -3287,10 +3481,25 @@ sub tool_changes { } if ($userenv->{$envkey} ne '') { $oldaccess->{$tool} = &mt('custom'); - if ($userenv->{$envkey}) { - $oldaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($userenv->{$envkey} =~ /^autolimit=(\d*)$/) { + my $currlimit = $1; + if ($currlimit eq '') { + $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } else { + $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$currlimit); + } + } elsif ($userenv->{$envkey}) { + $oldaccesstext->{$tool} = $reqdisplay{$userenv->{$envkey}}; + } else { + $oldaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $oldaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($userenv->{$envkey}) { + $oldaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $oldaccesstext->{$tool} = &mt("availability set to 'off'"); + } } $changeHash->{$envkey} = $userenv->{$envkey}; if ($env{'form.custom'.$tool} == 1) { @@ -3299,17 +3508,45 @@ sub tool_changes { $context); if ($changed->{$tool}) { $newaccess->{$tool} = &mt('custom'); - if ($newval) { - $newaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($newval =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } elsif ($newval) { + $newaccesstext->{$tool} = $reqdisplay{$newval}; + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $newaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($newval) { + $newaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } } else { $newaccess->{$tool} = $oldaccess->{$tool}; - if ($userenv->{$context.'.'.$tool}) { - $newaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($newval =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } elsif ($newval) { + $newaccesstext->{$tool} = $reqdisplay{$newval}; + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $newaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($userenv->{$context.'.'.$tool}) { + $newaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } } } else { @@ -3322,10 +3559,24 @@ sub tool_changes { $newaccess->{$tool} = &mt('default'); } else { $newaccess->{$tool} = $oldaccess->{$tool}; - if ($userenv->{$context.'.'.$tool}) { - $newaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($newval =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } elsif ($newval) { + $newaccesstext->{$tool} = $reqdisplay{$newval}; + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $newaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($userenv->{$context.'.'.$tool}) { + $newaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } } } @@ -3336,10 +3587,24 @@ sub tool_changes { $context); if ($changed->{$tool}) { $newaccess->{$tool} = &mt('custom'); - if ($newval) { - $newaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($newval =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } elsif ($newval) { + $newaccesstext->{$tool} = $reqdisplay{$newval}; + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $newaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($newval) { + $newaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } } else { $newaccess->{$tool} = $oldaccess->{$tool}; @@ -3353,7 +3618,7 @@ sub tool_changes { } sub update_roles { - my ($r,$context) = @_; + my ($r,$context,$showcredits) = @_; my $now=time; my @rolechanges; my %disallowed; @@ -3370,14 +3635,20 @@ sub update_roles { &Apache::lonnet::revokerole($env{'form.ccdomain'}, $env{'form.ccuname'}, $scope,$role,'','',$context); - $r->print(&mt('Revoking [_1] in [_2]: [_3]', - $role,$scope,''.$result.'').'
'); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Revoking [_1] in [_2]', + &Apache::lonnet::plaintext($role), + &Apache::loncommon::show_role_extent($scope,$context,$role)), + $result ne "ok").'
'); + if ($result ne "ok") { + $r->print(&mt('Error: [_1]',$result).'
'); + } if ($role eq 'st') { my $result = &Apache::lonuserutils::classlist_drop($scope, $env{'form.ccuname'},$env{'form.ccdomain'}, $now); - $r->print($result); + $r->print(&Apache::lonhtmlcommon::confirm_success($result)); } if (!grep(/^\Q$role\E$/,@rolechanges)) { push(@rolechanges,$role); @@ -3385,11 +3656,15 @@ sub update_roles { } if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}s) { # Revoke 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,'','',$context). - '
'); + my $result = &Apache::lonnet::revokecustomrole( + $env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Revoking custom role [_1] by [_2] in [_3]', + $4,$3.':'.$2,&Apache::loncommon::show_role_extent($1,$context,'cr')), + $result ne 'ok').'
'); + if ($result ne "ok") { + $r->print(&mt('Error: [_1]',$result).'
'); + } if (!grep(/^cr$/,@rolechanges)) { push(@rolechanges,'cr'); } @@ -3403,14 +3678,21 @@ sub update_roles { $env{'form.ccuname'}, $scope,$role,$now,0,1,'', $context); - $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope, - ''.$result.'').'
'); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Deleting [_1] in [_2]', + &Apache::lonnet::plaintext($role), + &Apache::loncommon::show_role_extent($scope,$context,$role)), + $result ne 'ok').'
'); + if ($result ne "ok") { + $r->print(&mt('Error: [_1]',$result).'
'); + } + if ($role eq 'st') { my $result = &Apache::lonuserutils::classlist_drop($scope, $env{'form.ccuname'},$env{'form.ccdomain'}, $now); - $r->print($result); + $r->print(&Apache::lonhtmlcommon::confirm_success($result)); } if (!grep(/^\Q$role\E$/,@rolechanges)) { push(@rolechanges,$role); @@ -3419,11 +3701,17 @@ sub update_roles { if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); # Delete custom role - $r->print(&mt('Deleting custom role [_1] by [_2] in [_3]', - $rolename,$rnam.':'.$rdom,$url).': '. - &Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, - $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, - 0,1,$context).'
'); + my $result = + &Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, + $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, + 0,1,$context); + $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]', + $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')), + $result ne "ok").'
'); + if ($result ne "ok") { + $r->print(&mt('Error: [_1]',$result).'
'); + } + if (!grep(/^cr$/,@rolechanges)) { push(@rolechanges,'cr'); } @@ -3439,27 +3727,38 @@ sub update_roles { my $output; if ($role eq 'st') { if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) { - my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3); + my ($cdom,$cnum,$csec) = ($1,$2,$3); + my $credits; + if ($showcredits) { + my $defaultcredits = + &Apache::lonuserutils::get_defaultcredits($cdom,$cnum); + $credits = &get_user_credits($defaultcredits,$cdom,$cnum); + } + my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits); if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) { if ($result eq 'refused' && $logmsg) { $output = $logmsg; } else { - $output = "Error: $result\n"; + $output = &mt('Error: [_1]',$result)."\n"; } } else { - $output = &mt('Assigning').' '.$role.' in '.$url. - &mt('starting').' '.localtime($now). - ':
'.$logmsg.'
'. - &mt('Add to classlist').': ok
'; + $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]', + &Apache::lonnet::plaintext($role), + &Apache::loncommon::show_role_extent($url,$context,'st'), + &Apache::lonlocal::locallocaltime($now))).'
'.$logmsg.'
'; } } } else { my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'}, $env{'form.ccuname'},$url,$role,0,$now,'','', $context); - $output = &mt('Re-enabling [_1] in [_2]: [_3]', - $role,$url,''.$result.'').'
'; - } + $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]', + &Apache::lonnet::plaintext($role), + &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'
'; + if ($result ne "ok") { + $output .= &mt('Error: [_1]',$result).'
'; + } + } $r->print($output); if (!grep(/^\Q$role\E$/,@rolechanges)) { push(@rolechanges,$role); @@ -3471,8 +3770,13 @@ sub update_roles { my $result = &Apache::lonnet::assigncustomrole( $env{'form.ccdomain'}, $env{'form.ccuname'}, $url,$rdom,$rnam,$rolename,0,$now,undef,$context); - $r->print(&mt('Re-enabling custom role [_1] by [_2] in [_3]: [_4]', - $rolename,$rnam.':'.$rdom,$url,''.$result.'').'
'); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Re-enabling custom role [_1] by [_2] in [_3]', + $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')), + $result ne "ok").'
'); + if ($result ne "ok") { + $r->print(&mt('Error: [_1]',$result).'
'); + } if (!grep(/^cr$/,@rolechanges)) { push(@rolechanges,'cr'); } @@ -3529,8 +3833,20 @@ sub update_roles { # split multiple sections my %sections = (); my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three); + my $credits; + if ($three eq 'st') { + if ($showcredits) { + my $defaultcredits = + &Apache::lonuserutils::get_defaultcredits($one,$two); + $credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three}; + $credits =~ s/[^\d\.]//g; + if ($credits eq $defaultcredits) { + undef($credits); + } + } + } if ($num_sections == 0) { - $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context)); + $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits)); } else { my %curr_groups = &Apache::longroup::coursegroups($one,$two); @@ -3544,13 +3860,13 @@ sub update_roles { next; } my $securl = $url.'/'.$sec; - $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context)); + $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context,$credits)); } else { $emptysec = 1; } } if ($emptysec) { - $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context)); + $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits)); } } if (!grep(/^\Q$three\E$/,@rolechanges)) { @@ -3612,13 +3928,36 @@ sub update_roles { # Flush the course logs so reverse user roles immediately updated $r->register_cleanup(\&Apache::lonnet::flushcourselogs); if (@rolechanges == 0) { - $r->print(&mt('No roles to modify')); + $r->print('

'.&mt('No roles to modify').'

'); } return @rolechanges; } +sub get_user_credits { + my ($uname,$udom,$defaultcredits,$cdom,$cnum) = @_; + if ($cdom eq '' || $cnum eq '') { + return unless ($env{'request.course.id'}); + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + } + my $credits; + my %currhash = + &Apache::lonnet::get('classlist',[$uname.':'.$udom],$cdom,$cnum); + if (keys(%currhash) > 0) { + my @items = split(/:/,$currhash{$uname.':'.$udom}); + my $crdidx = &Apache::loncoursedata::CL_CREDITS() - 3; + $credits = $items[$crdidx]; + $credits =~ s/[^\d\.]//g; + } + if ($credits eq $defaultcredits) { + undef($credits); + } + return $credits; +} + sub enroll_single_student { - my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype) = @_; + my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype, + $showcredits,$defaultcredits) = @_; $r->print('

'); if ($crstype eq 'Community') { $r->print(&mt('Enrolling Member')); @@ -3630,6 +3969,17 @@ sub enroll_single_student { # Remove non alphanumeric values from section $env{'form.sections'}=~s/\W//g; + my $credits; + if (($showcredits) && ($env{'form.credits'} ne '')) { + $credits = $env{'form.credits'}; + $credits =~ s/[^\d\.]//g; + if ($credits ne '') { + if ($credits eq $defaultcredits) { + undef($credits); + } + } + } + # Clean out any old student roles the user has in this class. &Apache::lonuserutils::modifystudent($env{'form.ccdomain'}, $env{'form.ccuname'},$env{'request.course.id'},undef,$uhome); @@ -3639,9 +3989,10 @@ sub enroll_single_student { $env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'}, $env{'form.cmiddlename'},$env{'form.clastname'}, $env{'form.generation'},$env{'form.sections'},$enddate, - $startdate,'manual',undef,$env{'request.course.id'},'',$context); + $startdate,'manual',undef,$env{'request.course.id'},'',$context, + $credits); if ($enroll_result =~ /^ok/) { - $r->print(&mt('[_1] enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'})); + $r->print(&mt('[_1] enrolled',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.'')); if ($env{'form.sections'} ne '') { $r->print(' '.&mt('in section [_1]',$env{'form.sections'})); } @@ -3658,11 +4009,11 @@ sub enroll_single_student { } $r->print('.
'.$showstart.'; '.$showend); if ($startdate <= $now && !$newuser) { - $r->print('

'); + $r->print('

'); if ($crstype eq 'Community') { - $r->print(&mt('If the member is currently logged-in to LON-CAPA, the new role will be available when the member next logs in.')); + $r->print(&mt('If the member is currently logged-in to LON-CAPA, the new role can be displayed by using the "Check for changes" link on the Roles/Courses page.')); } else { - $r->print(&mt('If the student is currently logged-in to LON-CAPA, the new role will be available when the student next logs in.')); + $r->print(&mt('If the student is currently logged-in to LON-CAPA, the new role can be displayed by using the "Check for changes" link on the Roles/Courses page.')); } $r->print('

'); } @@ -3676,14 +4027,14 @@ sub get_defaultquota_text { my ($settingstatus) = @_; my $defquotatext; if ($settingstatus eq '') { - $defquotatext = &mt('(default)'); + $defquotatext = &mt('default'); } else { my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'}); if ($usertypes->{$settingstatus} eq '') { - $defquotatext = &mt('(default)'); + $defquotatext = &mt('default'); } else { - $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus}); + $defquotatext = &mt('default for [_1]',$usertypes->{$settingstatus}); } } return $defquotatext; @@ -3692,7 +4043,7 @@ sub get_defaultquota_text { sub update_result_form { my ($uhome) = @_; my $outcome = - '
'."\n"; + ''."\n"; foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') { $outcome .= ''."\n"; } @@ -3708,20 +4059,20 @@ sub update_result_form { $outcome .= ''."\n"; } $outcome .= ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". '
'; return $outcome; } sub quota_admin { - my ($setquota,$changeHash) = @_; + my ($setquota,$changeHash,$name) = @_; my $quotachanged; if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) { # Current user has quota modification privileges if (ref($changeHash) eq 'HASH') { $quotachanged = 1; - $changeHash->{'portfolioquota'} = $setquota; + $changeHash->{$name.'quota'} = $setquota; } } return $quotachanged; @@ -3828,6 +4179,7 @@ sub custom_role_editor { my $dompriv=''; my $coursepriv=''; my $body_top; + my $newrole; my ($rdummy,$roledef)= &Apache::lonnet::get('roles',["rolesdef_$rolename"]); # ------------------------------------------------------- Does this role exist? @@ -3840,6 +4192,7 @@ sub custom_role_editor { $syspriv =~ s/bre\&S//; } } else { + $newrole = 1; $body_top .= &mt('New Role').' "'; $roledef=''; } @@ -3966,7 +4319,7 @@ sub custom_role_editor { $r->print('
'); $r->print(< +
ENDCCF @@ -4109,6 +4462,7 @@ sub set_custom_role { bread_crumbs_component => 'User Management'}; $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args)); + my $newrole; my ($rdummy,$roledef)= &Apache::lonnet::get('roles',["rolesdef_$rolename"]); @@ -4119,6 +4473,7 @@ sub set_custom_role { } else { $r->print(&mt('New Role').' "'); $roledef=''; + $newrole = 1; } $r->print($rolename.'"

'); # ------------------------------------------------------- What can be assigned? @@ -4149,21 +4504,44 @@ sub set_custom_role { $sysrole.=':'.$item; } } - $r->print('
Defining Role: '. - &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole)); + # Assign role; Compile and show result + my $errmsg; + my $result = + &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole); + if ($result ne 'ok') { + $errmsg = ': '.$result; + } + my $message = + &Apache::lonhtmlcommon::confirm_success( + &mt('Defining Role').$errmsg, ($result eq 'ok' ? 0 : 1)); if ($env{'request.course.id'}) { my $url='/'.$env{'request.course.id'}; $url=~s/\_/\//g; - $r->print('
'.&mt('Assigning Role to Self').': '. - &Apache::lonnet::assigncustomrole($env{'user.domain'}, - $env{'user.name'}, - $url, - $env{'user.domain'}, - $env{'user.name'}, - $rolename,undef,undef,undef,$context)); - } - $r->print('

'.&mt('Create or edit another custom role').'

'); - $r->print(&Apache::lonhtmlcommon::echo_form_input([]).''); + $result = + &Apache::lonnet::assigncustomrole( + $env{'user.domain'},$env{'user.name'}, + $url, + $env{'user.domain'},$env{'user.name'}, + $rolename,undef,undef,undef,$context); + if ($result ne 'ok') { + $errmsg = ': '.$result; + } + $message .= + '
' + .&Apache::lonhtmlcommon::confirm_success( + &mt('Assigning Role to Self').$errmsg, ($result eq 'ok' ? 0 : 1)); + } + $r->print( + &Apache::loncommon::confirmwrapper($message) + .'
' + .&Apache::lonhtmlcommon::actionbox([ + '' + .&mt('Create or edit another custom role') + .'']) + .'
' + .&Apache::lonhtmlcommon::echo_form_input([]) + .'
' + ); } # ================================================================ Main Handler @@ -4183,14 +4561,15 @@ sub handler { } else { $context = 'domain'; } + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['action','state','callingform','roletype','showrole','bulkaction','popup','phase', - 'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']); + 'username','domain','srchterm','srchdomain','srchin','srchby','srchtype','queue']); &Apache::lonhtmlcommon::clear_breadcrumbs(); my $args; my $brcrum = []; my $bread_crumbs_component = 'User Management'; - if ($env{'form.action'} ne 'dateselect') { + if (($env{'form.action'} ne 'dateselect') && ($env{'form.action'} ne 'displayuserreq')) { $brcrum = [{href=>"/adm/createuser", text=>"User Management", help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'} @@ -4214,6 +4593,16 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + my $showcredits; + if ((($context eq 'course') && ($crstype eq 'Course')) || + ($context eq 'domain')) { + my %domdefaults = + &Apache::lonnet::get_domain_defaults($env{'request.role.domain'}); + if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) { + $showcredits = 1; + } + } + # Main switch on form.action and form.state, as appropriate if (! exists($env{'form.action'})) { $args = {bread_crumbs => $brcrum, @@ -4236,11 +4625,12 @@ sub handler { if (! exists($env{'form.state'})) { &Apache::lonuserutils::print_first_users_upload_form($r,$context); } elsif ($env{'form.state'} eq 'got_file') { - &Apache::lonuserutils::print_upload_manager_form($r,$context, - $permission,$crstype); + &Apache::lonuserutils::print_upload_manager_form($r,$context,$permission, + $crstype,$showcredits); } elsif ($env{'form.state'} eq 'enrolling') { if ($env{'form.datatoken'}) { - &Apache::lonuserutils::upfile_drop_add($r,$context,$permission); + &Apache::lonuserutils::upfile_drop_add($r,$context,$permission, + $showcredits); } } else { &Apache::lonuserutils::print_first_users_upload_form($r,$context); @@ -4265,13 +4655,15 @@ sub handler { .' letters numbers - . @') .''; $env{'form.phase'} = ''; - &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum); + &print_username_entry_form($r,$context,$response,$srch,undef, + $crstype,$brcrum,$showcredits); } else { my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'}); my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'}); &print_user_modification_page($r,$ccuname,$ccdomain, $srch,$response,$context, - $permission,$crstype,$brcrum); + $permission,$crstype,$brcrum, + $showcredits); } } elsif ($env{'form.phase'} eq 'get_user_info') { my ($currstate,$response,$forcenewuser,$results) = @@ -4316,7 +4708,7 @@ sub handler { $brcrum); } } elsif ($env{'form.phase'} eq 'update_user_data') { - &update_user_data($r,$context,$crstype,$brcrum); + &update_user_data($r,$context,$crstype,$brcrum,$showcredits); } else { &print_username_entry_form($r,$context,undef,$srch,undef,$crstype, $brcrum); @@ -4332,7 +4724,7 @@ sub handler { (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) { push(@{$brcrum}, {href => '/adm/createuser?action=processauthorreq', - text => 'Authoring space requests', + text => 'Authoring Space requests', help => 'Domain_Role_Approvals'}); $bread_crumbs_component = 'Authoring requests'; if ($env{'form.state'} eq 'done') { @@ -4344,7 +4736,8 @@ sub handler { } $args = { bread_crumbs => $brcrum, bread_crumbs_component => $bread_crumbs_component}; - $r->print(&header(undef,$args)); + my $js = &usernamerequest_javascript(); + $r->print(&header(&add_script($js),$args)); if (!exists($env{'form.state'})) { $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestauthor', $env{'request.role.domain'})); @@ -4353,6 +4746,103 @@ sub handler { $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestauthor', $env{'request.role.domain'})); } + } elsif (($env{'form.action'} eq 'processusernamereq') && + ($permission->{'cusr'}) && + (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) { + push(@{$brcrum}, + {href => '/adm/createuser?action=processusernamereq', + text => 'LON-CAPA account requests', + help => 'Domain_Username_Approvals'}); + $bread_crumbs_component = 'Account requests'; + if ($env{'form.state'} eq 'done') { + push(@{$brcrum}, + {href => '/adm/createuser?action=usernamereqqueue', + text => 'Result', + help => 'Domain_Username_Approvals'}); + $bread_crumbs_component = 'LON-CAPA account request result'; + } + $args = { bread_crumbs => $brcrum, + bread_crumbs_component => $bread_crumbs_component}; + my $js = &usernamerequest_javascript(); + $r->print(&header(&add_script($js),$args)); + if (!exists($env{'form.state'})) { + $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestusername', + $env{'request.role.domain'})); + } elsif ($env{'form.state'} eq 'done') { + $r->print('

'.&mt('LON-CAPA account request processing').'

'."\n"); + $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestusername', + $env{'request.role.domain'})); + } + } elsif (($env{'form.action'} eq 'displayuserreq') && + ($permission->{'cusr'})) { + my $dom = $env{'form.domain'}; + my $uname = $env{'form.username'}; + my $warning; + if (($dom =~ /^$match_domain$/) && (&Apache::lonnet::domain($dom) ne '')) { + if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) { + if (($uname =~ /^$match_username$/) && ($env{'form.queue'} eq 'approval')) { + my $uhome = &Apache::lonnet::homeserver($uname,$dom); + if ($uhome eq 'no_host') { + my $queue = $env{'form.queue'}; + my $reqkey = &escape($uname).'_'.$queue; + my $namespace = 'usernamequeue'; + my $domconfig = &Apache::lonnet::get_domainconfiguser($dom); + my %queued = + &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig); + unless ($queued{$reqkey}) { + $warning = &mt('No information was found for this LON-CAPA account request.'); + } + } else { + $warning = &mt('A LON-CAPA account already exists for the requested username and domain.'); + } + } else { + $warning = &mt('LON-CAPA account request status check is for an invalid username.'); + } + } else { + $warning = &mt('You do not have rights to view LON-CAPA account requests in the domain specified.'); + } + } else { + $warning = &mt('LON-CAPA account request status check is for an invalid domain.'); + } + my $args = { only_body => 1 }; + $r->print(&header(undef,$args). + '

'.&mt('LON-CAPA Account Request Details').'

'); + if ($warning ne '') { + $r->print('
'.$warning.'
'); + } else { + my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); + my $domconfiguser = &Apache::lonnet::get_domainconfiguser($dom); + my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); + if (ref($domconfig{'usercreation'}) eq 'HASH') { + if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') { + if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}) eq 'HASH') { + my $count = scalar(keys(%{$domconfig{'usercreation'}{'cancreate'}{'emailusername'}})); + my %info = + &Apache::lonnet::get('nohist_requestedusernames',[$uname],$dom,$domconfiguser); + if (ref($info{$uname}) eq 'HASH') { + if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) { + $r->print('
'.&Apache::lonhtmlcommon::start_pick_box()); + my $num; + foreach my $field (@{$infofields}) { + next unless ($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$field}); + next unless ($infotitles->{$field}); + $r->print(&Apache::lonhtmlcommon::row_title($infotitles->{$field}). + $info{$uname}{$field}); + $num ++; + if ($count == $num) { + $r->print(&Apache::lonhtmlcommon::row_closure(1)); + } else { + $r->print(&Apache::lonhtmlcommon::row_closure()); + } + } + $r->print(&Apache::lonhtmlcommon::end_pick_box().'
'); + } + } + } + } + } + $r->print(&close_popup_form()); + } } elsif (($env{'form.action'} eq 'listusers') && ($permission->{'view'} || $permission->{'cusr'})) { if ($env{'form.phase'} eq 'bulkchange') { @@ -4419,7 +4909,8 @@ sub handler { $r->print(&header(&add_script($jscript),$args)); } &Apache::lonuserutils::print_userlist($r,undef,$permission,$context, - $formname,$totcodes,$codetitles,$idlist,$idlist_titles); + $formname,$totcodes,$codetitles,$idlist,$idlist_titles, + $showcredits); } } elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) { my $brtext; @@ -4450,8 +4941,8 @@ sub handler { } elsif ($env{'form.action'} eq 'dateselect') { if ($permission->{'cusr'}) { $r->print(&header(undef,{'no_nav_bar' => 1}). - &Apache::lonuserutils::date_section_selector($context, - $permission,$crstype)); + &Apache::lonuserutils::date_section_selector($context,$permission, + $crstype,$showcredits)); } else { $r->print(&header(undef,{'no_nav_bar' => 1}). ''.&mt('You do not have permission to modify dates or sections for users').''); @@ -4551,8 +5042,39 @@ sub add_script { .''."\n"; } +sub usernamerequest_javascript { + my $js = <
+ +

+END +} + sub verify_user_display { my ($context) = @_; + my %lt = &Apache::lonlocal::texthash ( + course => 'course(s): description, section(s), status', + community => 'community(s): description, section(s), status', + author => 'author', + ); my $photos; if (($context eq 'course') && $env{'request.course.id'}) { $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}; @@ -4576,16 +5098,25 @@ function updateCols(caller) { var context = '$context'; var photos = '$photos'; if (caller == 'Status') { - if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') { - document.getElementById('showcolstatus').checked = true; - document.getElementById('showcolstatus').disabled = ''; - document.getElementById('showcolstart').checked = true; - document.getElementById('showcolend').checked = true; - } else { + if ((context == 'domain') && + ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') || + (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community'))) { document.getElementById('showcolstatus').checked = false; document.getElementById('showcolstatus').disabled = 'disabled'; document.getElementById('showcolstart').checked = false; document.getElementById('showcolend').checked = false; + } else { + if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') { + document.getElementById('showcolstatus').checked = true; + document.getElementById('showcolstatus').disabled = ''; + document.getElementById('showcolstart').checked = true; + document.getElementById('showcolend').checked = true; + } else { + document.getElementById('showcolstatus').checked = false; + document.getElementById('showcolstatus').disabled = 'disabled'; + document.getElementById('showcolstart').checked = false; + document.getElementById('showcolend').checked = false; + } } } if (caller == 'output') { @@ -4603,13 +5134,74 @@ function updateCols(caller) { } } if (caller == 'showrole') { - if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') { + if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') || + (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'cr')) { document.getElementById('showcolrole').checked = true; document.getElementById('showcolrole').disabled = ''; } else { document.getElementById('showcolrole').checked = false; document.getElementById('showcolrole').disabled = 'disabled'; } + if (context == 'domain') { + var quotausageshow = 0; + if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') || + (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) { + document.getElementById('showcolstatus').checked = false; + document.getElementById('showcolstatus').disabled = 'disabled'; + document.getElementById('showcolstart').checked = false; + document.getElementById('showcolend').checked = false; + } else { + if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') { + document.getElementById('showcolstatus').checked = true; + document.getElementById('showcolstatus').disabled = ''; + document.getElementById('showcolstart').checked = true; + document.getElementById('showcolend').checked = true; + } + } + if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'domain') { + document.getElementById('showcolextent').disabled = 'disabled'; + document.getElementById('showcolextent').checked = 'false'; + document.getElementById('showextent').style.display='none'; + document.getElementById('showcoltextextent').innerHTML = ''; + if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'au') || + (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any')) { + if (document.getElementById('showcolauthorusage')) { + document.getElementById('showcolauthorusage').disabled = ''; + } + if (document.getElementById('showcolauthorquota')) { + document.getElementById('showcolauthorquota').disabled = ''; + } + quotausageshow = 1; + } + } else { + document.getElementById('showextent').style.display='block'; + document.getElementById('showextent').style.textAlign='left'; + document.getElementById('showextent').style.textFace='normal'; + if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'author') { + document.getElementById('showcolextent').disabled = ''; + document.getElementById('showcolextent').checked = 'true'; + document.getElementById('showcoltextextent').innerHTML="$lt{'author'}"; + } else { + document.getElementById('showcolextent').disabled = ''; + document.getElementById('showcolextent').checked = 'true'; + if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community') { + document.getElementById('showcoltextextent').innerHTML="$lt{'community'}"; + } else { + document.getElementById('showcoltextextent').innerHTML="$lt{'course'}"; + } + } + } + if (quotausageshow == 0) { + if (document.getElementById('showcolauthorusage')) { + document.getElementById('showcolauthorusage').checked = false; + document.getElementById('showcolauthorusage').disabled = 'disabled'; + } + if (document.getElementById('showcolauthorquota')) { + document.getElementById('showcolauthorquota').checked = false; + document.getElementById('showcolauthorquota').disabled = 'disabled'; + } + } + } } return; } @@ -4729,6 +5321,14 @@ sub print_main_menu { linktitle => 'Approve or reject author role requests', }, { + linktext => 'LON-CAPA Account Requests', + icon => 'list-add.png', + #help => 'Domain_Username_Approvals', + url => '/adm/createuser?action=processusernamereq', + permission => $permission->{'cusr'}, + linktitle => 'Approve or reject LON-CAPA account requests', + }, + { linktext => 'Change Log', icon => 'document-properties.png', #help => 'Course_User_Logs', @@ -4853,6 +5453,7 @@ sub print_main_menu { ); } } elsif ($context eq 'author') { + push(@{ $menu[2]->{items} }, #Category: Administration { linktext => 'Change Log', icon => 'document-properties.png', @@ -4861,6 +5462,7 @@ sub print_main_menu { permission => $permission->{'cusr'}, linktitle => 'View change log.', }, + ); } return Apache::lonhtmlcommon::generate_menu(@menu); # { text => 'View Log-in History', @@ -5847,7 +6449,7 @@ sub role_display_filter { &mt('Context:').'
'."\n". ' '.$plrole.''."\n". ' '.$area.'
Domain: '.$domain.''."\n"; + if (($role eq 'st') && ($crstype eq 'Course')) { + $row .= + ''; + } else { + $row .= ' '; + } if (($role eq 'cc') || ($role eq 'co')) { $row .= ' '; } elsif ($env{'request.course.sec'} ne '') { @@ -6528,7 +7145,7 @@ sub course_level_row { ''."\n"; } else { $row .= ''."\n"; + 'name="sec_'.$protectedcourse.'_'.$role.'" />'."\n"; } } $row .= <'. @@ -6552,7 +7169,11 @@ sub course_level_dc { ''; my $courseform=&Apache::loncommon::selectcourse_link ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Select','crstype'); - my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser'); + my $credit_elem; + if ($showcredits) { + $credit_elem = 'credits'; + } + my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser',$credit_elem); my %lt=&Apache::lonlocal::texthash( 'rol' => "Role", 'grs' => "Section", @@ -6562,39 +7183,46 @@ sub course_level_dc { 'end' => "End", 'ssd' => "Set Start Date", 'sed' => "Set End Date", - 'scc' => "Course/Community" + 'scc' => "Course/Community", + 'crd' => "Credits", ); my $header = '

'.&mt('Course/Community Level').'

'. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). - ''.$lt{'scc'}.''.$lt{'rol'}.''.$lt{'grs'}.''.$lt{'sta'}.''.$lt{'end'}.''. + ''.$lt{'scc'}.''.$lt{'rol'}.''."\n". + ''.$lt{'grs'}.''.$lt{'crd'}.''."\n". + ''.$lt{'sta'}.''.$lt{'end'}.''."\n". &Apache::loncommon::end_data_table_header_row(); my $otheritems = &Apache::loncommon::start_data_table_row()."\n". '
'. $courseform.(' ' x4).''."\n". - '
'."\n"; foreach my $role (@roles) { my $plrole=&Apache::lonnet::plaintext($role); - $otheritems .= ' '; } if ( keys %customroles > 0) { foreach my $cust (sort keys %customroles) { my $custrole='cr_cr_'.$env{'user.domain'}. '_'.$env{'user.name'}.'_'.$cust; - $otheritems .= ' '; } } $otheritems .= ''. ''. ''. + ' '. ''. ''. - '
'.$lt{'exs'}.'
   '.$lt{'new'}.'
'. ''. ''. ''. '
'; + ''."\n"; + if ($showcredits) { + $otheritems .= '
'."\n". + ''."\n"; + } $otheritems .= <