diff options
Diffstat (limited to 'share/perl/lib/OpenSim/UserServer/UserManager.pm')
-rw-r--r-- | share/perl/lib/OpenSim/UserServer/UserManager.pm | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/share/perl/lib/OpenSim/UserServer/UserManager.pm b/share/perl/lib/OpenSim/UserServer/UserManager.pm new file mode 100644 index 0000000..ce35329 --- /dev/null +++ b/share/perl/lib/OpenSim/UserServer/UserManager.pm | |||
@@ -0,0 +1,49 @@ | |||
1 | package OpenSim::UserServer::UserManager; | ||
2 | |||
3 | use strict; | ||
4 | use Carp; | ||
5 | use OpenSim::Utility; | ||
6 | use OpenSim::UserServer::Config; | ||
7 | |||
8 | sub getUserByName { | ||
9 | my ($first, $last) = @_; | ||
10 | my $res = &OpenSim::Utility::getSimpleResult($OpenSim::UserServer::Config::SYS_SQL{select_user_by_name}, $first, $last); | ||
11 | my $count = @$res; | ||
12 | my %user = (); | ||
13 | if ($count == 1) { | ||
14 | my $user_row = $res->[0]; | ||
15 | foreach (@OpenSim::UserServer::Config::USERS_COLUMNS) { | ||
16 | $user{$_} = $user_row->{$_} || ""; | ||
17 | } | ||
18 | } else { | ||
19 | Carp::croak("user not found"); | ||
20 | } | ||
21 | return \%user; | ||
22 | } | ||
23 | |||
24 | sub getUserByUUID { | ||
25 | my ($uuid) = @_; | ||
26 | my $res = &OpenSim::Utility::getSimpleResult($OpenSim::UserServer::Config::SYS_SQL{select_user_by_uuid}, $uuid); | ||
27 | my $count = @$res; | ||
28 | my %user = (); | ||
29 | if ($count == 1) { | ||
30 | my $user_row = $res->[0]; | ||
31 | foreach (@OpenSim::UserServer::Config::USERS_COLUMNS) { | ||
32 | $user{$_} = $user_row->{$_} || ""; | ||
33 | } | ||
34 | } else { | ||
35 | Carp::croak("user not found"); | ||
36 | } | ||
37 | return \%user; | ||
38 | } | ||
39 | |||
40 | sub createUser { | ||
41 | my $user = shift; | ||
42 | my @params = (); | ||
43 | foreach (@OpenSim::UserServer::Config::USERS_COLUMNS) { | ||
44 | push @params, $user->{$_}; | ||
45 | } | ||
46 | my $res = &OpenSim::Utility::getSimpleResult($OpenSim::UserServer::Config::SYS_SQL{create_user}, @params); | ||
47 | } | ||
48 | |||
49 | 1; | ||