'."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
return $output;
}
@@ -649,8 +734,9 @@ ENDFORMINFO
}
if ($newuser) {
my $portfolioform;
- if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
- # Current user has quota modification privileges
+ if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
+ (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {
+ # Current user has quota or user tools modification privileges
$portfolioform = ' '.&portfolio_quota($ccuname,$ccdomain);
}
&initialize_authen_forms($ccdomain,$formname);
@@ -705,6 +791,7 @@ $lt{'hs'}: $home_server_pick
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
} else {
my $authparm = $rules->{$matchedrule}{'authparm'};
+ $authmsg = $rules->{$matchedrule}{'authmsg'};
if ($authtype =~ /^krb(4|5)$/) {
my $ver = $1;
if ($authparm ne '') {
@@ -713,7 +800,6 @@ $lt{'hs'}: $home_server_pick
KERB
- $authmsg = $rules->{$matchedrule}{'authmsg'};
}
} else {
$fixedauth =
@@ -722,8 +808,16 @@ KERB
$fixedauth .=
''."\n";
} else {
- $varauth =
+ if ($authtype eq 'int') {
+ $varauth = ' '.
+&mt('[_1] Internally authenticated (with initial password [_2])','','')."';
+ } elsif ($authtype eq 'loc') {
+ $varauth = ' '.
+&mt('[_1] Local Authentication with argument [_2]','','')."\n";
+ } else {
+ $varauth =
''."\n";
+ }
}
}
}
@@ -773,37 +867,70 @@ ENDCHANGEUSER
if ($showforceid) {
$r->print(&Apache::lonuserutils::forceid_change($context));
}
+ if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
+ $r->print('
'.&mt('User Can Request Creation of Courses?').'
'.
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,'requestcourse').
+ &Apache::loncommon::end_data_table());
+ }
$r->print('');
my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname);
- my $user_quota_text;
- if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
+ 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
$user_quota_text = &portfolio_quota($ccuname,$ccdomain);
- } elsif (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
- # Get the user's portfolio information
- my %portq = &Apache::lonnet::get('environment',['portfolioquota'],
- $ccdomain,$ccuname);
-
- my %lt=&Apache::lonlocal::texthash(
- 'dska' => "Disk space allocated to user's portfolio files",
- 'youd' => "You do not have privileges to modify the portfolio quota for this user.",
- 'ichr' => "If a change is required, contact a domain coordinator for the domain",
- );
- $user_quota_text = < "Disk space allocated to user's portfolio files",
+ 'youd' => "You do not have privileges to modify the portfolio quota for this user.",
+ 'ichr' => "If a change is required, contact a domain coordinator for the domain",
+ );
+ $user_quota_text = <$lt{'dska'}
$lt{'youd'} $lt{'ichr'}: $ccdomain
ENDNOPORTPRIV
+ }
+ }
+ if (!&Apache::lonnet::allowed('mut',$ccdomain)) {
+ 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.",
+ 'ifch' => "If a change is required, contact a domain coordinator for the domain",
+ );
+ $user_tools_text = <$lt{'utav'}
+$lt{'yodo'} $lt{'ifch'}: $ccdomain
+ENDNOTOOLSPRIV
+ }
}
if ($user_auth_text ne '') {
$r->print('
'.$user_auth_text);
if ($user_quota_text ne '') {
$r->print($user_quota_text);
}
+ if ($user_tools_text ne '') {
+ $r->print($user_tools_text);
+ }
if ($env{'form.action'} eq 'singlestudent') {
$r->print(&date_sections_select($context,$newuser,$formname));
}
} elsif ($user_quota_text ne '') {
$r->print('
'.$user_quota_text);
+ if ($user_tools_text ne '') {
+ $r->print($user_tools_text);
+ }
+ if ($env{'form.action'} eq 'singlestudent') {
+ $r->print(&date_sections_select($context,$newuser,$formname));
+ }
+ } elsif ($user_tools_text ne '') {
+ $r->print('
'.&mt('User [_1] in domain [_2]',
$env{'form.ccuname'}, $env{'form.ccdomain'}).'
');
my (%alerts,%rulematch,%inst_results,%curr_rules);
+ my @usertools = ('aboutme','blog','portfolio');
+ my @requestcourses = ('official','unofficial');
if ($env{'form.makeuser'}) {
$r->print('
'.&mt('Creating new account.').'
');
# Check for the authentication mode and password
@@ -1646,26 +1833,42 @@ sub update_user_data {
$r->print(&mt('Generating user').': '.$result);
$uhome = &Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
- if (($uhome ne 'no_host') && ($env{'form.customquota'} == 1)) {
- my (%changeHash,$newportfolioquota);
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
- } else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
+ my (%changeHash,%newcustom,%changed);
+ if ($uhome ne 'no_host') {
+ if ($env{'form.customquota'} == 1) {
+ if ($env{'form.portfolioquota'} eq '') {
+ $newcustom{'quota'} = 0;
+ } else {
+ $newcustom{'quota'} = $env{'form.portfolioquota'};
+ $newcustom{'quota'} =~ s/[^\d\.]//g;
+ }
+ $changed{'quota'} = "a_admin($newcustom{'quota'},\%changeHash);
}
- my $quotachanged = "a_admin($newportfolioquota,\%changeHash);
- if ($quotachanged) {
+ foreach my $item (@usertools) {
+ if ($env{'form.custom'.$item} == 1) {
+ $newcustom{$item} = $env{'form.tools_'.$item};
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'tools');
+ }
+ }
+ if (&Apache::lonnet::allowed('ccc',$env{'request.domain'})) {
+ foreach my $item (@requestcourses) {
+ $newcustom{$item} = $env{'form.requestcourse_'.$item};
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'requestcourse');
+ }
+ }
+ if (keys(%changed)) {
$changeHash{'firstname'} = $env{'form.cfirstname'};
$changeHash{'middlename'} = $env{'form.cmiddlename'};
$changeHash{'lastname'} = $env{'form.clastname'};
$changeHash{'generation'} = $env{'form.cgeneration'};
$changeHash{'id'} = $env{'form.cid'};
$changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
- my $quotachgresult =
- &Apache::lonnet::put('environment',\%changeHash,
- $env{'form.ccdomain'},$env{'form.ccuname'});
- }
+ my $chgresult =
+ &Apache::lonnet::put('environment',\%changeHash,
+ $env{'form.ccdomain'},$env{'form.ccuname'});
+ }
}
$r->print(' '.&mt('Home server').': '.$uhome.' '.
&Apache::lonnet::hostname($uhome));
@@ -1698,7 +1901,9 @@ sub update_user_data {
# Check for need to change
my %userenv = &Apache::lonnet::get
('environment',['firstname','middlename','lastname','generation',
- 'id','permanentemail','portfolioquota','inststatus'],
+ 'id','permanentemail','portfolioquota','inststatus','tools.aboutme',
+ 'tools.blog','tools.portfolio','requestcourse.official',
+ 'requestcourse.unofficial'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -1789,7 +1994,7 @@ sub update_user_data {
$env{'form.c'.$item} = $userenv{$item};
}
}
- # Check to see if we can change the ID/student number
+ # Check to see if we can change the Student/Employee ID
my $forceid = $env{'form.forceid'};
my $recurseid = $env{'form.recurseid'};
my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules);
@@ -1800,7 +2005,10 @@ sub update_user_data {
(!$forceid)) {
if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) {
$env{'form.cid'} = $userenv{'id'};
- $no_forceid_alert = &mt('New student/employeeID does not match existing ID for this user.').' '.&mt('Change is not permitted without checking the \'Force ID change\' checkbox on the previous page.').' '."\n";
+ $no_forceid_alert = &mt('New Student/Employee ID does not match existing ID for this user.')
+ .' '
+ .&mt("Change is not permitted without checking the 'Force ID change' checkbox on the previous page.")
+ .' '."\n";
}
}
if ($env{'form.cid'} ne $userenv{'id'}) {
@@ -1820,14 +2028,20 @@ sub update_user_data {
}
my ($quotachanged,$oldportfolioquota,$newportfolioquota,
$inststatus,$oldisdefault,$newisdefault,$olddefquotatext,
- $newdefquotatext);
+ $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext);
my ($defquota,$settingstatus) =
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
- my $showquota;
+ my ($showquota,$showtools,$showrequestcourses);
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
$showquota = 1;
}
- my %changeHash;
+ if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
+ $showtools = 1;
+ }
+ if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
+ $showrequestcourses = 1;
+ }
+ my (%changeHash,%changed);
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
if ($userenv{'portfolioquota'} ne '') {
$oldportfolioquota = $userenv{'portfolioquota'};
@@ -1839,10 +2053,10 @@ sub update_user_data {
$newportfolioquota =~ s/[^\d\.]//g;
}
if ($newportfolioquota != $oldportfolioquota) {
- $quotachanged = "a_admin($newportfolioquota,\%changeHash);
+ $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
}
} else {
- $quotachanged = "a_admin('',\%changeHash);
+ $changed{'quota'} = "a_admin('',\%changeHash);
$newportfolioquota = $defquota;
$newisdefault = 1;
}
@@ -1856,7 +2070,7 @@ sub update_user_data {
$newportfolioquota = $env{'form.portfolioquota'};
$newportfolioquota =~ s/[^\d\.]//g;
}
- $quotachanged = "a_admin($newportfolioquota,\%changeHash);
+ $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
} else {
$newportfolioquota = $defquota;
$newisdefault = 1;
@@ -1868,6 +2082,10 @@ sub update_user_data {
if ($newisdefault) {
$newdefquotatext = &get_defaultquota_text($settingstatus);
}
+ &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,
+ \%changeHash,\%changed,\%newaccess,\%newaccesstext);
+ &tool_changes('requestcourse',\@requestcourses,\%oldaccess,\%oldaccesstext,
+ \%userenv, \%changeHash,\%changed,\%newaccess,\%newaccesstext);
if ($env{'form.cfirstname'} ne $userenv{'firstname'} ||
$env{'form.cmiddlename'} ne $userenv{'middlename'} ||
$env{'form.clastname'} ne $userenv{'lastname'} ||
@@ -1876,18 +2094,41 @@ sub update_user_data {
$env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) {
$namechanged = 1;
}
- if ($namechanged || $quotachanged) {
+ if (($namechanged) || (keys(%changed) > 0)) {
$changeHash{'firstname'} = $env{'form.cfirstname'};
$changeHash{'middlename'} = $env{'form.cmiddlename'};
$changeHash{'lastname'} = $env{'form.clastname'};
$changeHash{'generation'} = $env{'form.cgeneration'};
$changeHash{'id'} = $env{'form.cid'};
$changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
- my ($quotachgresult,$namechgresult);
- if ($quotachanged) {
- $quotachgresult =
+ my ($chgresult,$namechgresult);
+ if (keys(%changed) > 0) {
+ $chgresult =
&Apache::lonnet::put('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
+ if ($chgresult eq 'ok') {
+ if (($env{'user.name'} eq $env{'form.ccuname'}) &&
+ ($env{'user.domain'} eq $env{'form.ccdomain'})) {
+ my %newenvhash;
+ foreach my $key (keys(%changed)) {
+ if (($key eq 'official') || ($key eq 'unofficial')) {
+ $newenvhash{'environment.canrequest.'.$key} =
+ $changeHash{'requestcourse.'.$key};
+ $newenvhash{'environment.canrequest.'.$key} =
+ $changeHash{'requestcourse.'.$key};
+
+ } elsif ($key ne 'quota') {
+ $newenvhash{'environment.tools.'.$key} =
+ $changeHash{'tools.'.$key};
+ $newenvhash{'environment.availabletools.'.$key} =
+ $changeHash{'tools.'.$key};
+ }
+ }
+ if (keys(%newenvhash)) {
+ &Apache::lonnet::appenv(\%newenvhash);
+ }
+ }
+ }
}
if ($namechanged) {
# Make the change
@@ -1906,19 +2147,24 @@ sub update_user_data {
);
}
if (($namechanged && $namechgresult eq 'ok') ||
- ($quotachanged && $quotachgresult eq 'ok')) {
+ ((keys(%changed) > 0) && $chgresult eq 'ok')) {
# Tell the user we changed the name
my %lt=&Apache::lonlocal::texthash(
- 'uic' => "User Information Changed",
- 'frst' => "first",
- 'mddl' => "middle",
- 'lst' => "last",
- 'gen' => "generation",
- 'id' => "ID/Student number",
- 'mail' => "permanent e-mail",
- 'disk' => "disk space allocated to portfolio files",
- 'prvs' => "Previous",
- 'chto' => "Changed To"
+ 'uic' => "User Information Changed",
+ 'frst' => "First",
+ 'mddl' => "Middle",
+ 'lst' => "Last",
+ 'gen' => "Generation",
+ 'id' => "Student/Employee ID",
+ 'mail' => "Permanent E-mail",
+ 'disk' => "Disk space allocated to portfolio files",
+ 'blog' => "Blog Availability",
+ 'aboutme' => "Home Page Availability",
+ 'portfolio' => "Portfolio Availability",
+ 'official' => "Can Request Official Courses",
+ 'unofficial' => "Can Request Unofficial Courses",
+ 'prvs' => "Previous",
+ 'chto' => "Changed To"
);
$r->print('
'.$lt{'uic'}.'
'.
&Apache::loncommon::start_data_table().
@@ -1932,10 +2178,22 @@ sub update_user_data {
$lt{'id'}
$lt{'mail'}
END
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$lt{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$lt{'disk'}
\n");
}
+ if ($showtools) {
+ foreach my $item (@usertools) {
+ $r->print("
+
END
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+
$newaccess{$item} $newaccesstext{$item}
\n");
+ }
+ }
if ($showquota) {
$r->print("
$newportfolioquota Mb $newdefquotatext
\n");
}
+ if ($showtools) {
+ foreach my $item (@usertools) {
+ $r->print("
+
$newaccess{$item} $newaccesstext{$item}
\n");
+ }
+ }
$r->print(&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table().' ');
if ($env{'form.cid'} ne $userenv{'id'}) {
@@ -1994,12 +2276,18 @@ END
$env{'form.ccdomain'}.' ');
}
} else { # End of if ($env ... ) logic
- # They did not want to change the users name or quota but we can
- # still tell them what the name and quota are
+ # 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' => "ID/Student number",
- 'mail' => "Permanent e-mail",
- 'disk' => "Disk space allocated to user's portfolio files",
+ '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",
+ 'official' => "Can Request Official Courses",
+ 'unofficial' => "Can Request Unofficial Course",
);
$r->print(<<"END");
'.&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.').'
'.&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('
');
+ }
+ 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.',
+ 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.',
+ 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:',
+ 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)".',
+ dc_instcode => 'Ask a domain coordinator to assign an institutional code (if this is an official course).',
+ dc_catalog => 'Ask a domain coordinator to enable or create at least one course category in the domain.',
+ dc_categories => 'Ask a domain coordinator to create a hierarchy of categories and sub categories for courses in the domain.',
+ dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain',
+ dc_addcat => 'Ask a domain coordinator to assign a category to the course.',
+ );
+ $visactions{'unhide'} = &mt('Use [_1]Set course environment[_2] to change the "Exclude from course catalog" setting.','"','"');
+ $visactions{'chgcat'} = &mt('Use [_1]Set course environment[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"','"');
+ $visactions{'addcat'} = &mt('Use [_1]Set course environment[_2] to assign a category to the course.','"','"');
+ if (ref($domconf{'coursecategories'}) eq 'HASH') {
+ if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
+ $settable{'togglecats'} = 1;
+ }
+ if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
+ $settable{'categorize'} = 1;
+ }
+ $cathash = $domconf{'coursecategories'}{'cats'};
+ }
+ if ($settable{'togglecats'} && $settable{'categorize'}) {
+ $cansetvis = &mt('You are able to both assign a course category and choose to exclude this course from the catalog.');
+ } elsif ($settable{'togglecats'}) {
+ $cansetvis = &mt('You are able to choose to exclude this course from the catalog, but only a Domain Coordinator may assign a course category.');
+ } elsif ($settable{'categorize'}) {
+ $cansetvis = &mt('You may assign a course category, but only a Domain Coordinator may choose to exclude this course from the catalog.');
+ } else {
+ $cansetvis = &mt('Only a Domain Coordinator may assign a course category or choose to exclude this course from the catalog.');
+ }
+
+ my %currsettings =
+ &Apache::lonnet::get('environment',['hidefromcat','categories','internal.coursecode'],
+ $cdom,$cnum);
+ my $visible = 0;
+ if ($currsettings{'internal.coursecode'} ne '') {
+ if (ref($domconf{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconf{'coursecategories'}{'cats'};
+ if (ref($cathash) eq 'HASH') {
+ if ($cathash->{'instcode::0'} eq '') {
+ push(@vismsgs,'dc_addinst');
+ } else {
+ $visible = 1;
+ }
+ } else {
+ $visible = 1;
+ }
+ } else {
+ $visible = 1;
+ }
+ } else {
+ if (ref($cathash) eq 'HASH') {
+ if ($cathash->{'instcode::0'} ne '') {
+ push(@vismsgs,'dc_instcode');
+ }
+ } else {
+ push(@vismsgs,'dc_instcode');
+ }
+ }
+ if ($currsettings{'categories'} ne '') {
+ my $cathash;
+ if (ref($domconf{'coursecategories'}) eq 'HASH') {
+ $cathash = $domconf{'coursecategories'}{'cats'};
+ if (ref($cathash) eq 'HASH') {
+ if (keys(%{$cathash}) == 0) {
+ push(@vismsgs,'dc_catalog');
+ } elsif ((keys(%{$cathash}) == 1) && ($cathash->{'instcode::0'} ne '')) {
+ push(@vismsgs,'dc_categories');
+ } else {
+ my @currcategories = split('&',$currsettings{'categories'});
+ my $matched = 0;
+ foreach my $cat (@currcategories) {
+ if ($cathash->{$cat} ne '') {
+ $visible = 1;
+ $matched = 1;
+ last;
+ }
+ }
+ if (!$matched) {
+ if ($settable{'categorize'}) {
+ push(@vismsgs,'chgcat');
+ } else {
+ push(@vismsgs,'dc_chgcat');
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if (ref($cathash) eq 'HASH') {
+ if ((keys(%{$cathash}) > 1) ||
+ (keys(%{$cathash}) == 1) && ($cathash->{'instcode::0'} eq '')) {
+ if ($settable{'categorize'}) {
+ push(@vismsgs,'addcat');
+ } else {
+ push(@vismsgs,'dc_addcat');
+ }
+ }
+ }
+ }
+ if ($currsettings{'hidefromcat'} eq 'yes') {
+ $visible = 0;
+ if ($settable{'togglecats'}) {
+ unshift(@vismsgs,'unhide');
+ } else {
+ unshift(@vismsgs,'dc_unhide')
+ }
+ }
+ return ($visible,$cansetvis,\@vismsgs,\%visactions);
+}
+
+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()
+ .'
';
+ }
+ return $output;
+}
+
sub selfenroll_date_forms {
my ($startform,$endform) = @_;
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".
$startform."\n".
&Apache::lonhtmlcommon::row_closure(1).
- &Apache::lonhtmlcommon::row_title(&mt('Ends'),
+ &Apache::lonhtmlcommon::row_title(&mt('End date'),
'LC_oddrow_value')."\n".
$endform."\n".
&Apache::lonhtmlcommon::row_closure(1).
@@ -3327,8 +4578,9 @@ sub print_userchangelogs_display {
$curr{$key} = $defaults{$key};
}
}
- my (%whodunit,%changed);
- $r->print(&role_display_filter($formname,$cdom,$cnum,\%curr));
+ my (%whodunit,%changed,$version);
+ ($version) = ($r->dir_config('lonVersion') =~ /^([\d\.]+)\-/);
+ $r->print(&role_display_filter($formname,$cdom,$cnum,\%curr,$version));
my $showntablehdr = 0;
my $tablehdr = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
@@ -3337,7 +4589,7 @@ sub print_userchangelogs_display {
&mt('Context').'
'.&mt('Start').'
'.&mt('End').'
'.
&Apache::loncommon::end_data_table_header_row();
my ($minshown,$maxshown);
- my $minshown = 1;
+ $minshown = 1;
my $count = 0;
if ($curr{'show'} ne &mt('all')) {
$maxshown = $curr{'page'} * $curr{'show'};
@@ -3445,7 +4697,7 @@ ENDSCRIPT
}
sub role_display_filter {
- my ($formname,$cdom,$cnum,$curr) = @_;
+ my ($formname,$cdom,$cnum,$curr,$version) = @_;
my $context = 'course';
my $nolink = 1;
my $output = '
'.
@@ -3496,9 +4748,14 @@ sub role_display_filter {
next if (!&Apache::lonnet::auto_run($cnum,$cdom));
}
$output .= ''."\n";
- }
+ }
$output .= '
';
+ &mt('Update Display').'" />'.
+ ''.
+ &mt('[_1]Note:[_2] Only changes made from servers running LON-CAPA 2.6.99.0 or later are displayed.');
+ if ($version) {
+ $output .= ' '.&mt('This server is version [_3].','','',$version); }
+ $output .= ' ';
return $output;
}
@@ -3547,7 +4804,13 @@ sub user_search_result {
if (($srch->{'srchin'} eq 'dom') || ($srch->{'srchin'} eq 'crs') ||
($srch->{'srchin'} eq 'alc')) {
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 - . @');
}
}
@@ -3885,10 +5148,30 @@ sub build_search_response {
&Apache::lonuserutils::can_create_user($env{'request.role.domain'},$context);
if ($cancreate) {
my $showdom = &display_domain_info($env{'request.role.domain'});
- $response .= '
'.&mt("To add a new user (you can only create new users in your current role's domain - [_1]):",$env{'request.role.domain'}).'
'.&mt("Set 'Domain/institution to search' to: [_1]",$showdom).'
'.&mt("Set 'Search criteria' to: 'username is ...... in selected LON-CAPA domain'").'
'.&mt('Provide the proposed username').'
'.&mt('Search').'
';
+ $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'}.'')
+ .'
'
+ .&mt("Set 'Domain/institution to search' to: [_1]",''.$showdom.'')
+ .'
'
+ .&mt("Set 'Search criteria' to: [_1]username is ..... in selected LON-CAPA domain[_2]",'','')
+ .'
'.&mt("You are not authorized to create new users in your current role's domain - [_1].",$env{'request.role.domain'}).' '.&mt('Contact the helpdesk if you need to create a new user.',$helplink).'
';
+ $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.'
+ ,' '
+ ,'')
+ .'
';
}
}
}
@@ -4138,13 +5421,13 @@ ENDTIMEENTRY
}
sub update_selfenroll_config {
- my ($r,$context) = @_;
+ my ($r,$context,$permission) = @_;
my ($row,$lt) = &get_selfenroll_titles();
- my $groupslist = &Apache::lonuserutils::get_groupslist();
+ my %curr_groups = &Apache::longroup::coursegroups();
my (%changes,%warning);
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- $r->print('
'.$lt->{'selfenroll'}.'
'."\n");
+ my $curr_types;
if (ref($row) eq 'ARRAY') {
foreach my $item (@{$row}) {
if ($item eq 'enroll_dates') {
@@ -4165,18 +5448,152 @@ sub update_selfenroll_config {
$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;
+ }
+ } else {
+ my %currdoms;
+ my @entries = split(/;/,$curr_types);
+ my @deletedoms = &Apache::loncommon::get_env_multiple('form.selfenroll_delete');
+ my @activations = &Apache::loncommon::get_env_multiple('form.selfenroll_activate');
+ my $newnum = 0;
+ my @latesttypes;
+ foreach my $num (@activations) {
+ my @types = &Apache::loncommon::get_env_multiple('form.selfenroll_types_'.$num);
+ if (@types > 0) {
+ @types = sort(@types);
+ my $typestr = join(',',@types);
+ my $typedom = $env{'form.selfenroll_dom_'.$num};
+ $latesttypes[$newnum] = $typedom.':'.$typestr;
+ $currdoms{$typedom} = 1;
+ $newnum ++;
+ }
+ }
+ for (my $j=0; $j<$env{'form.selfenroll_types_total'}; $j++) { if ((!grep(/^$j$/,@deletedoms)) && (!grep(/^$j$/,@activations))) {
+ my @types = &Apache::loncommon::get_env_multiple('form.selfenroll_types_'.$j);
+ if (@types > 0) {
+ @types = sort(@types);
+ my $typestr = join(',',@types);
+ my $typedom = $env{'form.selfenroll_dom_'.$j};
+ $latesttypes[$newnum] = $typedom.':'.$typestr;
+ $currdoms{$typedom} = 1;
+ $newnum ++;
+ }
+ }
+ }
+ if ($env{'form.selfenroll_newdom'} ne '') {
+ my $typedom = $env{'form.selfenroll_newdom'};
+ if ((!defined($currdoms{$typedom})) &&
+ (&Apache::lonnet::domain($typedom) ne '')) {
+ my $typestr;
+ my ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($typedom);
+ my $othervalue = 'any';
+ if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) {
+ if (@{$types} > 0) {
+ my @esc_types = map { &escape($_); } @{$types};
+ $othervalue = 'other';
+ $typestr = join(',',(@esc_types,$othervalue));
+ }
+ $typestr = $othervalue;
+ } else {
+ $typestr = $othervalue;
+ }
+ $latesttypes[$newnum] = $typedom.':'.$typestr;
+ $newnum ++ ;
+ }
+ }
+ my $selfenroll_types = join(';',@latesttypes);
+ if ($selfenroll_types ne $curr_types) {
+ $changes{'internal.selfenroll_types'} = $selfenroll_types;
+ }
+ }
+ } elsif ($item eq 'limit') {
+ my $newlimit = $env{'form.selfenroll_limit'};
+ my $newcap = $env{'form.selfenroll_cap'};
+ $newcap =~s/\s+//g;
+ my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'};
+ $currlimit = 'none' if ($currlimit eq '');
+ my $currcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'};
+ if ($newlimit ne $currlimit) {
+ if ($newlimit ne 'none') {
+ if ($newcap =~ /^\d+$/) {
+ if ($newcap ne $currcap) {
+ $changes{'internal.selfenroll_cap'} = $newcap;
+ }
+ $changes{'internal.selfenroll_limit'} = $newlimit;
+ } else {
+ $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
+ }
+ } elsif ($currcap ne '') {
+ $changes{'internal.selfenroll_cap'} = '';
+ $changes{'internal.selfenroll_limit'} = $newlimit;
+ }
+ } elsif ($currlimit ne 'none') {
+ if ($newcap =~ /^\d+$/) {
+ if ($newcap ne $currcap) {
+ $changes{'internal.selfenroll_cap'} = $newcap;
+ }
+ } else {
+ $warning{$item} = &mt('Maximum enrollment setting unchanged.').' '.&mt('The value provided was invalid - it must be a positive integer if enrollment is being limited.');
+ }
+ }
+ } elsif ($item eq 'approval') {
+ my (@currnotified,@newnotified);
+ my $currapproval = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_approval'};
+ my $currnotifylist = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_notifylist'};
+ if ($currnotifylist ne '') {
+ @currnotified = split(/,/,$currnotifylist);
+ @currnotified = sort(@currnotified);
+ }
+ my $newapproval = $env{'form.selfenroll_approval'};
+ @newnotified = &Apache::loncommon::get_env_multiple('form.selfenroll_notify');
+ @newnotified = sort(@newnotified);
+ if ($newapproval ne $currapproval) {
+ $changes{'internal.selfenroll_approval'} = $newapproval;
+ if (!$newapproval) {
+ if ($currnotifylist ne '') {
+ $changes{'internal.selfenroll_notifylist'} = '';
+ }
+ } else {
+ my @differences =
+ &compare_arrays(\@currnotified,\@newnotified);
+ if (@differences > 0) {
+ if (@newnotified > 0) {
+ $changes{'internal.selfenroll_notifylist'} = join(',',@newnotified);
+ } else {
+ $changes{'internal.selfenroll_notifylist'} = join(',',@newnotified);
+ }
+ }
+ }
+ } else {
+ my @differences = &compare_arrays(\@currnotified,\@newnotified);
+ if (@differences > 0) {
+ if (@newnotified > 0) {
+ $changes{'internal.selfenroll_notifylist'} = join(',',@newnotified);
+ } else {
+ $changes{'internal.selfenroll_notifylist'} = '';
+ }
+ }
+ }
} else {
my $curr_val =
$env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_'.$item};
my $newval = $env{'form.selfenroll_'.$item};
if ($item eq 'section') {
$newval = $env{'form.sections'};
- if (grep(/^\Q$newval\E$/,keys(%{$groupslist}))) {
+ if (defined($curr_groups{$newval})) {
$newval = $curr_val;
$warning{$item} = &mt('Section for self-enrolled users unchanged as the proposed section is a group').' '.&mt('Group names and section names must be distinct');
} elsif ($newval eq 'all') {
$newval = $curr_val;
- $warning{$item} = &mt("Section for self-enrolled users unchanged, as 'all' is a reserved section name.");
+ $warning{$item} = &mt('Section for self-enrolled users unchanged, as "all" is a reserved section name.');
}
if ($newval eq '') {
$newval = 'none';
@@ -4185,7 +5602,7 @@ sub update_selfenroll_config {
if ($newval ne $curr_val) {
$changes{'internal.selfenroll_'.$item} = $newval;
}
- }
+ }
}
if (keys(%warning) > 0) {
foreach my $item (@{$row}) {
@@ -4225,7 +5642,7 @@ sub update_selfenroll_config {
foreach my $type ('start','end') {
if (exists($changes{'internal.selfenroll_'.$type.'_date'})) {
my $newdate = &Apache::lonlocal::locallocaltime($changes{'internal.selfenroll_'.$type.'_date'});
- $r->print('
'.&mt('[_1]: [_2] set to "[_3]".',
+ $r->print('
'.&mt('[_1]: "[_2]" set to "[_3]".',
$title,$type,$newdate).'
');
}
}
@@ -4233,14 +5650,83 @@ sub update_selfenroll_config {
foreach my $type ('start','end') {
if (exists($changes{'internal.selfenroll_'.$type.'_access'})) {
my $newdate = &Apache::lonlocal::locallocaltime($changes{'internal.selfenroll_'.$type.'_access'});
- $r->print('
'.&mt('[_1]: [_2] set to "[_3]".',
+ $r->print('
'.&mt('[_1]: "[_2]" set to "[_3]".',
$title,$type,$newdate).'
');
}
}
+ } elsif ($item eq 'limit') {
+ if ((exists($changes{'internal.selfenroll_limit'})) ||
+ (exists($changes{'internal.selfenroll_cap'}))) {
+ my ($newval,$newcap);
+ if ($changes{'internal.selfenroll_cap'} ne '') {
+ $newcap = $changes{'internal.selfenroll_cap'}
+ } else {
+ $newcap = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_cap'};
+ }
+ if ($changes{'internal.selfenroll_limit'} eq 'none') {
+ $newval = &mt('No limit');
+ } elsif ($changes{'internal.selfenroll_limit'} eq
+ 'allstudents') {
+ $newval = &mt('New self-enrollment no longer allowed when total (all students) reaches [_1].',$newcap);
+ } elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') {
+ $newval = &mt('New self-enrollment no longer allowed when total number of self-enrolled students reaches [_1].',$newcap);
+ } else {
+ my $currlimit = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_limit'};
+ if ($currlimit eq 'allstudents') {
+ $newval = &mt('New self-enrollment no longer allowed when total (all students) reaches [_1].',$newcap);
+ } elsif ($changes{'internal.selfenroll_limit'} eq 'selfenrolled') {
+ $newval = &mt('New self-enrollment no longer allowed when total umber of self-enrolled students reaches [_1].',$newcap);
+ }
+ }
+ $r->print('
'.&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");
}
}
}
@@ -4254,23 +5740,56 @@ sub update_selfenroll_config {
$r->print(&mt('An error occurred when saving changes to self-enrollment settings in this course.').' '.&mt('The error was: [_1].',$putresult));
}
} else {
- $r->print(&mt('No changes were needed to the existing self-enrollment settings in this course.'));
+ $r->print(&mt('No changes were made to the existing self-enrollment settings in this course.'));
}
} else {
- $r->print(&mt('No changes were needed to the existing self-enrollment settings in this course.'));
+ $r->print(&mt('No changes were made to the existing self-enrollment settings in this course.'));
}
+ my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum);
+ if (ref($visactions) eq 'HASH') {
+ if (!$visible) {
+ $r->print(' '.$visactions->{'miss'}.' '.$visactions->{'yous'}.
+ ' ');
+ if (ref($vismsgs) eq 'ARRAY') {
+ $r->print(' '.$visactions->{'take'}.'
');
+ foreach my $item (@{$vismsgs}) {
+ $r->print('
'.$visactions->{$item}.'
');
+ }
+ $r->print('
');
+ }
+ $r->print($cansetvis);
+ }
+ }
return;
}
+sub compare_arrays {
+ my ($arrayref1,$arrayref2) = @_;
+ my (@difference,%count);
+ @difference = ();
+ %count = ();
+ if ((ref($arrayref1) eq 'ARRAY') && (ref($arrayref2) eq 'ARRAY')) {
+ foreach my $element (@{$arrayref1}, @{$arrayref2}) { $count{$element}++; }
+ foreach my $element (keys(%count)) {
+ if ($count{$element} == 1) {
+ push(@difference,$element);
+ }
+ }
+ }
+ return @difference;
+}
+
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 (
- selfenroll => 'Self-enrollment with a student role',
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',
- access_dates => 'Access dates for self-enrolled users',
- section => 'Section',
+ 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);
}