diff --git a/app/destinations/app_languages.php b/app/destinations/app_languages.php index baa6a05a5c..2d5b47e559 100644 --- a/app/destinations/app_languages.php +++ b/app/destinations/app_languages.php @@ -1,275 +1,278 @@ +?> \ No newline at end of file diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index 59703504c3..5d0c380e08 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -244,7 +244,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "accountcode=".$destination_accountcode; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; $y++; - + //increment the dialplan detail order $dialplan_detail_order = $dialplan_detail_order + 10; } @@ -291,10 +291,10 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "tone_detect_hits=1"; $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $dialplan_detail_order; $y++; - + //increment the dialplan detail order $dialplan_detail_order = $dialplan_detail_order + 10; - + // execute on tone detect $dialplan["dialplan_details"][$y]["domain_uuid"] = $domain_uuid; $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action"; @@ -724,12 +724,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; - echo " ".$text['label-accountcode'].":\n"; + echo " ".$text['label-account_code'].":\n"; echo "\n"; echo "\n"; echo " \n"; echo "
\n"; - echo $text['description-accountcode']."\n"; + echo $text['description-account_code']."\n"; if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")){ echo " ".$text['billing-warning']; } diff --git a/app/devices/app_config.php b/app/devices/app_config.php index 759393a512..ef92ceaa24 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -102,6 +102,24 @@ $apps[$x]['permissions'][$y]['name'] = 'device_domain'; $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; $y++; + $apps[$x]['permissions'][$y]['name'] = "device_profile_view"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "device_profile_add"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "device_profile_edit"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "device_profile_delete"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'device_profile_domain'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; //schema details $y = 0; //table array index @@ -132,6 +150,15 @@ $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "device_profile_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_device_profiles"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "device_profile_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "v_id"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; @@ -172,16 +199,6 @@ $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']['text'] = "device_username"; - //$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "phone_username"; - //$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']['text'] = "device_password"; - //$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "phone_password"; - //$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']['text'] = "device_time_zone"; $apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "phone_time_zone"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; @@ -337,6 +354,15 @@ $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_devices'; $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'device_uuid'; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "device_profile_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_device_profiles"; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "device_profile_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'device_key_id'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select the key ID.'; @@ -366,4 +392,34 @@ $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the label.'; $z++; + $y = 4; //table array index + $z = 0; //field array index + $apps[$x]['db'][$y]['table'] = 'v_device_profiles'; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'device_profile_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary'; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid'; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "device_profile_name"; + $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'] = "device_profile_enabled"; + $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'] = "device_profile_description"; + $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; + $z++; + ?> \ No newline at end of file diff --git a/app/devices/app_languages.php b/app/devices/app_languages.php index f7732ff7dc..a9351348eb 100644 --- a/app/devices/app_languages.php +++ b/app/devices/app_languages.php @@ -76,7 +76,7 @@ $text['description-device_model']['pt-pt'] = "Introduza o nome do modelo ou número."; $text['description-device_model']['fr-fr'] = "Entrer le nom ou le numéro du modèle"; - $text['label-device_firmware_version']['en-us'] = "Firmware Version"; + $text['label-device_firmware_version']['en-us'] = "Firmware"; $text['label-device_firmware_version']['es-cl'] = "Versión de Firmware"; $text['label-device_firmware_version']['pt-pt'] = "Versão do Firmware"; $text['label-device_firmware_version']['fr-fr'] = "Version Firmware"; @@ -236,6 +236,88 @@ $text['description-device_description']['pt-pt'] = "Introduza a descrição."; $text['description-device_description']['fr-fr'] = "Entrez la description."; + //profiles + $text['title-profiles']['en-us'] = "Key Profiles"; + $text['title-profiles']['es-cl'] = "Perfiles Clave"; + $text['title-profiles']['pt-pt'] = "Perfis-Chave"; + $text['title-profiles']['fr-fr'] = "Profils Clés"; + + $text['title-profile']['en-us'] = "Key Profile"; + $text['title-profile']['es-cl'] = "Perfil Clave"; + $text['title-profile']['pt-pt'] = "Perfil Chave"; + $text['title-profile']['fr-fr'] = "Profil Clés"; + + $text['header-profiles']['en-us'] = "Key Profiles"; + $text['header-profiles']['es-cl'] = "Perfiles Clave"; + $text['header-profiles']['pt-pt'] = "Perfis-Chave"; + $text['header-profiles']['fr-fr'] = "Profils Clés"; + + $text['description-profiles']['en-us'] = "Define a set of keys as a profile. Any changes to the profile effect all devices assigned to the profile."; + $text['description-profiles']['es-cl'] = "Definir un conjunto de claves como un perfil. Cualquier cambio en el perfil de efectos todos los dispositivos asignados al perfil."; + $text['description-profiles']['pt-pt'] = "Defina um conjunto de chaves como um perfil. Quaisquer mudanças no perfil de todos os dispositivos de efeito atribuído ao perfil."; + $text['description-profiles']['fr-fr'] = "Définir un ensemble de touches comme un profil. Toute modification apportée à l'effet de profil tous les appareils affectés au profil."; + + $text['header-profile']['en-us'] = "Key Profile"; + $text['header-profile']['es-cl'] = "Perfil Clave"; + $text['header-profile']['pt-pt'] = "Perfil Chave"; + $text['header-profile']['fr-fr'] = "Profil Clés"; + + $text['description-profile']['en-us'] = "Define the assignments for this key profile."; + $text['description-profile']['es-cl'] = "Definir las asignaciones para este perfil de llave."; + $text['description-profile']['pt-pt'] = "Definir as atribuições para esse perfil de chave."; + $text['description-profile']['fr-fr'] = "Définir les missions pour ce profil de clé."; + + $text['label-profile']['en-us'] = "Key Profile"; + $text['label-profile']['es-cl'] = "Perfil Clave"; + $text['label-profile']['pt-pt'] = "Perfil Chave"; + $text['label-profile']['fr-fr'] = "Profil Clés"; + + $text['description-profile2']['en-us'] = "Select a Key Profile and/or define custom keys below."; + $text['description-profile2']['es-cl'] = "Seleccione un perfil de llave y / o definir teclas personalizadas a continuación."; + $text['description-profile2']['pt-pt'] = "Selecione um perfil Key e / ou definir chaves personalizados abaixo."; + $text['description-profile2']['fr-fr'] = "Sélectionnez un profil à clé et / ou définir des touches personnalisées ci-dessous."; + + $text['button-profiles']['en-us'] = "Key Profiles"; + $text['button-profiles']['es-cl'] = "Perfiles Clave"; + $text['button-profiles']['pt-pt'] = "Perfis-Chave"; + $text['button-profiles']['fr-fr'] = "Profils Clés"; + + $text['label-profile_name']['en-us'] = "Name"; + $text['label-profile_name']['es-cl'] = "Nombre"; + $text['label-profile_name']['pt-pt'] = "Nome"; + $text['label-profile_name']['fr-fr'] = "Nom"; + + $text['description-profile_name']['en-us'] = "Enter a name to identify this profile."; + $text['description-profile_name']['es-cl'] = "Introduzca un nombre para identificar este perfil."; + $text['description-profile_name']['pt-pt'] = "Digite um nome para identificar este perfil."; + $text['description-profile_name']['fr-fr'] = "Entrez un nom pour identifier ce profil."; + + $text['label-profile_domain']['en-us'] = "Domain"; + $text['label-profile_domain']['es-cl'] = "Dominio"; + $text['label-profile_domain']['pt-pt'] = "Domínio"; + $text['label-profile_domain']['fr-fr'] = "Domaine"; + + $text['label-profile_enabled']['en-us'] = "Enabled"; + $text['label-profile_enabled']['es-cl'] = "Activado"; + $text['label-profile_enabled']['pt-pt'] = "Activado"; + $text['label-profile_enabled']['fr-fr'] = "Actif"; + + $text['description-profile_enabled']['en-us'] = "Select the current state of this profile."; + $text['description-profile_enabled']['es-cl'] = "Seleccione el estado actual de este perfil."; + $text['description-profile_enabled']['pt-pt'] = "Selecione o estado atual deste perfil."; + $text['description-profile_enabled']['fr-fr'] = "Sélectionnez l'état actuel de ce profil."; + + $text['label-profile_description']['en-us'] = "Description"; + $text['label-profile_description']['es-cl'] = "Descripción"; + $text['label-profile_description']['pt-pt'] = "Descrição"; + $text['label-profile_description']['fr-fr'] = "Description"; + + $text['description-profile_description']['en-us'] = "Additional details about this profile."; + $text['description-profile_description']['es-cl'] = "Detalles adicionales acerca de este perfil."; + $text['description-profile_description']['pt-pt'] = "Detalhes adicionais sobre este perfil."; + $text['description-profile_description']['fr-fr'] = "Des détails supplémentaires sur ce profil."; + + //keys $text['label-keys']['en-us'] = "Keys"; $text['label-keys']['es-cl'] = "Claves"; diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 6227a29b00..443ffe85aa 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -98,6 +98,8 @@ require_once "resources/require.php"; $user_id = check_str($_POST["user_id"]); $auth_id = check_str($_POST["auth_id"]); $password = check_str($_POST["password"]); + //profile + $device_profile_uuid = check_str($_POST["device_profile_uuid"]); //keys $device_key_category = check_str($_POST["device_key_category"]); $device_key_id = check_str($_POST["device_key_id"]); @@ -277,6 +279,7 @@ require_once "resources/require.php"; $device_firmware_version = $row["device_firmware_version"]; $device_provision_enable = $row["device_provision_enable"]; $device_template = $row["device_template"]; + $device_profile_uuid = $row["device_profile_uuid"]; $device_description = $row["device_description"]; } unset ($prep_statement); @@ -312,7 +315,7 @@ require_once "resources/require.php"; $sql .= "ORDER by "; $sql .= "CASE device_key_category "; $sql .= "WHEN 'line' THEN 1 "; - $sql .= "WHEN 'memort' THEN 2 "; + $sql .= "WHEN 'memory' THEN 2 "; $sql .= "WHEN 'programmable' THEN 3 "; $sql .= "WHEN 'expansion' THEN 4 "; $sql .= "ELSE 100 END, "; @@ -406,18 +409,16 @@ require_once "resources/require.php"; "; - echo "\n"; - echo "\n"; - echo "
\n"; - echo "
"; - echo "
\n"; - echo "
\n"; - echo "\n"; + echo "
\n"; echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " "; - echo " "; + echo " "; echo "
".$text['header-device']."\n"; + echo ""; + echo " ".$text['header-device'].""; + echo "

"; + echo " ".$text['description-device']; + echo "

"; + echo "
\n"; echo " \n"; if ($action != "add") { echo " \n"; @@ -426,15 +427,9 @@ require_once "resources/require.php"; echo "
\n"; - echo $text['description-device']."

\n"; - echo "
\n"; - echo " ".$text['label-device_mac_address'].":\n"; + echo " ".$text['label-device_mac_address']."\n"; echo "\n"; echo " \n"; @@ -447,7 +442,7 @@ require_once "resources/require.php"; echo "
\n"; - echo " ".$text['label-device_label'].":\n"; + echo " ".$text['label-device_label']."\n"; echo "\n"; echo " \n"; @@ -458,7 +453,7 @@ require_once "resources/require.php"; echo "
\n"; - echo " ".$text['label-device_template'].":\n"; + echo " ".$text['label-device_template']."\n"; echo "\n"; $device = new device; @@ -500,7 +495,7 @@ require_once "resources/require.php"; echo "
".$text['label-lines'].":".$text['label-lines'].""; echo " \n"; echo " \n"; @@ -614,10 +609,35 @@ require_once "resources/require.php"; echo " "; if (permission_exists('device_key_add') || permission_exists('device_key_edit')) { + //device profile + $sql = "select * from v_device_profiles "; + $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; + $sql .= "order by device_profile_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + if ($result_count > 0) { + echo " "; + echo " "; + echo " "; + echo " "; + } + + //custom keys echo " "; - echo " "; + echo " "; echo "
".$text['label-profile'].""; + echo " \n"; + echo "
".$text['description-profile2']."\n"; + echo "
".$text['label-keys'].":".$text['label-keys'].""; - echo " \n"; + echo "
\n"; echo " \n"; echo " \n"; echo " \n"; @@ -856,23 +876,12 @@ require_once "resources/require.php"; \n"; - $selected = "selected='selected'"; echo "\n"; @@ -913,9 +922,9 @@ require_once "resources/require.php"; //device settings if (permission_exists('device_setting_add')) { echo " "; - echo " "; + echo " "; echo " "; - echo " "; - echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."\n"; echo " \n"; echo "
".$text['label-settings'].":".$text['label-settings'].""; - echo " \n"; + echo "
\n"; echo " \n"; echo " \n"; echo " \n"; @@ -1001,7 +1010,7 @@ require_once "resources/require.php"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; - /* - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - */ - if (permission_exists('device_domain')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " "; echo "
".$text['label-device_setting_name']."".$text['label-device_setting_value']."
\n"; - echo " ".$text['label-device_vendor'].":\n"; + echo " ".$text['label-device_vendor']."\n"; echo "\n"; echo " \n"; @@ -1012,7 +1021,7 @@ require_once "resources/require.php"; echo "
\n"; - echo " ".$text['label-device_model'].":\n"; + echo " ".$text['label-device_model']."\n"; echo "\n"; echo " \n"; @@ -1023,7 +1032,7 @@ require_once "resources/require.php"; echo "
\n"; - echo " ".$text['label-device_firmware_version'].":\n"; + echo " ".$text['label-device_firmware_version']."\n"; echo "\n"; echo " \n"; @@ -1032,34 +1041,10 @@ require_once "resources/require.php"; echo "
\n"; - echo " ".$text['label-device_username'].":\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-device_username']."\n"; - echo "
\n"; - echo " ".$text['label-device_password'].":\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-device_password']."\n"; - echo "
\n"; - echo " ".$text['label-domain'].":\n"; + echo " ".$text['label-domain']."\n"; echo "\n"; echo "
\n"; - echo " ".$text['label-device_provision_enable'].":\n"; + echo " ".$text['label-device_provision_enable']."\n"; echo "\n"; echo "
\n"; - echo " ".$text['label-device_description'].":\n"; + echo " ".$text['label-device_description']."\n"; echo "\n"; echo " \n"; @@ -1123,17 +1108,13 @@ require_once "resources/require.php"; if ($action == "update") { echo " \n"; } + echo "
"; echo " \n"; echo "
"; echo ""; - echo "
"; - echo ""; - //show the footer require_once "resources/footer.php"; ?> \ No newline at end of file diff --git a/app/devices/device_key_delete.php b/app/devices/device_key_delete.php index 24103841b2..0f060bc217 100644 --- a/app/devices/device_key_delete.php +++ b/app/devices/device_key_delete.php @@ -41,20 +41,26 @@ else { if (count($_GET)>0) { $id = check_str($_GET["id"]); $device_uuid = check_str($_GET["device_uuid"]); + $device_profile_uuid = check_str($_GET["device_profile_uuid"]); } if (strlen($id)>0) { //delete device_key $sql = "delete from v_device_keys "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and device_key_uuid = '$id' "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and device_key_uuid = '".$id."' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); unset($sql); } $_SESSION["message"] = $text['message-delete']; -header("Location: device_edit.php?id=".$device_uuid); +if ($device_uuid != '') { + header("Location: device_edit.php?id=".$device_uuid); +} +else if ($device_profile_uuid != '') { + header("Location: device_profile_edit.php?id=".$device_profile_uuid); +} return; ?> \ No newline at end of file diff --git a/app/devices/device_profile_delete.php b/app/devices/device_profile_delete.php new file mode 100644 index 0000000000..aef023b9f2 --- /dev/null +++ b/app/devices/device_profile_delete.php @@ -0,0 +1,83 @@ + + Copyright (C) 2008-2012 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('device_profile_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the id + if (count($_GET) > 0) { + $id = check_str($_GET["id"]); + } + +//delete the data and subdata + if (strlen($id) > 0) { + + //delete device profile keys + $sql = "delete from v_device_keys "; + $sql .= "where device_profile_uuid = '".$id."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //delete device profile + $sql = "delete from v_device_profiles "; + $sql .= "where device_profile_uuid = '".$id."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //remove device profile uuid from any assigned devices + $sql = "update v_devices set "; + $sql .= "device_profile_uuid = null "; + $sql .= "where device_profile_uuid = '".$id."' "; + $db->exec(check_sql($sql)); + unset($sql); + } + +/* +// necessary? + +//write the provision files + require_once "app/provision/provision_write.php"; + +*/ + +//set the message and redirect the user + $_SESSION["message"] = $text['message-delete']; + header("Location: device_profiles.php"); + return; + +?> \ No newline at end of file diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php new file mode 100644 index 0000000000..b3092a04e7 --- /dev/null +++ b/app/devices/device_profile_edit.php @@ -0,0 +1,610 @@ + + Copyright (C) 2008-2013 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('device_profile_add') || permission_exists('device_profile_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $device_profile_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST) > 0) { + //echo ""; exit; + $device_profile_name = check_str($_POST["device_profile_name"]); + $device_profile_domain_uuid = check_str($_POST["domain_uuid"]); + $device_profile_enabled = check_str($_POST["device_profile_enabled"]); + $device_profile_description = check_str($_POST["device_profile_description"]); + + $device_key_category = check_str($_POST["device_key_category"]); + $device_key_id = check_str($_POST["device_key_id"]); + $device_key_type = check_str($_POST["device_key_type"]); + $device_key_line = check_str($_POST["device_key_line"]); + $device_key_value = check_str($_POST["device_key_value"]); + $device_key_extension = check_str($_POST["device_key_extension"]); + $device_key_label = check_str($_POST["device_key_label"]); + } + +//add or update the database + if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + + //check for all required data + $msg = ''; + if (strlen($device_profile_name) == 0) { $msg .= $text['message-required'].$text['label-profile_name']."
\n"; } + if (strlen($msg) > 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + //add domain_uuid to the array + foreach ($_POST as $key => $value) { + if (is_array($value)) { + $y = 0; + foreach ($value as $k => $v) { + if (!isset($v["domain_uuid"])) { + $_POST[$key][$y]["domain_uuid"] = $_POST["domain_uuid"]; + } + $y++; + } + } + } + + //array cleanup + $x = 0; + foreach ($_POST["device_keys"] as $row) { + //unset the empty row + if (strlen($row["device_key_category"]) == 0) { + unset($_POST["device_keys"][$x]); + } + //unset device_detail_uuid if the field has no value + if (strlen($row["device_key_uuid"]) == 0) { + unset($_POST["device_keys"][$x]["device_key_uuid"]); + } + //increment the row + $x++; + } + + //set the default + $save = true; + + //save the profile + if ($save) { + $orm = new orm; + $orm->name('device_profiles'); + if (strlen($device_profile_uuid) > 0) { + $orm->uuid($device_profile_uuid); + } + $orm->save($_POST); + $response = $orm->message; + if (strlen($response['uuid']) > 0) { + $device_profile_uuid = $response['uuid']; + } + } +/* +// necessary? + //write the provision files + if (strlen($_SESSION['switch']['provision']['dir']) > 0) { + require_once "app/provision/provision_write.php"; + } +*/ + + //set the message + if (!isset($_SESSION['message'])) { + if ($save) { + if ($action == "add") { + //save the message to a session variable + $_SESSION['message'] = $text['message-add']; + } + if ($action == "update") { + //save the message to a session variable + $_SESSION['message'] = $text['message-update']; + + } + //redirect the browser + header("Location: device_profile_edit.php?id=".$device_profile_uuid); + exit; + } + } + + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + $orm = new orm; + $orm->name('device_profiles'); + $orm->uuid($device_profile_uuid); + $result = $orm->find()->get(); + //$message = $orm->message; + foreach ($result as &$row) { + $device_profile_name = $row["device_profile_name"]; + $device_profile_domain_uuid = $row["domain_uuid"]; + $device_profile_enabled = $row["device_profile_enabled"]; + $device_profile_description = $row["device_profile_description"]; + } + unset ($prep_statement); + } + +//set the sub array index + $x = "999"; + +//get device keys + $sql = "select * from v_device_keys "; + $sql .= "where device_profile_uuid = '".$device_profile_uuid."' "; + $sql .= "order by "; + $sql .= "case device_key_category "; + $sql .= " when 'line' then 1 "; + $sql .= " when 'memory' then 2 "; + $sql .= " when 'programmable' then 3 "; + $sql .= " when 'expansion' then 4 "; + $sql .= "else "; + $sql .= " 100 "; + $sql .= "end, "; + if ($db_type == "mysql") { + $sql .= "device_key_id asc "; + } + else { + $sql .= "cast(device_key_id as numeric) asc "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $device_keys = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $device_keys[$x]['device_key_category'] = ''; + $device_keys[$x]['device_key_id'] = ''; + $device_keys[$x]['device_key_type'] = ''; + $device_keys[$x]['device_key_line'] = ''; + $device_keys[$x]['device_key_value'] = ''; + $device_keys[$x]['device_key_extension'] = ''; + $device_keys[$x]['device_key_label'] = ''; + +//show the header + require_once "resources/header.php"; + $document['title'] = $text['title-profile']; + +//javascript to change select to input and back again + ?> +\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " "; + echo " "; + echo " "; + echo " "; + + if (permission_exists('device_profile_domain')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo ""; + echo "
"; + echo " ".$text['header-profile'].""; + echo "

"; + echo " ".$text['description-profile']; + echo "

"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-profile_name']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-profile_name']."\n"; + echo "
".$text['label-keys'].""; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + $x = 0; + foreach($device_keys as $row) { + //determine whether to hide the element + if (strlen($device_key_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_key_uuid']) > 0) { + echo " \n"; + } + //show all the rows in the array + echo " \n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo " \n"; + echo " \n"; + //increment the array key + $x++; + } + echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_label']." 
\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + ?> + + + + + + \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + if (strlen($row['device_key_uuid']) > 0) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + if (strlen($text['description-keys']) > 0) { + echo "
".$text['description-keys']."\n"; + } + echo "
\n"; + echo " ".$text['label-profile_domain']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-profile_enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-profile_enabled']."\n"; + echo "
\n"; + echo " ".$text['label-profile_description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-profile_description']."\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo "
"; + echo " \n"; + echo "
"; + echo ""; + +//show the footer + require_once "resources/footer.php"; +?> \ No newline at end of file diff --git a/app/devices/device_profiles.php b/app/devices/device_profiles.php new file mode 100644 index 0000000000..e8fa7fdf60 --- /dev/null +++ b/app/devices/device_profiles.php @@ -0,0 +1,177 @@ + + Copyright (C) 2008-2012 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('device_profile_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the http values and set them as variables + $search = check_str($_GET["search"]); + if (isset($_GET["order_by"])) { + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + } + +//additional includes + require_once "resources/header.php"; + $document['title'] = $text['title-profiles']; + require_once "resources/paging.php"; + +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
"; + echo " ".$text['header-profiles'].""; + echo "

"; + echo " ".$text['description-profiles']; + echo "
\n"; + echo "
\n"; + echo " \n"; + echo " "; + echo " "; + echo "
\n"; + echo "
\n"; + echo "
"; + + //prepare to page the results + $sql = "select count(*) as num_rows from v_device_profiles "; + $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; + if (strlen($search) > 0) { + $sql .= "and ("; + $sql .= " device_profile_name like '%".$search."%' "; + $sql .= " or device_profile_description like '%".$search."%' "; + $sql .= ") "; + } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + $num_rows = ($row['num_rows'] > 0) ? $row['num_rows'] : 0; + } + + //prepare to page the results + $rows_per_page = 50; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = "select * from v_device_profiles "; + $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; + if (strlen($search) > 0) { + $sql .= "and ("; + $sql .= " device_profile_name like '%".$search."%' "; + $sql .= " or device_profile_description like '%".$search."%' "; + $sql .= ") "; + } + if (strlen($order_by) == 0) { + $sql .= "order by device_profile_name asc "; + } + else { + $sql .= "order by ".$order_by." ".$order." "; + } + $sql .= "limit ".$rows_per_page." offset ".$offset." "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "\n"; + echo "\n"; + echo th_order_by('name', $text['label-profile_name'], $order_by, $order); + echo th_order_by('enabled', $text['label-profile_enabled'], $order_by, $order); + echo th_order_by('description', $text['label-profile_description'], $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + $tr_link = (permission_exists('device_profile_edit')) ? "href='device_profile_edit.php?id=".$row['device_profile_uuid']."'" : null; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $c = ($c == 0) ? 1 : 0; + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + if (permission_exists('device_profile_add')) { + echo " ".$v_link_label_add."\n"; + } + echo "
"; + echo (permission_exists('device_profile_edit')) ? "".$row['device_profile_name']."" : $row['device_profile_name']; + echo ($row['domain_uuid'] == '') ? "    ".$text['select-global']."" : null; + echo " ".$text['label-'.$row['device_profile_enabled']]." ".$row['device_profile_description']." "; + if (permission_exists('device_profile_edit')) { + echo "".$v_link_label_edit.""; + } + if (permission_exists('device_profile_delete')) { + echo "".$v_link_label_delete.""; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 ".$paging_controls.""; + if (permission_exists('device_profile_add')) { + echo " ".$v_link_label_add.""; + } + echo "
\n"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; +?> \ No newline at end of file diff --git a/app/devices/devices.php b/app/devices/devices.php index 7713a88897..6edf40f297 100644 --- a/app/devices/devices.php +++ b/app/devices/devices.php @@ -49,24 +49,23 @@ else { require_once "resources/paging.php"; //show the content - echo "
"; - echo "
"; - echo "\n"; + echo "
\n"; echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo "
".$text['header-devices']."
\n"; - echo " "; - echo " "; - echo "
\n"; - echo " ".$text['description-devices']."

\n"; + echo "
"; + echo " ".$text['header-devices'].""; + echo "

"; + echo " ".$text['description-devices']; + echo "
\n"; + echo "
\n"; + echo " "; + echo " "; + echo " "; + echo "
\n"; echo "
\n"; + echo "
"; //prepare to page the results $sql = "select count(*) as num_rows from v_devices "; @@ -81,7 +80,6 @@ else { $sql .= " or device_description like '%".$search."%' "; $sql .= ") "; } - //if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); @@ -132,22 +130,15 @@ else { $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; - echo "
\n"; echo "\n"; echo "\n"; - //echo th_order_by('device_uuid', $text['label-device_uuid'], $order_by, $order); echo th_order_by('device_mac_address', $text['label-device_mac_address'], $order_by, $order); echo th_order_by('device_label', $text['label-device_label'], $order_by, $order); echo th_order_by('device_vendor', $text['label-device_vendor'], $order_by, $order); - //echo th_order_by('device_model', $text['label-device_model'], $order_by, $order); - //echo th_order_by('device_firmware_version', $text['label-device_firmware_version'], $order_by, $order); echo th_order_by('device_provision_enable', $text['label-device_provision_enable'], $order_by, $order); echo th_order_by('device_template', $text['label-device_template'], $order_by, $order); - //echo th_order_by('device_username', $text['label-device_username'], $order_by, $order); - //echo th_order_by('device_password', $text['label-device_password'], $order_by, $order); - //echo th_order_by('device_time_zone', $text['label-device_time_zone'], $order_by, $order); echo th_order_by('device_description', $text['label-device_description'], $order_by, $order); - echo "\n"; - //echo " \n"; echo " \n"; echo " \n"; echo " \n"; - //echo " \n"; - //echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; - //echo " \n"; - //echo " \n"; - //echo " \n"; echo " \n"; echo " \n"; - echo "
\n"; + echo "\n"; if (permission_exists('device_add')) { echo " $v_link_label_add\n"; } @@ -164,7 +155,6 @@ else { $tr_link = (permission_exists('device_edit')) ? "href='device_edit.php?id=".$row['device_uuid']."'" : null; echo "
".$row['device_uuid']." "; if (permission_exists('device_edit')) { echo "".$row['device_mac_address'].""; @@ -175,13 +165,8 @@ else { echo " ".$row['device_label']." ".$row['device_vendor']." ".$row['device_model']." ".$row['device_firmware_version']." ".$row['device_provision_enable']." ".$text['label-'.$row['device_provision_enable']]." ".$row['device_template']." ".$row['device_username']." ".$row['device_password']." ".$row['device_time_zone']." ".$row['device_description']." "; if (permission_exists('device_edit')) { @@ -198,19 +183,14 @@ else { } //end if results echo "
\n"; + echo "\n"; echo " \n"; echo " \n"; echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; @@ -218,7 +198,6 @@ else { echo "\n"; echo "\n"; echo "
   $paging_controls".$paging_controls.""; if (permission_exists('device_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; + echo " $v_link_label_add"; } echo "
"; - echo ""; echo "

"; //include the footer