summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
Diffstat (limited to 'LedgerSMB')
-rw-r--r--LedgerSMB/Admin.pm7
-rw-r--r--LedgerSMB/DBObject.pm26
-rw-r--r--LedgerSMB/DBObject/Admin.pm14
-rw-r--r--LedgerSMB/DBObject/User.pm55
4 files changed, 61 insertions, 41 deletions
diff --git a/LedgerSMB/Admin.pm b/LedgerSMB/Admin.pm
index 98a466bf..d2c303fd 100644
--- a/LedgerSMB/Admin.pm
+++ b/LedgerSMB/Admin.pm
@@ -192,11 +192,4 @@ sub get_entire_user {
return $user;
}
-sub get_roles {
-
- my $self = shift @_;
-
- return $self->exec_method(funcname=>'get_roles',args=>[$self->{company}]);
-}
-
1; \ No newline at end of file
diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm
index f7f16c7d..de14b2e3 100644
--- a/LedgerSMB/DBObject.pm
+++ b/LedgerSMB/DBObject.pm
@@ -125,24 +125,28 @@ sub exec_method {
my @proc_args;
if ( !$ref->{proname} ) { # no such function
-
+ # If the function doesn't exist, $funcname gets zeroed?
$self->error( "No such function: $funcname");
# die;
}
$ref->{pronargs} = 0 unless defined $ref->{pronargs};
-
- @proc_args = $self->_parse_array($args);
- if (@proc_args) {
- for my $arg (@proc_args) {
- if ( $arg =~ s/^in_// ) {
- push @call_args, $self->{$arg};
+ # If the user provided args..
+ if (length(@in_args) == 0) {
+ @proc_args = $self->_parse_array($args);
+ if (@proc_args) {
+ for my $arg (@proc_args) {
+ if ( $arg =~ s/^in_// ) {
+ push @call_args, $self->{$arg};
+ }
}
}
+ for (@in_args) { push @call_args, $_ } ;
+ $self->{call_args} = \@call_args;
+ return $self->call_procedure( procname => $funcname, args => \@call_args );
+ }
+ else {
+ return $self->call_procedure( procname => $funcname, args => \@in_args );
}
-
- for (@in_args) { push @call_args, $_ } ;
- $self->{call_args} = \@call_args;
- return $self->call_procedure( procname => $funcname, args => \@call_args );
}
sub run_custom_queries {
diff --git a/LedgerSMB/DBObject/Admin.pm b/LedgerSMB/DBObject/Admin.pm
index 52e1d8b3..e6e519ac 100644
--- a/LedgerSMB/DBObject/Admin.pm
+++ b/LedgerSMB/DBObject/Admin.pm
@@ -241,9 +241,15 @@ sub get_salutations {
sub get_roles {
- # These are direct, assignable roles.
- my $self = shift;
-
- return $self->exec_method( procname => "admin__all_roles" );
+ my $self = shift @_;
+# print STDERR "attempting to get roles";
+ my @s_rows = $self->call_procedure(procname=>'admin__get_roles',args=>[$self->{company}]);
+ my @rows;
+ for my $role (@s_rows) {
+ my $rolname = $role->{'admin__get_roles'};
+ $rolname =~ s/lsmb_ledgersmb_13__//gi;
+ push @rows, $rolname;
+ }
+ return \@rows;
}
1;
diff --git a/LedgerSMB/DBObject/User.pm b/LedgerSMB/DBObject/User.pm
index af02e7ff..18bfca9a 100644
--- a/LedgerSMB/DBObject/User.pm
+++ b/LedgerSMB/DBObject/User.pm
@@ -40,36 +40,53 @@ sub get {
my $self = shift @_;
my $id = shift;
- $self->{user} = @{ $self->exec_method(
+ my @users = $self->exec_method(
funcname=>'admin__get_user',
args=>[$id]
- )
- }[0];
- $self->{pref} = @{ $self->exec_method(
+ );
+ $self->{user} = $users[0];
+ my @prefs = $self->exec_method(
funcname=>'admin__user_preferences',
args=>[$id]
- )
- }[0];
- $self->{person} = @{ $self->exec_method(
- funcname=>'admin__user_preferences',
- args=>[$self->{user}->{entity_id}]
- )
- }[0];
- $self->{employee} = @{ $self->exec_method(
+ );
+ $self->{pref} = $prefs[0];
+# $self->{person} = @{ $self->exec_method(
+# funcname=>'admin__user_preferences',
+# args=>[$self->{user}->{entity_id}]
+# )
+# }[0];
+ my @emp = $self->exec_method(
funcname=>'employee__get',
- args=>[$id]
- )
- }[0];
- $self->{entity} = @{ $self->exec_method(
+ args=>[$self->{user}->{entity_id}]
+ );
+ $self->{employee} = $emp[0];
+ my @ent = $self->exec_method(
funcname=>'entity__get_entity',
args=>[ $self->{user}->{entity_id} ]
- )
- }[0];
- $self->{roles} = $self->exec_method(
+ );
+ $self->{entity} = $ent[0];
+ my @roles = $self->exec_method(
funcname=>'admin__get_roles_for_user',
args=>[$id]
);
+ # Now, location and stuff.
+ my @loc = $self->exec_method(
+ funcname=>'person__list_locations',
+ args=>[ $self->{user}->{entity_id} ]
+ );
+ $self->{location} = \@loc;
+ my @contacts = $self->exec_method(
+ funcname=>"person__list_contacts",
+ args=>[$self->{user}->{entity_id} ]
+ );
+ my @rolstore;
+
+ for my $role (@roles) {
+ push @rolstore, $role->{'admin__get_roles_for_user'}; # Only one key=>value pair
+ }
+ $self->{roles} = \@rolstore;
+ print STDERR "Got all user information";
#$user->{user} = $u->get($id);
#$user->{pref} = $u->preferences($id);