');
+ }
+ $r->print(''.&Apache::loncommon::end_page());
+ } else {
+ $r->print(''."\n".
+ ''."\n");
+ }
+}
+sub print_user_query_page {
+ my ($r,$caller) = @_;
+# FIXME - this is for a network-wide name search (similar to catalog search)
+# To use frames with similar behavior to catalog/portfolio search.
+# To be implemented.
+ return;
+}
+
+sub print_user_modification_page {
+ my ($r,$ccuname,$ccdomain,$srch,$response,$context) = @_;
+ if (($ccuname eq '') || ($ccdomain eq '')) {
+ my $usermsg = &mt('No username and/or domain provided.');
+ &print_username_entry_form($r,$context,$usermsg);
+ return;
+ }
+ my %abv_auth = &auth_abbrev();
+ my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser,
+ %alerts,%curr_rules,%got_rules);
+ my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
+ if ($uhome eq 'no_host') {
+ $newuser = 1;
+ my $checkhash;
+ my $checks = { 'username' => 1 };
+ $checkhash->{$ccuname.':'.$ccdomain} = { 'newuser' => $newuser };
+ &Apache::loncommon::user_rule_check($checkhash,$checks,
+ \%alerts,\%rulematch,\%inst_results,\%curr_rules,\%got_rules);
+ if (ref($alerts{'username'}) eq 'HASH') {
+ if (ref($alerts{'username'}{$ccdomain}) eq 'HASH') {
+ my $domdesc =
+ &Apache::lonnet::domain($ccdomain,'description');
+ if ($alerts{'username'}{$ccdomain}{$ccuname}) {
+ my $userchkmsg;
+ if (ref($curr_rules{$ccdomain}) eq 'HASH') {
+ $userchkmsg =
+ &Apache::loncommon::instrule_disallow_msg('username',
+ $domdesc,1).
+ &Apache::loncommon::user_rule_formats($ccdomain,
+ $domdesc,$curr_rules{$ccdomain}{'username'},
+ 'username');
+ }
+ &print_username_entry_form($r,$context,$userchkmsg);
+ return;
+ }
+ }
+ }
+ } else {
+ $newuser = 0;
+ my $currentauth =
+ &Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
+ if ($currentauth =~ /^(krb4|krb5|unix|internal|localauth):/) {
+ $curr_authtype = $abv_auth{$1};
+ if ($currentauth =~ /^krb(4|5)/) {
+ $curr_kerb_ver = $1;
+ }
+ }
+ }
+ if ($response) {
+ $response = ' '.$response
+ }
my $defdom=$env{'request.role.domain'};
my ($krbdef,$krbdefdom) =
@@ -220,13 +529,14 @@ sub print_user_modification_page {
my %param = ( formname => 'document.cu',
kerb_def_dom => $krbdefdom,
- kerb_def_auth => $krbdef
- );
+ kerb_def_auth => $krbdef,
+ curr_authtype => $curr_authtype,
+ curr_kerb_ver => $curr_kerb_ver,
+ domain => $ccdomain,
+ );
$loginscript = &Apache::loncommon::authform_header(%param);
$authformkrb = &Apache::loncommon::authform_kerberos(%param);
- $ccuname=~s/\W//g;
- $ccdomain=~s/\W//g;
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
my $dc_setcourse_code = '';
my $nondc_setsection_code = '';
@@ -240,7 +550,7 @@ sub print_user_modification_page {
$groupslist = '"'.$groupslist.'"';
}
- if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
+ if ($env{'request.role'} =~ m-^dc\./($match_domain)/$-) {
my $dcdom = $1;
$loaditem{'onload'} = "document.cu.coursedesc.value='';";
my @rolevals = ('st','ta','ep','in','cc');
@@ -313,18 +623,27 @@ sub print_user_modification_page {
alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections.");
section = "";
}
+ var coursename = "_$dcdom"+"_"+course+"_"+userrole
var numcourse = getIndex(document.cu.dccourse);
if (numcourse == "-1") {
alert("There was a problem with your course selection");
return
}
- else {
- var coursename = "_$dcdom"+"_"+course+"_"+userrole
- document.cu.elements[numcourse].name = "act"+coursename
- document.cu.elements[numcourse+4].name = "sec"+coursename
- document.cu.elements[numcourse+4].value = section
- document.cu.elements[numcourse+6].name = "start"+coursename
- document.cu.elements[numcourse+7].name = "end"+coursename
+ else {
+ document.cu.elements[numcourse].name = "act"+coursename;
+ var numnewsec = getIndex(document.cu.newsec);
+ if (numnewsec != "-1") {
+ document.cu.elements[numnewsec].name = "sec"+coursename;
+ document.cu.elements[numnewsec].value = section;
+ }
+ var numstart = getIndex(document.cu.start);
+ if (numstart != "-1") {
+ document.cu.elements[numstart].name = "start"+coursename;
+ }
+ var numend = getIndex(document.cu.end);
+ if (numend != "-1") {
+ document.cu.elements[numend].name = "end"+coursename
+ }
}
}
document.cu.submit();
@@ -338,241 +657,214 @@ sub print_user_modification_page {
}
return -1;
}
-
- function setType() {
- var crstype = 'Course'
- rolevals = new Array("$rolevalslist");
- if (crstype == 'Group') {
- if (document.cu.currsec.options[0].text == "$pickcrsfirst") {
- document.cu.currsec.options[0].text = "$pickgrpfirst";
- }
- grprolenames = new Array("$grprolenameslist");
- for (var i=0; i 0) {
- if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) {
- sections = sections + "," + document.cu.elements[i+1].value;
- }
- }
- else {
- sections = document.cu.elements[i+1].value;
- }
- var newsecs = document.cu.elements[i+1].value;
- var numsplit;
- if (newsecs != null && newsecs != "") {
- numsplit = newsecs.split(/,/g);
- numsec = numsec + numsplit.length;
- }
-
- if ((role == 'st') && (numsec > 1)) {
- alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.")
- return;
- }
- else if (numsplit != null) {
- for (var j=0; j'."\n".$jsback."\n".
+ $javascript_validations.'';
my $start_page =
- &Apache::loncommon::start_page('Create Users, Change User Privileges',
+ &Apache::loncommon::start_page('User Management',
$js,{'add_entries' => \%loaditem,});
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.cu)",
+ text=>"Create/modify user",
+ faq=>282,bug=>'Instructor Interface',});
+
+ if ($env{'form.phase'} eq 'userpicked') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.cu,'get_user_info','select')",
+ text=>"Select a user",
+ faq=>282,bug=>'Instructor Interface',});
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.cu,'$env{'form.phase'}','modify')",
+ text=>"Set user role",
+ faq=>282,bug=>'Instructor Interface',});
+ my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management');
my $forminfo =<<"ENDFORMINFO";
".&Apache::loncommon::end_page());
}
+sub user_authentication {
+ my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_;
+ my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);
+ my ($loginscript,$outcome);
+ if ($currentauth=~/^(krb)(4|5):(.*)/) {
+ my $long_auth = $1.$2;
+ my $curr_kerb_ver = $2;
+ my $krbdefdom=$3;
+ my $curr_authtype = $abv_auth->{$long_auth};
+ my %param = ( formname => 'document.cu',
+ kerb_def_dom => $krbdefdom,
+ domain => $ccdomain,
+ curr_authtype => $curr_authtype,
+ curr_kerb_ver => $curr_kerb_ver,
+ );
+ $loginscript = &Apache::loncommon::authform_header(%param);
+ }
+ # Check for a bad authentication type
+ if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {
+ # bad authentication scheme
+ my %lt=&Apache::lonlocal::texthash(
+ 'err' => "ERROR",
+ 'uuas' => "This user has an unrecognized authentication scheme",
+ 'adcs' => "Please alert a domain coordinator of this situation",
+ 'sldb' => "Please specify login data below",
+ 'ld' => "Login Data"
+ );
+ if (&Apache::lonnet::allowed('mau',$ccdomain)) {
+ &initialize_authen_forms($ccdomain);
+ my $choices = &Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc);
+ $outcome = <
+$loginscript
+
+$lt{'err'}:
+$lt{'uuas'} ($currentauth). $lt{'sldb'}.
+
$lt{'ld'}
+$choices
+ENDBADAUTH
+ } else {
+ # This user is not allowed to modify the user's
+ # authentication scheme, so just notify them of the problem
+ $outcome = < $lt{'err'}:
+$lt{'uuas'} ($currentauth). $lt{'adcs'}.
+
+ENDBADAUTH
+ }
+ } else { # Authentication type is valid
+ &initialize_authen_forms($ccdomain,$currentauth,'modifyuser');
+ my ($authformcurrent,$can_modify,@authform_others) =
+ &modify_login_block($ccdomain,$currentauth);
+ if (&Apache::lonnet::allowed('mau',$ccdomain)) {
+ # Current user has login modification privileges
+ my %lt=&Apache::lonlocal::texthash (
+ 'ld' => "Login Data",
+ 'ccld' => "Change Current Login Data",
+ 'enld' => "Enter New Login Data"
+ );
+ $outcome =
+ ''."\n".
+ '
");
+ $r->print(''.&mt('Unable to successfully change environment for').' '.
+ $env{'form.ccuname'}.' '.&mt('in domain').' '.
+ $env{'form.ccdomain'}.' ');
}
} else { # End of if ($env ... ) logic
- # They did not want to change the users name but we can
- # still tell them what the name is
+ # They did not want to change the users name or quota but we can
+ # still tell them what the name and quota are
my %lt=&Apache::lonlocal::texthash(
- 'usr' => "User",
- 'id' => "in domain",
- 'gen' => "Generation"
+ 'id' => "ID/Student number",
+ 'mail' => "Permanent e-mail",
+ 'disk' => "Disk space allocated to user's portfolio files",
);
- $r->print(<<"END");
-
$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
END
+ if ($userenv{'permanentemail'} ne '') {
+ $r->print(' ['.$lt{'mail'}.': '.
+ $userenv{'permanentemail'}.']');
+ }
+ $r->print(' ['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '.
+ $olddefquotatext.']
');
+ }
+ if (@mod_disallowed) {
+ my ($rolestr,$contextname);
+ if (@longroles > 0) {
+ $rolestr = join(', ',@longroles);
+ } else {
+ $rolestr = &mt('No roles');
+ }
+ if ($context eq 'course') {
+ $contextname = &mt('course');
+ } elsif ($context eq 'author') {
+ $contextname = &mt('co-author');
+ }
+ $r->print(&mt('The following fields were not updated: ').'
');
+ my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
+ foreach my $field (@mod_disallowed) {
+ $r->print('
'.$fieldtitles{$field}.'
'."\n");
+ }
+ $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));
+ } 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(''.$rolestr.' '.
+ &mt('Contact your helpdesk for more information.',"javascript:helpMenu('display')").' ');
}
+ $r->print($no_forceid_alert.
+ &Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules));
}
##
my $now=time;
+ my $rolechanges = 0;
$r->print('
'.&mt('Modifying Roles').'
');
- foreach (keys (%env)) {
- next if (! $env{$_});
+ foreach my $key (keys (%env)) {
+ next if (! $env{$key});
+ next if ($key eq 'form.action');
# Revoke roles
- if ($_=~/^form\.rev/) {
- if ($_=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
+ if ($key=~/^form\.rev/) {
+ if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) {
# Revoke standard role
- $r->print(&mt('Revoking').' '.$2.' in '.$1.': '.
- &Apache::lonnet::revokerole($env{'form.ccdomain'},
- $env{'form.ccuname'},$1,$2).' ');
- if ($2 eq 'st') {
- $1=~/^\/(\w+)\/(\w+)/;
- my $cid=$1.'_'.$2;
- $r->print(&mt('Drop from classlist').': '.
- &Apache::lonnet::critical('put:'.
- $env{'course.'.$cid.'.domain'}.':'.
- $env{'course.'.$cid.'.num'}.':classlist:'.
- &escape($env{'form.ccuname'}.':'.
- $env{'form.ccdomain'}).'='.
- &escape($now.':'),
- $env{'course.'.$cid.'.home'}).' ');
+ my ($scope,$role) = ($1,$2);
+ my $result =
+ &Apache::lonnet::revokerole($env{'form.ccdomain'},
+ $env{'form.ccuname'},
+ $scope,$role);
+ $r->print(&mt('Revoking [_1] in [_2]: [_3]',
+ $role,$scope,''.$result.'').' ');
+ if ($role eq 'st') {
+ my $result =
+ &Apache::lonuserutils::classlist_drop($scope,
+ $env{'form.ccuname'},$env{'form.ccdomain'},
+ $now);
+ $r->print($result);
}
- }
- if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ }
+ 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.': '.
+ ' '.$4.' by '.$3.':'.$2.' in '.$1.': '.
&Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
$env{'form.ccuname'},$1,$2,$3,$4).
' ');
}
- } elsif ($_=~/^form\.del/) {
- if ($_=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
+ $rolechanges ++;
+ } elsif ($key=~/^form\.del/) {
+ if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
# Delete standard role
- $r->print(&mt('Deleting').' '.$2.' in '.$1.': '.
- &Apache::lonnet::assignrole($env{'form.ccdomain'},
- $env{'form.ccuname'},$1,$2,$now,0,1).' ');
- if ($2 eq 'st') {
- $1=~/^\/(\w+)\/(\w+)/;
- my $cid=$1.'_'.$2;
- $r->print(&mt('Drop from classlist').': '.
- &Apache::lonnet::critical('put:'.
- $env{'course.'.$cid.'.domain'}.':'.
- $env{'course.'.$cid.'.num'}.':classlist:'.
- &escape($env{'form.ccuname'}.':'.
- $env{'form.ccdomain'}).'='.
- &escape($now.':'),
- $env{'course.'.$cid.'.home'}).' ');
+ my ($scope,$role) = ($1,$2);
+ my $result =
+ &Apache::lonnet::assignrole($env{'form.ccdomain'},
+ $env{'form.ccuname'},
+ $scope,$role,$now,0,1);
+ $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,
+ ''.$result.'').' ');
+ if ($role eq 'st') {
+ my $result =
+ &Apache::lonuserutils::classlist_drop($scope,
+ $env{'form.ccuname'},$env{'form.ccdomain'},
+ $now);
+ $r->print($result);
}
}
- if ($_=~/^form\.del\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ 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]@[_3] in [_4]',
+ $r->print(&mt('Deleting custom role [_1] by [_2]:[_3] in [_4]',
$rolename,$rnam,$rdom,$url).': '.
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
0,1).' ');
}
- } elsif ($_=~/^form\.ren/) {
+ $rolechanges ++;
+ } elsif ($key=~/^form\.ren/) {
my $udom = $env{'form.ccdomain'};
my $uname = $env{'form.ccuname'};
# Re-enable standard role
- if ($_=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {
+ if ($key=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {
my $url = $1;
my $role = $2;
my $logmsg;
my $output;
if ($role eq 'st') {
- if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) {
+ if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
$output = "Error: $result\n";
@@ -1270,7 +2085,7 @@ END
$r->print($output);
}
# Re-enable custom role
- if ($_=~/^form\.ren\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
my $result = &Apache::lonnet::assigncustomrole(
$env{'form.ccdomain'}, $env{'form.ccuname'},
@@ -1278,10 +2093,11 @@ END
$r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : [_5]',
$rolename,$rnam,$rdom,$url,$result).' ');
}
- } elsif ($_=~/^form\.act/) {
+ $rolechanges ++;
+ } elsif ($key=~/^form\.act/) {
my $udom = $env{'form.ccdomain'};
my $uname = $env{'form.ccuname'};
- if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
+ if ($key=~/^form\.act\_($match_domain)\_($match_courseid)\_cr_cr_($match_domain)_($match_username)_([^\_]+)$/) {
# Activate a custom role
my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
my $url='/'.$one.'/'.$two;
@@ -1312,7 +2128,7 @@ END
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
}
}
- } elsif ($_=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) {
+ } elsif ($key=~/^form\.act\_($match_domain)\_($match_name)\_([^\_]+)$/) {
# Activate roles for sections with 3 id numbers
# set start, end times, and the url for the class
my ($one,$two,$three)=($1,$2,$3);
@@ -1351,7 +2167,7 @@ END
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
}
}
- } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
+ } elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
# Activate roles for sections with two id numbers
# set start, end times, and the url for the class
my $start = ( $env{'form.start_'.$1.'_'.$2} ?
@@ -1381,7 +2197,7 @@ END
}
}
} else {
- $r->print('
');
}
foreach my $key (sort(keys(%disallowed))) {
if (($key eq 'none') || ($key eq 'all')) {
@@ -1391,14 +2207,70 @@ END
}
$r->print(' '.&mt('Please go back and choose a different section name.').' ');
}
+ $rolechanges ++;
}
} # End of foreach (keys(%env))
# Flush the course logs so reverse user roles immediately updated
&Apache::lonnet::flushcourselogs();
- $r->print('
');
+ if (!$rolechanges) {
+ $r->print(&mt('No roles to modify'));
+ }
$r->print(&Apache::loncommon::end_page());
}
+sub get_defaultquota_text {
+ my ($settingstatus) = @_;
+ my $defquotatext;
+ if ($settingstatus eq '') {
+ $defquotatext = &mt('(default)');
+ } else {
+ my ($usertypes,$order) =
+ &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'});
+ if ($usertypes->{$settingstatus} eq '') {
+ $defquotatext = &mt('(default)');
+ } else {
+ $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus});
+ }
+ }
+ return $defquotatext;
+}
+
+sub update_result_form {
+ my ($uhome) = @_;
+ my $outcome =
+ ''."\n";
+ foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') {
+ $outcome .= ''."\n";
+ }
+ if ($env{'form.origname'} ne '') {
+ $outcome .= ''."\n";
+ }
+ foreach my $item ('sortby','seluname','seludom') {
+ if (exists($env{'form.'.$item})) {
+ $outcome .= ''."\n";
+ }
+ }
+ if ($uhome eq 'no_host') {
+ $outcome .= ''."\n";
+ }
+ $outcome .= ''."\n".
+ ''."\n".
+ ''."\n".
+ '';
+ return $outcome;
+}
+
+sub quota_admin {
+ my ($setquota,$changeHash) = @_;
+ my $quotachanged;
+ if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
+ # Current user has quota modification privileges
+ $quotachanged = 1;
+ $changeHash->{'portfolioquota'} = $setquota;
+ }
+ return $quotachanged;
+}
+
sub build_roles {
my ($sectionstr,$sections,$role) = @_;
my $num_sections = 0;
@@ -1411,7 +2283,7 @@ sub build_roles {
} else {
foreach my $sec (@secnums) {
$sec =~ ~s/\W//g;
- unless ($sec eq "") {
+ if (!($sec eq "")) {
if (exists($$sections{$sec})) {
$$sections{$sec} ++;
} else {
@@ -1435,7 +2307,7 @@ sub build_roles {
# ========================================================== Custom Role Editor
sub custom_role_editor {
- my $r=shift;
+ my ($r) = @_;
my $rolename=$env{'form.rolename'};
if ($rolename eq 'make new role') {
@@ -1444,35 +2316,35 @@ sub custom_role_editor {
$rolename=~s/[^A-Za-z0-9]//gs;
- unless ($rolename) {
+ if (!$rolename || $env{'form.phase'} eq 'pickrole') {
&print_username_entry_form($r);
return;
}
-
- $r->print(&Apache::loncommon::start_page('Custom Role Editor'));
+# ------------------------------------------------------- What can be assigned?
+ my %full=();
+ my %courselevel=();
+ my %courselevelcurrent=();
my $syspriv='';
my $dompriv='';
my $coursepriv='';
+ my $body_top;
+ my ($disp_dummy,$disp_roles) = &Apache::lonnet::get('roles',["st"]);
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
# ------------------------------------------------------- Does this role exist?
- $r->print('
');
+ $body_top .= '
';
if (($rdummy ne 'con_lost') && ($roledef ne '')) {
- $r->print(&mt('Existing Role').' "');
+ $body_top .= &mt('Existing Role').' "';
# ------------------------------------------------- Get current role privileges
($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
} else {
- $r->print(&mt('New Role').' "');
+ $body_top .= &mt('New Role').' "';
$roledef='';
}
- $r->print($rolename.'"
');
-# ------------------------------------------------------- What can be assigned?
- my %full=();
- my %courselevel=();
- my %courselevelcurrent=();
- foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
- my ($priv,$restrict)=split(/\&/,$_);
- unless ($restrict) { $restrict='F'; }
+ $body_top .= $rolename.'"
';
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
+ my ($priv,$restrict)=split(/\&/,$item);
+ if (!$restrict) { $restrict='F'; }
$courselevel{$priv}=$restrict;
if ($coursepriv=~/\:$priv/) {
$courselevelcurrent{$priv}=1;
@@ -1481,9 +2353,9 @@ sub custom_role_editor {
}
my %domainlevel=();
my %domainlevelcurrent=();
- foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
- my ($priv,$restrict)=split(/\&/,$_);
- unless ($restrict) { $restrict='F'; }
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
+ my ($priv,$restrict)=split(/\&/,$item);
+ if (!$restrict) { $restrict='F'; }
$domainlevel{$priv}=$restrict;
if ($dompriv=~/\:$priv/) {
$domainlevelcurrent{$priv}=1;
@@ -1492,98 +2364,213 @@ sub custom_role_editor {
}
my %systemlevel=();
my %systemlevelcurrent=();
- foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
- my ($priv,$restrict)=split(/\&/,$_);
- unless ($restrict) { $restrict='F'; }
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
+ my ($priv,$restrict)=split(/\&/,$item);
+ if (!$restrict) { $restrict='F'; }
$systemlevel{$priv}=$restrict;
if ($syspriv=~/\:$priv/) {
$systemlevelcurrent{$priv}=1;
}
$full{$priv}=1;
}
+ my ($jsback,$elements) = &crumb_utilities();
+ my $button_code = "\n";
+ my $head_script = "\n";
+ $head_script .= ''."\n";
+ $r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script));
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.form1,'pickrole','')",
+ text=>"Pick custom role",
+ faq=>282,bug=>'Instructor Interface',},
+ {href=>"javascript:backPage(document.form1,'','')",
+ text=>"Edit custom role",
+ faq=>282,bug=>'Instructor Interface',});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+
+ $r->print($body_top);
my %lt=&Apache::lonlocal::texthash(
'prv' => "Privilege",
'crl' => "Course Level",
'dml' => "Domain Level",
- 'ssl' => "System Level"
- );
+ 'ssl' => "System Level");
+ $r->print('Select a Template ');
+ $r->print('');
$r->print(<
+