Diff for /loncom/lond between versions 1.516 and 1.517

version 1.516, 2015/06/14 00:43:51 version 1.517, 2016/01/31 21:25:53
Line 4377  sub put_domain_handler { Line 4377  sub put_domain_handler {
 }  }
 &register_handler("putdom", \&put_domain_handler, 0, 1, 0);  &register_handler("putdom", \&put_domain_handler, 0, 1, 0);
   
   # Updates one or more entries in clickers.db file at the domain level
   #
   # Parameters:
   #    $cmd      - The command that got us here.
   #    $tail     - Tail of the command (remaining parameters).
   #                In this case a colon separated list containing:
   #                (a) the domain for which we are updating the entries,
   #                (b) the action required -- add or del -- and
   #                (c) a &-separated list of entries to add or delete.
   #    $client   - File descriptor connected to client.
   # Returns
   #     1        - Continue processing.
   #     0        - Requested to exit, caller should shut down.
   #  Side effects:
   #     reply is written to $client.
   #
   
   
   sub update_clickers {
       my ($cmd, $tail, $client)  = @_;
   
       my $userinput = "$cmd:$tail";
       my ($udom,$action,$what) =split(/:/,$tail,3);
       chomp($what);
   
       my $hashref = &tie_domain_hash($udom, "clickers", &GDBM_WRCREAT(),
                                    "U","$action:$what");
   
       if (!$hashref) {
           &Failure( $client, "error: ".($!+0)." tie(GDBM) Failed ".
                     "while attempting updateclickers\n", $userinput);
           return 1;
       }
   
       my @pairs=split(/\&/,$what);
       foreach my $pair (@pairs) {
           my ($key,$value)=split(/=/,$pair);
           if ($action eq 'add') {
               if (exists($hashref->{$key})) {
                   my @newvals = split(/,/,&unescape($value));
                   my @currvals = split(/,/,&unescape($hashref->{$key}));
                   my @merged = sort(keys(%{{map { $_ => 1 } (@newvals,@currvals)}}));
                   $hashref->{$key}=&escape(join(',',@merged));
               } else {
                   $hashref->{$key}=$value;
               }
           } elsif ($action eq 'del') {
               if (exists($hashref->{$key})) {
                   my %current;
                   map { $current{$_} = 1; } split(/,/,&unescape($hashref->{$key}));
                   map { delete($current{$_}); } split(/,/,&unescape($value));
                   if (keys(%current)) {
                       $hashref->{$key}=&escape(join(',',sort(keys(%current))));
                   } else {
                       delete($hashref->{$key});
                   }
               }
           }
       }
       if (&untie_user_hash($hashref)) {
           &Reply( $client, "ok\n", $userinput);
       } else {
           &Failure($client, "error: ".($!+0)." untie(GDBM) failed ".
                    "while attempting put\n",
                    $userinput);
       }
       return 1;
   }
   &register_handler("updateclickers", \&update_clickers, 0, 1, 0);
   
   
   # Deletes one or more entries in a namespace db file at the domain level
   #
   # Parameters:
   #    $cmd      - The command that got us here.
   #    $tail     - Tail of the command (remaining parameters).
   #                In this case a colon separated list containing:
   #                (a) the domain for which we are deleting the entries,
   #                (b) &-separated list of keys to delete.  
   #    $client   - File descriptor connected to client.
   # Returns
   #     1        - Continue processing.
   #     0        - Requested to exit, caller should shut down.
   #  Side effects:
   #     reply is written to $client.
   #
   
   sub del_domain_handler {
       my ($cmd,$tail,$client) = @_;
   
       my $userinput = "$cmd:$tail";
   
       my ($udom,$namespace,$what)=split(/:/,$tail,3);
       chomp($what);
       my $hashref = &tie_domain_hash($udom,$namespace,&GDBM_WRCREAT(),
                                      "D", $what);
       if ($hashref) {
           my @keys=split(/\&/,$what);
           foreach my $key (@keys) {
               delete($hashref->{$key});
           }
           if (&untie_user_hash($hashref)) {
               &Reply($client, "ok\n", $userinput);
           } else {
               &Failure($client, "error: ".($!+0)." untie(GDBM) Failed ".
                       "while attempting deldom\n", $userinput);
           }
       } else {
           &Failure( $client, "error: ".($!+0)." tie(GDBM) Failed ".
                    "while attempting deldom\n", $userinput);
       }
       return 1;
   }
   &register_handler("deldom", \&del_domain_handler, 0, 1, 0);
   
   
 # Unencrypted get from the namespace database file at the domain level.  # Unencrypted get from the namespace database file at the domain level.
 # This function retrieves a keyed item from a specific named database in the  # This function retrieves a keyed item from a specific named database in the
 # domain directory.  # domain directory.
Line 7699  Allow for a password to be set. Line 7815  Allow for a password to be set.
   
 Make a user.  Make a user.
   
 =item passwd  =item changeuserauth
   
 Allow for authentication mechanism and password to be changed.  Allow for authentication mechanism and password to be changed.
   
Line 7788  for each student, defined perhaps by the Line 7904  for each student, defined perhaps by the
 Returns usernames corresponding to IDs.  (These "IDs" are unique identifiers  Returns usernames corresponding to IDs.  (These "IDs" are unique identifiers
 for each student, defined perhaps by the institutional Registrar.)  for each student, defined perhaps by the institutional Registrar.)
   
   =item iddel
   
   Deletes one or more ids in a domain's id database.
   
 =item tmpput  =item tmpput
   
 Accept and store information in temporary space.  Accept and store information in temporary space.

Removed from v.1.516  
changed lines
  Added in v.1.517


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>