Users: Add setting to require username format be an email address or not.

This commit is contained in:
Nate 2020-10-16 11:48:07 -06:00
parent 68dfa0d66d
commit 06f79d79e7
9 changed files with 130 additions and 0 deletions

View File

@ -642,6 +642,13 @@
echo " <option value='none' ".(($default_setting_value == "none") ? "selected='selected'" : null).">".$text['label-none']."</option>\n";
echo " </select>\n";
}
elseif ($category == "users" && $subcategory == "username_format" && $name == "text" ) {
echo " <select class='formfld' id='default_setting_value' name='default_setting_value'>\n";
echo " <option value='any' ".($default_setting_value == 'any' ? "selected='selected'" : null).">".$text['option-username_format_any']."</option>\n";
echo " <option value='email' ".($default_setting_value == 'email' ? "selected='selected'" : null).">".$text['option-username_format_email']."</option>\n";
echo " <option value='no_email' ".($default_setting_value == 'no_email' ? "selected='selected'" : null).">".$text['option-username_format_no_email']."</option>\n";
echo " </select>\n";
}
elseif ($category == "voicemail" && $subcategory == "voicemail_file" && $name == "text" ) {
echo " <select class='formfld' id='default_setting_value' name='default_setting_value'>\n";
echo " <option value='listen' ".(($default_setting_value == "listen") ? "selected='selected'" : null).">".$text['option-voicemail_file_listen']."</option>\n";

View File

@ -368,6 +368,9 @@
echo " ".(img_spacer('15px', '15px', 'background: '.escape($row['default_setting_value']).'; margin-right: 4px; vertical-align: middle; border: 1px solid '.(color_adjust($row['default_setting_value'], -0.18)).'; padding: -1px;'));
echo "<span style=\"font-family: 'Courier New'; line-height: 6pt;\">".escape($row['default_setting_value'])."</span>\n";
}
else if ($category == 'users' && $subcategory == 'username_format' && $name == 'text') {
echo " ".$text['option-username_format_'.$row['default_setting_value']]."\n";
}
else if ($category == 'recordings' && $subcategory == 'storage_type' && $name == 'text') {
echo " ".$text['label-'.$row['default_setting_value']]."\n";
}

View File

@ -695,6 +695,13 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo " <option value='none' ".(($row['domain_setting_value'] == "none") ? "selected='selected'" : null).">".$text['label-none']."</option>\n";
echo " </select>\n";
}
elseif ($category == "users" && $subcategory == "username_format" && $name == "text" ) {
echo " <select class='formfld' id='domain_setting_value' name='domain_setting_value'>\n";
echo " <option value='any' ".($row['domain_setting_value'] == 'any' ? "selected='selected'" : null).">".$text['option-username_format_any']."</option>\n";
echo " <option value='email' ".($row['domain_setting_value'] == 'email' ? "selected='selected'" : null).">".$text['option-username_format_email']."</option>\n";
echo " <option value='no_email' ".($row['domain_setting_value'] == 'no_email' ? "selected='selected'" : null).">".$text['option-username_format_no_email']."</option>\n";
echo " </select>\n";
}
elseif ($category == "voicemail" && $subcategory == "voicemail_file" && $name == "text" ) {
echo " <select class='formfld' id='domain_setting_value' name='domain_setting_value'>\n";
echo " <option value='listen' ".(($row['domain_setting_value'] == "listen") ? "selected='selected'" : null).">".$text['option-voicemail_file_listen']."</option>\n";

View File

@ -332,6 +332,9 @@
echo " ".(img_spacer('15px', '15px', 'background: '.escape($row['domain_setting_value']).'; margin-right: 4px; vertical-align: middle; border: 1px solid '.(color_adjust($row['domain_setting_value'], -0.18)).'; padding: -1px;'));
echo "<span style=\"font-family: 'Courier New'; line-height: 6pt;\">".escape($row['domain_setting_value'])."</span>\n";
}
else if ($category == 'users' && $subcategory == 'username_format' && $name == 'text') {
echo " ".$text['option-username_format_'.$row['domain_setting_value']]."\n";
}
else if ($category == 'recordings' && $subcategory == 'storage_type' && $name == 'text') {
echo " ".$text['label-'.$row['domain_setting_value']]."\n";
}

View File

@ -657,6 +657,13 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo " <option value='none' ".(($user_setting_value == "none") ? "selected='selected'" : null).">".$text['label-none']."</option>\n";
echo " </select>\n";
}
elseif ($user_setting_category == "users" && $user_setting_subcategory == "username_format" && $user_setting_name == "text" ) {
echo " <select class='formfld' id='user_setting_value' name='user_setting_value'>\n";
echo " <option value='any' ".($user_setting_value == 'any' ? "selected='selected'" : null).">".$text['option-username_format_any']."</option>\n";
echo " <option value='email' ".($user_setting_value == 'email' ? "selected='selected'" : null).">".$text['option-username_format_email']."</option>\n";
echo " <option value='no_email' ".($user_setting_value == 'no_email' ? "selected='selected'" : null).">".$text['option-username_format_no_email']."</option>\n";
echo " </select>\n";
}
else {
echo " <input class='formfld' type='text' id='user_setting_value' name='user_setting_value' maxlength='255' value=\"".escape($user_setting_value)."\">\n";
}

View File

@ -298,6 +298,9 @@
echo " ".(img_spacer('15px', '15px', 'background: '.escape($row['user_setting_value']).'; margin-right: 4px; vertical-align: middle; border: 1px solid '.(color_adjust($row['user_setting_value'], -0.18)).'; padding: -1px;'));
echo "<span style=\"font-family: 'Courier New'; line-height: 6pt;\">".escape($row['user_setting_value'])."</span>\n";
}
else if ($category == 'users' && $subcategory == 'username_format' && $name == 'text') {
echo " ".$text['option-username_format_'.$row['user_setting_value']]."\n";
}
else if ($category == 'recordings' && $subcategory == 'storage_type' && $name == 'text') {
echo " ".$text['label-'.$row['user_setting_value']]."\n";
}

View File

@ -94,6 +94,14 @@
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "53cc1060-78f9-44ca-b9b0-17fb2fffd5e1";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "users";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "username_format";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "any";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Require a specific username format.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "e3f5f4cd-0f17-428a-b788-2f2db91b6dc7";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "users";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "password_length";

View File

@ -152,6 +152,14 @@
if ($username == '') {
$invalid[] = $text['label-username'];
}
if ($_SESSION['users']['username_format']['text'] != '' && $_SESSION['users']['username_format']['text'] != 'any') {
if (
($_SESSION['users']['username_format']['text'] == 'email' && !valid_email($username)) ||
($_SESSION['users']['username_format']['text'] == 'no_email' && valid_email($username))
) {
message::add($text['message-username_format_invalid'], 'negative', 7500);
}
}
if ((permission_exists('user_edit') && $action == 'edit' && $username != $username_old && $username != '') ||
(permission_exists('user_add') && $action == 'add' && $username != '')) {
$sql = "select count(*) from v_users where username = :username ";

View File

@ -409,6 +409,90 @@ $text['message-unsupported_file_type']['ru-ru'] = "Тип файла не под
$text['message-unsupported_file_type']['sv-se'] = "Inte stöds filtyp";
$text['message-unsupported_file_type']['uk-ua'] = "Тип файлу не підтримується";
$text['message-username_format_invalid']['en-us'] = "Invalid Username Format";
$text['message-username_format_invalid']['en-gb'] = "Invalid Username Format";
$text['message-username_format_invalid']['ar-eg'] = "";
$text['message-username_format_invalid']['de-at'] = "Ungültiger Benutzername"; //copied from de-de
$text['message-username_format_invalid']['de-ch'] = "Ungültiger Benutzername"; //copied from de-de
$text['message-username_format_invalid']['de-de'] = "Ungültiger Benutzername";
$text['message-username_format_invalid']['es-cl'] = "";
$text['message-username_format_invalid']['es-mx'] = "";
$text['message-username_format_invalid']['fr-ca'] = "";
$text['message-username_format_invalid']['fr-fr'] = "";
$text['message-username_format_invalid']['he-il'] = "";
$text['message-username_format_invalid']['it-it'] = "";
$text['message-username_format_invalid']['nl-nl'] = "";
$text['message-username_format_invalid']['pl-pl'] = "";
$text['message-username_format_invalid']['pt-br'] = "Nome de usuário inválida";
$text['message-username_format_invalid']['pt-pt'] = "";
$text['message-username_format_invalid']['ro-ro'] = "";
$text['message-username_format_invalid']['ru-ru'] = "Неверное имя пользователя";
$text['message-username_format_invalid']['sv-se'] = "";
$text['message-username_format_invalid']['uk-ua'] = "Geçersiz Kullanıcı Adı";
$text['option-username_format_any']['en-us'] = "Any";
$text['option-username_format_any']['en-gb'] = "Any";
$text['option-username_format_any']['ar-eg'] = "Any";
$text['option-username_format_any']['de-at'] = "Any";
$text['option-username_format_any']['de-ch'] = "Any";
$text['option-username_format_any']['de-de'] = "Any";
$text['option-username_format_any']['es-cl'] = "Any";
$text['option-username_format_any']['es-mx'] = "Any";
$text['option-username_format_any']['fr-ca'] = "Any";
$text['option-username_format_any']['fr-fr'] = "Any";
$text['option-username_format_any']['he-il'] = "Any";
$text['option-username_format_any']['it-it'] = "Any";
$text['option-username_format_any']['nl-nl'] = "Any";
$text['option-username_format_any']['pl-pl'] = "Any";
$text['option-username_format_any']['pt-br'] = "Any";
$text['option-username_format_any']['pt-pt'] = "Any";
$text['option-username_format_any']['ro-ro'] = "Any";
$text['option-username_format_any']['ru-ru'] = "Any";
$text['option-username_format_any']['sv-se'] = "Any";
$text['option-username_format_any']['uk-ua'] = "Any";
$text['option-username_format_email']['en-us'] = "Email Address";
$text['option-username_format_email']['en-gb'] = "Email Address";
$text['option-username_format_email']['ar-eg'] = "Email Address";
$text['option-username_format_email']['de-at'] = "Email Address";
$text['option-username_format_email']['de-ch'] = "Email Address";
$text['option-username_format_email']['de-de'] = "Email Address";
$text['option-username_format_email']['es-cl'] = "Email Address";
$text['option-username_format_email']['es-mx'] = "Email Address";
$text['option-username_format_email']['fr-ca'] = "Email Address";
$text['option-username_format_email']['fr-fr'] = "Email Address";
$text['option-username_format_email']['he-il'] = "Email Address";
$text['option-username_format_email']['it-it'] = "Email Address";
$text['option-username_format_email']['nl-nl'] = "Email Address";
$text['option-username_format_email']['pl-pl'] = "Email Address";
$text['option-username_format_email']['pt-br'] = "Email Address";
$text['option-username_format_email']['pt-pt'] = "Email Address";
$text['option-username_format_email']['ro-ro'] = "Email Address";
$text['option-username_format_email']['ru-ru'] = "Email Address";
$text['option-username_format_email']['sv-se'] = "Email Address";
$text['option-username_format_email']['uk-ua'] = "Email Address";
$text['option-username_format_no_email']['en-us'] = "Not Email Address";
$text['option-username_format_no_email']['en-gb'] = "Not Email Address";
$text['option-username_format_no_email']['ar-eg'] = "Not Email Address";
$text['option-username_format_no_email']['de-at'] = "Not Email Address";
$text['option-username_format_no_email']['de-ch'] = "Not Email Address";
$text['option-username_format_no_email']['de-de'] = "Not Email Address";
$text['option-username_format_no_email']['es-cl'] = "Not Email Address";
$text['option-username_format_no_email']['es-mx'] = "Not Email Address";
$text['option-username_format_no_email']['fr-ca'] = "Not Email Address";
$text['option-username_format_no_email']['fr-fr'] = "Not Email Address";
$text['option-username_format_no_email']['he-il'] = "Not Email Address";
$text['option-username_format_no_email']['it-it'] = "Not Email Address";
$text['option-username_format_no_email']['nl-nl'] = "Not Email Address";
$text['option-username_format_no_email']['pl-pl'] = "Not Email Address";
$text['option-username_format_no_email']['pt-br'] = "Not Email Address";
$text['option-username_format_no_email']['pt-pt'] = "Not Email Address";
$text['option-username_format_no_email']['ro-ro'] = "Not Email Address";
$text['option-username_format_no_email']['ru-ru'] = "Not Email Address";
$text['option-username_format_no_email']['sv-se'] = "Not Email Address";
$text['option-username_format_no_email']['uk-ua'] = "Not Email Address";
$text['confirm-delete']['en-us'] = "Do you really want to DELETE this?";
$text['confirm-delete']['en-gb'] = "Do you really want to DELETE this?";
$text['confirm-delete']['ar-eg'] = "هل تريد حقا أن تحذف هذا؟";