Skip to content

Commit

Permalink
Remove groups and skel from the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Oct 4, 2021
1 parent 35af043 commit 7b2f2b7
Showing 1 changed file with 2 additions and 123 deletions.
125 changes: 2 additions & 123 deletions src/include/users/widgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def initialize_users_widgets(include_target)
"samba" => _("Samba")
}

# auth methods and respective module calls
# auth methods and respective module calls
@auth_methods = {
"nis" => {
# menubutton label
Expand Down Expand Up @@ -195,10 +195,8 @@ def initialize_users_widgets(include_target)
VSpacing(0.2),
"defaults_global",
"defaultgroup",
"groups",
"shell",
HBox("home", VBox(Label(""), "browse_home")),
HBox("skel", VBox(Label(""), "browse_skel")),
"umask",
"expire",
"inactive",
Expand All @@ -210,12 +208,9 @@ def initialize_users_widgets(include_target)
"widget_names" => [
"defaults_global",
"defaultgroup",
"groups",
"shell",
"home",
"browse_home",
"skel",
"browse_skel",
"umask",
"expire",
"inactive"
Expand Down Expand Up @@ -340,17 +335,6 @@ def initialize_users_widgets(include_target)
"boolean (string, map)"
)
},
"groups" => {
"widget" => :textentry,
# text entry
"label" => _("Se&condary Groups"),
"no_help" => true,
"validate_type" => :function,
"validate_function" => fun_ref(
method(:ValidateGroupList),
"boolean (string, map)"
)
},
"home" => {
"widget" => :textentry,
# text entry
Expand All @@ -375,28 +359,6 @@ def initialize_users_widgets(include_target)
),
"no_help" => true
},
"skel" => {
"widget" => :textentry,
# text entry
"label" => _("&Skeleton for Home Directory"),
"no_help" => true,
"validate_type" => :function,
"validate_function" => fun_ref(
method(:ValidateSkeleton),
"boolean (string, map)"
)
},
"browse_skel" => {
"widget" => :push_button,
# push button label
"label" => _("Bro&wse..."),
"opt" => [:key_F7],
"handle" => fun_ref(
method(:HandleBrowseDirectory),
"symbol (string, map)"
),
"no_help" => true
},
"expire" => {
"widget" => :textentry,
# text entry
Expand Down Expand Up @@ -1667,23 +1629,6 @@ def ValidateExpire(key, event)
true
end

# Validation function for home directory skeleton directory
def ValidateSkeleton(key, event)
event = deep_copy(event)
new_skel = Convert.to_string(UI.QueryWidget(Id(key), :Value))
if SCR.Read(path(".target.dir"), new_skel) == nil
# popup error label
Report.Error(
_(
"The entered home directory skeleton is not a directory.\nTry again.\n"
)
)
UI.SetFocus(Id(key))
return false
end
true
end

# Validation function for the default home prefix
def ValidateHomePrefix(key, event)
event = deep_copy(event)
Expand Down Expand Up @@ -1717,57 +1662,6 @@ def ValidateHomePrefix(key, event)
true
end

# Validation function for the value of the default list of groups
def ValidateGroupList(key, event)
event = deep_copy(event)
groups = Users.GetDefaultGrouplist("local")
grouplist = Builtins.mergestring(Builtins.maplist(groups) { |g, i| g }, ",")
new_grouplist = Convert.to_string(UI.QueryWidget(Id(key), :Value))

if new_grouplist != grouplist
l_grouplist = []
dont_exist = []
Builtins.foreach(Builtins.splitstring(new_grouplist, ",")) do |g|
# check for group existence
if Ops.get(@all_groupnames, ["local", g], 0) == 0 &&
Ops.get(@all_groupnames, ["system", g], 0) == 0
dont_exist = Convert.convert(
Builtins.union(dont_exist, [g]),
:from => "list",
:to => "list <string>"
)
else
# filter out the duplicates
l_grouplist = Convert.convert(
Builtins.union(l_grouplist, [g]),
:from => "list",
:to => "list <string>"
)
end
end
if dont_exist != []
# error message
Report.Error(
Builtins.sformat(
_(
"These groups do not exist in your system:\n" +
"%1\n" +
"Try again.\n"
),
Builtins.mergestring(dont_exist, ",")
)
)

UI.SetFocus(Id("groups"))
return false
end
new_grouplist = Builtins.mergestring(l_grouplist, ",")
UI.ChangeWidget(Id("groups"), :Value, new_grouplist)
end
true
end

# Validation function for the default login shell
def ValidateShell(key, event)
event = deep_copy(event)
new_shell = Convert.to_string(UI.QueryWidget(Id(key), :Value))
Expand Down Expand Up @@ -1804,19 +1698,11 @@ def InitDefaults(key)
UI.ChangeWidget(Id("shell"), :Items, Users.AllShells)
UI.ChangeWidget(Id("shell"), :Value, Users.GetDefaultShell("local"))

groups = Users.GetDefaultGrouplist("local")
grouplist = Builtins.mergestring(Builtins.maplist(groups) { |g, i| g }, ",")
UI.ChangeWidget(Id("groups"), :Value, grouplist)
UI.ChangeWidget(
Id("home"),
:Value,
Ops.get_string(defaults, "home", "/home")
)
UI.ChangeWidget(
Id("skel"),
:Value,
Ops.get_string(defaults, "skel", "/etc/skel")
)

UI.ChangeWidget(
Id("inactive"),
Expand Down Expand Up @@ -1851,20 +1737,13 @@ def StoreDefaults(key, event)
event = deep_copy(event)
defaults = Users.GetLoginDefaults
new_defaults = {}
Builtins.foreach(["home", "shell", "skel", "inactive", "umask"]) do |key2|
Builtins.foreach(["home", "shell", "inactive", "umask"]) do |key2|
val = UI.QueryWidget(Id(key2), :Value)
val = Builtins.sformat("%1", val) if Ops.is_integer?(val)
if Ops.get(defaults, key2) != val
Ops.set(new_defaults, key2, Convert.to_string(val))
end
end
new_grouplist = Convert.to_string(UI.QueryWidget(Id("groups"), :Value))
if Builtins.sort(
Builtins.splitstring(Ops.get_string(defaults, "groups", ""), ",")
) !=
Builtins.sort(Builtins.splitstring(new_grouplist, ","))
Ops.set(new_defaults, "groups", new_grouplist)
end

new_exp_date = Convert.to_string(UI.QueryWidget(Id("expire"), :Value))
new_expire = Ops.get_string(defaults, "expire", "")
Expand Down

0 comments on commit 7b2f2b7

Please sign in to comment.