From a905043d0897d3b47729d3a6eccf794d542a45aa Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Sun, 12 Oct 2014 00:22:53 +0200 Subject: Added group name by ID into Shared --- lib/AdminPanel/Module/Users.pm | 8 ++++---- lib/AdminPanel/Shared/Users.pm | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/AdminPanel/Module/Users.pm b/lib/AdminPanel/Module/Users.pm index 217d46e..5335f0a 100644 --- a/lib/AdminPanel/Module/Users.pm +++ b/lib/AdminPanel/Module/Users.pm @@ -1756,8 +1756,8 @@ sub _userGroupsTabWidget { $replace_pnt->deleteChildren(); my %userGroupsWidget; - my $userEnt = $self->sh_users->ctx->LookupUserByName($userData->{username}); - my $lastchg = $userEnt->ShadowLastChange($self->sh_users->USER_GetValue); + my $userInfo = $self->sh_users->getUserInfo($userData->{username}); + my $lastchg = $userInfo->{last_change}; my $layout = _labeledFrameBox($replace_pnt, $self->loc->N("Select groups that the user will be member of:")); @@ -1783,8 +1783,8 @@ sub _userGroupsTabWidget { $userGroupsWidget{members}->setNotify(1); my $primgroup = ''; if ($userData->{primary_group} != -1) { - my $Gent = $self->sh_users->ctx->LookupGroupById($userData->{primary_group}); - $primgroup = $Gent->GroupName($self->sh_users->USER_GetValue); + $DB::single = 1; + $primgroup = $self->sh_users->groupName($userData->{primary_group}); } my $align = $factory->createLeft($layout); diff --git a/lib/AdminPanel/Shared/Users.pm b/lib/AdminPanel/Shared/Users.pm index 237fee9..9839f8b 100644 --- a/lib/AdminPanel/Shared/Users.pm +++ b/lib/AdminPanel/Shared/Users.pm @@ -573,6 +573,37 @@ sub groupID { return undef; } + +#============================================================= + +=head2 groupName + +=head3 INPUT + +$gid grou identifier + +=head3 OUTPUT + +group name or undef + +=head3 DESCRIPTION + +This method returns the group name for the given group +identifier + +=cut + +#============================================================= +sub groupName { + my ($self, $gid) = @_; + + my $gr = $self->ctx->LookupGroupById($gid); + return $gr->GroupName($self->USER_GetValue) if ($gr); + + return undef; +} + + #============================================================= =head2 addGroup -- cgit v1.2.1