ACC SHELL
/**
* File: users_proposal.ycp
* Author: Jiri Suchomel <jsuchome@suse.cz>
* Purpose: Proposal for user and root setting
*
* $Id: users_proposal.ycp 59599 2009-11-19 07:32:43Z jsuchome $
*/
{
textdomain "users";
import "HTML";
import "UsersSimple";
import "Wizard";
string func = (string) WFM::Args(0);
map param = (map) WFM::Args(1);
map ret = $[];
map auth2label = $[
// authentication type
"ldap": _("LDAP"),
// authentication type
"nis": _("NIS"),
// authentication type
"samba": _("Samba (Windows Domain)"),
// authentication type
"edir_ldap": _("eDirectory LDAP"),
];
map<string,string> encoding2label = $[
// encryption type
"des" : _("DES"),
// encryption type
"md5" : _("MD5"),
// encryption type
"blowfish" : _("Blowfish"),
];
if ( func == "MakeProposal" )
{
boolean force_reset = param["force_reset" ]:false;
string root_proposal = UsersSimple::GetRootPassword () != "" ?
// summary label <%1>-<%2> are HTML tags, leave untouched
sformat (_("<%1>Root Password<%2> set"),
"a href=\"users--root\"", "/a") :
sformat (_("<%1>Root Password<%2> not set"),
"a href=\"users--root\"", "/a");
string ahref = "a href=\"users--user\"";
// summary label <%1>-<%2> are HTML tags, leave untouched
string prop = sformat (_("No <%1>user<%2> configured"),ahref, "/a");
string auth_method = UsersSimple::AfterAuth ();
list<map> users = (list<map>) UsersSimple::GetUsers ();
map user = users[0]:$[];
if (auth_method != "users")
{
// summary line: <%1>-<%2> are HTML tags, leave untouched,
// % is LDAP/NIS etc.
prop = sformat (_("<%1>Authentication method<%2>: %3"),
ahref, "/a", auth2label[auth_method]:auth_method);
if (UsersSimple::KerberosConfiguration ())
// summary line: <%1>-<%2> are HTML tags, leave untouched,
// % is LDAP/NIS etc.
prop = sformat (_("<%1>Authentication method<%2>: %3 and Kerberos."),
ahref, "/a", auth2label[auth_method]:auth_method);
}
else if (size (users) > 1 || user["__imported"]:nil != nil)
{
list<string> to_import = maplist (map u, users, ``(u["uid"]:""));
// summary line, %3 are user names (comma separated)
// <%1>,<%2> are HTML tags, leave untouched,
prop = sformat (_("<%1>Users<%2> %3 selected for import"),
ahref, "/a", mergestring (to_import, ","));
if (size (to_import) == 1)
// summary line, <%1>,<%2> are HTML tags, %3 user name
prop = sformat (_("<%1>User<%2> %3 will be imported."),
ahref, "/a", to_import[0]:"");
}
else if (user["uid"]:"" != "")
{
// summary line: <%1>-<%2> are HTML tags, leave untouched,
// %3 is login name
prop = sformat (_("<%1>User<%2> %3 configured"),
ahref, "/a", user["uid"]:"");
if (user["cn"]:"" != "")
// summary line: <%1>-<%2> are HTML tags, leave untouched,
// %3 is full name, %4 login name
prop = sformat (_("<%1>User<%2> %3 (%4) configured"),
ahref, "/a", user["cn"]:"", user["uid"]:"");
}
string rest = "";
if (UsersSimple::EncryptionMethod () != "blowfish")
{
// summary line
rest = sformat (_("Password Encryption Method: %1"),
encoding2label[UsersSimple::EncryptionMethod ()]:"");
}
ret = $[
"preformatted_proposal" : rest == "" ? HTML::List ([ prop, root_proposal]) : HTML::List ([ prop, root_proposal, rest]),
"language_changed" : false,
"links" : [ "users--user", "users--root" ],
];
}
else if ( func == "Description" )
{
ret = $[
// rich text label
"rich_text_title" : _("User Settings"),
"menu_titles" : [
// menu button label
$[ "id" : "users--user", "title" : _("&User") ],
// menu button label
$[ "id" : "users--root", "title" : _("&Root Password") ]
],
"id" : "users",
];
}
else if (func == "AskUser")
{
Wizard::OpenAcceptDialog();
map args = $[
"enable_back" : true,
"enable_next" : param["has_next"]:false,
];
symbol result = `back;
if (param["chosen_id"]:"" == "users--root")
{
UsersSimple::SkipRootPasswordDialog (false); // do not skip now...
result = (symbol)WFM::CallFunction ("inst_root_first", [args]);
}
else
{
args["root_dialog_follows"] = false;
result = (symbol)WFM::CallFunction ("inst_user_first", [args]);
}
Wizard::CloseDialog();
ret = $[ "workflow_sequence" : result ];
y2debug( "Returning from users_proposal AskUser() with: %1", ret );
}
return ret;
}
ACC SHELL 2018