Module: Yast::NisServerMapsInclude

Defined in:
../../src/include/nis_server/maps.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) initialize_nis_server_maps(include_target)



42
43
44
45
46
47
48
49
50
51
52
# File '../../src/include/nis_server/maps.rb', line 42

def initialize_nis_server_maps(include_target)
  Yast.import "UI"

  textdomain "nis_server"

  Yast.import "Wizard"
  Yast.import "Popup"

  Yast.import "NisServer"
  Yast.include include_target, "nis_server/routines.rb"
end

- (Object) MapsDialog

Maps dialog

Returns:

  • back,abort or `next



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File '../../src/include/nis_server/maps.rb', line 56

def MapsDialog
  # help text 1/1
  # Translators: the text was truncated because now there's
  # a MultiSelectionBox instead of two SelectionBoxes that
  # were a pain to use.
  helptext = _(
    "<p>With this dialog, adjust which maps will be available.</p>"
  )

  # Let's call a yp map a table, not to get too confused.

  # All tables that ypserv Makefile knows about
  all = NisServer.GetAllMaps

  # Assign a source file to all tables.
  # Some tables are built of more files while we only check for one.
  # Still it's better than no checking at all.
  passwd_tables = ["passwd", "group", "passwd.adjunct", "shadow"]
  passwd_dir = NisServer.pwd_srcdir
  files = Builtins.listmap(all) do |table|
    { table => Builtins.sformat("/etc/%1", table) }
  end
  Builtins.foreach(passwd_tables) do |table|
    Ops.set(files, table, Builtins.sformat("%1/%2", passwd_dir, table))
  end
  # irregularly named tables
  Ops.set(files, "netgrp", "/etc/netgroup")
  Ops.set(files, "mail", "/etc/mail/aliases")

  # We want to construct a list of items:
  # `item (`id (table), table, true|false)
  enabled = Builtins.listmap(all) { |table| { table => false } }
  # filter out tables that are merged or their sources don't exist
  enabled = Builtins.remove(enabled, "shadow") if NisServer.merge_passwd
  enabled = Builtins.filter(enabled) do |table, dummy|
    Ops.greater_or_equal(
      SCR.Read(path(".target.size"), Ops.get_string(files, table, "/")),
      0
    )
  end
  current = deep_copy(NisServer.maps)
  Builtins.foreach(current) { |table| Ops.set(enabled, table, true) }
  items = Builtins.maplist(enabled) { |table, e| Item(Id(table), table, e) }

  contents = MultiSelectionBox(
    # multilesection box label
    Id(:current),
    _("&Maps"),
    items
  )

  # To translators: dialog label
  Wizard.SetContents(
    _("NIS Server Maps Setup"),
    contents,
    helptext,
    true,
    true
  )

  ui = nil
  begin
    ui = Convert.to_symbol(UI.UserInput)
    ui = :abort if ui == :cancel

    ui = :again if ui == :abort && !Popup.ReallyAbort(NisServer.modified)
  end until Builtins.contains([:back, :next, :abort], ui)

  current = Convert.convert(
    UI.QueryWidget(Id(:current), :SelectedItems),
    :from => "any",
    :to   => "list <string>"
  )
  if ui == :next && Builtins.sort(current) != Builtins.sort(NisServer.maps)
    NisServer.maps = deep_copy(current)
    NisServer.modified = true
  end
  ui
end