diff options
author | Angelo Naselli <anaselli@linux.it> | 2014-10-06 23:04:13 +0200 |
---|---|---|
committer | Angelo Naselli <anaselli@linux.it> | 2014-10-06 23:04:13 +0200 |
commit | 0ebbb4d0eb180c6b95da35667ea70d740085a2dd (patch) | |
tree | a20f30dfb50e5635e28a63ac05e3570ba2cb3cdd /lib/AdminPanel/Module | |
parent | f4ac24e95ef87873b9ba8d05d359a60db0166913 (diff) | |
download | manatools-0ebbb4d0eb180c6b95da35667ea70d740085a2dd.tar manatools-0ebbb4d0eb180c6b95da35667ea70d740085a2dd.tar.gz manatools-0ebbb4d0eb180c6b95da35667ea70d740085a2dd.tar.bz2 manatools-0ebbb4d0eb180c6b95da35667ea70d740085a2dd.tar.xz manatools-0ebbb4d0eb180c6b95da35667ea70d740085a2dd.zip |
moved getUsersInfo to Shared::Users and updated
_refreshUsers accordingly
Diffstat (limited to 'lib/AdminPanel/Module')
-rw-r--r-- | lib/AdminPanel/Module/Users.pm | 69 |
1 files changed, 22 insertions, 47 deletions
diff --git a/lib/AdminPanel/Module/Users.pm b/lib/AdminPanel/Module/Users.pm index 753b79e5..f7815f4f 100644 --- a/lib/AdminPanel/Module/Users.pm +++ b/lib/AdminPanel/Module/Users.pm @@ -123,14 +123,6 @@ has 'action_menu' => ( ); -## min UID was 500 now is 1000, let's change in a single point -has 'min_UID' => ( - default => 1000, - is => 'ro', - isa => 'Int', - init_arg => undef, -); - has 'edit_tab_widgets' => ( traits => ['Hash'], default => sub { {} }, @@ -845,7 +837,7 @@ sub addUserDialog { $hbox = $factory->createHBox($align); my $uidManually = $factory->createCheckBox($hbox, $self->loc->N("Specify user ID manually"), 0); $factory->createHSpacing($hbox, 2.0); - my $UID = $factory->createIntField($hbox, $self->loc->N("UID"), 1, 65000, $self->min_UID); + my $UID = $factory->createIntField($hbox, $self->loc->N("UID"), 1, 65000, $self->sh_users->min_UID); $UID->setEnabled($uidManually->value()); $uidManually->setNotify(1); # $uidManually->setWeight($yui::YD_HORIZ, 2); @@ -932,10 +924,10 @@ sub addUserDialog { } my $uid = -1; if ($continue && $uidManually->value()) { - if (($uid = $UID->value()) < $self->min_UID) { + if (($uid = $UID->value()) < $self->sh_users->min_UID) { $errorString = ""; - my $uidchoice = $self->sh_gui->ask_YesOrNo({title => $self->loc->N("User Uid is < %d", $self->min_UID), - text => $self->loc->N("Creating a user with a UID less than %d is not recommended.\nAre you sure you want to do this?\n\n", $self->min_UID)}); + my $uidchoice = $self->sh_gui->ask_YesOrNo({title => $self->loc->N("User Uid is < %d", $self->sh_users->min_UID), + text => $self->loc->N("Creating a user with a UID less than %d is not recommended.\nAre you sure you want to do this?\n\n", $self->sh_users->min_UID)}); $continue = $uidchoice; } } @@ -1130,8 +1122,11 @@ sub _refreshUsers { my $strfilt = $self->get_widget('filter')->value(); my $filterusers = $self->get_widget('filter_system')->isChecked(); - my ($users, $group, $groupnm, $expr); - defined $self->sh_users->ctx and $users = $self->sh_users->ctx->UsersEnumerateFull; + my $usersInfo = $self->sh_users->getUsersInfo({ + username_filter => $strfilt, + filter_system => $filterusers, + }); + $self->dialog->startMultipleChanges(); #for some reasons QT send an event using table->selectItem() @@ -1139,46 +1134,26 @@ sub _refreshUsers { $self->get_widget('table')->setImmediateMode(0); $self->get_widget('table')->deleteAllItems(); - my @UserReal; - LOOP: foreach my $l (@$users) { - next LOOP if $filterusers && $l->Uid($self->sh_users->USER_GetValue) <= 499 || $l->Uid($self->sh_users->USER_GetValue) == 65534; - next LOOP if $filterusers && $l->Uid($self->sh_users->USER_GetValue) > 499 && $l->Uid($self->sh_users->USER_GetValue) < $self->min_UID && - ($l->HomeDir($self->sh_users->USER_GetValue) =~ /^\/($|var\/|run\/)/ || $l->LoginShell($self->sh_users->USER_GetValue) =~ /(nologin|false)$/); - push @UserReal, $l if $l->UserName($self->sh_users->USER_GetValue) =~ /^\Q$strfilt/; - } - my $i; my $itemColl = new yui::YItemCollection; - foreach my $l (@UserReal) { - $i++; - my $uid = $l->Uid($self->sh_users->USER_GetValue); - if (!defined $uid) { - warn "bogus user at line $i\n"; - next; - } - my $a = $l->Gid($self->sh_users->USER_GetValue); - $group = $self->sh_users->ctx->LookupGroupById($a); - $groupnm = ''; - $expr = $self->sh_users->computeLockExpire($l); - $group and $groupnm = $group->GroupName($self->sh_users->USER_GetValue); - my $fulln = $l->Gecos($self->sh_users->USER_GetValue); - utf8::decode($fulln); - my $username = $l->UserName($self->sh_users->USER_GetValue); - my $Uid = $l->Uid($self->sh_users->USER_GetValue); - my $shell = $l->LoginShell($self->sh_users->USER_GetValue); - my $homedir = $l->HomeDir($self->sh_users->USER_GetValue); - my $item = new yui::YTableItem ("$username", - "$Uid", - "$groupnm", - "$fulln", - "$shell", - "$homedir", - "$expr"); + foreach my $username (keys %{$usersInfo}) { + my $info = $usersInfo->{$username}; + my $item = new yui::YTableItem ( + "$username", + "$info->{uid}", + "$info->{group}", + "$info->{fullname}", + "$info->{shell}", + "$info->{home}", + "$info->{status}" + ); + # TODO workaround to get first cell at least until we don't # a cast from YItem $item->setLabel( $username ); $itemColl->push($item); $item->DISOWN(); } + $self->get_widget('table')->addItems($itemColl); my $item = $self->get_widget('table')->selectedItem(); $self->get_widget('table')->selectItem($item, 0) if $item; |