--- loncom/interface/loncreateuser.pm 2008/12/18 17:27:49 1.271
+++ loncom/interface/loncreateuser.pm 2010/01/19 22:41:02 1.295.2.24
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.271 2008/12/18 17:27:49 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.295.2.24 2010/01/19 22:41:02 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -51,13 +51,14 @@ In LON-CAPA, roles are actually collecti
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 roles can be defined by a Domain Coordinator, Course Coordinator
+or Community Coordinator via the Manage User functionality.
+The custom role editor screen will show all privileges which can be
+assigned to users. For a complete list of privileges, please see
+C.
-Custom role definitions are stored in the C file of the role
-author.
+Custom role definitions are stored in the C file of the creator
+of the role.
=cut
@@ -68,6 +69,7 @@ use Apache::loncommon;
use Apache::lonlocal;
use Apache::longroup;
use Apache::lonuserutils;
+use Apache::loncoursequeueadmin;
use LONCAPA qw(:DEFAULT :match);
my $loginscript; # piece of javascript used in two separate instances
@@ -109,6 +111,7 @@ sub initialize_authen_forms {
sub auth_abbrev {
my %abv_auth = (
+ krb5 => 'krb',
krb4 => 'krb',
internal => 'int',
localuth => 'loc',
@@ -123,18 +126,10 @@ sub portfolio_quota {
my ($ccuname,$ccdomain) = @_;
my %lt = &Apache::lonlocal::texthash(
'usrt' => "User Tools",
- 'blog' => "Personal User Blog",
- 'aboutme' => "Personal Information Page",
- 'portfolio' => "Personal User Portfolio",
- 'avai' => "Available",
- 'cusa' => "availability",
- 'chse' => "Change setting",
'disk' => "Disk space allocated to user's portfolio files",
'cuqu' => "Current quota",
'cust' => "Custom quota",
'defa' => "Default",
- 'usde' => "Use default",
- 'uscu' => "Use custom",
'chqu' => "Change quota",
);
my ($currquota,$quotatype,$inststatus,$defquota) =
@@ -150,6 +145,7 @@ sub portfolio_quota {
$custom_off = ' checked="checked" ';
my $quota_javascript = <<"END_SCRIPT";
END_SCRIPT
if ($quotatype eq 'custom') {
@@ -190,51 +187,7 @@ END_SCRIPT
&Apache::loncommon::start_data_table();
if (&Apache::lonnet::allowed('mut',$ccdomain)) {
- my %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
- 'tools.aboutme','tools.portfolio','tools.blog');
- my @usertools = ('aboutme','blog','portfolio');
- foreach my $item (@usertools) {
- my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off);
- $cust_off = 'checked="checked" ';
- $tool_on = 'checked="checked" ';
- $curr_access = &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item);
- if ($userenv{'tools.'.$item} eq '') {
- $custom_access = 'default';
- if (!$curr_access) {
- $tool_off = 'checked="checked" ';
- $tool_on = '';
- }
- } else {
- $custom_access = 'custom';
- $cust_on = ' checked="checked" ';
- $cust_off = '';
- if ($userenv{'tools.'.$item} == 0) {
- $tool_off = 'checked="checked" ';
- $tool_on = '';
- }
- }
- $curr_access = &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item);
- $output .= '
');
+ } else {
+ $r->print($response.''.&Apache::loncommon::end_page());
+ }
}
sub print_user_query_page {
@@ -584,11 +899,11 @@ sub print_user_query_page {
}
sub print_user_modification_page {
- my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission) = @_;
+ my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype) = @_;
if (($ccuname eq '') || ($ccdomain eq '')) {
my $usermsg = &mt('No username and/or domain provided.');
$env{'form.phase'} = '';
- &print_username_entry_form($r,$context,$usermsg);
+ &print_username_entry_form($r,$context,$usermsg,'','',$crstype);
return;
}
my ($form,$formname);
@@ -612,7 +927,7 @@ sub print_user_modification_page {
&Apache::lonuserutils::can_create_user($ccdomain,$context,
$usertype);
if (!$cancreate) {
- my $helplink = ' href="javascript:helpMenu('."'display'".')"';
+ my $helplink = 'javascript:helpMenu('."'display'".')';
my %usertypetext = (
official => 'institutional',
unofficial => 'non-institutional',
@@ -622,9 +937,14 @@ sub print_user_modification_page {
$response = ''.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain).
' ';
}
- $response .= ''.&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.").' '.&mt('Contact the helpdesk for assistance.',$helplink).'
';
+ $response .= '
'
+ .&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.")
+ .' '
+ .&mt('Please contact the [_1]helpdesk[_2] for assistance.'
+ ,'','')
+ .'
');
my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname);
- my ($user_quota_text,$user_tools_text);
+ my ($user_quota_text,$user_tools_text,$user_reqcrs_text);
if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
(&Apache::lonnet::allowed('mut',$ccdomain))) {
# Current user has quota modification privileges
@@ -868,7 +1226,7 @@ ENDNOPORTPRIV
if (&Apache::lonnet::allowed('mut',$env{'request.role.domain'})) {
my %lt=&Apache::lonlocal::texthash(
'utav' => "User Tools Availability",
- 'yodo' => "You do not have privileges to modify Portfolio, Blog or Home Page settings for this user.",
+ 'yodo' => "You do not have privileges to modify Portfolio, Blog or Personal Information Page settings for this user.",
'ifch' => "If a change is required, contact a domain coordinator for the domain",
);
$user_tools_text = <print(' '."\n");
+ my $btntxt;
+ if ($crstype eq 'Community') {
+ $btntxt = &mt('Enroll Member');
+ } else {
+ $btntxt = &mt('Enroll Student');
+ }
+ $r->print(' '."\n");
} else {
$r->print('
'.
&Apache::loncommon::end_data_table_header_row());
- foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') {
+ foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
if ($output{$type}) {
$r->print($output{$type}."\n");
}
@@ -1250,7 +1633,7 @@ sub new_coauthor_roles {
&Apache::loncommon::end_data_table_header_row()."\n".
&Apache::loncommon::start_data_table_row().'
-
+
'.$lt{'cau'}.'
'.$cudom.'_'.$cuname.'
@@ -1262,7 +1645,7 @@ sub new_coauthor_roles {
"javascript:pjump('."'date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'sed'}.''."\n".
&Apache::loncommon::end_data_table_row()."\n".
&Apache::loncommon::start_data_table_row()."\n".
-'
+'
'.$lt{'caa'}.'
'.$cudom.'_'.$cuname.'
@@ -1302,8 +1685,10 @@ sub new_domain_roles {
&mt('Extent').''.
'
'.&mt('Start').'
'.&mt('End').'
'.
&Apache::loncommon::end_data_table_header_row();
+ my @allroles = &Apache::lonuserutils::roles_by_context('domain');
foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) {
- foreach my $role ('dc','li','dg','au','sc') {
+ foreach my $role (@allroles) {
+ next if ($role eq 'ad');
if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) {
my $plrole=&Apache::lonnet::plaintext($role);
my %lt=&Apache::lonlocal::texthash(
@@ -1313,7 +1698,7 @@ sub new_domain_roles {
$num_domain_level ++;
$domaintext .=
&Apache::loncommon::start_data_table_row().
-'
\n");
@@ -2268,15 +2809,19 @@ END
$env{'form.ccdomain'}.' ');
}
} else { # End of if ($env ... ) logic
- # They did not want to change the users name, quota or tool availability,
+ # They did not want to change the users name, quota, tool availability,
+ # or ability to request creation of courses,
# but we can still tell them what the name and quota and availabilities are
my %lt=&Apache::lonlocal::texthash(
- 'id' => "Student/Employee ID",
- 'mail' => "Permanent e-mail",
- 'disk' => "Disk space allocated to user's portfolio files",
- 'blog' => "Blog Availability",
- 'aboutme' => "Home Page Availability",
- 'portfolio' => "Portfolio Availability",
+ 'id' => "Student/Employee ID",
+ 'mail' => "Permanent e-mail address",
+ 'disk' => "Disk space allocated to user's portfolio files",
+ 'blog' => "Blog Availability",
+ 'aboutme' => "Personal Information Page Availability",
+ 'portfolio' => "Portfolio Availability",
+ 'official' => "Can Request Official Courses",
+ 'unofficial' => "Can Request Unofficial Courses",
+ 'inststatus' => "Affiliation",
);
$r->print(<<"END");
$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
@@ -2285,6 +2830,20 @@ END
$r->print(' ['.$lt{'mail'}.': '.
$userenv{'permanentemail'}.']');
}
+ if ($showinststatus) {
+ $r->print(' ['.$lt{'inststatus'}.': '.$oldinststatuses.']');
+ }
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print(' ['.$lt{$item}.': '.$newaccess{$item}.' '.
+ $newaccesstext{$item}.']'."\n");
+ }
+ } elsif ($showreqotherdom) {
+ foreach my $item (@requestcourses) {
+ $r->print(' ['.$lt{$item}.': '.$newaccess{$item}.' '.
+ $newaccesstext{$item}.']'."\n");
+ }
+ }
if ($showtools) {
foreach my $item (@usertools) {
$r->print(' ['.$lt{$item}.': '.$newaccess{$item}.' '.
@@ -2320,8 +2879,11 @@ END
} 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')").' ');
+ my $helplink = 'javascript:helpMenu('."'display'".')';
+ $r->print(''.$rolestr.' '
+ .&mt('Please contact your [_1]helpdesk[_2] for more information.'
+ ,'','')
+ .' ');
}
$r->print(''
.$no_forceid_alert
@@ -2329,9 +2891,14 @@ END
.'');
}
if ($env{'form.action'} eq 'singlestudent') {
- &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context);
- $r->print('
'.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key));
+ $r->print(&mt('[_1] may not be used as the name for a section, as it is a reserved word.',''.$key.''));
} else {
- $r->print('
'.&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',$key));
+ $r->print(&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',''.$key.''));
}
- $r->print(' '.&mt('Please go back and choose a different section name.').'
');
+ 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.'));
+ } 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('
');
}
} else {
$r->print(&mt('unable to enroll').": ".$enroll_result);
@@ -2721,13 +3477,25 @@ sub quota_admin {
}
sub tool_admin {
- my ($tool,$settool,$changeHash) = @_;
- my $toolchanged;
- if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
+ my ($tool,$settool,$changeHash,$context) = @_;
+ my $canchange = 0;
+ if ($context eq 'requestcourses') {
+ if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
+ $canchange = 1;
+ }
+ } elsif ($context eq 'reqcrsotherdom') {
+ if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
+ $canchange = 1;
+ }
+ } elsif (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
# Current user has quota modification privileges
+ $canchange = 1;
+ }
+ my $toolchanged;
+ if ($canchange) {
if (ref($changeHash) eq 'HASH') {
$toolchanged = 1;
- $changeHash->{'tools.'.$tool} = $settool;
+ $changeHash->{$context.'.'.$tool} = $settool;
}
}
return $toolchanged;
@@ -2770,18 +3538,27 @@ sub build_roles {
sub custom_role_editor {
my ($r) = @_;
- my $rolename=$env{'form.rolename'};
-
- if ($rolename eq 'make new role') {
- $rolename=$env{'form.newrolename'};
+ my $action = $env{'form.customroleaction'};
+ my $rolename;
+ if ($action eq 'new') {
+ $rolename=$env{'form.newrolename'};
+ } else {
+ $rolename=$env{'form.rolename'};
}
$rolename=~s/[^A-Za-z0-9]//gs;
-
if (!$rolename || $env{'form.phase'} eq 'pickrole') {
&print_username_entry_form($r);
return;
}
+ my ($crstype,$context);
+ if ($env{'request.course.id'}) {
+ $crstype = &Apache::loncommon::course_type();
+ $context = 'course';
+ } else {
+ $context = 'domain';
+ $crstype = $env{'form.templatecrstype'};
+ }
# ------------------------------------------------------- What can be assigned?
my %full=();
my %courselevel=();
@@ -2799,6 +3576,9 @@ sub custom_role_editor {
$body_top .= &mt('Existing Role').' "';
# ------------------------------------------------- Get current role privileges
($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
+ if ($crstype eq 'Community') {
+ $syspriv =~ s/bre\&S//;
+ }
} else {
$body_top .= &mt('New Role').' "';
$roledef='';
@@ -2838,15 +3618,56 @@ sub custom_role_editor {
my ($jsback,$elements) = &crumb_utilities();
my $button_code = "\n";
my $head_script = "\n";
- $head_script .= ''."\n";
+ my $context_code;
+ if ($context eq 'domain') {
+ my $checkedCommunity = '';
+ my $checkedCourse = ' checked="checked"';
+ if ($env{'form.templatecrstype'} eq 'Community') {
+ $checkedCommunity = $checkedCourse;
+ $checkedCourse = '';
+ }
+ $context_code = ''.(' ' x2).
+ ''.
+ ''.
+ '';
+ if ($env{'form.customroleaction'} eq 'new') {
+ $context_code .= '';
+ } else {
+ $context_code .= '';
+ }
+ $context_code .= ''.
+ '';
+ }
+ $head_script .= "\n".$jsback."\n".
+ '// ]]>'."\n".
+ ''."\n";
$r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script));
- &Apache::lonhtmlcommon::add_breadcrumb
+ &Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:backPage(document.form1,'pickrole','')",
text=>"Pick custom role",
faq=>282,bug=>'Instructor Interface',},
@@ -2863,13 +3684,21 @@ sub custom_role_editor {
'dml' => "Domain Level",
'ssl' => "System Level");
- $r->print('
';
}
$output .= &Apache::lonhtmlcommon::row_closure(1);
}
}
$output .= &Apache::lonhtmlcommon::end_pick_box().
' '
+ .&mt('Save').'" onclick="validate_types(this.form);" />'
.'';
$r->print($output);
return;
@@ -3862,12 +4847,12 @@ sub visible_in_cat {
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
my ($cathash,%settable,@vismsgs,$cansetvis);
my %visactions = &Apache::lonlocal::texthash(
- vis => 'Your course currently appears in the Course Catalog for this domain.',
+ vis => 'Your course/community currently appears in the Course/Community Catalog for this domain.',
gen => 'Courses can be both self-cataloging, based on an institutional code (e.g., fs08phy231), or can be assigned categories from a hierarchy defined for the domain.',
- miss => 'Your course does not currently appear in the Course Catalog for this domain.',
+ miss => 'Your course/community does not currently appear in the Course/Community Catalog for this domain.',
yous => 'You should remedy this if you plan to allow self-enrollment, otherwise students will have difficulty finding your course.',
coca => 'Courses can be absent from the Catalog, because they do not have an institutional code, have no assigned category, or have been specifically excluded.',
- make => 'Make any changes to self-enrollment settings below, click "Save changes", then take action to include the course in the Catalog:',
+ make => 'Make any changes to self-enrollment settings below, click "Save", then take action to include the course in the Catalog:',
take => 'Take the following action to ensure the course appears in the Catalog:',
dc_unhide => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.',
dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".',
@@ -4080,6 +5065,7 @@ sub print_userchangelogs_display {
my $formname = 'roleslog';
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $crstype = &Apache::loncommon::course_type();
my %roleslog=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
if ((keys(%roleslog))[0]=~/^error\:/) { undef(%roleslog); }
@@ -4118,7 +5104,7 @@ sub print_userchangelogs_display {
}
my (%whodunit,%changed,$version);
($version) = ($r->dir_config('lonVersion') =~ /^([\d\.]+)\-/);
- $r->print(&role_display_filter($formname,$cdom,$cnum,\%curr,$version));
+ $r->print(&role_display_filter($formname,$cdom,$cnum,\%curr,$version,$crstype));
my $showntablehdr = 0;
my $tablehdr = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
@@ -4194,11 +5180,11 @@ sub print_userchangelogs_display {
if ($roleslog{$id}{'logentry'}{'selfenroll'}) {
$chgcontext = 'selfenroll';
}
- my %lt = &rolechg_contexts();
+ my %lt = &rolechg_contexts($crstype);
if ($chgcontext ne '' && $lt{$chgcontext} ne '') {
$chgcontext = $lt{$chgcontext};
}
- $r->print(&Apache::loncommon::start_data_table_row().'
'.&Apache::loncommon::end_data_table_row()."\n");
}
if ($showntablehdr) {
$r->print(&Apache::loncommon::end_data_table().' ');
@@ -4213,6 +5199,7 @@ sub print_userchangelogs_display {
$r->print('');
$r->print(<<"ENDSCRIPT");
ENDSCRIPT
}
} else {
- $r->print(&mt('There are no records to display'));
+ $r->print('
'.
+ &mt('There are no records to display').
+ '
');
}
$r->print(''.
'');
@@ -4235,11 +5225,12 @@ ENDSCRIPT
}
sub role_display_filter {
- my ($formname,$cdom,$cnum,$curr,$version) = @_;
+ my ($formname,$cdom,$cnum,$curr,$version,$crstype) = @_;
my $context = 'course';
+ my $lctype = lc($crstype);
my $nolink = 1;
my $output = '
';
@@ -4251,7 +5242,7 @@ sub role_display_filter {
&Apache::lonhtmlcommon::date_setter($formname,'rolelog_end_date',
$curr->{'rolelog_end_date'},undef,
undef,undef,undef,undef,undef,undef,$nolink);
- my %lt = &rolechg_contexts();
+ my %lt = &rolechg_contexts($crstype);
$output .= '
'.&mt('Window during which changes occurred:').'
'.&mt('After:').
'
'.$startform.'
'.&mt('Before:').'
'.
$endform.'
'.
@@ -4261,13 +5252,13 @@ sub role_display_filter {
$output .= ' selected="selected"';
}
$output .= '>'.&mt('Any').''."\n";
- my @roles = &Apache::lonuserutils::course_roles($context,undef,1);
+ my @roles = &Apache::lonuserutils::course_roles($context,undef,1,$lctype);
foreach my $role (@roles) {
my $plrole;
if ($role eq 'cr') {
$plrole = &mt('Custom Role');
} else {
- $plrole=&Apache::lonnet::plaintext($role);
+ $plrole=&Apache::lonnet::plaintext($role,$crstype);
}
my $selstr = '';
if ($role eq $curr->{'role'}) {
@@ -4277,27 +5268,37 @@ sub role_display_filter {
}
$output .= '
'.
&mt('Context:').'
'.
- ''.
- &mt('[_1]Note:[_2] Only changes made from servers running LON-CAPA 2.6.99.0 or later are displayed.');
+ $output .= ''
+ .'';
+
+ # Update Display button
+ $output .= '
'
+ .''
+ .'
';
+
+ # Server version info
+ $output .= '
'
+ .&mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.'
+ ,'2.6.99.0');
if ($version) {
- $output .= ' '.&mt('This server is version [_3].','','',$version); }
- $output .= '
';
+ $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version);
+ }
+ $output .= '
';
return $output;
}
sub rolechg_contexts {
+ my ($crstype) = @_;
my %lt = &Apache::lonlocal::texthash (
any => 'Any',
auto => 'Automated enrollment',
@@ -4305,8 +5306,14 @@ sub rolechg_contexts {
createcourse => 'Course Creation',
course => 'User Management in course',
domain => 'User Management in domain',
- selfenroll => 'Self-enrolled',
+ selfenroll => 'Self-enrolled',
+ requestcourses => 'Course Request',
);
+ if ($crstype eq 'Community') {
+ $lt{'createcourse'} = &mt('Community Creation');
+ $lt{'course'} = &mt('User Management in community');
+ $lt{'requestcourses'} = &mt('Community Request');
+ }
return %lt;
}
@@ -4390,6 +5397,15 @@ sub user_search_result {
&build_search_response($context,$srch,%srch_results);
} else {
$currstate = 'modify';
+ my $uname = $srch->{'srchterm'};
+ my $udom = $srch->{'srchdomain'};
+ $srch_results{$uname.':'.$udom} =
+ { &Apache::lonnet::get('environment',
+ ['firstname',
+ 'lastname',
+ 'permanentemail'],
+ $udom,$uname)
+ };
}
} else {
%srch_results = &Apache::lonnet::usersearch($srch);
@@ -4681,17 +5697,27 @@ sub build_search_response {
$response .= ' '.&mt('You may want to broaden your search to the selected LON-CAPA domain.');
}
}
- if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {
+ my $createdom = $env{'request.role.domain'};
+ if ($context eq 'requestcrs') {
+ if ($env{'form.coursedom'} ne '') {
+ $createdom = $env{'form.coursedom'};
+ }
+ }
+ if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $createdom)) {
my $cancreate =
- &Apache::lonuserutils::can_create_user($env{'request.role.domain'},$context);
+ &Apache::lonuserutils::can_create_user($createdom,$context);
+ my $targetdom = ''.$createdom.'';
if ($cancreate) {
- my $showdom = &display_domain_info($env{'request.role.domain'});
+ my $showdom = &display_domain_info($createdom);
$response .= '
'
.''.&mt('To add a new user:').''
- .' '
- .&mt("(You can only create new users in your current role's domain - [_1])"
- ,''.$env{'request.role.domain'}.'')
- .'
'
+ .' ';
+ if ($context eq 'requestcrs') {
+ $response .= &mt("(You can only define new users in the new course's domain - [_1])",$targetdom);
+ } else {
+ $response .= &mt("(You can only create new users in your current role's domain - [_1])",$targetdom);
+ }
+ $response .= '
'
.&mt("Set 'Domain/institution to search' to: [_1]",''.$showdom.'')
.'
'
.&mt("Set 'Search criteria' to: [_1]username is ..... in selected LON-CAPA domain[_2]",'','')
@@ -4702,11 +5728,14 @@ sub build_search_response {
.'
'
- .&mt("You are not authorized to create new users in your current role's domain - [_1]."
- ,''.$env{'request.role.domain'}.'')
- .' '
- .&mt('Contact the [_1]helpdesk[_2] if you need to create a new user.'
+ $response .= '
';
+ if ($context eq 'requestcrs') {
+ $response .= &mt("You are not authorized to define new users in the new course's domain - [_1].",$targetdom);
+ } else {
+ $response .= &mt("You are not authorized to create new users in your current role's domain - [_1].",$targetdom);
+ }
+ $response .= ' '
+ .&mt('Please contact the [_1]helpdesk[_2] if you need to create a new user.'
,' '
,'')
.'
';
@@ -4800,7 +5829,7 @@ sub course_level_table {
$thiscourse=~s:_:/:g;
my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
my $area=$coursedata{'description'};
- my $type=$coursedata{'type'};
+ my $crstype=$coursedata{'type'};
if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; }
my ($domain,$cnum)=split(/\//,$thiscourse);
my %sections_count;
@@ -4810,9 +5839,9 @@ sub course_level_table {
&Apache::loncommon::get_sections($domain,$cnum);
}
}
- my @roles = &Apache::lonuserutils::roles_by_context('course');
+ my @roles = &Apache::lonuserutils::roles_by_context('course','',$crstype);
foreach my $role (@roles) {
- my $plrole=&Apache::lonnet::plaintext($role);
+ my $plrole=&Apache::lonnet::plaintext($role,$crstype);
if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) {
$table .= &course_level_row($protectedcourse,$role,$area,$domain,
$plrole,\%sections_count,\%lt);
@@ -4825,7 +5854,8 @@ sub course_level_table {
}
}
if (&Apache::lonnet::allowed('ccr',$thiscourse)) {
- foreach my $cust (sort keys %customroles) {
+ foreach my $cust (sort(keys(%customroles))) {
+ next if ($crstype eq 'Community' && $customroles{$cust} =~ /bre\&S/);
my $role = 'cr_cr_'.$env{'user.domain'}.'_'.$env{'user.name'}.'_'.$cust;
$table .= &course_level_row($protectedcourse,$role,$area,$domain,
$cust,\%sections_count,\%lt);
@@ -4856,7 +5886,7 @@ sub course_level_row {
$protectedcourse.'_'.$role.'" />'."\n".
'
'.$plrole.'
'."\n".
'
'.$area.' Domain: '.$domain.'
'."\n";
- if ($role eq 'cc') {
+ if (($role eq 'cc') || ($role eq 'co')) {
$row .= '
';
} elsif ($env{'request.course.sec'} ne '') {
$row .= '
';
my $courseform=''.&Apache::loncommon::selectcourse_link
('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course').'';
- my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu');
+ my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser');
my %lt=&Apache::lonlocal::texthash(
'rol' => "Role",
'grs' => "Section",
@@ -4916,14 +5946,14 @@ sub course_level_dc {
'ssd' => "Set Start Date",
'sed' => "Set End Date"
);
- my $header = '
'.&mt('"[_1]" set to "[_2]".',$title,$newval));
+ if ($newnotify) {
+ $r->print(' '.&mt('The following will be notified when an enrollment request needs approval, or has been approved: [_1].',$newnotify));
+ } else {
+ $r->print(' '.&mt('No notifications sent when an enrollment request needs approval, or has been approved.'));
+ }
+ $r->print('
'."\n");
+ }
} else {
if (exists($changes{'internal.selfenroll_'.$item})) {
my $newval = $changes{'internal.selfenroll_'.$item};
@@ -5178,13 +6334,16 @@ sub update_selfenroll_config {
}
sub get_selfenroll_titles {
- my @row = ('types','registered','enroll_dates','access_dates','section');
+ my @row = ('types','registered','enroll_dates','access_dates','section',
+ 'approval','limit');
my %lt = &Apache::lonlocal::texthash (
types => 'Users allowed to self-enroll in this course',
registered => 'Restrict self-enrollment to students officially registered for the course',
enroll_dates => 'Dates self-enrollment available',
access_dates => 'Course access dates assigned to self-enrolling users',
section => 'Section assigned to self-enrolling users',
+ approval => 'Self-enrollment requests need approval?',
+ limit => 'Enrollment limit',
);
return (\@row,\%lt);
}