'."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ return $output;
+}
+
+sub courserequest_titles {
+ my %titles = &Apache::lonlocal::texthash (
+ official => 'Official',
+ unofficial => 'Unofficial',
+ community => 'Communities',
+ norequest => 'Not allowed',
+ approval => 'Approval by Dom. Coord.',
+ validate => 'With validation',
+ autolimit => 'Numerical limit',
+ unlimited => '(blank for unlimited)',
+ );
+ return %titles;
+}
+
+sub courserequest_display {
+ my %titles = &Apache::lonlocal::texthash (
+ approval => 'Yes, need approval',
+ validate => 'Yes, with validation',
+ norequest => 'No',
+ );
+ return %titles;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
- my ($r,$context,$response,$srch,$forcenewuser) = @_;
+ my ($r,$context,$response,$srch,$forcenewuser,$crstype) = @_;
my $defdom=$env{'request.role.domain'};
my $formtoset = 'crtuser';
if (exists($env{'form.startrolename'})) {
@@ -299,13 +480,15 @@ sub print_username_entry_form {
my $jscript = &Apache::loncommon::studentbrowser_javascript()."\n".
''."\n";
my %loaditems = (
'onload' => "javascript:setFormElements(document.$formtoset)",
);
- my %breadcrumb_text = &singleuser_breadcrumb();
+ my %breadcrumb_text = &singleuser_breadcrumb($crstype);
my $start_page =
&Apache::loncommon::start_page('User Management',
$jscript,{'add_entries' => \%loaditems,});
@@ -332,6 +515,8 @@ sub print_username_entry_form {
('make new role' => 'Generate new role ...',%existingroles));
my %lt=&Apache::lonlocal::texthash(
'srst' => 'Search for a user and enroll as a student',
+ 'srme' => 'Search for a user and enroll as a member',
+
'srad' => 'Search for a user and modify/add user information or roles',
'usr' => "Username",
'dom' => "Domain",
@@ -355,20 +540,23 @@ ENDCUSTOM
} else {
my $actiontext = $lt{'srad'};
if ($env{'form.action'} eq 'singlestudent') {
- $actiontext = $lt{'srst'};
+ if ($crstype eq 'Community') {
+ $actiontext = $lt{'srme'};
+ } else {
+ $actiontext = $lt{'srst'};
+ }
}
- $r->print("
-
$actiontext
");
+ $r->print("
$actiontext
");
if ($env{'form.origform'} ne 'crtusername') {
$r->print("\n".$response);
}
- $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response));
+ $r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response,$crstype));
}
$r->print(&Apache::loncommon::end_page());
}
sub entry_form {
- my ($dom,$srch,$forcenewuser,$context,$responsemsg) = @_;
+ my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_;
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
my ($usertype,$inexact);
if (ref($srch) eq 'HASH') {
@@ -408,6 +596,7 @@ ENDBLOCK
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
my %lt=&Apache::lonlocal::texthash(
'enro' => 'Enroll one student',
+ 'enrm' => 'Enroll one member',
'admo' => 'Add/modify a single user',
'crea' => 'create new user if required',
'uskn' => "username is known",
@@ -420,7 +609,11 @@ ENDBLOCK
my $sellink=&Apache::loncommon::selectstudent_link('crtusername','srchterm','srchdomain');
my ($title,$buttontext,$showresponse);
if ($env{'form.action'} eq 'singlestudent') {
- $title = $lt{'enro'};
+ if ($crstype eq 'Community') {
+ $title = $lt{'enrm'};
+ } else {
+ $title = $lt{'enro'};
+ }
$buttontext = $lt{'enrl'};
} else {
$title = $lt{'admo'};
@@ -466,6 +659,7 @@ sub user_modification_js {
return <
+//
END
}
# =================================================================== Phase two
sub print_user_selection_page {
- my ($r,$response,$srch,$srch_results,$srcharray,$context) = @_;
+ my ($r,$response,$srch,$srch_results,$srcharray,$context,$opener_elements,$crstype) = @_;
my @fields = ('username','domain','lastname','firstname','permanentemail');
my $sortby = $env{'form.sortby'};
@@ -502,6 +696,7 @@ sub print_user_selection_page {
my $jscript = (<
+//
ENDSCRIPT
my %lt=&Apache::lonlocal::texthash(
'usrch' => "User Search to add/modify roles",
'stusrch' => "User Search to enroll student",
+ 'memsrch' => "User Search to enroll member",
'usel' => "Select a user to add/modify roles",
- 'stusel' => "Select a user to enroll as a student",
+ 'stusel' => "Select a user to enroll as a student",
+ 'memsel' => "Select a user to enroll as a member",
'username' => "username",
'domain' => "domain",
'lastname' => "last name",
'firstname' => "first name",
'permanentemail' => "permanent e-mail",
);
- $r->print(&Apache::loncommon::start_page('User Management',$jscript));
+ if ($context eq 'requestcrs') {
+ $r->print('
');
# Remove non alphanumeric values from section
$env{'form.sections'}=~s/\W//g;
@@ -2922,7 +3341,13 @@ sub enroll_single_student {
}
$r->print('. '.$showstart.'; '.$showend);
if ($startdate <= $now && !$newuser) {
- $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('
');
+ 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);
@@ -2992,6 +3417,10 @@ sub tool_admin {
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;
@@ -3111,13 +3540,25 @@ sub custom_role_editor {
my ($jsback,$elements) = &crumb_utilities();
my $button_code = "\n";
my $head_script = "\n";
- $head_script .= ''."\n";
+ $head_script .= "\n".$jsback."\n".
+ '// ]]>'."\n".
+ ''."\n";
$r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script));
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:backPage(document.form1,'pickrole','')",
@@ -3155,7 +3596,7 @@ ENDCCF
'
'.$lt{'ssl'}.'
'.
&Apache::loncommon::end_data_table_header_row());
foreach my $priv (sort keys %full) {
- my $privtext = &Apache::lonnet::plaintext($priv);
+ my $privtext = &Apache::lonnet::plaintext($priv,$crstype);
$r->print(&Apache::loncommon::start_data_table_row().
'
'.$privtext.'
'.
($courselevel{$priv}?'';
+ my ($role,$crstype) = @_;
+ my $label = &Apache::lonnet::plaintext($role,$crstype);
+ my $button_code = '';
return ($button_code);
}
# ---------------------------------------------------------- Call to definerole
@@ -3260,7 +3701,11 @@ sub set_custom_role {
return;
}
my ($jsback,$elements) = &crumb_utilities();
- my $jscript = '';
+ my $jscript = '';
$r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript);
&Apache::lonhtmlcommon::add_breadcrumb
@@ -3342,9 +3787,10 @@ sub handler {
$r->send_http_header;
return OK;
}
- my $context;
+ my ($context,$crstype);
if ($env{'request.course.id'}) {
$context = 'course';
+ $crstype = &Apache::loncommon::course_type();
} elsif ($env{'request.role'} =~ /^au\./) {
$context = 'author';
} else {
@@ -3363,7 +3809,7 @@ sub handler {
#SD Following files not added to help, because the corresponding .tex-files seem to
#be missing: Course_Approve_Selfenroll,Course_User_Logs,
my ($permission,$allowed) =
- &Apache::lonuserutils::get_permission($context);
+ &Apache::lonuserutils::get_permission($context,$crstype);
if (!$allowed) {
$env{'user.error.msg'}=
"/adm/createuser:cst:0:0:Cannot create/modify user data ".
@@ -3378,7 +3824,7 @@ sub handler {
if (! exists($env{'form.action'})) {
$r->print(&header());
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management'));
- $r->print(&print_main_menu($permission,$context));
+ $r->print(&print_main_menu($permission,$context,$crstype));
$r->print(&Apache::loncommon::end_page());
} elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) {
$r->print(&header());
@@ -3394,7 +3840,7 @@ sub handler {
&Apache::lonuserutils::print_first_users_upload_form($r,$context);
} elsif ($env{'form.state'} eq 'got_file') {
&Apache::lonuserutils::print_upload_manager_form($r,$context,
- $permission);
+ $permission,$crstype);
} elsif ($env{'form.state'} eq 'enrolling') {
if ($env{'form.datatoken'}) {
&Apache::lonuserutils::upfile_drop_add($r,$context,$permission);
@@ -3419,13 +3865,13 @@ sub handler {
if ($env{'form.srchterm'} !~ /^$match_username$/) {
my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @');
$env{'form.phase'} = '';
- &print_username_entry_form($r,$context,$response,$srch);
+ &print_username_entry_form($r,$context,$response,$srch,undef,$crstype);
} else {
my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'});
my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
&print_user_modification_page($r,$ccuname,$ccdomain,
$srch,$response,$context,
- $permission);
+ $permission,$crstype);
}
} elsif ($env{'form.phase'} eq 'get_user_info') {
my ($currstate,$response,$forcenewuser,$results) =
@@ -3435,7 +3881,7 @@ sub handler {
}
if ($currstate eq 'select') {
&print_user_selection_page($r,$response,$srch,$results,
- \@search,$context);
+ \@search,$context,undef,$crstype);
} elsif ($currstate eq 'modify') {
my ($ccuname,$ccdomain);
if (($srch->{'srchby'} eq 'uname') &&
@@ -3453,24 +3899,24 @@ sub handler {
}
&print_user_modification_page($r,$ccuname,$ccdomain,
$srch,$response,$context,
- $permission);
+ $permission,$crstype);
} elsif ($currstate eq 'query') {
&print_user_query_page($r,'createuser');
} else {
$env{'form.phase'} = '';
&print_username_entry_form($r,$context,$response,$srch,
- $forcenewuser);
+ $forcenewuser,$crstype);
}
} elsif ($env{'form.phase'} eq 'userpicked') {
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'});
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'});
&print_user_modification_page($r,$ccuname,$ccdomain,$srch,'',
- $context,$permission);
+ $context,$permission,$crstype);
}
} elsif ($env{'form.phase'} eq 'update_user_data') {
- &update_user_data($r,$context);
+ &update_user_data($r,$context,$crstype);
} else {
- &print_username_entry_form($r,$context,undef,$srch);
+ &print_username_entry_form($r,$context,undef,$srch,undef,$crstype);
}
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) {
if ($env{'form.phase'} eq 'set_custom_roles') {
@@ -3505,10 +3951,22 @@ sub handler {
text=>"List Users"});
my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
my $formname = 'studentform';
- if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
- ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) =
- &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
- $formname);
+ if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community'))) {
+ if ($env{'form.roletype'} eq 'course') {
+ ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) =
+ &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
+ $formname);
+ } elsif ($env{'form.roletype'} eq 'community') {
+ $cb_jscript =
+ &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
+ my %elements = (
+ coursepick => 'radio',
+ coursetotal => 'text',
+ courselist => 'text',
+ );
+ $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements);
+ }
$jscript .= &verify_user_display();
my $js = &add_script($jscript).$cb_jscript;
my $loadcode =
@@ -3529,19 +3987,25 @@ sub handler {
}
} elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) {
$r->print(&header());
+ my $brtext;
+ if ($crstype eq 'Community') {
+ $brtext = 'Drop Members';
+ } else {
+ $brtext = 'Drop Students';
+ }
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/createuser?action=drop',
- text=>"Drop Students"});
+ text=>$brtext});
if (!exists($env{'form.state'})) {
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Drop Students',
'Course_Drop_Student'));
- &Apache::lonuserutils::print_drop_menu($r,$context,$permission);
+ &Apache::lonuserutils::print_drop_menu($r,$context,$permission,$crstype);
} elsif ($env{'form.state'} eq 'done') {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/createuser?action=drop',
text=>"Result"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Drop Students',
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs($brtext,
'Course_Drop_Student'));
&Apache::lonuserutils::update_user_list($r,$context,undef,
$env{'form.action'});
@@ -3551,7 +4015,7 @@ sub handler {
if ($permission->{'cusr'}) {
$r->print(&header(undef,undef,{'no_nav_bar' => 1}).
&Apache::lonuserutils::date_section_selector($context,
- $permission).
+ $permission,$crstype).
&Apache::loncommon::end_page());
} else {
$r->print(&header().
@@ -3586,11 +4050,14 @@ sub handler {
my $cid = $env{'request.course.id'};
my $cdom = $env{'course.'.$cid.'.domain'};
my $cnum = $env{'course.'.$cid.'.num'};
+ my $coursedesc = $env{'course.'.$cid.'.description'};
if (!exists($env{'form.state'})) {
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment requests',
'Course_SelfEnrollment_Approval'));
$r->print('
'.&mt('The following enrollment requests were deleted because the user is already enrolled in the course:').'
');
- foreach my $user (@existing) {
- $r->print('
'.$user.'
');
- }
- $r->print('
');
- }
- if (@missingreq) {
- $r->print('
'.&mt('The following enrollment requests were ignored because the request is no longer in the enrollment queue:').'
');
- foreach my $user (@missingreq) {
- $r->print('
'.$user.'
');
- }
- $r->print('
');
- }
- if (@invalidusers) {
- $r->print('
'.&mt('The following enrollment requests were deleted because the requestor does not have a LON-CAPA account:').'
');
- foreach my $user (@invalidusers) {
- $r->print('
'.$user.'
');
- }
- $r->print('
');
- }
- if (@limitexceeded) {
- $r->print('
'.&mt('The following enrollment requests were skipped because the enrollment limit has been reached for the course:').'
');
- foreach my $user (@limitexceeded) {
- $r->print('
'.$user.'
');
- }
- $r->print('
');
- }
- if (@enrollerrors) {
- $r->print('
'.&mt('The following enrollment requests could not be processed because an error occurred:').'
');
- foreach my $user (@enrollerrors) {
- $r->print('
'.$user.'
');
- }
- $r->print('
');
- }
- if (@warn_approves) {
- $r->print('
'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'
');
- foreach my $user (@warn_approves) {
- $r->print('
'.$user.'
');
- }
- $r->print('
');
- }
- if (@warn_rejects) {
- $r->print('
'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'
');
- foreach my $user (@warn_rejects) {
- $r->print('
'.$user.'
');
- }
- $r->print('
');
- }
- return;
-}
-
-sub get_student_counts {
- my ($cdom,$cnum) = @_;
- my (%idx,%stucounts);
- my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
- $idx{'type'} = &Apache::loncoursedata::CL_TYPE();
- $idx{'status'} = &Apache::loncoursedata::CL_STATUS();
- while (my ($student,$data) = each(%$classlist)) {
- if (($data->[$idx{'status'}] eq 'Active') ||
- ($data->[$idx{'status'}] eq 'Future')) {
- if ($data->[$idx{'type'}] eq 'selfenroll') {
- $stucounts{'selfenroll'} ++;
- }
- $stucounts{'allstudents'} ++;
- }
- }
- return (\%stucounts,\%idx,$classlist);
-}
-
sub visible_in_cat {
my ($cdom,$cnum) = @_;
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", then take action to include the course in the Catalog:',
@@ -4752,6 +4940,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); }
@@ -4790,7 +4979,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().
@@ -4866,11 +5055,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().' ');
@@ -4885,6 +5074,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(''.
'');
@@ -4907,11 +5100,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 = '
';
@@ -4923,7 +5117,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.'
'.
@@ -4933,13 +5127,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'}) {
@@ -4949,27 +5143,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',
@@ -4977,8 +5181,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;
}
@@ -5062,6 +5272,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);
@@ -5353,17 +5572,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]",'','')
@@ -5374,10 +5603,13 @@ sub build_search_response {
.'
'
- .&mt("You are not authorized to create new users in your current role's domain - [_1]."
- ,''.$env{'request.role.domain'}.'')
- .' '
+ $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.'
,' '
,'')
@@ -5472,7 +5704,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;
@@ -5482,9 +5714,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);
@@ -5577,7 +5809,7 @@ sub course_level_dc {
'';
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",
@@ -5594,7 +5826,7 @@ sub course_level_dc {
'
'.$courseform.'
'.$lt{'rol'}.'
'.$lt{'grs'}.'
'.$lt{'sta'}.'
'.$lt{'end'}.'
'.
&Apache::loncommon::end_data_table_header_row();
my $otheritems = &Apache::loncommon::start_data_table_row()."\n".
- '