';
+ foreach my $level ('course','domain','system') {
+ if ($customroles{$key}{$level}) {
+ my $suffix;
+ if (($level eq 'domain') || ($level eq 'system')) {
+ $suffix = ' ('.&mt($level).')';
+ }
+ my @privs = split(/:/,$customroles{$key}{$level});
+ foreach my $item (@privs) {
+ next if ($item eq '');
+ my ($priv,$cond) = split(/\&/,$item);
+ $output .= &Apache::lonnet::plaintext($priv,'Course').$suffix.' ';
+ }
+ }
+ }
+ $output .= '
'.
+ &Apache::loncommon::end_data_table_row();
+ }
+ $output .= &Apache::loncommon::end_data_table();
+ }
+ return $output;
+}
+
sub courserequest_titles {
my %titles = &Apache::lonlocal::texthash (
official => 'Official',
unofficial => 'Unofficial',
community => 'Communities',
+ textbook => 'Textbook',
+ placement => 'Placement Tests',
norequest => 'Not allowed',
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
@@ -811,7 +884,7 @@ sub entry_form {
}
my $cancreate =
&Apache::lonuserutils::can_create_user($dom,$context,$usertype);
- my $userpicker =
+ my ($userpicker,$cansearch) =
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
'document.crtuser',$cancreate,$usertype);
my $srchbutton = &mt('Search');
@@ -820,7 +893,9 @@ sub entry_form {
} elsif ($cancreate && $responsemsg ne '' && $inexact) {
$srchbutton = &mt('Search or Add New User');
}
- my $output = <<"ENDBLOCK";
+ my $output;
+ if ($cansearch) {
+ $output = <<"ENDBLOCK";
ENDBLOCK
+ } else {
+ $output = '
'.$userpicker.'
';
+ }
if ($env{'form.phase'} eq '') {
my $defdom=$env{'request.role.domain'};
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
@@ -1227,8 +1305,9 @@ ENDFORMINFO
}
}
}
+ my $title = '';
if ($newuser) {
- my ($portfolioform,$domroleform);
+ my ($portfolioform,$domroleform,$adhocroleform);
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
@@ -1238,12 +1317,14 @@ ENDFORMINFO
($ccdomain eq $env{'request.role.domain'})) {
$domroleform = ' '.&domainrole_req($ccuname,$ccdomain);
}
+ if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
+ $adhocroleform = &domadhocroles($ccuname,$ccdomain);
+ if ($adhocroleform) {
+ $adhocroleform = ' '.$adhocroleform;
+ }
+ }
&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",
);
@@ -1257,20 +1338,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('
');
- my @order = ('auth','quota','tools','requestauthor');
+ my @order = ('auth','quota','tools','requestauthor','adhocroles');
my %user_text;
my ($isadv,$isauthor) =
&Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
@@ -1406,6 +1479,9 @@ ENDCHANGEUSER
&& ($env{'request.role.domain'} eq $ccdomain)) {
$user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
}
+ if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
+ $user_text{'adhocroles'} = &domadhocroles($ccuname,$ccdomain);
+ }
$user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname);
if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
(&Apache::lonnet::allowed('mut',$ccdomain))) {
@@ -1415,8 +1491,8 @@ ENDCHANGEUSER
if (!&Apache::lonnet::allowed('mpq',$ccdomain)) {
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
my %lt=&Apache::lonlocal::texthash(
- '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.",
+ '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(' '."\n");
} else {
- $r->print(' print('
'.
+ &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;
@@ -2471,9 +2619,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;
}
}
@@ -2513,7 +2664,7 @@ sub update_user_data {
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','placement');
my @requestauthor = ('requestauthor');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
@@ -2623,6 +2774,12 @@ sub update_user_data {
$newcustom{'requestauthor'},
\%changeHash,'requestauthor');
}
+ if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
+ my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd');
+ if (&adhocrole_changes(\%changeHash)) {
+ $changed{'adhocroles.'.$env{'request.role.domain'}} = $changeHash{'adhocroles.'.$env{'request.role.domain'}};
+ }
+ }
}
if ($canmodify_status{'inststatus'}) {
if (exists($env{'form.inststatus'})) {
@@ -2651,7 +2808,7 @@ sub update_user_data {
$r->print($error.'Invalid login mode or password'.$end.$rtnlink);
return;
}
- # Only allow authentification modification if the person has authority
+ # Only allow authentication modification if the person has authority
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
$r->print('Modifying authentication: '.
&Apache::lonnet::modifyuserauth(
@@ -2661,7 +2818,7 @@ sub update_user_data {
($env{'form.ccuname'},$env{'form.ccdomain'}));
} else {
# Okay, this is a non-fatal error.
- $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);
+ $r->print($error.&mt('You do not have the authority to modify this users authentication information.').$end);
}
}
$r->rflush(); # Finish display of header before time consuming actions start
@@ -2683,9 +2840,11 @@ sub update_user_data {
'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',
- 'requestauthor'],
+ 'requestcourses.community','requestcourses.textbook',
+ 'reqcrsotherdom.official','reqcrsotherdom.unofficial',
+ 'reqcrsotherdom.community','reqcrsotherdom.textbook',
+ 'reqcrsotherdom.placement','requestauthor',
+ 'adhocroles.'.$env{'request.role.domain'}],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -2824,6 +2983,7 @@ sub update_user_data {
&Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);
($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});
}
+ push(@disporder,'adhocroles');
my %canshow;
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
$canshow{'quota'} = 1;
@@ -2842,6 +3002,9 @@ sub update_user_data {
if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
$canshow{'requestauthor'} = 1;
}
+ if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {
+ $canshow{'adhocroles'} = 1;
+ }
my (%changeHash,%changed);
if ($oldinststatus eq '') {
$oldsettings{'inststatus'} = $othertitle;
@@ -2949,11 +3112,20 @@ sub update_user_data {
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);
}
+ if ($userenv{'adhocroles.'.$env{'request.role.domain'}}) {
+ $changeHash{'adhocroles.'.$env{'request.role.domain'}} = $userenv{'adhocroles.'.$env{'request.role.domain'}};
+ }
+ if (&adhocrole_changes(\%changeHash,\%userenv)) {
+ $changed{'adhocroles'} = 1;
+ $oldsettings{'adhocroles'} = $userenv{'adhocroles.'.$env{'request.role.domain'}};
+ $newsettings{'adhocroles'} = $changeHash{'adhocroles.'.$env{'request.role.domain'}};
+ }
}
foreach my $item (@userinfo) {
if ($env{'form.c'.$item} ne $userenv{$item}) {
@@ -2961,8 +3133,8 @@ sub update_user_data {
}
}
foreach my $name ('portfolio','author') {
- $oldsettings{'quota'}{$name} = $oldquota{$name}.' MB';
- $newsettings{'quota'}{$name} = $newquota{$name}.' MB';
+ $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);
@@ -2975,8 +3147,9 @@ sub update_user_data {
($env{'user.domain'} eq $env{'form.ccdomain'})) {
my %newenvhash;
foreach my $key (keys(%changed)) {
- if (($key eq 'official') || ($key eq 'unofficial')
- || ($key eq 'community')) {
+ if (($key eq 'official') || ($key eq 'unofficial') ||
+ ($key eq 'community') || ($key eq 'textbook') ||
+ ($key eq 'placement')) {
$newenvhash{'environment.requestcourses.'.$key} =
$changeHash{'requestcourses.'.$key};
if ($changeHash{'requestcourses.'.$key}) {
@@ -2995,6 +3168,9 @@ sub update_user_data {
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
$key,'reload','requestauthor');
}
+ } elsif ($key eq 'adhocroles') {
+ $newenvhash{'adhocroles.'.$env{'request.role.domain'}} =
+ $changeHash{'adhocroles.'.$env{'request.role.domain'}};
} elsif ($key ne 'quota') {
$newenvhash{'environment.tools.'.$key} =
$changeHash{'tools.'.$key};
@@ -3042,7 +3218,7 @@ sub update_user_data {
\%newsettingstext);
if ($env{'form.cid'} ne $userenv{'id'}) {
&Apache::lonnet::idput($env{'form.ccdomain'},
- ($env{'form.ccuname'} => $env{'form.cid'}));
+ {$env{'form.ccuname'} => $env{'form.cid'}},$uhome,'ids');
if (($recurseid) &&
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) {
my $idresult =
@@ -3061,9 +3237,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,
@@ -3081,9 +3260,9 @@ sub update_user_data {
$rolestr = &mt('No roles');
}
if ($context eq 'course') {
- $contextname = &mt('course');
+ $contextname = 'course';
} elsif ($context eq 'author') {
- $contextname = &mt('co-author');
+ $contextname = 'co-author';
}
$r->print(&mt('The following fields were not updated: ').'
');
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
@@ -3092,9 +3271,9 @@ sub update_user_data {
}
$r->print('
');
if (@mod_disallowed == 1) {
- $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future [_1] roles:",$contextname));
+ $r->print(&mt("You do not have the authority to change this field given the user's current set of active/future $contextname roles:"));
} else {
- $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles:",$contextname));
+ $r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future $contextname roles:"));
}
my $helplink = 'javascript:helpMenu('."'display'".')';
$r->print(''.$rolestr.' '
@@ -3111,13 +3290,14 @@ sub update_user_data {
if ($env{'form.action'} eq 'singlestudent') {
&enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,
$crstype,$showcredits,$defaultcredits);
- $r->print('
');
+ 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,$showcredits);
if (keys(%namechanged) > 0) {
@@ -3172,7 +3352,7 @@ sub display_userinfo {
'id' => 'Student/Employee ID',
'permanentemail' => 'Permanent e-mail address',
'portfolioquota' => 'Disk space allocated to portfolio files',
- 'authorquota' => 'Disk space allocated to authoring space',
+ 'authorquota' => 'Disk space allocated to Authoring Space',
'blog' => 'Blog Availability',
'webdav' => 'WebDAV Availability',
'aboutme' => 'Personal Information Page Availability',
@@ -3180,7 +3360,10 @@ sub display_userinfo {
'official' => 'Can Request Official Courses',
'unofficial' => 'Can Request Unofficial Courses',
'community' => 'Can Request Communities',
+ 'textbook' => 'Can Request Textbook Courses',
+ 'placement' => 'Can Request Placement Tests',
'requestauthor' => 'Can Request Author Role',
+ 'adhocroles' => 'Ad Hoc Roles Selectable via Helpdesk Role',
'inststatus' => "Affiliation",
'prvs' => 'Previous Value:',
'chto' => 'Changed To:'
@@ -3214,7 +3397,7 @@ sub display_userinfo {
@items = ($entry);
} else {
@items = @{$requestcourses};
- }
+ }
foreach my $item (@items) {
if (($newsetting->{$item} ne $oldsetting->{$item}) ||
($newsettingtext->{$item} ne $oldsettingtext->{$item})) {
@@ -3546,13 +3729,77 @@ sub tool_changes {
return;
}
+sub adhocrole_changes {
+ my ($changehashref,$userenv) = @_;
+ my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd');
+ my @dels = &Apache::loncommon::get_env_multiple('form.adhocroledel');
+ my (@saved,@added,@alladhoc,$changed);
+ my $adhoc_key = 'adhocroles.'.$env{'request.role.domain'};
+ if (!$env{'form.makeuser'}) {
+ if (ref($userenv) eq 'HASH') {
+ my @current;
+ if ($userenv->{$adhoc_key}) {
+ @current = split(/,/,$userenv->{$adhoc_key});
+ if (@dels) {
+ foreach my $curr (@current) {
+ next if ($curr eq '');
+ unless (grep(/\Q$curr\E$/,@dels)) {
+ push(@saved,$curr);
+ }
+ }
+ $changed = 1;
+ } else {
+ @saved = @current;
+ }
+ }
+ }
+ }
+ if (@adds) {
+ my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'});
+ my %existing=&Apache::lonnet::dump('roles',$env{'request.role.domain'},
+ $confname,'rolesdef_');
+ foreach my $poss (@adds) {
+ if (exists($existing{'rolesdef_'.$poss})) {
+ push(@added,$poss);
+ $changed = 1;
+ }
+ }
+ }
+ if (@added) {
+ if (@saved) {
+ foreach my $add (@added) {
+ unless (grep(/^\Q$add\E$/,@saved)) {
+ push(@alladhoc,$add);
+ }
+ }
+ } else {
+ push(@alladhoc,@added);
+ }
+ }
+ if (@saved) {
+ push(@alladhoc,@saved);
+ }
+ if (@alladhoc) {
+ my $adhocstr = join(',',sort(@alladhoc));
+ $changehashref->{$adhoc_key} = $adhocstr;
+ } elsif (@dels) {
+ &Apache::lonnet::del('environment',[$adhoc_key],$env{'form.ccdomain'},$env{'form.ccuname'});
+ delete($changehashref->{$adhoc_key});
+ if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&
+ ($env{'form.ccuname'} eq $env{'user.name'})) {
+ &Apache::lonnet::delenv($adhoc_key);
+ }
+ }
+ return $changed;
+}
+
sub update_roles {
my ($r,$context,$showcredits) = @_;
my $now=time;
my @rolechanges;
my %disallowed;
$r->print('
'.&mt('Modifying Roles').'
');
- foreach my $key (keys (%env)) {
+ foreach my $key (keys(%env)) {
next if (! $env{$key});
next if ($key eq 'form.action');
# Revoke roles
@@ -3734,7 +3981,7 @@ sub update_roles {
} else {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
if (($sec eq 'none') || ($sec eq 'all') ||
exists($curr_groups{$sec})) {
$disallowed{$sec} = $url;
@@ -3780,7 +4027,7 @@ sub update_roles {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
my $emptysec = 0;
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
$sec =~ s/\W//g;
if ($sec ne '') {
if (($sec eq 'none') || ($sec eq 'all') ||
@@ -3820,7 +4067,7 @@ sub update_roles {
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));
} else {
my $emptysec = 0;
- foreach my $sec (sort {$a cmp $b} keys %sections) {
+ foreach my $sec (sort {$a cmp $b} keys(%sections)) {
if ($sec ne '') {
my $securl = $url.'/'.$sec;
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context));
@@ -3938,11 +4185,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('
');
}
@@ -4076,7 +4323,7 @@ sub build_roles {
# ========================================================== Custom Role Editor
sub custom_role_editor {
- my ($r,$brcrum) = @_;
+ my ($r,$brcrum,$prefix) = @_;
my $action = $env{'form.customroleaction'};
my $rolename;
if ($action eq 'new') {
@@ -4091,7 +4338,7 @@ sub custom_role_editor {
$context = 'course';
} else {
$context = 'domain';
- $crstype = $env{'form.templatecrstype'};
+ $crstype = 'course';
}
$rolename=~s/[^A-Za-z0-9]//gs;
@@ -4100,118 +4347,54 @@ sub custom_role_editor {
return;
}
-# ------------------------------------------------------- What can be assigned?
- my %full=();
- my %courselevel=();
- my %courselevelcurrent=();
- my $syspriv='';
- my $dompriv='';
- my $coursepriv='';
- my $body_top;
+ my $formname = 'form1';
+ my %privs=();
+ my $body_top = '
';
+# ------------------------------------------------------- Does this role exist?
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
-# ------------------------------------------------------- Does this role exist?
- $body_top .= '