');
+ }
+ $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) = @_;
+ if (($ccuname eq '') || ($ccdomain eq '')) {
+ my $usermsg = &mt('No username and/or domain provided.');
+ &print_username_entry_form($r,$usermsg);
+ return;
+ }
+ my ($instsrch,$rulematch,$rules,%inst_results);
+ my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain);
+ if ($uhome eq 'no_host') {
+ $instsrch =
+ {
+ srchin => 'instd',
+ srchby => 'uname',
+ srchtype => 'exact',
+ srchterm => $ccuname,
+ srchdomain => $ccdomain,
+ };
+ (my $usercheckmsg,$rulematch,$rules,%inst_results) =
+ &Apache::loncommon::username_rule_check($instsrch,'new');
+ if ($usercheckmsg) {
+ &print_username_entry_form($r,$usercheckmsg);
+ return;
+ }
+ }
+ if ($response) {
+ $response = ' '.$response
+ }
my $defdom=$env{'request.role.domain'};
my ($krbdef,$krbdefdom) =
@@ -235,12 +454,10 @@ sub print_user_modification_page {
my %param = ( formname => 'document.cu',
kerb_def_dom => $krbdefdom,
kerb_def_auth => $krbdef
- );
+ );
$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 = '';
@@ -254,7 +471,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');
@@ -361,36 +578,6 @@ sub print_user_modification_page {
}
return -1;
}
-
- function setType() {
- var crstype = document.cu.crstype.options[document.cu.crstype.selectedIndex].value;
- 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'."\n".$jsback."\n".'';
+
my $start_page =
&Apache::loncommon::start_page('Create Users, Change User Privileges',
$js,{'add_entries' => \%loaditem,});
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.cu)",
+ text=>"User modify/custom role edit",
+ 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 set_login {
+ my $response = (<$generalrule
+
$authformkrb
+
$authformint
+
$authformfsys
+
$authformloc
+ENDAUTH
+ return $response;
+}
+
# ================================================================= Phase Three
sub update_user_data {
- my $r=shift;
+ my ($r) = @_;
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
# Error messages
@@ -1022,16 +1320,41 @@ sub update_user_data {
} else {
$title='Modify User Privileges';
}
- $r->print(&Apache::loncommon::start_page($title));
+
+ my ($jsback,$elements) = &crumb_utilities();
+ my $jscript = ''."\n";
+
+ $r->print(&Apache::loncommon::start_page($title,$jscript));
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.userupdate)",
+ text=>"User modify/custom role edit",
+ faq=>282,bug=>'Instructor Interface',});
+ if ($env{'form.prevphase'} eq 'userpicked') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.userupdate,'get_user_info','select')",
+ text=>"Select a user",
+ faq=>282,bug=>'Instructor Interface',});
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')",
+ text=>"Set user role",
+ faq=>282,bug=>'Instructor Interface',},
+ {href=>"/adm/createuser",
+ text=>"Result",
+ faq=>282,bug=>'Instructor Interface',});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+
my %disallowed;
# Check Inputs
if (! $env{'form.ccuname'} ) {
$r->print($error.&mt('No login name specified').'.'.$end);
return;
}
- if ( $env{'form.ccuname'} =~/\W/) {
+ if ( $env{'form.ccuname'} ne
+ &LONCAPA::clean_username($env{'form.ccuname'}) ) {
$r->print($error.&mt('Invalid login name').'. '.
- &mt('Only letters, numbers, and underscores are valid').'.'.
+ &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'.
$end);
return;
}
@@ -1039,9 +1362,10 @@ sub update_user_data {
$r->print($error.&mt('No domain specified').'.'.$end);
return;
}
- if ( $env{'form.ccdomain'} =~/\W/) {
+ if ( $env{'form.ccdomain'} ne
+ &LONCAPA::clean_domain($env{'form.ccdomain'}) ) {
$r->print($error.&mt ('Invalid domain name').'. '.
- &mt('Only letters, numbers, and underscores are valid').'.'.
+ &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'.
$end);
return;
}
@@ -1081,15 +1405,13 @@ sub update_user_data {
$r->print($error.&mt('Invalid login mode or password').$end);
return;
}
+
+
+ $r->print('
'.&mt('User [_1] in domain [_2]',
+ $env{'form.ccuname'}, $env{'form.ccdomain'}).'
');
+
if ($env{'form.makeuser'}) {
- # Create a new user
- my %lt=&Apache::lonlocal::texthash(
- 'cru' => "Creating user",
- 'id' => "in domain"
- );
- $r->print(<$lt{'cru'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"
-ENDNEWUSERHEAD
+ $r->print('
'.&mt('Creating new account.').'
');
# Check for the authentication mode and password
if (! $amode || ! $genpwd) {
$r->print($error.&mt('Invalid login mode or password').$end);
@@ -1100,8 +1422,8 @@ ENDNEWUSERHEAD
if (lc($desiredhost) eq 'default') {
$desiredhost = undef;
} else {
- my %home_servers = &Apache::loncommon::get_library_servers
- ($env{'form.ccdomain'});
+ my %home_servers =
+ &Apache::lonnet::get_servers($env{'form.ccdomain'},'library');
if (! exists($home_servers{$desiredhost})) {
$r->print($error.&mt('Invalid home server specified'));
return;
@@ -1112,23 +1434,16 @@ ENDNEWUSERHEAD
($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cstid'},
$amode,$genpwd,$env{'form.cfirst'},
$env{'form.cmiddle'},$env{'form.clast'},$env{'form.cgen'},
- undef,$desiredhost
+ undef,$desiredhost,$env{'form.cemail'}
);
$r->print(&mt('Generating user').': '.$result);
my $home = &Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
$r->print(' '.&mt('Home server').': '.$home.' '.
- $Apache::lonnet::libserv{$home});
+ &Apache::lonnet::hostname($home));
} elsif (($env{'form.login'} ne 'nochange') &&
($env{'form.login'} ne '' )) {
# Modify user privileges
- my %lt=&Apache::lonlocal::texthash(
- 'usr' => "User",
- 'id' => "in domain"
- );
- $r->print(<$lt{'usr'} "$env{'form.ccuname'}" $lt{'id'} "$env{'form.ccdomain'}"
-ENDMODIFYUSERHEAD
if (! $amode || ! $genpwd) {
$r->print($error.'Invalid login mode or password'.$end);
return;
@@ -1151,37 +1466,73 @@ ENDMODIFYUSERHEAD
# Check for need to change
my %userenv = &Apache::lonnet::get
('environment',['firstname','middlename','lastname','generation',
- 'portfolioquota'],$env{'form.ccdomain'},$env{'form.ccuname'});
+ 'permanentemail','portfolioquota','inststatus'],
+ $env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
%userenv = ();
}
# Check to see if we need to change user information
- foreach my $item ('firstname','middlename','lastname','generation') {
+ foreach my $item ('firstname','middlename','lastname','generation','permanentemail') {
# Strip leading and trailing whitespace
$env{'form.c'.$item} =~ s/(\s+$|^\s+)//g;
}
- my ($quotachanged,$namechanged,$oldportfolioquota);
+ my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota,
+ $inststatus,$isdefault,$defquotatext);
+ my ($defquota,$settingstatus) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
my %changeHash;
- if (exists($userenv{'portfolioquota'})) {
+ if ($userenv{'portfolioquota'} ne '') {
$oldportfolioquota = $userenv{'portfolioquota'};
- if (exists($env{'form.portfolioquota'})) {
- if ($env{'form.portfolioquota'} ne $userenv{'portfolioquota'}) {
- if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
- # Current user has quota modification privileges
- $quotachanged = 1;
- $changeHash{'portfolioquota'} = $env{'form.portfolioquota'};
- }
+ if ($env{'form.customquota'} == 1) {
+ if ($env{'form.portfolioquota'} eq '') {
+ $newportfolioquota = 0;
+ } else {
+ $newportfolioquota = $env{'form.portfolioquota'};
+ $newportfolioquota =~ s/[^\d\.]//g;
+ }
+ if ($newportfolioquota != $userenv{'portfolioquota'}) {
+ $quotachanged = "a_admin($newportfolioquota,\%changeHash);
}
+ } else {
+ $quotachanged = "a_admin('',\%changeHash);
+ $newportfolioquota = $defquota;
+ $isdefault = 1;
}
} else {
- $oldportfolioquota = &default_quota($env{'form.ccdomain'});
+ $oldportfolioquota = $defquota;
+ if ($env{'form.customquota'} == 1) {
+ if ($env{'form.portfolioquota'} eq '') {
+ $newportfolioquota = 0;
+ } else {
+ $newportfolioquota = $env{'form.portfolioquota'};
+ $newportfolioquota =~ s/[^\d\.]//g;
+ }
+ $quotachanged = "a_admin($newportfolioquota,\%changeHash);
+ } else {
+ $newportfolioquota = $defquota;
+ $isdefault = 1;
+ }
+ }
+ if ($isdefault) {
+ 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});
+ }
+ }
}
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) &&
($env{'form.cfirstname'} ne $userenv{'firstname'} ||
$env{'form.cmiddlename'} ne $userenv{'middlename'} ||
$env{'form.clastname'} ne $userenv{'lastname'} ||
- $env{'form.cgeneration'} ne $userenv{'generation'} )) {
+ $env{'form.cgeneration'} ne $userenv{'generation'} ||
+ $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} )) {
$namechanged = 1;
}
if ($namechanged) {
@@ -1190,6 +1541,7 @@ ENDMODIFYUSERHEAD
$changeHash{'middlename'} = $env{'form.cmiddlename'};
$changeHash{'lastname'} = $env{'form.clastname'};
$changeHash{'generation'} = $env{'form.cgeneration'};
+ $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
my $putresult = &Apache::lonnet::put
('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
@@ -1201,6 +1553,7 @@ ENDMODIFYUSERHEAD
'mddl' => "middle",
'lst' => "last",
'gen' => "generation",
+ 'mail' => "permanent e-mail",
'disk' => "disk space allocated to portfolio files",
'prvs' => "Previous",
'chto' => "Changed To"
@@ -1213,22 +1566,33 @@ ENDMODIFYUSERHEAD
$lt{'mddl'}
$lt{'lst'}
$lt{'gen'}
-
$lt{'disk'}
+
$lt{'mail'}
+
$lt{'disk'}
$lt{'prvs'}
$userenv{'firstname'}
$userenv{'middlename'}
$userenv{'lastname'}
$userenv{'generation'}
-
$oldportfolioquota
+
$userenv{'permanentemail'}
+
$oldportfolioquota Mb
$lt{'chto'}
$env{'form.cfirstname'}
$env{'form.cmiddlename'}
$env{'form.clastname'}
$env{'form.cgeneration'}
-
$env{'form.portfolioquota'} Mb
+
$env{'form.cpermanentemail'}
+
$newportfolioquota Mb $defquotatext
END
+ if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&
+ ($env{'form.ccuname'} eq $env{'user.name'})) {
+ my %newenvhash;
+ foreach my $key (keys(%changeHash)) {
+ $newenvhash{'environment.'.$key} = $changeHash{$key};
+ }
+ &Apache::lonnet::appenv(%newenvhash);
+ }
} else { # error occurred
$r->print("
".&mt('Unable to successfully change environment for')." ".
$env{'form.ccuname'}." ".&mt('in domain')." ".
@@ -1244,19 +1608,18 @@ END
# They did not want to change the users name but we can
# still tell them what the name is
my %lt=&Apache::lonlocal::texthash(
- 'usr' => "User",
- 'id' => "in domain",
- 'gen' => "Generation",
+ 'mail' => "Permanent e-mail",
'disk' => "Disk space allocated to user's portfolio files",
);
$r->print(<<"END");
-
');
+ $r->print(''."\n");
+ foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') {
+ $r->print(''."\n");
+ }
+ foreach my $item ('sortby','seluname','seludom') {
+ if (exists($env{'form.'.$item})) {
+ $r->print(''."\n");
+ }
+ }
+ $r->print(''."\n".
+ ''."\n".
+ '');
$r->print(&Apache::loncommon::end_page());
}
+sub classlist_drop {
+ my ($scope,$uname,$udom,$now) = @_;
+ my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)});
+ my $cid=$cdom.'_'.$cnum;
+ my $user = $uname.':'.$udom;
+ if (!&active_student_roles($cnum,$cdom,$uname,$udom)) {
+ my $result =
+ &Apache::lonnet::cput('classlist',
+ { $user => $now },
+ $env{'course.'.$cid.'.domain'},
+ $env{'course.'.$cid.'.num'});
+ return &mt('Drop from classlist: [_1]',
+ ''.$result.'').' ';
+ }
+}
+
+sub active_student_roles {
+ my ($cnum,$cdom,$uname,$udom) = @_;
+ my %roles =
+ &Apache::lonnet::get_my_roles($uname,$udom,'userroles',
+ ['future','active'],['st']);
+ return exists($roles{"$cnum:$cdom:st"});
+}
+
+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;
@@ -1493,7 +1897,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 {
@@ -1517,7 +1921,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') {
@@ -1526,35 +1930,35 @@ sub custom_role_editor {
$rolename=~s/[^A-Za-z0-9]//gs;
- unless ($rolename) {
+ if (!$rolename) {
&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=();
+ $body_top .= $rolename.'"
';
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
my ($priv,$restrict)=split(/\&/,$item);
- unless ($restrict) { $restrict='F'; }
+ if (!$restrict) { $restrict='F'; }
$courselevel{$priv}=$restrict;
if ($coursepriv=~/\:$priv/) {
$courselevelcurrent{$priv}=1;
@@ -1565,7 +1969,7 @@ sub custom_role_editor {
my %domainlevelcurrent=();
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
my ($priv,$restrict)=split(/\&/,$item);
- unless ($restrict) { $restrict='F'; }
+ if (!$restrict) { $restrict='F'; }
$domainlevel{$priv}=$restrict;
if ($dompriv=~/\:$priv/) {
$domainlevelcurrent{$priv}=1;
@@ -1576,21 +1980,45 @@ sub custom_role_editor {
my %systemlevelcurrent=();
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
my ($priv,$restrict)=split(/\&/,$item);
- unless ($restrict) { $restrict='F'; }
+ 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,'','')",
+ text=>"User modify/custom role edit",
+ 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(<
+'.
&Apache::loncommon::end_page());
}
-
+# --------------------------------------------------------
+sub make_script_template {
+ my ($role) = @_;
+ my %full_c=();
+ my %full_d=();
+ my %full_s=();
+ my $return_script;
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
+ my ($priv,$restrict)=split(/\&/,$item);
+ $full_c{$priv}=1;
+ }
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
+ my ($priv,$restrict)=split(/\&/,$item);
+ $full_d{$priv}=1;
+ }
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
+ my ($priv,$restrict)=split(/\&/,$item);
+ $full_s{$priv}=1;
+ }
+ $return_script .= 'function set_'.$role.'() {'."\n";
+ my @temp = split(/:/,$Apache::lonnet::pr{$role.':c'});
+ my %role_c;
+ foreach my $priv (@temp) {
+ my ($priv_item, $dummy) = split(/\&/,$priv);
+ $role_c{$priv_item} = 1;
+ }
+ foreach my $priv_item (keys(%full_c)) {
+ my ($priv, $dummy) = split(/\&/,$priv_item);
+ if (exists($role_c{$priv})) {
+ $return_script .= "document.form1.$priv"."_c.checked = true;\n";
+ } else {
+ $return_script .= "document.form1.$priv"."_c.checked = false;\n";
+ }
+ }
+ my %role_d;
+ @temp = split(/:/,$Apache::lonnet::pr{$role.':d'});
+ foreach my $priv(@temp) {
+ my ($priv_item, $dummy) = split(/\&/,$priv);
+ $role_d{$priv_item} = 1;
+ }
+ foreach my $priv_item (keys(%full_d)) {
+ my ($priv, $dummy) = split(/\&/,$priv_item);
+ if (exists($role_d{$priv})) {
+ $return_script .= "document.form1.$priv"."_d.checked = true;\n";
+ } else {
+ $return_script .= "document.form1.$priv"."_d.checked = false;\n";
+ }
+ }
+ my %role_s;
+ @temp = split(/:/,$Apache::lonnet::pr{$role.':s'});
+ foreach my $priv(@temp) {
+ my ($priv_item, $dummy) = split(/\&/,$priv);
+ $role_s{$priv_item} = 1;
+ }
+ foreach my $priv_item (keys(%full_s)) {
+ my ($priv, $dummy) = split(/\&/,$priv_item);
+ if (exists($role_s{$priv})) {
+ $return_script .= "document.form1.$priv"."_s.checked = true;\n";
+ } else {
+ $return_script .= "document.form1.$priv"."_s.checked = false;\n";
+ }
+ }
+ $return_script .= '}'."\n";
+ return ($return_script);
+}
+# ----------------------------------------------------------
+sub make_button_code {
+ my ($role) = @_;
+ my $label = &Apache::lonnet::plaintext($role);
+ my $button_code = '';
+ return ($button_code);
+}
# ---------------------------------------------------------- Call to definerole
sub set_custom_role {
my ($r) = @_;
@@ -1627,16 +2129,32 @@ sub set_custom_role {
$rolename=~s/[^A-Za-z0-9]//gs;
- unless ($rolename) {
+ if (!$rolename) {
&print_username_entry_form($r);
return;
}
- $r->print(&Apache::loncommon::start_page('Save Custom Role').'
');
+ my ($jsback,$elements) = &crumb_utilities();
+ my $jscript = '';
+
+ $r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript);
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:backPage(document.customresult,'','')",
+ text=>"User modify/custom role edit",
+ faq=>282,bug=>'Instructor Interface',},
+ {href=>"javascript:backPage(document.customresult,'selected_custom_edit','')",
+ text=>"Edit custom role",
+ faq=>282,bug=>'Instructor Interface',},
+ {href=>"javascript:backPage(document.customresult,'set_custom_roles','')",
+ text=>"Result",
+ faq=>282,bug=>'Instructor Interface',});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
+
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
# ------------------------------------------------------- Does this role exist?
+ $r->print('
');
if (($rdummy ne 'con_lost') && ($roledef ne '')) {
$r->print(&mt('Existing Role').' "');
} else {
@@ -1651,24 +2169,24 @@ sub set_custom_role {
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
my ($priv,$restrict)=split(/\&/,$item);
- unless ($restrict) { $restrict=''; }
- if ($env{'form.'.$priv.':c'}) {
+ if (!$restrict) { $restrict=''; }
+ if ($env{'form.'.$priv.'_c'}) {
$courole.=':'.$item;
}
}
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
my ($priv,$restrict)=split(/\&/,$item);
- unless ($restrict) { $restrict=''; }
- if ($env{'form.'.$priv.':d'}) {
+ if (!$restrict) { $restrict=''; }
+ if ($env{'form.'.$priv.'_d'}) {
$domrole.=':'.$item;
}
}
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
my ($priv,$restrict)=split(/\&/,$item);
- unless ($restrict) { $restrict=''; }
- if ($env{'form.'.$priv.':s'}) {
+ if (!$restrict) { $restrict=''; }
+ if ($env{'form.'.$priv.'_s'}) {
$sysrole.=':'.$item;
}
}
@@ -1685,7 +2203,8 @@ sub set_custom_role {
$env{'user.name'},
$rolename));
}
- $r->print('
+"javascript:pjump('date_end','End Date $plrole',document.cu.end_$customrole.value,'end_$customrole','cu.pres','dateset')">$lt{'sed'}
ENDENTRY
+ $table .= &Apache::loncommon::end_data_table_row();
}
}
}
return '' if ($table eq ''); # return nothing if there is nothing
# in the table
- my $result = <$lt{'crl'}
-