comparison scan.pl @ 88:0fa9cd836e1e

rewrited the viewIsland function.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 26 Oct 2008 16:12:03 +0800
parents 96ee35378696
children 86402d28544f
comparison
equal deleted inserted replaced
87:4c82cf844aa8 88:0fa9cd836e1e
50 50
51 sub saveUser 51 sub saveUser
52 { 52 {
53 my $users = shift; 53 my $users = shift;
54 54
55 foreach my $h_user (values(%{$users})) 55 if(defined($users)) {
56 { 56 foreach my $h_user (values(%{$users}))
57 # print(Dumper($user));
58 printf("Saving user %s\n", $h_user->{'name'});
59 $h_user->{'time'} = time;
60 my $user;
61 if($user = Ikariam::User->retrieve($h_user->{id}))
62 { 57 {
63 foreach my $i (keys(%$h_user)) { 58 # print(Dumper($user));
64 # eval($c->$i($h_user->{$i})); 59 printf("Saving user %s\n", $h_user->{'name'});
65 $user->set($i => $h_user->{$i}); 60 $h_user->{'time'} = time;
61 my $user;
62 if($user = Ikariam::User->retrieve($h_user->{id}))
63 {
64 foreach my $i (keys(%$h_user)) {
65 # eval($c->$i($h_user->{$i}));
66 $user->set($i => $h_user->{$i});
67 }
68 } else {
69 $user = Ikariam::User->insert($h_user);
66 } 70 }
67 } else { 71 $user->update();
68 $user = Ikariam::User->insert($h_user);
69 } 72 }
70 $user->update();
71 } 73 }
72 } 74 }
73 75
74 our $i = new Ikariam($::server, $::user, $::pass); 76 our $i = new Ikariam($::server, $::user, $::pass);
75 77