Diff for /loncom/lond between versions 1.317 and 1.318.2.6

version 1.317, 2006/02/07 05:08:27 version 1.318.2.6, 2006/03/04 04:27:38
Line 2915  sub dump_profile_database { Line 2915  sub dump_profile_database {
  while (my ($key,$value) = each(%$hashref)) {   while (my ($key,$value) = each(%$hashref)) {
     my ($v,$symb,$param) = split(/:/,$key);      my ($v,$symb,$param) = split(/:/,$key);
     next if ($v eq 'version' || $symb eq 'keys');      next if ($v eq 'version' || $symb eq 'keys');
     next if (exists($data{$symb}) &&       # making old style store  entries '$ver:$symb:$key = $value'
      exists($data{$symb}->{$param}) &&      # look like new             '$ver:compressed:$symb = "$key=$value"'
      $data{$symb}->{'v.'.$param} > $v);      if ($symb eq 'compressed') {
     $data{$symb}->{$param}=$value;   $symb = $param;
     $data{$symb}->{'v.'.$param}=$v;      } else {
    $value = $param.'='.$value;
       }
       foreach my $pair (split(/\&/,$value)) {
    my ($param,$value)=split(/=/,$pair);
    next if (exists($data{$symb}) && 
    exists($data{$symb}->{$param}) &&
    $data{$symb}->{'v.'.$param} > $v);
    $data{$symb}->{$param}=$value;
    $data{$symb}->{'v.'.$param}=$v;
       }
  }   }
  if (&untie_user_hash($hashref)) {   if (&untie_user_hash($hashref)) {
     while (my ($symb,$param_hash) = each(%data)) {      while (my ($symb,$param_hash) = each(%data)) {
Line 3068  sub store_handler { Line 3078  sub store_handler {
     my $version=$hashref->{"version:$rid"};      my $version=$hashref->{"version:$rid"};
     my $allkeys='';       my $allkeys=''; 
     foreach my $pair (@pairs) {      foreach my $pair (@pairs) {
  my ($key,$value)=split(/=/,$pair);   my ($key)=split(/=/,$pair);
  $allkeys.=$key.':';   $allkeys.=$key.':';
  $hashref->{"$version:$rid:$key"}=$value;  
     }      }
     $hashref->{"$version:$rid:timestamp"}=$now;      $hashref->{"$version:compressed:$rid"}=$what."\&timestamp=$now";
     $allkeys.='timestamp';      $allkeys.='timestamp';
     $hashref->{"$version:keys:$rid"}=$allkeys;      $hashref->{"$version:keys:$rid"}=$allkeys;
     if (&untie_user_hash($hashref)) {      if (&untie_user_hash($hashref)) {
Line 3093  sub store_handler { Line 3102  sub store_handler {
 }  }
 &register_handler("store", \&store_handler, 0, 1, 0);  &register_handler("store", \&store_handler, 0, 1, 0);
   
   sub putstore_handler {
       my ($cmd, $tail, $client) = @_;
    
       my $userinput = "$cmd:$tail";
   
       my ($udom,$uname,$namespace,$rid,$v,$what) =split(/:/,$tail);
       if ($namespace ne 'roles') {
   
    chomp($what);
    my $hashref  = &tie_user_hash($udom, $uname, $namespace,
          &GDBM_WRCREAT(), "C",
          "$rid:$what");
    if ($hashref) {
       my $now = time;
       my %data = &hash_extract($what);
       my @allkeys;
       if (exists($hashref->{"$v:compressed:$rid"})) {
    my %current = &hash_extract($hashref->{"$v:compressed:$rid"});
    while (my($key,$value) = each(%data)) {
       push(@allkeys,$key);
       $current{$key} = $value;
    }
    $hashref->{"$v:compressed:$rid"}= &hash_to_str(\%current);
       } else {
    while (my($key,$value) = each(%data)) {
       push(@allkeys,$key);
       $hashref->{"$v:$rid:$key"} = $value;
    }
       }
       my $allkeys = join(':',@allkeys);
       $hashref->{"$v:keys:$rid"}=$allkeys;
   
       if (&untie_user_hash($hashref)) {
    &Reply($client, "ok\n", $userinput);
       } else {
    &Failure($client, "error: ".($!+0)." untie(GDBM) Failed ".
    "while attempting store\n", $userinput);
       }
    } else {
       &Failure( $client, "error: ".($!+0)." tie(GDBM) Failed ".
        "while attempting store\n", $userinput);
    }
       } else {
    &Failure($client, "refused\n", $userinput);
       }
   
       return 1;
   }
   &register_handler("putstore", \&putstore_handler, 0, 1, 0);
   
   sub hash_extract {
       my ($str)=@_;
       my %hash;
       foreach my $pair (split(/\&/,$str)) {
    my ($key,$value)=split(/=/,$pair);
    $hash{$key}=$value;
       }
       return (%hash);
   }
   sub hash_to_str {
       my ($hash_ref)=@_;
       my $str;
       foreach my $key (keys(%$hash_ref)) {
    $str.=$key.'='.$hash_ref->{$key}.'&';
       }
       $str=~s/\&$//;
       return $str;
   }
   
 #  #
 #  Dump out all versions of a resource that has key=value pairs associated  #  Dump out all versions of a resource that has key=value pairs associated
 # with it for each version.  These resources are built up via the store  # with it for each version.  These resources are built up via the store
Line 3138  sub restore_handler { Line 3216  sub restore_handler {
     my @keys=split(/:/,$vkeys);      my @keys=split(/:/,$vkeys);
     my $key;      my $key;
     $qresult.="$scope:keys=$vkeys&";      $qresult.="$scope:keys=$vkeys&";
     foreach $key (@keys) {      if (exists($hashref->{"$scope:compressed:$rid"})) {
  $qresult.="$scope:$key=".$hashref->{"$scope:$rid:$key"}."&";   foreach my $pair (split(/\&/,$hashref->{"$scope:compressed:$rid"})) {
     }                                        my ($key,$value)=split(/=/,$pair);
       $qresult.="$scope:".$pair."&";
    }
       } else {
    foreach $key (@keys) {
       $qresult.="$scope:$key=".$hashref->{"$scope:$rid:$key"}."&";
    }
       }
  }   }
  if (&untie_user_hash($hashref)) {   if (&untie_user_hash($hashref)) {
     $qresult=~s/\&$//;      $qresult=~s/\&$//;
Line 4349  sub photo_permission_handler { Line 4434  sub photo_permission_handler {
     my $cdom = $tail;      my $cdom = $tail;
     my ($perm_reqd,$conditions);      my ($perm_reqd,$conditions);
     my $outcome = &localenroll::photo_permission($cdom,\$perm_reqd,      my $outcome = &localenroll::photo_permission($cdom,\$perm_reqd,
                                                                  \$conditions);   \$conditions);
     &Reply($client, &escape($outcome.':'.$perm_reqd.':'. $conditions)."\n",      &Reply($client, &escape($outcome.':'.$perm_reqd.':'. $conditions)."\n",
                                                                    $userinput);     $userinput);
 }  }
 &register_handler("autophotopermission",\&photo_permission_handler,0,1,0);  &register_handler("autophotopermission",\&photo_permission_handler,0,1,0);
   

Removed from v.1.317  
changed lines
  Added in v.1.318.2.6


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