Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce perl #137

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Makefile.am
Expand Up @@ -11,6 +11,7 @@ module_DATA = \
modules/UsersLDAP.pm \
modules/UsersSimple.pm \
modules/UsersCache.pm \
modules/UsersDialogsFlags.rb \
modules/UsersPluginLDAPAll.pm \
modules/UsersPluginLDAPPasswordPolicy.pm \
modules/UsersPluginKerberos.pm \
Expand Down
4 changes: 3 additions & 1 deletion src/clients/groups.rb
Expand Up @@ -33,6 +33,7 @@
# $Id$
#
# Just a shortcut to invoke groups management

module Yast
class GroupsClient < Client
def main
Expand All @@ -48,6 +49,7 @@ def main
Yast.import "Mode"
Yast.import "Users"
Yast.import "UsersCache"
Yast.import "UsersDialogsFlags"

Yast.include self, "users/wizards.rb"
Yast.include self, "users/cmdline.rb"
Expand Down Expand Up @@ -82,7 +84,7 @@ def main
@start_dialog,
Mode.test
)
Users.SetStartDialog(@start_dialog)
UsersDialogsFlags.assign_start_dialog(@start_dialog)
@ret = UsersSequence(@start_dialog)
Builtins.y2milestone("Users module finished with %1", @ret)
Builtins.y2milestone("----------------------------------------")
Expand Down
3 changes: 2 additions & 1 deletion src/clients/users.rb
Expand Up @@ -43,6 +43,7 @@ def main
Yast.import "Mode"
Yast.import "Users"
Yast.import "UsersCache"
Yast.import "UsersDialogsFlags"

Yast.include self, "users/wizards.rb"
Yast.include self, "users/cmdline.rb"
Expand Down Expand Up @@ -85,7 +86,7 @@ def main
@start_dialog,
Mode.test
)
Users.SetStartDialog(@start_dialog)
UsersDialogsFlags.assign_start_dialog(@start_dialog)
@ret = UsersSequence(@start_dialog)
Builtins.y2milestone("Users module finished with %1", @ret)
Builtins.y2milestone("----------------------------------------")
Expand Down
3 changes: 2 additions & 1 deletion src/include/users/cmdline.rb
Expand Up @@ -36,6 +36,7 @@ def initialize_users_cmdline(include_target)
Yast.import "Ldap"
Yast.import "Users"
Yast.import "UsersCache"
Yast.import "UsersDialogsFlags"
Yast.import "UsersLDAP"
Yast.import "UsersSimple"
Yast.import "Report"
Expand Down Expand Up @@ -750,7 +751,7 @@ def UsersWrite
end

def UsersGUI
UsersSequence(Users.GetStartDialog) == :next
UsersSequence(UsersDialogsFlags.start_dialog) == :next
end
end
end
3 changes: 2 additions & 1 deletion src/include/users/complex.rb
Expand Up @@ -42,6 +42,7 @@ def initialize_users_complex(include_target)
Yast.import "Stage"
Yast.import "Users"
Yast.import "UsersCache"
Yast.import "UsersDialogsFlags"
Yast.import "Wizard"

Yast.include include_target, "users/helps.rb"
Expand Down Expand Up @@ -101,7 +102,7 @@ def WriteDialog(useUI)
# first dialog for single user addition
# @return [Symbol] for wizard sequencer
def usersInstStart
Users.SetStartDialog("user_add")
UsersDialogsFlags.assign_start_dialog("user_add")
Users.AddUser({})
:next
end
Expand Down
19 changes: 12 additions & 7 deletions src/include/users/dialogs.rb
Expand Up @@ -46,6 +46,7 @@ def initialize_users_dialogs(include_target)
Yast.import "String"
Yast.import "Users"
Yast.import "UsersCache"
Yast.import "UsersDialogsFlags"
Yast.import "UsersLDAP"
Yast.import "UsersPlugins"
Yast.import "UsersRoutines"
Expand Down Expand Up @@ -160,9 +161,9 @@ def AskForOldPassword
# @return [Symbol] for wizard sequencer
def EditUserDialog(what)
# user has returned to the "add user dialog" during installation workflow:
if Users.StartDialog("user_add") && installation && Users.UseNextTime
if user_add_dialog? && installation && UsersDialogsFlags.use_next_time
Users.RestoreCurrentUser
Users.SetUseNextTime(false)
UsersDialogsFlags.assign_use_next_time(false)
end

display_info = UI.GetDisplayInfo
Expand Down Expand Up @@ -256,7 +257,7 @@ def EditUserDialog(what)
(user_type == "ldap" && Ldap.file_server ||
user_type == "local" || user_type == "system")

complex_layout = installation && Users.StartDialog("user_add")
complex_layout = installation && user_add_dialog?
groups = Ops.get_map(user, "grouplist", {})

available_shells = Users.AllShells
Expand Down Expand Up @@ -1104,7 +1105,7 @@ def EditUserDialog(what)
username = Convert.to_string(UI.QueryWidget(Id(:username), :Value))

# empty username during installation (-> go to next module)
if username == "" && ret == :next && Users.StartDialog("user_add")
if username == "" && ret == :next && user_add_dialog?
# The user login field is empty, this is allowed if the
# system is part of a network with (e.g.) NIS user management.
# yes-no popup headline
Expand Down Expand Up @@ -1363,7 +1364,7 @@ def EditUserDialog(what)
end
end
# --------------------------------- autologin (during installation)
if Users.StartDialog("user_add") && installation
if user_add_dialog? && installation
if Autologin.available
Autologin.user = Convert.to_boolean(
UI.QueryWidget(Id(:autologin), :Value)
Expand Down Expand Up @@ -2036,7 +2037,7 @@ def EditUserDialog(what)
# during installation, store the data of first user
# (to show it when clicking `back from Summary dialog)
Users.SaveCurrentUser
Users.SetStartDialog("users")
UsersDialogsFlags.assign_start_dialog("users")
end
ret
end
Expand Down Expand Up @@ -2633,7 +2634,7 @@ def EditGroupDialog(what)
def UserSave
Users.CommitUser
# adding only one user during install
if installation && Users.StartDialog("user_add")
if installation && user_add_dialog?
return :save
else
return :next
Expand All @@ -2655,5 +2656,9 @@ def GroupSave
Users.CommitGroup
:next
end

def user_add_dialog?
UsersDialogsFlags.start_dialog == "user_add"
end
end
end
7 changes: 4 additions & 3 deletions src/include/users/helps.rb
Expand Up @@ -40,6 +40,7 @@ def initialize_users_helps(include_target)
Yast.import "UsersCache"
Yast.import "UsersLDAP"
Yast.import "UsersRoutines"
Yast.import "UsersSimple"
end

# Password help text.
Expand Down Expand Up @@ -77,12 +78,12 @@ def help_password(type)
"</p>"
),
Ops.get_string(enc_to_string, method, method),
Users.GetMinPasswordLength(type),
Users.GetMaxPasswordLength(type)
UsersSimple.GetMinPasswordLength(type),
UsersSimple.GetMaxPasswordLength(type)
)
)

help_text = Ops.add(help_text, Users.ValidPasswordHelptext)
help_text = Ops.add(help_text, UsersSimple.ValidPasswordHelptext)

#help text 4/4
help_text = Ops.add(
Expand Down
5 changes: 3 additions & 2 deletions src/include/users/wizards.rb
Expand Up @@ -42,6 +42,7 @@ def initialize_users_wizards(include_target)
Yast.import "Sequencer"
Yast.import "Stage"
Yast.import "UsersCache"
Yast.import "UsersDialogsFlags"
Yast.import "Users"
Yast.import "Wizard"

Expand Down Expand Up @@ -125,8 +126,8 @@ def SummaryDialog
end

if Stage.cont && (ret == :back || ret == :abort)
Users.SetStartDialog("user_add")
Users.SetUseNextTime(true)
UsersDialogsFlags.assign_start_dialog("user_add")
UsersDialogsFlags.assign_use_next_time(true)
old_gui = Users.GetGUI
Users.SetGUI(false)
Users.Read
Expand Down