Browse Source

Add user_type options: default, virtual

markjcrane 2 years ago
parent
commit
33636f9089

+ 9 - 1
core/users/app_config.php

@@ -5,7 +5,7 @@
 		$apps[$x]['uuid'] = "112124b3-95c2-5352-7e9d-d14c0b88f207";
 		$apps[$x]['category'] = "Core";
 		$apps[$x]['subcategory'] = "";
-		$apps[$x]['version'] = "1.0";
+		$apps[$x]['version'] = "1.1";
 		$apps[$x]['license'] = "Mozilla Public License 1.1";
 		$apps[$x]['url'] = "http://www.fusionpbx.com";
 		$apps[$x]['description']['en-us'] = "Add, edit, delete, and search for users.";
@@ -61,6 +61,10 @@
 		$apps[$x]['permissions'][$y]['name'] = "user_import";
 		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
 		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "user_type";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$apps[$x]['permissions'][$y]['groups'][] = "admin";
+		$y++;
 		$apps[$x]['permissions'][$y]['name'] = "user_group_view";
 		$apps[$x]['permissions'][$y]['menu']['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
 		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
@@ -246,6 +250,10 @@
 		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
 		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
 		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "user_type";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = "user_enabled";
 		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
 		$apps[$x]['db'][$y]['fields'][$z]['toggle'] = ['true','false'];

+ 50 - 0
core/users/app_languages.php

@@ -2308,6 +2308,56 @@ $text['description-message_key']['zh-cn'] = "使用生成按钮创建密钥。";
 $text['description-message_key']['ja-jp'] = "生成ボタンを使用してキーを作成します。";
 $text['description-message_key']['ko-kr'] = "생성 버튼을 사용하여 키를 만듭니다.";
 
+$text['label-user_type']['en-us'] = "Type";
+$text['label-user_type']['ar-eg'] = "النوع";
+$text['label-user_type']['de-at'] = "Art";
+$text['label-user_type']['de-ch'] = "Art";
+$text['label-user_type']['de-de'] = "Art";
+$text['label-user_type']['es-cl'] = "Tipo";
+$text['label-user_type']['es-mx'] = "Tipo";
+$text['label-user_type']['fr-ca'] = "type";
+$text['label-user_type']['fr-fr'] = "type";
+$text['label-user_type']['he-il'] = "סוג";
+$text['label-user_type']['it-it'] = "Tipo";
+$text['label-user_type']['nl-nl'] = "Type";
+$text['label-user_type']['pl-pl'] = "Typ";
+$text['label-user_type']['pt-br'] = "Tipo";
+$text['label-user_type']['pt-pt'] = "Tipo";
+$text['label-user_type']['ro-ro'] = "Tip";
+$text['label-user_type']['ru-ru'] = "Тип";
+$text['label-user_type']['sv-se'] = "Typ";
+$text['label-user_type']['uk-ua'] = "Tip";
+$text['label-user_type']['tr-tr'] = "oluştur";
+$text['label-user_type']['zh-cn'] = "类型";
+$text['label-user_type']['ja-jp'] = "タイプ";
+$text['label-user_type']['ko-kr'] = "유형";
+
+$text['description-user_type']['en-us'] = "Select Default to enable login or to disable login select Virtual.";
+$text['description-user_type']['en-gb'] = "Select Default to enable login or to disable login select Virtual.";
+$text['description-user_type']['ar-eg'] = "حدد افتراضي لتمكين تسجيل الدخول أو لتعطيل تسجيل الدخول ، حدد افتراضي.";
+$text['description-user_type']['de-at'] = "Wählen Sie „Standard“, um die Anmeldung zu aktivieren, oder wählen Sie „Virtuell“, um die Anmeldung zu deaktivieren.";
+$text['description-user_type']['de-ch'] = "Wählen Sie „Standard“, um die Anmeldung zu aktivieren, oder wählen Sie „Virtuell“, um die Anmeldung zu deaktivieren.";
+$text['description-user_type']['de-de'] = "Wählen Sie „Standard“, um die Anmeldung zu aktivieren, oder wählen Sie „Virtuell“, um die Anmeldung zu deaktivieren.";
+$text['description-user_type']['el-gr'] = "Επιλέξτε Προεπιλογή για να ενεργοποιήσετε τη σύνδεση ή για να απενεργοποιήσετε τη σύνδεση επιλέξτε Εικονική.";
+$text['description-user_type']['es-cl'] = "Seleccione Predeterminado para habilitar el inicio de sesión o para deshabilitar el inicio de sesión, seleccione Virtual.";
+$text['description-user_type']['es-mx'] = "Seleccione Predeterminado para habilitar el inicio de sesión o para deshabilitar el inicio de sesión, seleccione Virtual.";
+$text['description-user_type']['fr-ca'] = "Sélectionnez Par défaut pour activer la connexion ou pour désactiver la connexion, sélectionnez Virtuel.";
+$text['description-user_type']['fr-fr'] = "Sélectionnez Par défaut pour activer la connexion ou pour désactiver la connexion, sélectionnez Virtuel.";
+$text['description-user_type']['he-il'] = "בחר ברירת מחדל כדי לאפשר התחברות או כדי להשבית את ההתחברות בחר וירטואלי.";
+$text['description-user_type']['it-it'] = "Selezionare Predefinito per abilitare l'accesso o per disabilitare l'accesso selezionare Virtuale.";
+$text['description-user_type']['nl-nl'] = "Velg Standard for å aktivere pålogging eller for å deaktivere pålogging velg Virtual.";
+$text['description-user_type']['pl-pl'] = "Wybierz Domyślne, aby włączyć logowanie lub aby wyłączyć logowanie, wybierz Wirtualny.";
+$text['description-user_type']['pt-br'] = "Selecione Padrão para habilitar o login ou para desabilitar o login, selecione Virtual.";
+$text['description-user_type']['pt-pt'] = "Selecione Padrão para habilitar o login ou para desabilitar o login, selecione Virtual.";
+$text['description-user_type']['ro-ro'] = "Selectați Implicit pentru a activa conectarea sau pentru a dezactiva autentificarea selectați Virtual.";
+$text['description-user_type']['ru-ru'] = "Выберите «По умолчанию», чтобы включить вход в систему, или, чтобы отключить вход, выберите «Виртуальный».";
+$text['description-user_type']['sv-se'] = "Välj Standard för att aktivera inloggning eller för att inaktivera inloggning välj Virtual.";
+$text['description-user_type']['uk-ua'] = "Виберіть «За замовчуванням», щоб увімкнути вхід, або щоб вимкнути вхід, виберіть «Віртуальний».";
+$text['description-user_type']['tr-tr'] = "Oturum açmayı etkinleştirmek için Varsayılan'ı seçin veya oturum açmayı devre dışı bırakmak için Sanal'ı seçin.";
+$text['description-user_type']['zh-cn'] = "选择“默认”以启用登录,或选择“虚拟”以禁用登录。";
+$text['description-user_type']['ja-jp'] = "ログインを有効にする場合は「デフォルト」を選択し、ログインを無効にする場合は「仮想」を選択します。";
+$text['description-user_type']['ko-kr'] = "로그인을 활성화하려면 기본값을 선택하고 로그인을 비활성화하려면 가상을 선택합니다.";
+
 $text['label-user_totp_secret']['en-us'] = "TOTP";
 $text['label-user_totp_secret']['en-gb'] = "TOTP";
 $text['label-user_totp_secret']['ar-eg'] = "totp";

+ 3 - 3
core/users/resources/classes/users.php

@@ -238,7 +238,7 @@ if (!class_exists('users')) {
 					}
 
 				//copy the checked records
-					if (is_array($records) && @sizeof($records) != 0) {
+					if (!empty($records) && is_array($records) && @sizeof($records) != 0) {
 
 						//get checked records
 							foreach($records as $record) {
@@ -248,7 +248,7 @@ if (!class_exists('users')) {
 							}
 
 						//create the array from existing data
-							if (is_array($uuids) && @sizeof($uuids) != 0) {
+							if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
 								$sql = "select * from v_".$this->table." ";
 								$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
 								$database = new database;
@@ -271,7 +271,7 @@ if (!class_exists('users')) {
 							}
 
 						//save the changes and set the message
-							if (is_array($array) && @sizeof($array) != 0) {
+							if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
 								//save the array
 									$database = new database;
 									$database->app_name = $this->app_name;

+ 20 - 1
core/users/user_edit.php

@@ -134,6 +134,7 @@
 				$contact_name_family = $_POST["contact_name_family"];
 			}
 			$group_uuid_name = $_POST["group_uuid_name"];
+			$user_type = $_POST["user_type"];
 			$user_enabled = $_POST["user_enabled"] ?? 'false';
 			if (permission_exists('api_key')) {
 				$api_key = $_POST["api_key"];
@@ -526,6 +527,7 @@
 				if (!empty($_SESSION['authentication']['methods']) && in_array('totp', $_SESSION['authentication']['methods'])) {
 					$array['users'][$x]['user_totp_secret'] = $user_totp_secret;
 				}
+				$array['users'][$x]['user_type'] = $user_type;
 				$array['users'][$x]['user_enabled'] = $user_enabled;
 				if (permission_exists('contact_add')) {
 					$array['users'][$x]['contact_uuid'] = (!empty($contact_uuid)) ? $contact_uuid : null;
@@ -606,7 +608,7 @@
 		//populate the form with values from db
 			if ($action == 'edit') {
 				$sql = "select domain_uuid, user_uuid, username, user_email, api_key, user_totp_secret, ";
-				$sql .= "user_enabled, contact_uuid, cast(user_enabled as text), user_status ";
+				$sql .= "user_type, user_enabled, contact_uuid, cast(user_enabled as text), user_status ";
 				$sql .= "from v_users ";
 				$sql .= "where user_uuid = :user_uuid ";
 				if (!permission_exists('user_all')) {
@@ -623,6 +625,7 @@
 					$user_email = $row["user_email"];
 					$api_key = $row["api_key"];
 					$user_totp_secret = $row["user_totp_secret"];
+					$user_type = $row["user_type"];
 					$user_enabled = $row["user_enabled"];
 					if (permission_exists('contact_view')) {
 						$contact_uuid = $row["contact_uuid"];
@@ -1029,6 +1032,22 @@
 		echo "	</tr>";
 	}
 
+	if (permission_exists('user_type')) {
+		echo "<tr>\n";
+		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+		echo "	".$text['label-user_type']."\n";
+		echo "</td>\n";
+		echo "<td class='vtable' align='left'>\n";
+		echo "	<select class='formfld' name='user_type' id='user_type'>\n";
+		echo "		<option value='default' ".(($user_type == "default") ? "selected='selected'" : null).">".$text['label-default']."</option>\n";
+		echo "		<option value='virtual' ".(($user_type == "virtual") ? "selected='selected'" : null).">".$text['label-virtual']."</option>\n";
+		echo "	</select>\n";
+		echo "<br />\n";
+		echo $text['description-user_type']."\n";
+		echo "</td>\n";
+		echo "</tr>\n";
+	}
+
 	if (permission_exists('user_domain')) {
 		echo "<tr>\n";
 		echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";

+ 1 - 1
core/users/users.php

@@ -17,7 +17,7 @@
 
 	The Initial Developer of the Original Code is
 	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008 - 2021
+	Portions created by the Initial Developer are Copyright (C) 2008 - 2023
 	the Initial Developer. All Rights Reserved.
 
 	Contributor(s):