Skip to content

Commit a399550

Browse files
dariusstefanrazvancrainea
authored andcommitted
alias_mgm: new alias type suppress feature
1 parent 2c408c7 commit a399550

File tree

3 files changed

+23
-35
lines changed

3 files changed

+23
-35
lines changed

config/tools/users/alias_management/settings.inc.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656
),
5757
"tip" => "If checked, the domain will automatically be used as the alias domain."
5858
),
59-
"show_one_option" => array(
60-
"default" => True,
61-
"name" => "Show One Option",
59+
"suppress_alias_type" => array(
60+
"default" => False,
61+
"name" => "Suppress Alias Type",
6262
"type" => "dropdown",
6363
"options" => array(
6464
"No" => False,
6565
"Yes" => True
6666
),
67-
"tip" => "If checked, select boxes will be shown even if there is only one option."
67+
"tip" => "Suppress alias type checkbox if only one choice is available."
6868
),
6969
"alias_format" => array(
7070
"name" => "Alias Format",

web/tools/users/alias_management/template/alias_management.form.php

+6-12
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,26 @@
2828
$alias_types = get_settings_value("table_aliases");
2929
$alias_format = get_settings_value("alias_format");
3030
$implicit_domain = get_settings_value("implicit_domain");
31-
$show_one_option = get_settings_value("show_one_option");
31+
$suppress_atype = get_settings_value("suppress_alias_type");
3232

3333
form_generate_input_text("Username", "The name of the user", "username",
3434
"n", $am_form['username'], 128, "^[a-zA-Z0-9&=+$,;?/%]+$");
3535

36-
if (count($domains) != 1 || $show_one_option)
37-
form_generate_select("Domain", "Users's domain", "domain", 200,
38-
$am_form['domain'], $domains);
36+
form_generate_select("Domain", "Users's domain", "domain", 200,
37+
$am_form['domain'], $domains);
3938

4039
form_generate_input_text("Alias Username", "The name of the alias", "alias_username",
4140
"n", $am_form['alias_username'], 128, $alias_format);
4241

43-
if (($am_edit || !$implicit_domain) && (count($domains) != 1 || $show_one_option))
42+
if ($am_edit || !$implicit_domain)
4443
form_generate_select("Alias Domain", "Alias's domain", "alias_domain", 200,
4544
$am_form['alias_domain'], $domains);
4645

47-
if (!$am_edit && (count($alias_types) != 1 || $show_one_option))
46+
if (!$am_edit && (count($alias_types) != 1 || !$suppress_atype))
4847
form_generate_select("Alias Type", "The type of the alias, as you may have multiple type/groups of aliases, for different purposes",
4948
"alias_type", 64, $am_form['alias_type'], array_values($alias_types), array_keys($alias_types));
5049

51-
if (count($domains) == 1 && !$show_one_option) {
52-
form_generate_hidden("domain", $domains[0]);
53-
form_generate_hidden("alias_domain", $domains[0]);
54-
}
55-
56-
if (count($alias_types) == 1 && !$show_one_option) {
50+
if (count($alias_types) == 1 && $suppress_atype) {
5751
form_generate_hidden("alias_type", array_values($alias_types)[0]);
5852
}
5953
?>

web/tools/users/alias_management/template/alias_management.main.php

+13-19
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@
2828
$search_atype=$_SESSION['alias_type'];
2929

3030
$implicit_domain = get_settings_value("implicit_domain");
31-
$show_one_option = get_settings_value("show_one_option");
32-
33-
require_once("../../../tools/system/domains/lib/functions.inc.php");
34-
$domains = get_domains("user_management", false);
3531

32+
$suppress_alias_type = get_settings_value("suppress_alias_type");
3633
$alias_types = get_alias_types();
3734
?>
3835

@@ -46,42 +43,33 @@
4643
value="<?=$search_ausername?>" maxlength="16" class="searchInput"></td>
4744
</tr>
4845

49-
<?php if ($show_one_option || count($domains) != 1) { ?>
5046
<tr>
5147
<td class="searchRecord" align="left">Domain</td>
5248
<td class="searchRecord" width="200"><?php print_domains("domain",$search_domain,TRUE);?></td>
5349
</tr>
54-
<?php } ?>
5550

5651
<tr>
5752
<td class="searchRecord" align="left">Alias Username</td>
5853
<td class="searchRecord" width="200"><input type="text" name="alias_username"
5954
value="<?=$search_aaliasusername?>" maxlength="16" class="searchInput"></td>
6055
</tr>
6156

62-
<?php if (!$implicit_domain && ($show_one_option || count($domains) != 1)) { ?>
57+
<?php if (!$implicit_domain) { ?>
6358
<tr>
6459
<td class="searchRecord" align="left">Alias Domain</td>
6560
<td class="searchRecord" width="200"><?php print_domains("alias_domain",$search_adomain,TRUE);?></td>
6661
</tr>
6762
<?php } ?>
6863

69-
<?php
70-
if (!$show_one_option && count($domains) == 1) {
71-
$search_domain = $domains[0];
72-
$search_adomain = $domains[0];
73-
}
74-
?>
75-
76-
<?php if ($show_one_option || count($alias_types) != 1) { ?>
64+
<?php if (!$suppress_alias_type || count($alias_types) != 1) { ?>
7765
<tr>
7866
<td class="searchRecord" align="left">Alias Type</td>
7967
<td class="searchRecord" width="200"><?php print_aliasType($search_atype,TRUE)?></td>
8068
</tr>
8169
<?php } ?>
8270

8371
<?php
84-
if (!$show_one_option && count($alias_types) == 1) {
72+
if ($suppress_alias_type && count($alias_types) == 1) {
8573
$search_atype = $alias_types[0]['label'];
8674
}
8775
?>
@@ -109,8 +97,9 @@
10997
<?php
11098
if (!$implicit_domain)
11199
echo('<th class="listTitle">Alias Domain</th>');
100+
if (!$suppress_alias_type || count($alias_types) != 1)
101+
echo('<th class="listTitle">Alias Type</th>');
112102
?>
113-
<th class="listTitle">Alias Type</th>
114103
<th class="listTitle">Username</th>
115104
<th class="listTitle">Domain</th>
116105
<?php
@@ -155,7 +144,11 @@
155144
$labels[$options[$k]['value']] = $options[$k]['label'];
156145

157146
if(!$_SESSION['read_only']){
158-
$colspan = $implicit_domain ? 6 : 7;
147+
$colspan = 7;
148+
if ($implicit_domain)
149+
$colspan--;
150+
if ($suppress_alias_type && count($alias_types) == 1)
151+
$colspan--;
159152
}else{
160153
$colspan = 5;
161154
}
@@ -309,8 +302,9 @@
309302
<?php
310303
if (!$implicit_domain)
311304
echo('<td class="'.$row_style.'">&nbsp;'.$resultset[$i]['alias_domain'].'</td>');
305+
if (!$suppress_alias_type || count($alias_types) != 1)
306+
echo('<td class="'.$row_style.'">&nbsp;'.(isset($labels[$table])?$labels[$table]:$table).'</td>');
312307
?>
313-
<td class="<?=$row_style?>">&nbsp;<?=(isset($labels[$table])?$labels[$table]:$table)?></td>
314308
<td class="<?=$row_style?>">&nbsp;<?=$resultset[$i]['username']?></td>
315309
<td class="<?=$row_style?>">&nbsp;<?=$resultset[$i]['domain']?></td>
316310
<?php

0 commit comments

Comments
 (0)