25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Fix port in IRC register form.

SVN Revision: 2470
This commit is contained in:
Badlop 2009-08-12 11:37:05 +00:00
parent 5098964df0
commit 3dc88feec9

View File

@ -860,7 +860,7 @@ generate_adhoc_register_form(Lang, Username, ConnectionsParams) ->
generate_connection_params_fields(Lang, ConnectionsParams, 1, [])}. generate_connection_params_fields(Lang, ConnectionsParams, 1, [])}.
generate_connection_params_fields(Lang, [], Number, Acc) -> generate_connection_params_fields(Lang, [], Number, Acc) ->
Field = generate_connection_params_field(Lang, "", "", 0, "", Number), Field = generate_connection_params_field(Lang, "", "", -1, "", Number),
lists:reverse(Field ++ Acc); lists:reverse(Field ++ Acc);
generate_connection_params_fields(Lang, [ConnectionParams | ConnectionsParams], Number, Acc) -> generate_connection_params_fields(Lang, [ConnectionParams | ConnectionsParams], Number, Acc) ->
@ -885,31 +885,33 @@ generate_connection_params_field(Lang, Server, Encoding, Port, Password, Number)
_ -> _ ->
Encoding Encoding
end, end,
PortUsed = if PortUsedInt = if
Port >= 0 andalso Port =< 65535 -> Port >= 0 andalso Port =< 65535 ->
Port; Port;
true -> true ->
?DEFAULT_IRC_PORT ?DEFAULT_IRC_PORT
end, end,
PortUsed = integer_to_list(PortUsedInt),
PasswordUsed = case Password of PasswordUsed = case Password of
[] -> [] ->
""; "";
_ -> _ ->
Password Password
end, end,
NumberString = integer_to_list(Number),
%% Fields are in reverse order, as they will be reversed again later. %% Fields are in reverse order, as they will be reversed again later.
[{xmlelement, "field", [{xmlelement, "field",
[{"var", "password" ++ io_lib:format("~b", [Number])}, [{"var", "password" ++ NumberString},
{"type", "text-single"}, {"type", "text-single"},
{"label", io_lib:format(translate:translate(Lang, "Password ~b"), [Number])}], {"label", io_lib:format(translate:translate(Lang, "Password ~b"), [Number])}],
[{xmlelement, "value", [], [{xmlcdata, PasswordUsed}]}]}, [{xmlelement, "value", [], [{xmlcdata, PasswordUsed}]}]},
{xmlelement, "field", {xmlelement, "field",
[{"var", "port" ++ io_lib:format("~b", [Number])}, [{"var", "port" ++ NumberString},
{"type", "text-single"}, {"type", "text-single"},
{"label", io_lib:format(translate:translate(Lang, "Port ~b"), [Number])}], {"label", io_lib:format(translate:translate(Lang, "Port ~b"), [Number])}],
[{xmlelement, "value", [], [{xmlcdata, PortUsed}]}]}, [{xmlelement, "value", [], [{xmlcdata, PortUsed}]}]},
{xmlelement, "field", {xmlelement, "field",
[{"var", "encoding" ++ io_lib:format("~b", [Number])}, [{"var", "encoding" ++ NumberString},
{"type", "list-single"}, {"type", "list-single"},
{"label", io_lib:format(translate:translate(Lang, "Encoding for server ~b"), [Number])}], {"label", io_lib:format(translate:translate(Lang, "Encoding for server ~b"), [Number])}],
[{xmlelement, "value", [], [{xmlcdata, EncodingUsed}]} | [{xmlelement, "value", [], [{xmlcdata, EncodingUsed}]} |
@ -918,7 +920,7 @@ generate_connection_params_field(Lang, Server, Encoding, Port, Password, Number)
[{xmlelement, "value", [], [{xmlcdata, E}]}]} [{xmlelement, "value", [], [{xmlcdata, E}]}]}
end, ?POSSIBLE_ENCODINGS)]}, end, ?POSSIBLE_ENCODINGS)]},
{xmlelement, "field", {xmlelement, "field",
[{"var", "server" ++ io_lib:format("~b", [Number])}, [{"var", "server" ++ NumberString},
{"type", "text-single"}, {"type", "text-single"},
{"label", io_lib:format(translate:translate(Lang, "Server ~b"), [Number])}], {"label", io_lib:format(translate:translate(Lang, "Server ~b"), [Number])}],
[{xmlelement, "value", [], [{xmlcdata, Server}]}]}]. [{xmlelement, "value", [], [{xmlcdata, Server}]}]}].