version 1.239, 2008/05/12 17:52:09
|
version 1.247, 2008/07/04 18:30:30
|
Line 2069 END
|
Line 2069 END
|
if ($env{'form.popup'}) { |
if ($env{'form.popup'}) { |
$r->print('<p><a href="javascript:window.close()">'.&mt('Close window').'</a></p>'); |
$r->print('<p><a href="javascript:window.close()">'.&mt('Close window').'</a></p>'); |
} else { |
} else { |
$r->print('<p><a href="javascript:backPage(document.userupdate,'."'$env{'form.prevphase'}','modify'".')">'.&mt('Modify this user: <span class="LC_cusr_emph">([_1])</span>',$userinfo).'</a>'.(' 'x5).'<a href="javascript:backPage(document.userupdate)">'.&mt('Create/Modify Another User').'</a></p>'); |
$r->print('<p><a href="javascript:backPage(document.userupdate,'."'$env{'form.prevphase'}','modify'".')">' |
|
.&mt('Modify this user: [_1]','<span class="LC_cusr_emph">'.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.')</span>').'</a>' |
|
.(' 'x5).'<a href="javascript:backPage(document.userupdate)">' |
|
.&mt('Create/Modify Another User').'</a></p>'); |
} |
} |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
Line 2146 sub update_roles {
|
Line 2149 sub update_roles {
|
$rolename,$rnam,$rdom,$url).': <b>'. |
$rolename,$rnam,$rdom,$url).': <b>'. |
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, |
&Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, |
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, |
$env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, |
0,1).'</b><br />'); |
0,1,$context).'</b><br />'); |
if (!grep(/^cr$/,@rolechanges)) { |
if (!grep(/^cr$/,@rolechanges)) { |
push(@rolechanges,'cr'); |
push(@rolechanges,'cr'); |
} |
} |
Line 2193 sub update_roles {
|
Line 2196 sub update_roles {
|
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); |
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); |
my $result = &Apache::lonnet::assigncustomrole( |
my $result = &Apache::lonnet::assigncustomrole( |
$env{'form.ccdomain'}, $env{'form.ccuname'}, |
$env{'form.ccdomain'}, $env{'form.ccuname'}, |
$url,$rdom,$rnam,$rolename,0,$now); |
$url,$rdom,$rnam,$rolename,0,$now,undef,$context); |
$r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>', |
$r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>', |
$rolename,$rnam,$rdom,$url,$result).'<br />'); |
$rolename,$rnam,$rdom,$url,$result).'<br />'); |
if (!grep(/^cr$/,@rolechanges)) { |
if (!grep(/^cr$/,@rolechanges)) { |
Line 2220 sub update_roles {
|
Line 2223 sub update_roles {
|
my %sections = (); |
my %sections = (); |
my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5); |
my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5); |
if ($num_sections == 0) { |
if ($num_sections == 0) { |
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end)); |
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end,$context)); |
} else { |
} else { |
my %curr_groups = |
my %curr_groups = |
&Apache::longroup::coursegroups($one,$two); |
&Apache::longroup::coursegroups($one,$two); |
Line 2231 sub update_roles {
|
Line 2234 sub update_roles {
|
next; |
next; |
} |
} |
my $securl = $url.'/'.$sec; |
my $securl = $url.'/'.$sec; |
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end)); |
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end,$context)); |
} |
} |
} |
} |
if (!grep(/^cr$/,@rolechanges)) { |
if (!grep(/^cr$/,@rolechanges)) { |
Line 2253 sub update_roles {
|
Line 2256 sub update_roles {
|
my %sections = (); |
my %sections = (); |
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three); |
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three); |
if ($num_sections == 0) { |
if ($num_sections == 0) { |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context)); |
} else { |
} else { |
my %curr_groups = |
my %curr_groups = |
&Apache::longroup::coursegroups($one,$two); |
&Apache::longroup::coursegroups($one,$two); |
Line 2267 sub update_roles {
|
Line 2270 sub update_roles {
|
next; |
next; |
} |
} |
my $securl = $url.'/'.$sec; |
my $securl = $url.'/'.$sec; |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec)); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context)); |
} else { |
} else { |
$emptysec = 1; |
$emptysec = 1; |
} |
} |
} |
} |
if ($emptysec) { |
if ($emptysec) { |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context)); |
} |
} |
} |
} |
if (!grep(/^\Q$three\E$/,@rolechanges)) { |
if (!grep(/^\Q$three\E$/,@rolechanges)) { |
Line 2295 sub update_roles {
|
Line 2298 sub update_roles {
|
my %sections = (); |
my %sections = (); |
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two},\%sections,$two); |
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two},\%sections,$two); |
if ($num_sections == 0) { |
if ($num_sections == 0) { |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'')); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context)); |
} else { |
} else { |
my $emptysec = 0; |
my $emptysec = 0; |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
if ($sec ne '') { |
if ($sec ne '') { |
my $securl = $url.'/'.$sec; |
my $securl = $url.'/'.$sec; |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec)); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context)); |
} else { |
} else { |
$emptysec = 1; |
$emptysec = 1; |
} |
} |
} |
} |
if ($emptysec) { |
if ($emptysec) { |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'')); |
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context)); |
} |
} |
} |
} |
if (!grep(/^\Q$two\E$/,@rolechanges)) { |
if (!grep(/^\Q$two\E$/,@rolechanges)) { |
Line 2670 sub make_button_code {
|
Line 2673 sub make_button_code {
|
} |
} |
# ---------------------------------------------------------- Call to definerole |
# ---------------------------------------------------------- Call to definerole |
sub set_custom_role { |
sub set_custom_role { |
my ($r) = @_; |
my ($r,$context) = @_; |
my $rolename=$env{'form.rolename'}; |
my $rolename=$env{'form.rolename'}; |
$rolename=~s/[^A-Za-z0-9]//gs; |
$rolename=~s/[^A-Za-z0-9]//gs; |
if (!$rolename) { |
if (!$rolename) { |
Line 2745 sub set_custom_role {
|
Line 2748 sub set_custom_role {
|
$url, |
$url, |
$env{'user.domain'}, |
$env{'user.domain'}, |
$env{'user.name'}, |
$env{'user.name'}, |
$rolename)); |
$rolename,undef,undef,undef,$context)); |
} |
} |
$r->print('<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'.&mt('Create or edit another custom role').'</a></p><form name="customresult" method="post">'); |
$r->print('<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'.&mt('Create or edit another custom role').'</a></p><form name="customresult" method="post">'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>'); |
Line 2889 sub handler {
|
Line 2892 sub handler {
|
} |
} |
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) { |
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) { |
if ($env{'form.phase'} eq 'set_custom_roles') { |
if ($env{'form.phase'} eq 'set_custom_roles') { |
&set_custom_role($r); |
&set_custom_role($r,$context); |
} else { |
} else { |
&custom_role_editor($r); |
&custom_role_editor($r); |
} |
} |
Line 2981 sub handler {
|
Line 2984 sub handler {
|
if (!exists($env{'form.state'})) { |
if (!exists($env{'form.state'})) { |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Configure Self-enrollment', |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Configure Self-enrollment', |
'Course_Self_Enrollment')); |
'Course_Self_Enrollment')); |
|
$r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'."\n"); |
&print_selfenroll_menu($r,$context,$permission); |
&print_selfenroll_menu($r,$context,$permission); |
} elsif ($env{'form.state'} eq 'done') { |
} elsif ($env{'form.state'} eq 'done') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
Line 2989 sub handler {
|
Line 2992 sub handler {
|
text=>"Result"}); |
text=>"Result"}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Self-enrollment result', |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Self-enrollment result', |
'Course_Self_Enrollment')); |
'Course_Self_Enrollment')); |
&update_selfenroll_config($r,$context); |
$r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'."\n"); |
|
&update_selfenroll_config($r,$context,$permission); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} elsif ($env{'form.action'} eq 'changelogs') { |
} elsif ($env{'form.action'} eq 'changelogs') { |
Line 3104 sub print_main_menu {
|
Line 3108 sub print_main_menu {
|
}); |
}); |
if (!exists($permission->{'cusr_section'})) { |
if (!exists($permission->{'cusr_section'})) { |
push(@courselinks, |
push(@courselinks, |
{ text => 'Automated Student Enrollment Manager', |
{ text => 'Automated Enrollment Manager', |
help => 'Course_Automated_Enrollment', |
help => 'Course_Automated_Enrollment', |
permission => (&Apache::lonnet::auto_run($cnum,$cdom) |
permission => (&Apache::lonnet::auto_run($cnum,$cdom) |
&& $permission->{'cusr'}), |
&& $permission->{'cusr'}), |
Line 3122 sub print_main_menu {
|
Line 3126 sub print_main_menu {
|
permission => $permission->{'grp_manage'}, |
permission => $permission->{'grp_manage'}, |
url => '/adm/coursegroups?refpage=cusr', |
url => '/adm/coursegroups?refpage=cusr', |
}, |
}, |
{ text => 'View Log-in History', |
|
help => 'Course_User_Logins', |
|
action => 'logins', |
|
permission => $permission->{'cusr'}, |
|
}, |
|
{ text => 'View Change Logs', |
{ text => 'View Change Logs', |
help => 'Course_User_Logs', |
help => 'Course_User_Logs', |
action => 'changelogs', |
action => 'changelogs', |
permission => $permission->{'cusr'}, |
permission => $permission->{'cusr'}, |
|
}, |
|
{ text => 'View Log-in History', |
|
help => 'Course_User_Logins', |
|
action => 'logins', |
|
permission => $permission->{'cusr'}, |
}); |
}); |
push(@menu,@courselinks); |
push(@menu,@courselinks); |
} |
} |
Line 3178 sub print_selfenroll_menu {
|
Line 3182 sub print_selfenroll_menu {
|
$setsec_js."\n". |
$setsec_js."\n". |
'</script>'."\n". |
'</script>'."\n". |
'<h3>'.$lt->{'selfenroll'}.'</h3>'."\n". |
'<h3>'.$lt->{'selfenroll'}.'</h3>'."\n". |
'<form name="'.$formname.'" method="post">'."\n". |
'<form name="'.$formname.'" method="post" action="/adm/createuser">'."\n". |
&Apache::lonhtmlcommon::start_pick_box(); |
&Apache::lonhtmlcommon::start_pick_box(); |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'},'.num'}; |
if (ref($row) eq 'ARRAY') { |
if (ref($row) eq 'ARRAY') { |
foreach my $item (@{$row}) { |
foreach my $item (@{$row}) { |
my $title = $item; |
my $title = $item; |
Line 3191 sub print_selfenroll_menu {
|
Line 3197 sub print_selfenroll_menu {
|
'LC_selfenroll_pick_box_title','LC_oddrow_value')."\n"; |
'LC_selfenroll_pick_box_title','LC_oddrow_value')."\n"; |
if ($item eq 'types') { |
if ($item eq 'types') { |
my $curr_types = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_types'}; |
my $curr_types = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_types'}; |
$output .= '<input type="text" name="selfenroll_types" value="'.$curr_types.'" size="50" />'; |
my $showdomdesc = 1; |
|
my $includeempty = 1; |
|
my $num = 0; |
|
$output .= &Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_row() |
|
.'<td colspan="2"><span class="LC_nobreak"><label>' |
|
.&mt('Any user in any domain:') |
|
.' <input type="radio" name="selfenroll_all" value="1" '; |
|
if ($curr_types eq '*') { |
|
$output .= ' checked="checked" '; |
|
} |
|
$output .= '/>'.&mt('Yes').'</label> <input type="radio" name="selfenroll_all" value="0" '; |
|
if ($curr_types ne '*') { |
|
$output .= ' checked="checked" '; |
|
} |
|
$output .= '/>'.&mt('No').'</label></td>' |
|
.&Apache::loncommon::end_data_table_row(); |
|
my %currdoms; |
|
if (($curr_types eq '') && ($env{'form.selfenroll_newdom'} eq '')) { |
|
$output .= &new_selfenroll_dom_row($cdom,'0'); |
|
} elsif ($curr_types ne '*') { |
|
my @entries = split(/;/,$curr_types); |
|
if (@entries > 0) { |
|
foreach my $entry (@entries) { |
|
my ($currdom,$typestr) = split(/:/,$entry); |
|
$currdoms{$currdom} = 1; |
|
my $domdesc = &Apache::lonnet::domain($currdom); |
|
my @currinsttypes = split(/,/,$typestr); |
|
$output .= &Apache::loncommon::start_data_table_row() |
|
.'<td valign="top"><span class="LC_nobreak">'.&mt('Domain:').'<b>' |
|
.' '.$domdesc.' ('.$currdom.')' |
|
.'</b><input type="hidden" name="selfenroll_dom_'.$num |
|
.'" value="'.$currdom.'" /></span><br />' |
|
.'<span class="LC_nobreak"><label><input type="checkbox" ' |
|
.'name="selfenroll_delete" value="'.$num.'" />' |
|
.&mt('Delete').'</label></span></td>'; |
|
$output .= '<td valign="top">'.&mt('User types:').'<br />' |
|
.&selfenroll_inst_types($num,$currdom,\@currinsttypes).'</td>' |
|
.&Apache::loncommon::end_data_table_row(); |
|
$num ++; |
|
} |
|
} |
|
} |
|
if ($env{'form.selfenroll_newdom'} ne '') { |
|
if (!defined($currdoms{$env{'form.selfenroll_newdom'}})) { |
|
$output .= &new_selfenroll_dom_row($env{'form.selfenroll_newdom'},$num); |
|
$num ++; |
|
} |
|
} |
|
my $add_domtitle = &mt('Additional domain:'); |
|
if ($curr_types eq '*') { |
|
$add_domtitle = &mt('Specific domain:'); |
|
} elsif ($curr_types eq '') { |
|
$add_domtitle = &mt('Other domain:'); |
|
} |
|
$output .= &Apache::loncommon::start_data_table_row() |
|
.'<td colspan="2"><span class="LC_nobreak">'.$add_domtitle.'</span><br />' |
|
.&Apache::loncommon::select_dom_form('','selfenroll_newdom', |
|
$includeempty,$showdomdesc) |
|
.'<input type="hidden" name="selfenroll_types_total" value="'.$num.'" />' |
|
.'</td>'.&Apache::loncommon::end_data_table_row() |
|
.&Apache::loncommon::end_data_table(); |
} elsif ($item eq 'registered') { |
} elsif ($item eq 'registered') { |
my ($regon,$regoff); |
my ($regon,$regoff); |
if ($env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_registered'}) { |
if ($env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_registered'}) { |
Line 3202 sub print_selfenroll_menu {
|
Line 3269 sub print_selfenroll_menu {
|
$regoff = ' checked="checked" '; |
$regoff = ' checked="checked" '; |
} |
} |
$output .= '<label>'. |
$output .= '<label>'. |
'<input type="radio" name="registered" value="0"'.$regoff.'/>'. |
'<input type="radio" name="selfenroll_registered" value="1"'.$regon.'/>'. |
&mt('No').'</label> <label>'. |
&mt('Yes').'</label> <label>'. |
'<input type="radio" name="registered" value="1"'.$regon.'/>'. |
'<input type="radio" name="selfenroll_registered" value="0"'.$regoff.'/>'. |
&mt('Yes').'</label>'; |
&mt('No').'</label>'; |
} elsif ($item eq 'enroll_dates') { |
} elsif ($item eq 'enroll_dates') { |
my $starttime = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_start_date'}; |
my $starttime = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_start_date'}; |
my $endtime = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_end_date'}; |
my $endtime = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_end_date'}; |
Line 3240 sub print_selfenroll_menu {
|
Line 3307 sub print_selfenroll_menu {
|
$output .= &selfenroll_date_forms($startform,$endform); |
$output .= &selfenroll_date_forms($startform,$endform); |
} elsif ($item eq 'section') { |
} elsif ($item eq 'section') { |
my $currsec = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_section'}; |
my $currsec = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_section'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'},'.num'}; |
|
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); |
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); |
my $newsecval; |
my $newsecval; |
if ($currsec ne 'none' && $currsec ne '') { |
if ($currsec ne 'none' && $currsec ne '') { |
Line 3265 sub print_selfenroll_menu {
|
Line 3330 sub print_selfenroll_menu {
|
} |
} |
} |
} |
$output .= &Apache::lonhtmlcommon::end_pick_box(). |
$output .= &Apache::lonhtmlcommon::end_pick_box(). |
'<br /><input type="button" name="selfenrollconf" value="'. |
'<br /><input type="button" name="selfenrollconf" value="' |
&mt('Save changes').'" onclick="setSections(this.form);" /></form>'; |
.&mt('Save changes').'" onclick="setSections(this.form);" />' |
|
.'<input type="hidden" name="action" value="selfenroll" /></form>'; |
$r->print($output); |
$r->print($output); |
return; |
return; |
} |
} |
|
|
|
sub new_selfenroll_dom_row { |
|
my ($newdom,$num) = @_; |
|
my $domdesc = &Apache::lonnet::domain($newdom); |
|
my $output; |
|
if ($domdesc ne '') { |
|
$output .= &Apache::loncommon::start_data_table_row() |
|
.'<td valign="top"><span class="LC_nobreak">'.&mt('Domain:').' <b>'.$domdesc |
|
.' ('.$newdom.')</b><input type="hidden" name="selfenroll_dom_'.$num |
|
.'" value="'.$newdom.'" /></span></td>'; |
|
my @currinsttypes; |
|
$output .= '<td>'.&mt('User types:').'<br />' |
|
.&selfenroll_inst_types($num,$newdom,\@currinsttypes).'</td>' |
|
.&Apache::loncommon::end_data_table_row(); |
|
} |
|
return $output; |
|
} |
|
|
|
sub selfenroll_inst_types { |
|
my ($num,$currdom,$currinsttypes) = @_; |
|
my $output; |
|
my $numinrow = 4; |
|
my $count = 0; |
|
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($currdom); |
|
my $othervalue = 'any'; |
|
if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) { |
|
if (@{$types} > 0) { |
|
$othervalue = 'other'; |
|
} |
|
$output .= '<table><tr>'; |
|
foreach my $type (@{$types}) { |
|
if (($count > 0) && ($count%$numinrow == 0)) { |
|
$output .= '</tr><tr>'; |
|
} |
|
if (defined($usertypes->{$type})) { |
|
$output .= '<td><span class="LC_nobreak"><label><input type = "checkbox" value="'. |
|
$type.'" '; |
|
if (ref($currinsttypes) eq 'ARRAY') { |
|
if (@{$currinsttypes} > 0) { |
|
if (grep(/^\Q$type\E$/,@{$currinsttypes})) { |
|
$output .= 'checked="checked"'; |
|
} |
|
} |
|
} |
|
$output .= ' name="selfenroll_types_'.$num.'" />'.$usertypes->{$type}.'</label></span></td>'; |
|
} |
|
$count ++; |
|
} |
|
if (($count > 0) && ($count%$numinrow == 0)) { |
|
$output .= '</tr><tr>'; |
|
} |
|
$output .= '<td><span class="LC_nobreak"><label><input type = "checkbox" value="'.$othervalue.'" '; |
|
if (ref($currinsttypes) eq 'ARRAY') { |
|
if (@{$currinsttypes} > 0) { |
|
if (grep(/^other$/,@{$currinsttypes})) { |
|
$output .= 'checked="checked" '; |
|
} |
|
} |
|
} |
|
$output .= ' name="selfenroll_types_'.$num.'" />'.$othertitle.'</label></span></td></tr></table>'; |
|
} |
|
return $output; |
|
} |
|
|
sub selfenroll_date_forms { |
sub selfenroll_date_forms { |
my ($startform,$endform) = @_; |
my ($startform,$endform) = @_; |
my $output .= &Apache::lonhtmlcommon::start_pick_box()."\n". |
my $output .= &Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::row_title(&mt('Starts'), |
&Apache::lonhtmlcommon::row_title(&mt('Start date'), |
'LC_oddrow_value')."\n". |
'LC_oddrow_value')."\n". |
$startform."\n". |
$startform."\n". |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title(&mt('Ends'), |
&Apache::lonhtmlcommon::row_title(&mt('End date'), |
'LC_oddrow_value')."\n". |
'LC_oddrow_value')."\n". |
$endform."\n". |
$endform."\n". |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
Line 3547 sub user_search_result {
|
Line 3676 sub user_search_result {
|
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') || |
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') || |
($srch->{'srchin'} eq 'alc')) { |
($srch->{'srchin'} eq 'alc')) { |
if ($srch->{'srchby'} eq 'uname') { |
if ($srch->{'srchby'} eq 'uname') { |
if ($srch->{'srchterm'} !~ /^$match_username$/) { |
my $unamecheck = $srch->{'srchterm'}; |
|
if ($srch->{'srchtype'} eq 'contains') { |
|
if ($unamecheck !~ /^\w/) { |
|
$unamecheck = 'a'.$unamecheck; |
|
} |
|
} |
|
if ($unamecheck !~ /^$match_username$/) { |
$response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); |
$response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); |
} |
} |
} |
} |
Line 4138 ENDTIMEENTRY
|
Line 4273 ENDTIMEENTRY
|
} |
} |
|
|
sub update_selfenroll_config { |
sub update_selfenroll_config { |
my ($r,$context) = @_; |
my ($r,$context,$permission) = @_; |
my ($row,$lt) = &get_selfenroll_titles(); |
my ($row,$lt) = &get_selfenroll_titles(); |
my $groupslist = &Apache::lonuserutils::get_groupslist(); |
my %curr_groups = &Apache::longroup::coursegroups(); |
my (%changes,%warning); |
my (%changes,%warning); |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$r->print('<h3>'.$lt->{'selfenroll'}.'</h3>'."\n"); |
my $curr_types; |
if (ref($row) eq 'ARRAY') { |
if (ref($row) eq 'ARRAY') { |
foreach my $item (@{$row}) { |
foreach my $item (@{$row}) { |
if ($item eq 'enroll_dates') { |
if ($item eq 'enroll_dates') { |
Line 4165 sub update_selfenroll_config {
|
Line 4300 sub update_selfenroll_config {
|
$changes{'internal.selfenroll_'.$type.'_access'} = $newdate{$type}; |
$changes{'internal.selfenroll_'.$type.'_access'} = $newdate{$type}; |
} |
} |
} |
} |
|
} elsif ($item eq 'types') { |
|
$curr_types = |
|
$env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item}; |
|
if ($env{'form.selfenroll_all'}) { |
|
if ($curr_types ne '*') { |
|
$changes{'internal.selfenroll_types'} = '*'; |
|
} else { |
|
next; |
|
} |
|
} elsif ($curr_types eq '') { |
|
my @types = &Apache::loncommon::get_env_multiple('form.selfenroll_types_0'); |
|
if (@types > 0) { |
|
$changes{'internal.selfenroll_types'} = $env{'form.selfenroll_dom_0'}.':'.join(',',@types); |
|
} |
|
} else { |
|
my @entries = split(/;/,$curr_types); |
|
my $num = 0; |
|
my @latesttypes; |
|
my @deletedoms = &Apache::loncommon::get_env_multiple('form.selfenroll_delete'); |
|
my $newnum = 0; |
|
for (my $j=0; $j<$env{'form.selfenroll_types_total'}; $j++) { |
|
if (!grep(/^$j$/,@deletedoms)) { |
|
my @types = &Apache::loncommon::get_env_multiple('form.selfenroll_types_'.$j); |
|
@types = sort(@types); |
|
my $typestr = join(',',@types); |
|
$latesttypes[$newnum] = $env{'form.selfenroll_dom_'.$j}.':'.$typestr; |
|
$newnum ++; |
|
} |
|
} |
|
my $selfenroll_types = join(';',@latesttypes); |
|
if ($selfenroll_types ne $curr_types) { |
|
$changes{'internal.selfenroll_types'} = $selfenroll_types; |
|
} |
|
} |
} else { |
} else { |
my $curr_val = |
my $curr_val = |
$env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item}; |
$env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item}; |
my $newval = $env{'form.selfenroll_'.$item}; |
my $newval = $env{'form.selfenroll_'.$item}; |
if ($item eq 'section') { |
if ($item eq 'section') { |
$newval = $env{'form.sections'}; |
$newval = $env{'form.sections'}; |
if (grep(/^\Q$newval\E$/,keys(%{$groupslist}))) { |
if (defined($curr_groups{$newval})) { |
$newval = $curr_val; |
$newval = $curr_val; |
$warning{$item} = &mt('Section for self-enrolled users unchanged as the proposed section is a group').'<br />'.&mt('Group names and section names must be distinct'); |
$warning{$item} = &mt('Section for self-enrolled users unchanged as the proposed section is a group').'<br />'.&mt('Group names and section names must be distinct'); |
} elsif ($newval eq 'all') { |
} elsif ($newval eq 'all') { |
Line 4185 sub update_selfenroll_config {
|
Line 4354 sub update_selfenroll_config {
|
if ($newval ne $curr_val) { |
if ($newval ne $curr_val) { |
$changes{'internal.selfenroll_'.$item} = $newval; |
$changes{'internal.selfenroll_'.$item} = $newval; |
} |
} |
} |
} |
} |
} |
if (keys(%warning) > 0) { |
if (keys(%warning) > 0) { |
foreach my $item (@{$row}) { |
foreach my $item (@{$row}) { |
Line 4225 sub update_selfenroll_config {
|
Line 4394 sub update_selfenroll_config {
|
foreach my $type ('start','end') { |
foreach my $type ('start','end') { |
if (exists($changes{'internal.selfenroll_'.$type.'_date'})) { |
if (exists($changes{'internal.selfenroll_'.$type.'_date'})) { |
my $newdate = &Apache::lonlocal::locallocaltime($changes{'internal.selfenroll_'.$type.'_date'}); |
my $newdate = &Apache::lonlocal::locallocaltime($changes{'internal.selfenroll_'.$type.'_date'}); |
$r->print('<li>'.&mt('[_1]: [_2] set to "[_3]".', |
$r->print('<li>'.&mt('[_1]: "[_2]" set to "[_3]".', |
$title,$type,$newdate).'</li>'); |
$title,$type,$newdate).'</li>'); |
} |
} |
} |
} |
Line 4233 sub update_selfenroll_config {
|
Line 4402 sub update_selfenroll_config {
|
foreach my $type ('start','end') { |
foreach my $type ('start','end') { |
if (exists($changes{'internal.selfenroll_'.$type.'_access'})) { |
if (exists($changes{'internal.selfenroll_'.$type.'_access'})) { |
my $newdate = &Apache::lonlocal::locallocaltime($changes{'internal.selfenroll_'.$type.'_access'}); |
my $newdate = &Apache::lonlocal::locallocaltime($changes{'internal.selfenroll_'.$type.'_access'}); |
$r->print('<li>'.&mt('[_1]: [_2] set to "[_3]".', |
$r->print('<li>'.&mt('[_1]: "[_2]" set to "[_3]".', |
$title,$type,$newdate).'</li>'); |
$title,$type,$newdate).'</li>'); |
} |
} |
} |
} |
} else { |
} else { |
if (exists($changes{'internal.selfenroll_'.$item})) { |
if (exists($changes{'internal.selfenroll_'.$item})) { |
$r->print('<li>'.&mt('[_1] set to "[_2]".',$title, |
my $newval = $changes{'internal.selfenroll_'.$item}; |
$changes{'internal.selfenroll_'.$item}).'</li>'."\n"); |
if ($item eq 'types') { |
|
if ($newval eq '') { |
|
$newval = &mt('None'); |
|
} elsif ($newval eq '*') { |
|
$newval = &mt('Any user in any domain'); |
|
} |
|
} elsif ($item eq 'registered') { |
|
if ($newval eq '1') { |
|
$newval = &mt('Yes'); |
|
} elsif ($newval eq '0') { |
|
$newval = &mt('No'); |
|
} |
|
} |
|
$r->print('<li>'.&mt('"[_1]" set to "[_2]".',$title,$newval).'</li>'."\n"); |
} |
} |
} |
} |
} |
} |
Line 4259 sub update_selfenroll_config {
|
Line 4441 sub update_selfenroll_config {
|
} else { |
} else { |
$r->print(&mt('No changes were needed to the existing self-enrollment settings in this course.')); |
$r->print(&mt('No changes were needed to the existing self-enrollment settings in this course.')); |
} |
} |
|
if ($env{'form.selfenroll_newdom'} ne '') { |
|
&print_selfenroll_menu($r,$context,$permission); |
|
} |
return; |
return; |
} |
} |
|
|
sub get_selfenroll_titles { |
sub get_selfenroll_titles { |
my @row = ('types','registered','enroll_dates','access_dates','section'); |
my @row = ('types','registered','enroll_dates','access_dates','section'); |
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
selfenroll => 'Self-enrollment with a student role', |
|
types => 'Users allowed to self-enroll in this course', |
types => 'Users allowed to self-enroll in this course', |
registered => 'Restrict self-enrollment to registered students?', |
registered => 'Restrict self-enrollment to students officially registered for the course', |
enroll_dates => 'Dates self-enrollment available', |
enroll_dates => 'Dates self-enrollment available', |
access_dates => 'Access dates for self-enrolled users', |
access_dates => 'Course access dates for self-enrolled users', |
section => 'Section', |
section => 'Section assigned to self-enrolled users', |
); |
); |
return (\@row,\%lt); |
return (\@row,\%lt); |
} |
} |