\n"
+ }
+ if ($can_assign{'loc'}) {
+ $show_override_msg = 1;
+ }
+ }
+ if ($show_override_msg) {
+ $authformcurrent.= ' '.
+ &mt('will override current values').
+ ' ';
+ }
+ return ($authformcurrent,$authform_other,$show_override_msg);
+}
+
# ================================================================= Phase Three
sub update_user_data {
- my $r=shift;
+ my ($r) = @_;
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
# Error messages
@@ -1045,7 +1380,31 @@ 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'} ) {
@@ -1055,7 +1414,7 @@ sub update_user_data {
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;
}
@@ -1106,15 +1465,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);
@@ -1137,7 +1494,7 @@ 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'},
@@ -1147,13 +1504,6 @@ ENDNEWUSERHEAD
} 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;
@@ -1176,14 +1526,14 @@ ENDMODIFYUSERHEAD
# Check for need to change
my %userenv = &Apache::lonnet::get
('environment',['firstname','middlename','lastname','generation',
- 'portfolioquota','inststatus'],$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;
}
@@ -1241,7 +1591,8 @@ ENDMODIFYUSERHEAD
($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) {
@@ -1250,6 +1601,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'});
@@ -1261,6 +1613,7 @@ ENDMODIFYUSERHEAD
'mddl' => "middle",
'lst' => "last",
'gen' => "generation",
+ 'mail' => "permanent e-mail",
'disk' => "disk space allocated to portfolio files",
'prvs' => "Previous",
'chto' => "Changed To"
@@ -1273,12 +1626,14 @@ ENDMODIFYUSERHEAD
$lt{'mddl'}
$lt{'lst'}
$lt{'gen'}
-
$lt{'disk'}
+
$lt{'mail'}
+
$lt{'disk'}
$lt{'prvs'}
$userenv{'firstname'}
$userenv{'middlename'}
$userenv{'lastname'}
$userenv{'generation'}
+
$userenv{'permanentemail'}
$oldportfolioquota Mb
$lt{'chto'}
@@ -1286,6 +1641,7 @@ ENDMODIFYUSERHEAD
$env{'form.cmiddlename'}
$env{'form.clastname'}
$env{'form.cgeneration'}
+
$env{'form.cpermanentemail'}
$newportfolioquota Mb $defquotatext
END
@@ -1312,15 +1668,12 @@ 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;
@@ -1598,7 +1981,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') {
@@ -1611,43 +1994,29 @@ sub custom_role_editor {
&print_username_entry_form($r);
return;
}
- my $head_script = <
- function setchecks() {
- document.form1.bre_c.checked = false;
- }
-
-END_SCRIPT
-
- $r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script));
+# ------------------------------------------------------- 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=();
- my @roles = ("st:c","st:d");
- #foreach my $item (@roles) {
- # &Apache::lonnet::logthis(" roles for $item: ".$Apache::lonnet::pr{$item});
- #}
-
+ $body_top .= $rolename.'"
';
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
-
my ($priv,$restrict)=split(/\&/,$item);
if (!$restrict) { $restrict='F'; }
$courselevel{$priv}=$restrict;
@@ -1678,14 +2047,38 @@ END_SCRIPT
}
$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");
- $r->print('');
+ $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) = @_;
@@ -1727,11 +2194,27 @@ sub set_custom_role {
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 {
@@ -1780,7 +2263,8 @@ sub set_custom_role {
$env{'user.name'},
$rolename));
}
- $r->print('