aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/share/perl/lib/OpenSim/UserServer/UserManager.pm
diff options
context:
space:
mode:
Diffstat (limited to 'share/perl/lib/OpenSim/UserServer/UserManager.pm')
-rw-r--r--share/perl/lib/OpenSim/UserServer/UserManager.pm49
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 @@
1package OpenSim::UserServer::UserManager;
2
3use strict;
4use Carp;
5use OpenSim::Utility;
6use OpenSim::UserServer::Config;
7
8sub 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
24sub 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
40sub 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
491;