diff options
author | Angelo Naselli <anaselli@linux.it> | 2014-10-11 19:06:25 +0200 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2014-10-11 19:06:25 +0200 |
commit | 26413fb9b2dd04171253d1480b8402cf5d74f0ad (patch) | |
tree | 447cec94818d1a9e76f6a1b3464a18aa4072d499 /lib/AdminPanel/Shared | |
parent | 68df8b379529df413788a324044127f0a89476a0 (diff) | |
download | colin-keep-26413fb9b2dd04171253d1480b8402cf5d74f0ad.tar colin-keep-26413fb9b2dd04171253d1480b8402cf5d74f0ad.tar.gz colin-keep-26413fb9b2dd04171253d1480b8402cf5d74f0ad.tar.bz2 colin-keep-26413fb9b2dd04171253d1480b8402cf5d74f0ad.tar.xz colin-keep-26413fb9b2dd04171253d1480b8402cf5d74f0ad.zip |
moved getUserInfo to Shared
Diffstat (limited to 'lib/AdminPanel/Shared')
-rw-r--r-- | lib/AdminPanel/Shared/Users.pm | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/lib/AdminPanel/Shared/Users.pm b/lib/AdminPanel/Shared/Users.pm index 52e939b..58b1a41 100644 --- a/lib/AdminPanel/Shared/Users.pm +++ b/lib/AdminPanel/Shared/Users.pm @@ -775,6 +775,65 @@ sub getGroupsInfo { #============================================================= +=head2 getUserInfo + +=head3 INPUT + + $username: user name + +=head3 OUTPUT + +$userInfo: HASH reference containing + uid => user identifier + gid => group identifier + fullname => user full name + home => home directory + shell => user shell + expire => shadow expire time + locked => is locked? + exp_min => shadow Min + exp_max => shadow Max + exp_warn => shadow Warn + exp_inact=> shadow Inact + members => groups the user belongs to + +=head3 DESCRIPTION + +This method get all the information for the given user + +=cut + +#============================================================= +sub getUserInfo { + my ($self, $username) = @_; + + my $userInfo = {}; + return $userInfo if !defined $self->ctx; + + my $userEnt = $self->ctx->LookupUserByName($username); + return $userInfo if !defined($userEnt); + + my $fullname = $userEnt->Gecos($self->USER_GetValue); + utf8::decode($fullname); + $userInfo->{fullname} = $fullname; + $userInfo->{shell} = $userEnt->LoginShell($self->USER_GetValue); + $userInfo->{home} = $userEnt->HomeDir($self->USER_GetValue); + $userInfo->{uid} = $userEnt->Uid($self->USER_GetValue); + $userInfo->{gid} = $userEnt->Gid($self->USER_GetValue); + $userInfo->{expire} = $userEnt->ShadowExpire($self->USER_GetValue); + $userInfo->{locked} = $self->ctx->IsLocked($userEnt); + + $userInfo->{exp_min} = $userEnt->ShadowMin($self->USER_GetValue); + $userInfo->{exp_max} = $userEnt->ShadowMax($self->USER_GetValue); + $userInfo->{exp_warn} = $userEnt->ShadowWarn($self->USER_GetValue); + $userInfo->{exp_inact} = $userEnt->ShadowInact($self->USER_GetValue); + $userInfo->{members} = $self->ctx->EnumerateGroupsByUser($username); + + return $userInfo; +} + +#============================================================= + =head2 getUsersInfo =head3 INPUT @@ -943,7 +1002,7 @@ sub computeLockExpire { my $tm = ceil(time()/(24*60*60)); $ep = -1 if int($tm) <= $ep; my $status = $self->ctx->IsLocked($l) ? $self->loc->N("Locked") : ($ep != -1 ? $self->loc->N("Expired") : ''); - $status; + return $status; } #============================================================= |