[LON-CAPA-cvs] cvs: loncom / lond /enrollment localenroll.pm /interface createaccount.pm domainprefs.pm /lonnet/perl lonnet.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 29 Feb 2008 21:01:44 -0000


This is a MIME encoded message

--raeburn1204318904
Content-Type: text/plain

raeburn		Fri Feb 29 16:01:44 2008 EDT

  Modified files:              
    /loncom	lond 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/interface	domainprefs.pm createaccount.pm 
    /loncom/enrollment	localenroll.pm 
  Log:
  - Replace "selfenroll" with "selfcreate" in various subroutine names, and modify text which refers to self-enrollment to refer to user creation of accounts.
  - Intended to clarify that these procedures relate to a user creating his/her own account in a LON-CAPA domain as opposed to self-enrolling in a course, once the user has an account.     
  
  
--raeburn1204318904
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080229160144.txt"

Index: loncom/lond
diff -u loncom/lond:1.396 loncom/lond:1.397
--- loncom/lond:1.396	Sun Feb 24 17:59:06 2008
+++ loncom/lond	Fri Feb 29 16:01:03 2008
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.396 2008/02/24 22:59:06 raeburn Exp $
+# $Id: lond,v 1.397 2008/02/29 21:01:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.396 $'; #' stupid emacs
+my $VERSION='$Revision: 1.397 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -3446,7 +3446,8 @@
     my $userinput = "$cmd:$tail";
 
     my ($udom,$since,$description,$instcodefilter,$ownerfilter,$coursefilter,
-        $typefilter,$regexp_ok,$rtn_as_hash) =split(/:/,$tail);
+        $typefilter,$regexp_ok,$rtn_as_hash,$selfenrollonly) =split(/:/,$tail);
+    my $now = time;
     if (defined($description)) {
 	$description=&unescape($description);
     } else {
@@ -3496,7 +3497,9 @@
     my $hashref = &tie_domain_hash($udom, "nohist_courseids", &GDBM_WRCREAT());
     if ($hashref) {
 	while (my ($key,$value) = each(%$hashref)) {
-            my ($unesc_key,$lasttime_key,$lasttime,$is_hash,%val,%unesc_val);
+            my ($unesc_key,$lasttime_key,$lasttime,$is_hash,%val,
+                %unesc_val,$selfenroll_start,$selfenroll_end,
+                $selfenroll_types);
             $unesc_key = &unescape($key);
             if ($unesc_key =~ /^lasttime:/) {
                 next;
@@ -3515,6 +3518,18 @@
                     $unesc_val{'inst_code'} = $items->{'inst_code'};
                     $unesc_val{'owner'} = $items->{'owner'};
                     $unesc_val{'type'} = $items->{'type'};
+                    $selfenroll_types = $items->{'selfenroll_types'};
+                    $selfenroll_start = $items->{'selfenroll_start_date'};
+                    $selfenroll_end = $items->{'selfenroll_end_date'};
+                    if ($selfenrollonly) {
+                        next if (!$selfenroll_types);
+                        if (($selfenroll_start > 0) && ($selfenroll_start > $now)) {
+                            next;
+                        }
+                        if (($selfenroll_end > 0) && ($selfenroll_end <= $now)) {
+                            next;
+                        }
+                    }
                 }
             } else {
                 $is_hash =  0;
@@ -4703,7 +4718,7 @@
 }
 &register_handler("instidrules",\&get_institutional_id_rules,0,1,0);
 
-sub get_institutional_selfenroll_rules {
+sub get_institutional_selfcreate_rules {
     my ($cmd, $tail, $client)   = @_;
     my $userinput               = "$cmd:$tail";
     my $dom = &unescape($tail);
@@ -4711,7 +4726,7 @@
     my $outcome;
     eval {
         local($SIG{__DIE__})='DEFAULT';
-        $outcome = &localenroll::selfenroll_rules($dom,\%rules_hash,\@rules_order);
+        $outcome = &localenroll::selfcreate_rules($dom,\%rules_hash,\@rules_order);
     };
     if (!$@) {
         if ($outcome eq 'ok') {
@@ -4735,7 +4750,7 @@
         &Failure($client,"unknown_cmd\n",$userinput);
     }
 }
-&register_handler("instemailrules",\&get_institutional_selfenroll_rules,0,1,0);
+&register_handler("instemailrules",\&get_institutional_selfcreate_rules,0,1,0);
 
 
 sub institutional_username_check {
@@ -4796,7 +4811,7 @@
 }
 &register_handler("instidrulecheck",\&institutional_id_check,0,1,0);
 
-sub institutional_selfenroll_check {
+sub institutional_selfcreate_check {
     my ($cmd, $tail, $client)   = @_;
     my $userinput               = "$cmd:$tail";
     my %rulecheck;
@@ -4807,7 +4822,7 @@
     @rules = map {&unescape($_);} (@rules);
     eval {
         local($SIG{__DIE__})='DEFAULT';
-        $outcome = &localenroll::selfenroll_check($udom,$email,\@rules,\%rulecheck);
+        $outcome = &localenroll::selfcreate_check($udom,$email,\@rules,\%rulecheck);
     };
     if (!$@) {
         if ($outcome eq 'ok') {
@@ -4823,7 +4838,7 @@
         &Failure($client,"unknown_cmd\n",$userinput);
     }
 }
-&register_handler("instselfenrollcheck",\&institutional_selfenroll_check,0,1,0);
+&register_handler("instselfcreatecheck",\&institutional_selfcreate_check,0,1,0);
 
 # Get domain specific conditions for import of student photographs to a course
 #
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.944 loncom/lonnet/perl/lonnet.pm:1.945
--- loncom/lonnet/perl/lonnet.pm:1.944	Tue Feb 26 05:39:44 2008
+++ loncom/lonnet/perl/lonnet.pm	Fri Feb 29 16:01:24 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.944 2008/02/26 10:39:44 foxr Exp $
+# $Id: lonnet.pm,v 1.945 2008/02/29 21:01:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1064,8 +1064,8 @@
                     $response=&unescape(&reply('instidrulecheck:'.&escape($udom).
                                               ':'.&escape($id).':'.$rulestr,
                                               $homeserver));
-                } elsif ($item eq 'selfenroll') {
-                    $response=&unescape(&reply('instselfenrollcheck:'.
+                } elsif ($item eq 'selfcreate') {
+                    $response=&unescape(&reply('instselfcreatecheck:'.
                                                &escape($udom).':'.&escape($uname).
                                               ':'.$rulestr,$homeserver));
                 }
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.44 loncom/interface/domainprefs.pm:1.45
--- loncom/interface/domainprefs.pm:1.44	Fri Feb 29 14:07:06 2008
+++ loncom/interface/domainprefs.pm	Fri Feb 29 16:01:36 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.44 2008/02/29 19:07:06 raeburn Exp $
+# $Id: domainprefs.pm,v 1.45 2008/02/29 21:01:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1300,7 +1300,7 @@
         }
     }
     my ($searchtitles,$titleorder) = &sorted_searchtitles();
-    my ($othertitle,$usertypes,$types) = &Apache::Loncommon::sorted_inst_types($dom);
+    my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
 
     my $numinrow = 4;
     my $cansrchrow = 0;
@@ -1509,7 +1509,7 @@
             $rowcount ++;
         }
     } elsif ($position eq 'middle') {
-        my @creators = ('author','course','selfenroll');
+        my @creators = ('author','course','selfcreate');
         my ($rules,$ruleorder) =
             &Apache::lonnet::inst_userrules($dom,'username');
         my %lt = &usercreation_types();
@@ -1531,7 +1531,7 @@
         foreach my $item (@creators) {
             $rownum ++;
             if ($checked{$item} eq '') {
-                if ($item eq 'selfenroll') {
+                if ($item eq 'selfcreate') {
                     $checked{$item} = 'none';
                 } else {
                     $checked{$item} = 'any';
@@ -1547,7 +1547,7 @@
                          '<td><span class="LC_nobreak">'.$lt{$item}.
                          '</span></td><td align="right">';
             my @options = ('any');
-            if ($item eq 'selfenroll') {
+            if ($item eq 'selfcreate') {
                 push(@options,('email','login','sso'));
             } else {
                 if (ref($rules) eq 'HASH') {
@@ -1626,7 +1626,7 @@
     my %text = (
                    'username' => 'new usernames',
                    'id'       => 'IDs',
-                   'email'    => 'e-mail addresses of self-enrollers',
+                   'email'    => 'self-created accounts (e-mail)',
                );
     my $css_class = $rowcount%2?' class="LC_odd_row"':'';
     $output = '<tr '.$css_class.'>'.
@@ -1677,7 +1677,7 @@
     my %lt = &Apache::lonlocal::texthash (
                     author     => 'When adding a co-author',
                     course     => 'When adding a user to a course',
-                    selfenroll => 'When a user is self-enrolling', 
+                    selfcreate => 'User creates own account', 
                     any        => 'Any',
                     official   => 'Institutional only ',
                     unofficial => 'Non-institutional only',
@@ -3181,10 +3181,10 @@
     my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
     my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
     my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
-    my @contexts = ('author','course','selfenroll');
+    my @contexts = ('author','course','selfcreate');
     foreach my $item(@contexts) {
         $cancreate{$item} = $env{'form.can_createuser_'.$item};
-        if ($item eq 'selfenroll') {
+        if ($item eq 'selfcreate') {
             my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
             if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) {
                 if (($cancreate{$item} eq 'any') || ($cancreate{$item} eq 'login')) {
@@ -3311,7 +3311,7 @@
                 my %lt = &usercreation_types();
                 foreach my $type (@{$changes{'cancreate'}}) {
                     my $chgtext =  $lt{$type}.', ';
-                    if ($type eq 'selfenroll') {
+                    if ($type eq 'selfcreate') {
                         if ($cancreate{$type} eq 'none') {
                             $chgtext .= &mt('creation of a new user account is not permitted.');
                         } elsif ($cancreate{$type} eq 'any') {
Index: loncom/interface/createaccount.pm
diff -u loncom/interface/createaccount.pm:1.1 loncom/interface/createaccount.pm:1.2
--- loncom/interface/createaccount.pm:1.1	Sun Feb 24 18:23:39 2008
+++ loncom/interface/createaccount.pm	Fri Feb 29 16:01:36 2008
@@ -3,7 +3,7 @@
 # institutional log-in ID (institutional authentication required - localauth
 #  or kerberos) or an e-mail address.
 #
-# $Id: createaccount.pm,v 1.1 2008/02/24 23:23:39 raeburn Exp $
+# $Id: createaccount.pm,v 1.2 2008/02/29 21:01:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -73,8 +73,8 @@
     my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
     if (ref($domconfig{'usercreation'}) eq 'HASH') {
         if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') { 
-            if ($domconfig{'usercreation'}{'cancreate'}{'selfenroll'} ne 'none') {
-                $cancreate = $domconfig{'usercreation'}{'cancreate'}{'selfenroll'};
+            if ($domconfig{'usercreation'}{'cancreate'}{'selfcreate'} ne 'none') {
+                $cancreate = $domconfig{'usercreation'}{'cancreate'}{'selfcreate'};
             }
         }
     }
@@ -754,7 +754,7 @@
     if (@user_rules > 0) {
         my %rule_check = 
             &Apache::lonnet::inst_rulecheck($domain,$useremail,undef,
-                                            'selfenroll',\@user_rules);
+                                            'selfcreate',\@user_rules);
         if (keys(%rule_check) > 0) {
             foreach my $item (keys(%rule_check)) {
                 if ($rule_check{$item}) {
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.30 loncom/enrollment/localenroll.pm:1.31
--- loncom/enrollment/localenroll.pm:1.30	Sun Feb 24 17:59:20 2008
+++ loncom/enrollment/localenroll.pm	Fri Feb 29 16:01:43 2008
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for 
 # automated enrollment
-# $Id: localenroll.pm,v 1.30 2008/02/24 22:59:20 raeburn Exp $
+# $Id: localenroll.pm,v 1.31 2008/02/29 21:01:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -660,7 +660,7 @@
 }
 
 ###############################
-# sub selfenroll_rules
+# sub selfcreate_rules
 #
 # Incoming data: three arguments
 # (a) $dom - domain
@@ -680,7 +680,7 @@
 ###############################
 
 
-sub selfenroll_rules {
+sub selfcreate_rules {
     my ($dom,$ruleshash,$rulesorder) = @_;
     my $outcome;
     return $outcome;
@@ -731,11 +731,11 @@
 }
 
 ###############################
-# sub selfenroll_check
+# sub selfcreate_check
 #
 # Incoming data: four arguments
 # (a) $dom - domain (scalar)
-# (b) $selfenrollname - e-mail proposed as username (compare against rules - scalar)
+# (b) $selfcreatename - e-mail proposed as username (compare against rules - scalar)
 # (c) $to_check (reference to array of rule names to check)
 # (d) $resultshash (reference to hash of results)
 #                   hash of results for rule checked
@@ -746,8 +746,8 @@
 #
 ###############################
 
-sub selfenroll_check {
-    my ($dom,$selfenrollname,$to_check,$resultshash) = @_;
+sub selfcreate_check {
+    my ($dom,$selfcreatename,$to_check,$resultshash) = @_;
     my $outcome;
     return $outcome;
 }

--raeburn1204318904--