--- loncom/interface/loncreateuser.pm 2002/11/18 20:06:53 1.44
+++ loncom/interface/loncreateuser.pm 2007/12/21 15:22:01 1.216
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.44 2002/11/18 20:06:53 matthew Exp $
+# $Id: loncreateuser.pm,v 1.216 2007/12/21 15:22:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,127 +25,333 @@
#
# http://www.lon-capa.org/
#
-# (Create a course
-# (My Desk
-#
-# (Internal Server Error Handler
-#
-# (Login Screen
-# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
-# 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
-#
-# YEAR=2001
-# 3/1/1 Gerd Kortemeyer)
-#
-# 3/1 Gerd Kortemeyer)
-#
-# 2/14 Gerd Kortemeyer)
-#
-# 2/14,2/17,2/19,2/20,2/21,2/22,2/23,3/2,3/17,3/24,04/12 Gerd Kortemeyer
-# April Guy Albertelli
-# 05/10,10/16 Gerd Kortemeyer
-# 11/12,11/13,11/15 Scott Harrison
-# 02/11/02 Matthew Hall
-#
-# $Id: loncreateuser.pm,v 1.44 2002/11/18 20:06:53 matthew Exp $
###
package Apache::loncreateuser;
+=pod
+
+=head1 NAME
+
+Apache::loncreateuser - handler to create users and custom roles
+
+=head1 SYNOPSIS
+
+Apache::loncreateuser provides an Apache handler for creating users,
+ editing their login parameters, roles, and removing roles, and
+ also creating and assigning custom roles.
+
+=head1 OVERVIEW
+
+=head2 Custom Roles
+
+In LON-CAPA, roles are actually collections of privileges. "Teaching
+Assistant", "Course Coordinator", and other such roles are really just
+collection of privileges that are useful in many circumstances.
+
+Creating custom roles can be done by the Domain Coordinator through
+the Create User functionality. That screen will show all privileges
+that can be assigned to users. For a complete list of privileges,
+please see C.
+
+Custom role definitions are stored in the C'.$lt{'disk'}.'
'.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_row().
+ ''.$lt{'cuqu'}.': '.$currquota.' Mb. '.
+ $defaultinfo.' '.
+ &Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::start_data_table_row().
+ ''.$lt{'chqu'}.
+ ': '.
+ ' '.
+ ' Mb '.
+ &Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table();
+ return $output;
}
# =================================================================== Phase one
sub print_username_entry_form {
- my $r=shift;
- my $defdom=$ENV{'request.role.domain'};
- my @domains = &Apache::loncommon::get_domains();
- my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
- my $bodytag =&Apache::loncommon::bodytag(
- 'Create Users, Change User Privileges');
- $r->print(<<"ENDDOCUMENT");
-
-
-$lt{'srch'} $sellink $actiontext
");
+ if ($env{'form.origform'} ne 'crtusername') {
+ $r->print("\n".$response);
+ }
+ $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response));
+ }
+ $r->print(&Apache::loncommon::end_page());
+}
+
+sub entry_form {
+ my ($dom,$srch,$forcenewuser,$context,$responsemsg) = @_;
+ my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
+ my $usertype;
+ if (ref($srch) eq 'HASH') {
+ if (($srch->{'srchin'} eq 'dom') &&
+ ($srch->{'srchby'} eq 'uname') &&
+ ($srch->{'srchtype'} eq 'exact') &&
+ ($srch->{'srchdomain'} ne '') &&
+ ($srch->{'srchterm'} ne '')) {
+ my ($rules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username');
+ $usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules);
+ }
+ }
+ my $cancreate =
+ &Apache::lonuserutils::can_create_user($dom,$context,$usertype);
+ my $userpicker =
+ &Apache::loncommon::user_picker($dom,$srch,$forcenewuser,
+ 'document.crtuser',$cancreate,$usertype);
+ my $srchbutton = &mt('Search');
+ my $output = <<"ENDBLOCK";
+
+ENDBLOCK
+ if ($cancreate && $env{'form.phase'} eq '') {
+ my $defdom=$env{'request.role.domain'};
+ my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
+ my $helpcrt=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
+ my %lt=&Apache::lonlocal::texthash(
+ 'crnu' => 'Create a new user',
+ 'usr' => 'Username',
+ 'dom' => 'in domain',
+ 'cra' => 'Create user',
+ );
+ $output .= <<"ENDDOCUMENT";
+