Author: jsuchome
Date: Fri Jul 13 13:37:33 2007
New Revision: 39396
URL: http://svn.opensuse.org/viewcvs/yast?rev=39396&view=rev
Log:
correct behaviour of tab dialog for groups
Modified:
trunk/users/src/Users.pm
trunk/users/src/UsersPluginQuota.pm
trunk/users/src/dialogs.ycp
trunk/users/src/users_plugin_quota.ycp
Modified: trunk/users/src/Users.pm
URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/Users.pm?rev=39396&r1=39395&r2=39396&view=diff
==============================================================================
--- trunk/users/src/Users.pm (original)
+++ trunk/users/src/Users.pm Fri Jul 13 13:37:33 2007
@@ -3300,48 +3300,20 @@
if (defined $user{"org_user"}) {
%org_user = %{$user{"org_user"}};
}
- if ($user{"type"} ne "ldap") {
- # grouplist can be ignored, it is a modification of groups
- while ( my ($key, $value) = each %org_user) {
-
- if ($key eq "grouplist") {
- next;
- }
- if (defined $user{$key} &&
- (ref ($value) eq "YaST::YCP::Boolean" &&
- ref ($user{$key}) eq "YaST::YCP::Boolean") ||
- (ref ($value) eq "YaST::YCP::Integer" &&
- ref ($user{$key}) eq "YaST::YCP::Integer"))
- {
- if ($user{$key}->value() != $value->value())
- {
- $ret = 1;
- y2milestone ("old value: ", $value->value());
- y2milestone ("changed to: ", $user{$key}->value());
- }
- next;
- }
- if (!defined $user{$key} || $user{$key} ne $value)
- {
- $ret = 1;
- y2debug ("old value: ", $value || "(not defined)");
- y2debug ("... changed to: ", $user{$key} || "(not defined)" );
- }
- }
-#FIXME quota edit not detected!!!!!!
- return $ret;
-#FIXME what if there is a new key? it's not in org_user map...
- }
- # search result, because some attributes were not filled yet
my @internal_keys = @{UsersLDAP->GetUserInternal ()};
foreach my $key (keys %user) {
-
+ last if $ret;
my $value = $user{$key};
if (!defined $user{$key} || contains (\@internal_keys, $key) ||
ref ($value) eq "HASH" ) {
next;
}
- if (!defined ($org_user{$key})) {
+ if ($key eq "quota" && ref ($value) eq "ARRAY") {
+ foreach my $qmap (@$value) {
+ $ret = 1 if exists $qmap->{"quota_modified"};
+ }
+ }
+ elsif (!defined ($org_user{$key})) {
if ($value ne "") {
$ret = 1;
}
@@ -3359,11 +3331,16 @@
ref ($org_user{$key}) eq "YaST::YCP::Integer")) {
if ($user{$key}->value() == $value->value()) { next;}
}
+ y2debug (sformat ("$key modified: old %1 new %2", $org_user{$key}, $value));
$ret = 1;
}
}
- if (!$ret && defined $org_user{"crypted_home_size"} && defined $user{"crypted_home_size"}) {
- $ret = ($org_user{"crypted_home_size"} ne $user{"crypted_home_size"});
+ # TODO should be caught in the previous tests?
+ if (!$ret &&
+ defined $org_user{"crypted_home_size"} &&
+ defined $user{"crypted_home_size"})
+ {
+ $ret = ($org_user{"crypted_home_size"} ne $user{"crypted_home_size"});
}
return $ret;
}
@@ -4259,7 +4236,7 @@
if ($groups_modified) {
if ($group_not_read) {
# error popup (%s is a file name)
- $ret = sprintf (__("File %s was not read correctly, so it will not be written."), "$base_directory/group");
+ $ret = sprintf (__("File %s was not read correctly, so it will not be written."), $base_directory."/group");
Report->Error ($ret);
return $ret;
}
@@ -4284,40 +4261,6 @@
Report->Error ($ret);
return $ret;
}
- # -------------------------------------- call Write on plugins
- foreach my $type (keys %modified_groups) {
- if ($type eq "ldap") { next; }
- foreach my $groupname (keys %{$modified_groups{$type}}) {
- if ($plugin_error) { last;}
- my $args = {
- "what" => "group",
- "type" => $type,
- "modified" => $modified_groups{$type}{$groupname}{"modified"}
- };
- my $result = UsersPlugins->Apply ("Write", $args,
- $modified_groups{$type}{$groupname});
- $plugin_error = GetPluginError ($args, $result);
-
- # store commands for calling groupadd_cmd script
- if ($groupadd_cmd ne "" && FileUtils->Exists ($groupadd_cmd)) {
- my $group = $modified_groups{$type}{$groupname};
- my $mod = $group->{"modified"} || "no";
- if ($mod eq "imported" || $mod eq "added") {
- my $cmd = sprintf ("%s %s", $groupadd_cmd, $groupname);
- push @groupadd_postcommands, $cmd;
- }
- }
- }
- # unset the 'modified' flags after write
- $self->UpdateGroupsAfterWrite ("local");
- $self->UpdateGroupsAfterWrite ("system");
- delete $modified_groups{"local"};
- delete $modified_groups{"system"};
- }
- if ($plugin_error) {
- Report->Error ($plugin_error);
- return $plugin_error;
- }
if (!$write_only) {
$nscd_group = 1;
}
@@ -4341,7 +4284,7 @@
if ($users_modified) {
if ($passwd_not_read) {
# error popup (%s is a file name)
- $ret = sprintf (__("File %s was not correctly read, so it will not be written."), "$base_directory/passwd");
+ $ret = sprintf (__("File %s was not correctly read, so it will not be written."), $base_directory."/passwd");
Report->Error ($ret);
return $ret;
}
@@ -4366,25 +4309,6 @@
Report->Error ($ret);
return $ret;
}
- # -------------------------------------- call Write on plugins
- foreach my $type (keys %modified_users) {
- if ($type eq "ldap") { next; }
- foreach my $username (keys %{$modified_users{$type}}) {
- if ($plugin_error) { last;}
- my $args = {
- "what" => "user",
- "type" => $type,
- "modified" => $modified_users{$type}{$username}{"modified"}
- };
- my $result = UsersPlugins->Apply ("Write", $args,
- $modified_users{$type}{$username});
- $plugin_error = GetPluginError ($args, $result);
- }
- }
- if ($plugin_error) {
- Report->Error ($plugin_error);
- return $plugin_error;
- }
if (!$write_only) {
$nscd_passwd = 1;
}
@@ -4457,12 +4381,6 @@
}
}
}
- # unset the 'modified' flags after write
- $self->UpdateUsersAfterWrite ("local");
- $self->UpdateUsersAfterWrite ("system");
- # not modified after successful write
- delete $modified_users{"local"};
- delete $modified_users{"system"};
}
if (%users_with_crypted_dir) {
Package->Install ("cryptconfig");
@@ -4484,7 +4402,7 @@
if ($users_modified) {
if ($shadow_not_read) {
# error popup (%s is a file name)
- $ret = sprintf (__("File %s was not correctly read, so it will not be written."), "$base_directory/shadow");
+ $ret = sprintf (__("File %s was not correctly read, so it will not be written."), $base_directory."/shadow");
Report->Error ($ret);
return $ret;
}
@@ -4505,6 +4423,72 @@
}
}
+ # last operation on plugins must be done after nscd restart
+ # (at least quota seems to need it)
+ if ($users_modified) {
+ # -------------------------------------- call Write on plugins
+ foreach my $type (keys %modified_users) {
+ if ($type eq "ldap") { next; }
+ foreach my $username (keys %{$modified_users{$type}}) {
+ if ($plugin_error) { last;}
+ my $args = {
+ "what" => "user",
+ "type" => $type,
+ "modified" => $modified_users{$type}{$username}{"modified"}
+ };
+ my $result = UsersPlugins->Apply ("Write", $args,
+ $modified_users{$type}{$username});
+ $plugin_error = GetPluginError ($args, $result);
+ }
+ }
+ if ($plugin_error) {
+ Report->Error ($plugin_error);
+ return $plugin_error;
+ }
+ # unset the 'modified' flags after write
+ $self->UpdateUsersAfterWrite ("local");
+ $self->UpdateUsersAfterWrite ("system");
+ # not modified after successful write
+ delete $modified_users{"local"};
+ delete $modified_users{"system"};
+ }
+ if ($groups_modified) {
+ # -------------------------------------- call Write on plugins
+ foreach my $type (keys %modified_groups) {
+ if ($type eq "ldap") { next; }
+ foreach my $groupname (keys %{$modified_groups{$type}}) {
+ if ($plugin_error) { last;}
+ my $args = {
+ "what" => "group",
+ "type" => $type,
+ "modified" => $modified_groups{$type}{$groupname}{"modified"}
+ };
+ my $result = UsersPlugins->Apply ("Write", $args,
+ $modified_groups{$type}{$groupname});
+ $plugin_error = GetPluginError ($args, $result);
+
+ # store commands for calling groupadd_cmd script
+ if ($groupadd_cmd ne "" && FileUtils->Exists ($groupadd_cmd)) {
+ my $group = $modified_groups{$type}{$groupname};
+ my $mod = $group->{"modified"} || "no";
+ if ($mod eq "imported" || $mod eq "added") {
+ my $cmd = sprintf ("%s %s", $groupadd_cmd, $groupname);
+ push @groupadd_postcommands, $cmd;
+ }
+ }
+ }
+ # unset the 'modified' flags after write
+ $self->UpdateGroupsAfterWrite ("local");
+ $self->UpdateGroupsAfterWrite ("system");
+ delete $modified_groups{"local"};
+ delete $modified_groups{"system"};
+ }
+ if ($plugin_error) {
+ Report->Error ($plugin_error);
+ return $plugin_error;
+ }
+ }
+
# call make on NIS server
if (($users_modified || $groups_modified) && $nis_master) {
my %out = %{SCR->Execute (".target.bash_output",
Modified: trunk/users/src/UsersPluginQuota.pm
URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/UsersPluginQuota.pm?rev=39396&r1=39395&r2=39396&view=diff
==============================================================================
--- trunk/users/src/UsersPluginQuota.pm (original)
+++ trunk/users/src/UsersPluginQuota.pm Fri Jul 13 13:37:33 2007
@@ -1,8 +1,7 @@
#! /usr/bin/perl -w
#
-# Example of plugin module
-# This is the API part of UsersPluginQuota plugin
-# - configuration of user quota (feature 120106)
+# This is the API part of UsersPluginQuota plugin:
+# configuration of user and group quota (feature 120106)
#
# For documentation and examples of function arguments and return values, see
# UsersPluginLDAPAll.pm
@@ -11,7 +10,7 @@
use strict;
-use YaST::YCP qw(:LOGGING);
+use YaST::YCP qw(:LOGGING sformat);
use YaPI;
use Data::Dumper;
@@ -36,9 +35,13 @@
# is quota available and set up
my $quota_available = undef;
-# list of keys use in user/group map
+# list of keys uses in quota map
my @quota_keys = ("quota_blocks_soft", "quota_blocks_hard",
- "quota_inodes_soft", "quota_inodes_hard", "quota_grace");
+ "quota_inodes_soft", "quota_inodes_hard",
+ "quota_blocks_grace", "quota_inodes_grace");
+
+# list of filesystems with quota enabled
+my @quota_enabled_filesystems = ();
##----------------------------------------
##--------------------- internal functions
@@ -71,59 +74,82 @@
my $i = 0;
foreach my $qmap (@{$data->{"quota"}}) {
$data->{"quota"}[$i]{$key} = 0 if defined $data->{"quota"}[$i]{$key};
+ $data->{"quota"}[$i]{"quota_modified"} = 1;
$i = $i + 1;
}
}
return $data;
}
-# read the quota information for given object
+# check which filesystems have quota support enabled
+sub get_quota_enabled_filesystems {
+
+ if (! @quota_enabled_filesystems) {
+ my $cmd = "LANG=C grep quota /etc/mtab | cut -f 1 -d ' '";
+ my $out = SCR->Execute (".target.bash_output", $cmd);
+ if ($out->{"stdout"}) {
+ # each line in stdout reports quota for one filesystem
+ foreach my $line (split (/\n/, $out->{"stdout"})) {
+ chomp $line;
+ push @quota_enabled_filesystems, $line if $line;
+ }
+ }
+ }
+ return @quota_enabled_filesystems;
+}
+
+# Read the quota information for given user/group and return the object
+# map updated with the quota data.
sub read_quota_info {
my ($config, $data) = @_;
- # check for any entry (all must be filled during read)
+
if (!defined $data->{"quota"}) {
- my $username = $data->{"uid"};
- my $cmd = "LANG=C quota -u $username -p 2>/dev/null | tail +3";
-y2internal ("cmd is '$cmd'");
+
+ my $opt = "-u ".$data->{"uid"} if defined $data->{"uid"};
+ if ($config->{"what"} eq "group") {
+ $opt = "-g ".$data->{"cn"} if defined $data->{"cn"};
+ }
+ return $data if not defined $opt;
+
+ my %fsystems = ();
+ my @quotalist = ();
+
+ my $cmd = "LANG=C quota $opt -pv 2>/dev/null | tail +3";
my $out = SCR->Execute (".target.bash_output", $cmd);
-# FIXME check retval of quota, not tail, see PIPESTATUS (echo ${PIPESTATUS[0]})
if ($out->{"stdout"}) {
# each line in stdout reports quota for one filesystem
- my @quotalist = ();
foreach my $line (split (/\n/, $out->{"stdout"})) {
chomp $line;
$line =~ s/^\s+//; # remove the leading space
my @l = split (/\s+/, $line);
if (@l == 9) {
my %item = ();
+ $fsystems{$l[0]} = 1;
$item{"quota_fs"} = $l[0];
$item{"quota_blocks_soft"} = $l[2];
$item{"quota_blocks_hard"} = $l[3];
$item{"quota_inodes_soft"} = $l[6];
$item{"quota_inodes_hard"} = $l[7];
- $item{"quota_grace"} = $l[4];
+ $item{"quota_blocks_grace_exceeded"} = 1 if $l[4] > 0;
+ $item{"quota_inodes_grace_exceeded"} = 1 if $l[8] > 0;
push @quotalist, \%item if %item;
}
}
-
- # fake, to simulate in the UI
- my %item = ();
- $item{"quota_fs"} = "/dev/hahahaha";
- $item{"quota_blocks_soft"} = 100;
- $item{"quota_blocks_hard"} = 200;
- $item{"quota_inodes_soft"} = 300;
- $item{"quota_inodes_hard"} = 400;
- $item{"quota_grace"} = 3601;
- push @quotalist, \%item if %item;
-
- $data->{"quota"} = \@quotalist if @quotalist;
}
+ # Add empty maps for the filesystems with quota support enabled but
+ # without quota set for this user/group
+ foreach my $fs (get_quota_enabled_filesystems ()) {
+ if (!defined $fsystems{$fs}) {
+ push @quotalist, { "quota_fs" => $fs };
+ }
+ }
+ $data->{"quota"} = \@quotalist if @quotalist;
}
return $data;
}
-# check if quota is available and configured
+# check if quota is available and configured (globally)
sub is_quota_available {
return $quota_available if defined $quota_available;
@@ -133,35 +159,40 @@
else {
$quota_available = (Service->Status ("boot.quota") == 0);
}
-
return $quota_available;
}
-# check if user has quota enabled
-sub user_has_quota {
+# check if user/group has quota enabled
+sub has_quota {
- my $u = shift;
- # quota returns 1 for success
- return SCR->Execute (".target.bash", "LANG=C quota -u $u 2>/dev/null");
+ my $opt = shift;
+ my $out = SCR->Execute (".target.bash_output", "LANG=C quota $opt -v 2>/dev/null | tail +3");
+ return ($out->{"stdout"});
}
##------------------------------------------
##--------------------- global API functions
-# return names of provided functions
+# All functions have 2 "any" parameters: these mean:
+# 1st: configuration map (hash) - e.g. saying if we work with user or group
+# 2nd: data map (hash) of user/group to work with
+# for details, see UsersPluginLDAPAll.pm
+
+# Return the names of provided functions
BEGIN { $TYPEINFO{Interface} = ["function", ["list", "string"], "any", "any"];}
sub Interface {
my $self = shift;
my @interface = (
"GUIClient",
- "Check",
"Name",
"Summary",
"Restriction",
"Write",
"Add",
+ "AddBefore",
"Edit",
+ "EditBefore",
"Interface",
"PluginPresent",
"PluginRemovable",
@@ -187,27 +218,34 @@
}
##------------------------------------
-# return plugin summary (to be shown in table with all plugins)
+# Return plugin summary (to be shown in table with all plugins)
BEGIN { $TYPEINFO{Summary} = ["function", "string", "any", "any"];}
sub Summary {
+ my ($self, $config, $data) = @_;
+
+ # user plugin summary (table item)
+ return __("Manage Group Quota") if ($config->{"what"} eq "group");
+
# user plugin summary (table item)
return __("Manage User Quota");
}
##------------------------------------
-# checks the current data map of user (2nd parameter) and returns
-# true if given user has this plugin
+# Checks the current data map of user/group (2nd parameter) and returns
+# true if given user/group has this plugin enabled
BEGIN { $TYPEINFO{PluginPresent} = ["function", "boolean", "any", "any"];}
sub PluginPresent {
- my ($self, $config, $data) = @_;
+ return 0 if not is_quota_available ();
- if (not is_quota_available ()) {
- return 0;
+ my ($self, $config, $data) = @_;
+ my $opt = "-u ".$data->{"uid"} if defined $data->{"uid"};
+ if ($config->{"what"} eq "group") {
+ $opt = "-g ".$data->{"cn"};
}
- my $username = $data->{"uid"} || "";
- if (contains ($data->{'plugins'}, $name, 1) || user_has_quota ($username)) {
+ return 0 if not $opt;
+ if (contains ($data->{'plugins'}, $name, 1) || has_quota ($opt)) {
y2milestone ("Quota plugin present");
return 1;
} else {
@@ -217,17 +255,17 @@
}
##------------------------------------
-# Is it possible to remove this plugin from user?
+# Is it possible to remove this plugin from user/group: setting all quota
+# values to 0.
BEGIN { $TYPEINFO{PluginRemovable} = ["function", "boolean", "any", "any"];}
sub PluginRemovable {
-# does it make sense? how to disable quota check for certain user?
return YaST::YCP::Boolean (1);
}
##------------------------------------
-# return name of YCP client defining YCP GUI
+# Return name of YCP client defining YCP GUI
BEGIN { $TYPEINFO{GUIClient} = ["function", "string", "any", "any"];}
sub GUIClient {
@@ -243,35 +281,41 @@
return {
"local" => 1,
-# "group" => 1,
+ "group" => 1,
"user" => 1
};
}
-##------------------------------------
-# check if required atributes of are present and have correct form
-# parameter is (whole) map of entry (user)
-# return error message
-BEGIN { $TYPEINFO{Check} = ["function",
- "string",
- "any",
- "any"];
+# this will be called at the beggining of Users::AddUser/AddGroup
+# Check if it is possible to add this plugin here.
+# (Could be called multiple times for one user/group)
+BEGIN { $TYPEINFO{AddBefore} = ["function",
+ ["map", "string", "any"],
+ "any", "any"];
}
-sub Check {
+sub AddBefore {
my ($self, $config, $data) = @_;
- return "";
+
+ if (!contains ($data->{'plugins_to_remove'}, $name, 1) &&
+ !is_quota_available ())
+ {
+ # error popup
+ $error = __("Quota is not enabled on your system.");
+ return undef;
+ }
+ return $data;
}
-# This will be called just after Users::Add - the data map probably contains
-# the values which we could use to create new ones
-# Could be called multiple times for one user!
+# This will be called at the end of Users::Add* : modify the object map
+# with quota data
BEGIN { $TYPEINFO{Add} = ["function", ["map", "string", "any"], "any", "any"];}
sub Add {
my ($self, $config, $data) = @_;
y2debug ("Add Quota called");
+ # "plugins_to_remove" is list of plugins which are set for removal
if (contains ($data->{'plugins_to_remove'}, $name, 1)) {
y2milestone ("removing plugin $name...");
$data = remove_plugin_data ($config, $data);
@@ -282,7 +326,29 @@
return $data;
}
-# this will be called just after Users::Edit
+# This will be called at the beggining of Users::EditUser/EditGroup
+# Check if it is possible to add this plugin here.
+# (Could be called multiple times for one user/group)
+BEGIN { $TYPEINFO{EditBefore} = ["function",
+ ["map", "string", "any"],
+ "any", "any"];
+}
+sub EditBefore {
+
+ my ($self, $config, $data) = @_;
+
+ if (!contains ($data->{'plugins_to_remove'}, $name, 1) &&
+ !is_quota_available ())
+ {
+ # error popup
+ $error = __("Quota is not enabled on your system.");
+ return undef;
+ }
+ return $data;
+}
+
+# This will be called at the end of Users::Edit* : modify the object map
+# with quota data
BEGIN { $TYPEINFO{Edit} = ["function",
["map", "string", "any"],
"any", "any"];
@@ -291,10 +357,9 @@
y2debug ("Edit Quota called");
my ($self, $config, $data) = @_;
- # in $data hash, there could be "plugins_to_remove": list of plugins which
- # has to be removed from the user
+ # "plugins_to_remove" is list of plugins which are set for removal
if (contains ($data->{'plugins_to_remove'}, $name, 1)) {
- y2internal ("removing plugin $name...");
+ y2milestone ("removing plugin $name...");
$data = remove_plugin_data ($config, $data);
}
else {
@@ -303,30 +368,53 @@
return $data;
}
-# what should be done after user is finally written
+# What should be done after user is finally written (this is called only once)
BEGIN { $TYPEINFO{Write} = ["function", "boolean", "any", "any"];}
sub Write {
-y2internal ("Write Quota called");
my ($self, $config, $data) = @_;
return YaST::YCP::Boolean (1) if not defined $data->{"quota"};
- my $username = $data->{"uid"};
- return YaST::YCP::Boolean (1) if not $username;
+ my $opt = "-u ".$data->{"uid"} if defined $data->{"uid"};
+ if ($config->{"what"} eq "group") {
+ $opt = "-g ".$data->{"cn"};
+ }
+ return YaST::YCP::Boolean (1) if not $opt;
foreach my $qmap (@{$data->{"quota"}}) {
my $quota_blocks_soft = $qmap->{"quota_blocks_soft"} || 0;
my $quota_blocks_hard = $qmap->{"quota_blocks_hard"} || 0;
my $quota_inodes_soft = $qmap->{"quota_inodes_soft"} || 0;
my $quota_inodes_hard = $qmap->{"quota_inodes_hard"} || 0;
- my $quota_grace = $qmap->{"quota_grace"} || 0;
+ my $quota_blocks_grace = $qmap->{"quota_blocks_grace"} || 0;
+ my $quota_inodes_grace = $qmap->{"quota_inodes_grace"} || 0;
my $quota_fs = $qmap->{"quota_fs"};
next if not $quota_fs;
- my $cmd = "setquota -u $username $quota_blocks_soft $quota_blocks_hard $quota_inodes_soft $quota_inodes_hard $quota_fs";
-y2warning ("cmd to call is '$cmd'");
+ my $cmd = "setquota $opt $quota_blocks_soft $quota_blocks_hard $quota_inodes_soft $quota_inodes_hard $quota_fs";
+ my $out = SCR->Execute (".target.bash_output", $cmd);
+ if ($out->{"exit"} && $out->{"stderr"}) {
+ y2error ("error calling $cmd: ", $out->{"stderr"});
+ # error popup, %1 is command, %2 command error output
+ $error = sformat (__("Error while calling
+\"%1\":
+%2"), $cmd, $out->{"stderr"});
+ return YaST::YCP::Boolean (0);
+ }
+ if ($quota_blocks_grace > 0 || $quota_inodes_grace > 0) {
+ $cmd = "setquota -T $opt $quota_blocks_grace $quota_inodes_grace $quota_fs";
+ $out = SCR->Execute (".target.bash_output", $cmd);
+ if ($out->{"exit"} && $out->{"stderr"}) {
+ y2error ("error calling $cmd: ", $out->{"stderr"});
+ # error popup, %1 is command, %2 command error output
+ $error = sformat (__("Error while calling
+\"%1\":
+%2"), $cmd, $out->{"stderr"});
+ return YaST::YCP::Boolean (0);
+ }
+ }
}
return YaST::YCP::Boolean (1);
}
-1
+42
# EOF
Modified: trunk/users/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/dialogs.ycp?rev=39396&r1=39395&r2=39396&view=diff
==============================================================================
--- trunk/users/src/dialogs.ycp (original)
+++ trunk/users/src/dialogs.ycp Fri Jul 13 13:37:33 2007
@@ -1834,7 +1834,8 @@
client2plugin [client] = plugin;
return client;
});
- boolean use_tabs = (size (clients) > 0);
+ boolean use_tabs = (size (clients) > 0);
+ boolean has_tabs = true;
if (use_tabs)
{
@@ -1851,6 +1852,7 @@
);
if (!UI::HasSpecialWidget (`DumbTab))
{
+ has_tabs = false;
term tabbar = `HBox ();
foreach (term it, tabs, {
string label = it[1]:"";
@@ -1877,6 +1879,14 @@
symbol current = nil;
list tabids = [`edit, `plugins ];
+ // switch focus to specified tab (after error message) and widget inside
+ define void focus_tab (symbol tab, any widget) {
+ if (use_tabs && has_tabs)
+ UI::ChangeWidget (`id (`tabs), `CurrentItem, tab);
+ UI::SetFocus (`id (widget));
+ ret = `notnext;
+ }
+
repeat
{
// map returned from Check*UI functions
@@ -1920,8 +1930,7 @@
if (error != "")
{
Report::Error (error);
- UI::SetFocus (`id(`groupname));
- ret = `notnext;
+ focus_tab (current, `groupname);
continue;
}
// --------------------------------- password checks
@@ -1932,8 +1941,7 @@
Report::Error(_("The passwords do not match.
Try again.")) ;
- ret = `notnext;
- UI::SetFocus(`id(`pw1));
+ focus_tab (current, `pw1);
continue;
}
if ( pw1 != "" && pw1 != default_pw )
@@ -1942,8 +1950,7 @@
if (error != "")
{
Report::Error (error);
- ret = `notnext;
- UI::SetFocus(`id(`pw1));
+ focus_tab (current, `pw1);
continue;
}
boolean failed = false;
@@ -1962,8 +1969,7 @@
} while (error_map != $[] && !failed);
if (failed)
{
- ret = `notnext;
- UI::SetFocus(`id(`pw1));
+ focus_tab (current, `pw1);
continue;
}
password = pw1;
@@ -1978,8 +1984,7 @@
if (error != "")
{
Report::Error (error);
- UI::SetFocus (`id(`gid));
- ret = `notnext;
+ focus_tab (current, `gid);
continue;
}
error_map = Users::CheckGIDUI (new_i_gid, ui_map);
@@ -1987,8 +1992,7 @@
{
if (!Popup::YesNo (error_map ["question"]:""))
{
- ret = `notnext;
- UI::SetFocus(`id(`gid));
+ focus_tab (current, `gid);
continue;
}
if(contains(["local","system"],error_map["question_id"]:""))
Modified: trunk/users/src/users_plugin_quota.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/users_plugin_quota.ycp?rev=39396&r1=39395&r2=39396&view=diff
==============================================================================
--- trunk/users/src/users_plugin_quota.ycp (original)
+++ trunk/users/src/users_plugin_quota.ycp Fri Jul 13 13:37:33 2007
@@ -6,8 +6,8 @@
* Configuration of Users
*
* Summary:
- * This is GUI part of UsersPluginQuota
- * - plugin for configuration of user quota
+ * This is GUI part of UsersPluginQuota,
+ * plugin for configuration of user and group quotas
*
* Authors:
* Jiri Suchomel