Przeglądaj źródła

Schemas is used by only 1-2 people so I'm moving it to an optional application under the apps directory.

Mark Crane 10 lat temu
rodzic
commit
0fed73e25c

+ 443 - 0
schemas/app_config.php

@@ -0,0 +1,443 @@
+<?php
+
+	//application details
+		$apps[$x]['name'] = "Schemas";
+		$apps[$x]['uuid'] = "8e98d409-8134-d33c-be70-fcee63d67a64";
+		$apps[$x]['category'] = "System";
+		$apps[$x]['subcategory'] = "";
+		$apps[$x]['version'] = "";
+		$apps[$x]['license'] = "Mozilla Public License 1.1";
+		$apps[$x]['url'] = "http://www.fusionpbx.com";
+		$apps[$x]['description']['en-us'] = "Provides the ability to quickly define information to store and dynamically makes tools available to view, add, edit, delete, and search.";
+		$apps[$x]['description']['es-cl'] = "Provee la habilidad de rápidamente definir información a almacenar y dinámicamente crea herramientas para ver, agregar, editar, eliminar y buscar.";
+		$apps[$x]['description']['es-mx'] = "";
+		$apps[$x]['description']['de-de'] = "";
+		$apps[$x]['description']['de-ch'] = "";
+		$apps[$x]['description']['de-at'] = "";
+		$apps[$x]['description']['fr-fr'] = "Fourni la possibilité de rapidement définir les informations à stocker et dynamiquement rendre disponible des outils pour voir, éditer, supprimer et chercher.";
+		$apps[$x]['description']['fr-ca'] = "";
+		$apps[$x]['description']['fr-ch'] = "";
+		$apps[$x]['description']['pt-pt'] = "Fornece a capacidade de definir rapidamente a informação para armazenar e dinamicamente faz ferramentas disponíveis para visualizar, adicionar, editar, apagar e pesquisa.";
+		$apps[$x]['description']['pt-br'] = "";
+
+	//permission details
+		$y = 0;
+		$apps[$x]['permissions'][$y]['name'] = "schema_view";
+		$apps[$x]['permissions'][$y]['menu']['uuid'] = "6be94b46-2126-947f-2365-0bea23651a6b";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_add";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_edit";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_delete";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_data_view";
+		$apps[$x]['permissions'][$y]['menu']['uuid'] = "6be94b46-2126-947f-2365-0bea23651a6b";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_data_add";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_data_edit";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_data_delete";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_name_value_view";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_name_value_add";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_name_value_edit";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_name_value_delete";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_field_view";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_field_add";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_field_edit";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+		$y++;
+		$apps[$x]['permissions'][$y]['name'] = "schema_field_delete";
+		$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
+
+	//schema details
+		$y = 0; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = "v_schema_data";
+		//$apps[$x]['db'][$y]['table']['text'] = "v_schema_data";
+		//$apps[$x]['db'][$y]['table']['deprecated'] = "v_virtual_table_data";
+
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "id";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_data_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_data_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_data_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";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$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";
+		$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'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "virtual_table_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_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_schemas";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "schema_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "data_row_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_data_row_uuid";
+		$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'] = "field_name";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_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']['text'] = "data_field_value";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_data_field_value";
+		$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'] = "data_add_user";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_data_add_user";
+		$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'] = "data_add_date";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_data_add_date";
+		$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'] = "data_del_user";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_data_del_user";
+		$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'] = "data_del_date";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_data_del_date";
+		$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'] = "table_parent_id";
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "virtual_table_parent_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_parent_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_parent_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]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "data_parent_row_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_data_parent_row_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+
+		$y = 1; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = "v_schema_name_values";
+		//$apps[$x]['db'][$y]['table']['text'] = "v_schema_name_values";
+		//$apps[$x]['db'][$y]['table']['deprecated'] = "v_virtual_table_name_values";
+
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "virtual_table_data_types_name_value_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_name_value_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_name_value_uuid";
+		//$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_data_types_name_value_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";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$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";
+		$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'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "virtual_table_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_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_schemas";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "schema_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "table_field_id";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_field_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_field_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_field_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_schema_fields";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "schema_field_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "data_types_name";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_data_types_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']['text'] = "data_types_value";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_data_types_value";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+
+		$y = 2; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = "v_schema_fields";
+		//$apps[$x]['db'][$y]['table']['text'] = "v_schema_fields";
+		//$apps[$x]['db'][$y]['table']['deprecated'] = "v_virtual_table_fields";
+
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_field_id";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_field_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_field_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_field_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";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$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";
+		$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'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "virtual_table_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_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_schemas";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "schema_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "field_label";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_label";
+		$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'] = "field_name";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_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']['text'] = "field_type";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_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']['text'] = "field_list_hidden";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_list_hidden";
+		$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'] = "field_search_by";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_search_by";
+		$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'] = "field_column";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_column";
+		$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'] = "field_required";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_required";
+		$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'] = "field_order";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_order";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "field_order_tab";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_order_tab";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "field_value";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_value";
+		$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'] = "field_description";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_field_description";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+
+		$y = 3; //table array index
+		$z = 0; //field array index
+		$apps[$x]['db'][$y]['table'] = "v_schemas";
+		//$apps[$x]['db'][$y]['table']['text'] = "v_schemas";
+		//$apps[$x]['db'][$y]['table']['deprecated'] = "v_virtual_tables";
+
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = "virtual_table_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
+		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_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";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$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";
+		$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'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_category";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_category";
+		$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'] = "schema_label";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_label";
+		$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'] = "schema_name";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_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']['text'] = "schema_auth";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_auth";
+		$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'] = "schema_captcha";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_captcha";
+		$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'] = "virtual_table_parent_id";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_parent_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_parent_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_schemas";
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "schema_uuid";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "schema_description";
+		$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "virtual_table_description";
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
+
+?>

+ 536 - 0
schemas/app_languages.php

@@ -0,0 +1,536 @@
+<?php
+
+	$text['button-add']['en-us'] = "Add";
+	$text['button-add']['es-cl'] = "Agregar";
+	$text['button-add']['fr-fr'] = "Ajouter";
+	$text['button-add']['pt-pt'] = "Adicionar";
+
+	$text['button-back']['en-us'] = "Back";
+	$text['button-back']['es-cl'] = "Volver";
+	$text['button-back']['fr-fr'] = "Retour";
+	$text['button-back']['pt-pt'] = "Voltar";
+
+	$text['button-delete']['en-us'] = "Delete";
+	$text['button-delete']['es-cl'] = "Eliminar";
+	$text['button-delete']['fr-fr'] = "Supprimer";
+	$text['button-delete']['pt-pt'] = "Remover";
+
+	$text['button-edit']['en-us'] = "Edit";
+	$text['button-edit']['es-cl'] = "Editar";
+	$text['button-edit']['fr-fr'] = "Editer";
+	$text['button-edit']['pt-pt'] = "Editar";
+
+	$text['button-import']['en-us'] = "Import";
+	$text['button-import']['es-cl'] = "Importar";
+	$text['button-import']['fr-fr'] = "Importer";
+	$text['button-import']['pt-pt'] = "Importar";
+
+	$text['button-next']['en-us'] = "Next";
+	$text['button-next']['es-cl'] = "Siguiente";
+	$text['button-next']['fr-fr'] = "Suivant";
+	$text['button-next']['pt-pt'] = "Seguinte";
+
+	$text['button-prev']['en-us'] = "Previous";
+	$text['button-prev']['es-cl'] = "Anterior";
+	$text['button-prev']['fr-fr'] = "Précédent";
+	$text['button-prev']['pt-pt'] = "Anterior";
+
+	$text['button-save']['en-us'] = "Save";
+	$text['button-save']['es-cl'] = "Guardar";
+	$text['button-save']['fr-fr'] = "Sauvegarder";
+	$text['button-save']['pt-pt'] = "Guardar";
+
+	$text['button-search_all']['en-us'] = "Search All";
+	$text['button-search_all']['es-cl'] = "Buscar Todo";
+	$text['button-search_all']['fr-fr'] = "Rechercher tout";
+	$text['button-search_all']['pt-pt'] = "Pesquisar Tudo";
+
+	$text['button-view']['en-us'] = "View";
+	$text['button-view']['es-cl'] = "Ver";
+	$text['button-view']['fr-fr'] = "Voir";
+	$text['button-view']['pt-pt'] = "Ver";
+
+	$text['confirm-delete']['en-us'] = "Do you really want to delete this?";
+	$text['confirm-delete']['es-cl'] = "¿Realmente desea eliminar esto?";
+	$text['confirm-delete']['fr-fr'] = "Voulez-vous vraiment supprimer cela?";
+	$text['confirm-delete']['pt-pt'] = "Tem a certeza que pretende remover?";
+
+	$text['description-authentication']['en-us'] = "Choose whether to require authentication.";
+	$text['description-authentication']['es-cl'] = "Indique si requiere autenticación.";
+	$text['description-authentication']['fr-fr'] = "Choisir si l'authentification est nécessaire.";
+	$text['description-authentication']['pt-pt'] = "Escolha se deseja ter autenticação.";
+
+	$text['description-category']['en-us'] = "Select the category.";
+	$text['description-category']['es-cl'] = "Seleccione la categoría.";
+	$text['description-category']['fr-fr'] = "Choisir la catégorie.";
+	$text['description-category']['pt-pt'] = "Escolha a categoria.";
+
+	$text['description-description']['en-us'] = "Enter a description (optional).";
+	$text['description-description']['es-cl'] = "Ingrese una descripción (opcional).";
+	$text['description-description']['fr-fr'] = "";
+	$text['description-description']['pt-pt'] = "Introduza uma descrição (opcional).";
+
+	$text['description-field']['en-us'] = "Define the properties of the field below.";
+	$text['description-field']['es-cl'] = "Definma las propiedades del campo a continuación.";
+	$text['description-field']['fr-fr'] = "Définir les propriétés des champs ci-dessous";
+	$text['description-field']['pt-pt'] = "Define as propriedades do campo em baixo.";
+
+	$text['description-field_column']['en-us'] = "Determines which column to show the field in.";
+	$text['description-field_column']['es-cl'] = "Determina en cual columna mostrar el campo.";
+	$text['description-field_column']['fr-fr'] = "Déterminer la colonne où afficher le champs";
+	$text['description-field_column']['pt-pt'] = "Determina qual a coluna para visualizar o respectivo campo.";
+
+	$text['description-field_description']['en-us'] = "Enter the description (optional).";
+	$text['description-field_description']['es-cl'] = "Ingrese una descripción (opcional).";
+	$text['description-field_description']['fr-fr'] = "";
+	$text['description-field_description']['pt-pt'] = "Introduza uma descrição (opcional).";
+
+	$text['description-field_label']['en-us'] = "Enter the field label.";
+	$text['description-field_label']['es-cl'] = "Ingrese una etiqueta de campo.";
+	$text['description-field_label']['fr-fr'] = "Choisil un label pour le champs";
+	$text['description-field_label']['pt-pt'] = "Introduza a etiqueta para o campo.";
+
+	$text['description-field_name']['en-us'] = "Enter field name.";
+	$text['description-field_name']['es-cl'] = "Ingrese el nombre del campo.";
+	$text['description-field_name']['fr-fr'] = "Choisir un nom pour le champs";
+	$text['description-field_name']['pt-pt'] = "Introduza o nome do campo.";
+
+	$text['description-field_order']['en-us'] = "Enter the order of the field.";
+	$text['description-field_order']['es-cl'] = "Ingrese el orden del campo.";
+	$text['description-field_order']['fr-fr'] = "Choisir l'ordre des champs";
+	$text['description-field_order']['pt-pt'] = "Introduza a ordem do campo.";
+
+	$text['description-field_required']['en-us'] = "Choose whether the field is required.";
+	$text['description-field_required']['es-cl'] = "Indique si el campo es requerido.";
+	$text['description-field_required']['fr-fr'] = "Choisir sir le champs est obligatoire";
+	$text['description-field_required']['pt-pt'] = "Escolha se o campo é obrigatório.";
+
+	$text['description-field_search_by']['en-us'] = "Choose whether the field will be used for searches.";
+	$text['description-field_search_by']['es-cl'] = "Indique si el campo será utilizado para búsquedas.";
+	$text['description-field_search_by']['fr-fr'] = "Choisir si le champs sera utilisé pour la recherche";
+	$text['description-field_search_by']['pt-pt'] = "Escolha que campo será utilizado para pesquisar.";
+
+	$text['description-field_tab_order']['en-us'] = "Enter the tab order.";
+	$text['description-field_tab_order']['es-cl'] = "Ingrese el orden de las pestañas.";
+	$text['description-field_tab_order']['fr-fr'] = "Choisir l'ordre des onglets";
+	$text['description-field_tab_order']['pt-pt'] = "Introduza a ordem do tab.";
+
+	$text['description-field_type']['en-us'] = "Select the field type.";
+	$text['description-field_type']['es-cl'] = "Seleccione el tipo de campo.";
+	$text['description-field_type']['fr-fr'] = "Choisir un type de champs";
+	$text['description-field_type']['pt-pt'] = "Introduza o tipo do campo.";
+
+	$text['description-field_value']['en-us'] = "Enter the default value.";
+	$text['description-field_value']['es-cl'] = "Ingrese el valor predeterminado.";
+	$text['description-field_value']['fr-fr'] = "Choisir la valeur par défaut";
+	$text['description-field_value']['pt-pt'] = "Introduza o valor por omissão.";
+
+	$text['description-field_visibility']['en-us'] = "Choose whether the field is hidden from the list.";
+	$text['description-field_visibility']['es-cl'] = "Indique si el campo estará escondido en la lista.";
+	$text['description-field_visibility']['fr-fr'] = "choisir si le champs est caché";
+	$text['description-field_visibility']['pt-pt'] = "Escolha se pretende que o campo esteja escondido da lista.";
+
+	$text['description-fields']['en-us'] = "Lists the fields in the database.";
+	$text['description-fields']['es-cl'] = "Listado de campos en la base de datos.";
+	$text['description-fields']['fr-fr'] = "Liste les champs de la base de données.";
+	$text['description-fields']['pt-pt'] = "Lista os campos da base de dados.";
+
+	$text['description-import_data']['en-us'] = "Copy and paste the comma delimitted data into the text area to begin the import.";
+	$text['description-import_data']['es-cl'] = "Copie y pegue la información delimitada por comas en el cuadro de texto para comenzar su importación.";
+	$text['description-import_data']['fr-fr'] = "Copier et coller les données séparées par une virgule ou un \"pipe\" dans la zone de texte pour commencer l'import.";
+	$text['description-import_data']['pt-pt'] = "Copie e cole os dados separados por vírgula para iniciar a importação.";
+
+	$text['description-import_delimiter']['en-us'] = "Select the field/column delimiter.";
+	$text['description-import_delimiter']['es-cl'] = "Seleccione el delimitador para campo/columna.";
+	$text['description-import_delimiter']['fr-fr'] = "Choisir le séparateur de champs/colonne";
+	$text['description-import_delimiter']['pt-pt'] = "Escolha o separador de campo/coluna.";
+
+	$text['description-import_enclosure']['en-us'] = "Select the field/column data enclosure.";
+	$text['description-import_enclosure']['es-cl'] = "Seleccione el cercado de datos de fila/columna.";
+	$text['description-import_enclosure']['fr-fr'] = "Choisir le conteneur de champs/colonne";
+	$text['description-import_enclosure']['pt-pt'] = "Escolha o conteúdo do campo/coluna.";
+
+	$text['description-label']['en-us'] = "Enter the label.";
+	$text['description-label']['es-cl'] = "Ingrese una etiqueta.";
+	$text['description-label']['fr-fr'] = "Choisir le label";
+	$text['description-label']['pt-pt'] = "Introduza uma etiqueta.";
+
+	$text['description-name']['en-us'] = "Enter the schema name.";
+	$text['description-name']['es-cl'] = "Ingrese el nombre del esquema.";
+	$text['description-name']['fr-fr'] = "Choisir le nom du schéma.";
+	$text['description-name']['pt-pt'] = "Introduza o nome da estrutura.";
+
+	$text['description-name_value']['en-us'] = "Define a name and value pair for the Select Box.";
+	$text['description-name_value']['es-cl'] = "Par nombre y valor del campo seleccionado.";
+	$text['description-name_value']['fr-fr'] = "Définir le nom et la valeur de la sélection.";
+	$text['description-name_value']['pt-pt'] = "Define um par nome-valor para a caixa de opções.";
+
+	$text['description-name_value_name']['en-us'] = "Enter the option text.";
+	$text['description-name_value_name']['es-cl'] = "Ingrese un texto de opción.";
+	$text['description-name_value_name']['fr-fr'] = "Choisire le text de l'option.";
+	$text['description-name_value_name']['pt-pt'] = "Introduza o texto da opção.";
+
+	$text['description-name_value_value']['en-us'] = "Enter the option value.";
+	$text['description-name_value_value']['es-cl'] = "Ingrese el valor de opción.";
+	$text['description-name_value_value']['fr-fr'] = "Choisir la valeur de l'option.";
+	$text['description-name_value_value']['pt-pt'] = "Introduza o valor da opção.";
+
+	$text['description-name_values']['en-us'] = "Name and value pairs of the Select Box.";
+	$text['description-name_values']['es-cl'] = "Par nombre y valor del campo seleccionado.";
+	$text['description-name_values']['fr-fr'] = "Nom et valeur de la sélection.";
+	$text['description-name_values']['pt-pt'] = "Pares nome-valor da caixa de opções.";
+
+	$text['description-parent_schema']['en-us'] = "Select a parent schema.";
+	$text['description-parent_schema']['es-cl'] = "Seleccione un esquema padre.";
+	$text['description-parent_schema']['fr-fr'] = "Choisir un schéma parent.";
+	$text['description-parent_schema']['pt-pt'] = "Escolha uma estrutura pai.";
+
+	$text['description-schema']['en-us'] = "Define the properties of the schema below.";
+	$text['description-schema']['es-cl'] = "Defina las propiedades del esquema a continuación.";
+	$text['description-schema']['fr-fr'] = "Définir les propriétés du schéma ci-dessous.";
+	$text['description-schema']['pt-pt'] = "Defina abaixo as propriedades da estrutura de dados.";
+
+	$text['description-schemas']['en-us'] = "Provides the ability to quickly define information to store and dynamically makes tools available to view, add, edit, delete, and search.";
+	$text['description-schemas']['es-cl'] = "Provee la habilidad de rápidamente definir información a almacenar y dinámicamente crea herramientas para ver, agregar, editar, eliminar y buscar.";
+	$text['description-schemas']['fr-fr'] = "Permet de rapidement de stocker des informations et créer dynamiquement de soutils pour voir, ajouter, éditer, supprimer et chercher.";
+	$text['description-schemas']['pt-pt'] = "Oferece a possibilidade de definir rapidamente a informação a guardar e criar ferramentas para visualizar, adicionar, editar, remover e pesquisar.";
+
+	$text['header-data']['en-us'] = "Schema Data";
+	$text['header-data']['es-cl'] = "Datos de Esquema";
+	$text['header-data']['fr-fr'] = "Données";
+	$text['header-data']['pt-pt'] = "Estrutura de Dados";
+
+	$text['header-data_view']['en-us'] = "Schema Data View";
+	$text['header-data_view']['es-cl'] = "Ver de Datos de Esquema";
+	$text['header-data_view']['fr-fr'] = "Affichage des données";
+	$text['header-data_view']['pt-pt'] = "Visualização da Estrutura de Dados";
+
+	$text['header-field']['en-us'] = "Field";
+	$text['header-field']['es-cl'] = "Campo";
+	$text['header-field']['es-cl'] = "Campo";
+	$text['header-field']['fr-fr'] = "Champs";
+	$text['header-field']['pt-pt'] = "Campo";
+
+	$text['header-fields']['en-us'] = "Fields";
+	$text['header-fields']['fr-fr'] = "Champs";
+	$text['header-fields']['pt-pt'] = "Campos";
+
+	$text['header-import']['en-us'] = "Schema Import";
+	$text['header-import']['es-cl'] = "Importar Esquema";
+	$text['header-import']['fr-fr'] = "Importer Schéma";
+	$text['header-import']['pt-pt'] = "Importar Estrutura";
+
+	$text['header-import_results']['en-us'] = "Schema Import Results";
+	$text['header-import_results']['es-cl'] = "Resultados de importación de Esquema";
+	$text['header-import_results']['fr-fr'] = "Résultat de l'import";
+	$text['header-import_results']['pt-pt'] = "Resultados da Importação da Estrutura de Dados";
+
+	$text['header-name_value']['en-us'] = "Select Box Option";
+	$text['header-name_value']['es-cl'] = "Seleccione un campo";
+	$text['header-name_value']['fr-fr'] = "Choisir l'option";
+	$text['header-name_value']['pt-pt'] = "Escolha a Opção";
+
+	$text['header-name_values']['en-us'] = "Select Box Options";
+	$text['header-name_values']['es-cl'] = "Seleccione un campo";
+	$text['header-name_values']['fr-fr'] = "Choisir l'option";
+	$text['header-name_values']['pt-pt'] = "Escolher a Opção";
+
+	$text['header-schema']['en-us'] = "Schema";
+	$text['header-schema']['es-cl'] = "Esquema";
+	$text['header-schema']['fr-fr'] = "Schéma";
+	$text['header-schema']['pt-pt'] = "Estrutura Virtual";
+
+	$text['header-schemas']['en-us'] = "Schemas";
+	$text['header-schemas']['es-cl'] = "Esquemas";
+	$text['header-schemas']['fr-fr'] = "Schémas";
+	$text['header-schemas']['pt-pt'] = "Estruturas Virtuais";
+
+	$text['label-authentication']['en-us'] = "Authentication";
+	$text['label-authentication']['es-cl'] = "Autenticación";
+	$text['label-authentication']['fr-fr'] = "Authentification";
+	$text['label-authentication']['pt-pt'] = "Autenticação";
+
+	$text['label-category']['en-us'] = "Category";
+	$text['label-category']['es-cl'] = "Categoria";
+	$text['label-category']['fr-fr'] = "Catégorie";
+	$text['label-category']['pt-pt'] = "Categoria";
+
+	$text['label-description']['en-us'] = "Description";
+	$text['label-description']['fr-fr'] = "Description";
+	$text['label-description']['pt-pt'] = "Descrição";
+
+	$text['label-field_column']['en-us'] = "Column";
+	$text['label-field_column']['es-cl'] = "Columna";
+	$text['label-field_column']['fr-fr'] = "Colone";
+	$text['label-field_column']['pt-pt'] = "Coluna";
+
+	$text['label-field_description']['en-us'] = "Description";
+	$text['label-field_description']['es-cl'] = "Descripción";
+	$text['label-field_description']['fr-fr'] = "Description";
+	$text['label-field_description']['pt-pt'] = "Descrição";
+
+	$text['label-field_label']['en-us'] = "Label";
+	$text['label-field_label']['es-cl'] = "Etiqueta";
+	$text['label-field_label']['fr-fr'] = "Label";
+	$text['label-field_label']['pt-pt'] = "Etiqueta";
+
+	$text['label-field_name']['en-us'] = "Name";
+	$text['label-field_name']['fr-fr'] = "Nom";
+	$text['label-field_name']['pt-pt'] = "Nome";
+
+	$text['label-field_order']['en-us'] = "Field Order";
+	$text['label-field_order']['es-cl'] = "Orden del campo";
+	$text['label-field_order']['fr-fr'] = "Ordre des Champs";
+	$text['label-field_order']['pt-pt'] = "Ordem dos Campos";
+
+	$text['label-field_required']['en-us'] = "Required";
+	$text['label-field_required']['es-cl'] = "Requerido";
+	$text['label-field_required']['fr-fr'] = "Requis";
+	$text['label-field_required']['pt-pt'] = "Obrigatório";
+
+	$text['label-field_search_by']['en-us'] = "Search By";
+	$text['label-field_search_by']['es-cl'] = "Buscar por";
+	$text['label-field_search_by']['fr-fr'] = "Rechercher Par";
+	$text['label-field_search_by']['pt-pt'] = "Pesquisar Por";
+
+	$text['label-field_tab_order']['en-us'] = "Tab Order";
+	$text['label-field_tab_order']['es-cl'] = "Orden de pestaña";
+	$text['label-field_tab_order']['fr-fr'] = "Odre des onglets";
+	$text['label-field_tab_order']['pt-pt'] = "Ordem das Tabs";
+
+	$text['label-field_type']['en-us'] = "Type";
+	$text['label-field_type']['es-cl'] = "Tipo";
+	$text['label-field_type']['fr-fr'] = "Type";
+	$text['label-field_type']['pt-pt'] = "Tipo";
+
+	$text['label-field_value']['en-us'] = "Value";
+	$text['label-field_value']['es-cl'] = "Valor";
+	$text['label-field_value']['fr-fr'] = "Valeur";
+	$text['label-field_value']['pt-pt'] = "Valor";
+
+	$text['label-field_visibility']['en-us'] = "Visibility";
+	$text['label-field_visibility']['es-cl'] = "Visibilidad";
+	$text['label-field_visibility']['fr-fr'] = "Visible";
+	$text['label-field_visibility']['pt-pt'] = "Visibilidade";
+
+	$text['label-import_data']['en-us'] = "Data";
+	$text['label-import_data']['es-cl'] = "Datos";
+	$text['label-import_data']['fr-fr'] = "Donnée";
+	$text['label-import_data']['pt-pt'] = "Dados";
+
+	$text['label-import_delimiter']['en-us'] = "Delimiter";
+	$text['label-import_delimiter']['es-cl'] = "Delimitador";
+	$text['label-import_delimiter']['fr-fr'] = "Séparateur de champs";
+	$text['label-import_delimiter']['pt-pt'] = "Separador";
+
+	$text['label-import_enclosure']['en-us'] = "Enclosure";
+	$text['label-import_enclosure']['es-cl'] = "Cercado";
+	$text['label-import_enclosure']['fr-fr'] = "Champs entre";
+	$text['label-import_enclosure']['pt-pt'] = "Entre Campos";
+
+	$text['label-label']['en-us'] = "Label";
+	$text['label-label']['es-cl'] = "Etiqueta";
+	$text['label-label']['fr-fr'] = "Label";
+	$text['label-label']['pt-pt'] = "Etiqueta";
+
+	$text['label-name']['en-us'] = "Name";
+	$text['label-name']['es-cl'] = "Nombre";
+	$text['label-name']['fr-fr'] = "Nom";
+	$text['label-name']['pt-pt'] = "Nome";
+
+	$text['label-name_value_name']['en-us'] = "Name";
+	$text['label-name_value_name']['es-cl'] = "Nombre";
+	$text['label-name_value_name']['fr-fr'] = "Nom";
+	$text['label-name_value_name']['pt-pt'] = "Nome";
+
+	$text['label-name_value_value']['en-us'] = "Value";
+	$text['label-name_value_value']['es-cl'] = "Valor";
+	$text['label-name_value_value']['fr-fr'] = "Valeur";
+	$text['label-name_value_value']['pt-pt'] = "Valor";
+
+	$text['label-parent_schema']['en-us'] = "Parent Schema";
+	$text['label-parent_schema']['es-cl'] = "Esquema padre";
+	$text['label-parent_schema']['fr-fr'] = "Schéma parent";
+	$text['label-parent_schema']['pt-pt'] = "Estrutura Pai";
+
+	$text['label-schema_name']['en-us'] = "Schema Name";
+	$text['label-schema_name']['es-cl'] = "Nombre de Esquema";
+	$text['label-schema_name']['fr-fr'] = "Nom du schéma";
+	$text['label-schema_name']['pt-pt'] = "Nome da Estrutura";
+
+	$text['message-add']['en-us'] = "Add Completed";
+	$text['message-add']['es-cl'] = "Agregar Completado";
+	$text['message-add']['fr-fr'] = "Ajouté";
+	$text['message-add']['pt-pt'] = "Adição Efectuada";
+
+	$text['message-delete']['en-us'] = "Delete Completed";
+	$text['message-delete']['es-cl'] = "Eliminación Completada";
+	$text['message-delete']['fr-fr'] = "Supprimé";
+	$text['message-delete']['pt-pt'] = "Remoção Efectuada";
+
+	$text['message-required']['en-us'] = "Please provide: ";
+	$text['message-required']['es-cl'] = "Por favor indique: ";
+	$text['message-required']['fr-fr'] = "Merci d'indiquer: ";
+	$text['message-required']['pt-pt'] = "Por favor indique: ";
+
+	$text['message-update']['en-us'] = "Update Completed";
+	$text['message-update']['es-cl'] = "Actualización Completada";
+	$text['message-update']['fr-fr'] = "Télécharger";
+	$text['message-update']['pt-pt'] = "Alteração Efectuada";
+
+	$text['option-check_box']['en-us'] = "Check Box";
+	$text['option-check_box']['es-cl'] = "Check Box";
+	$text['option-check_box']['fr-fr'] = "option";
+	$text['option-check_box']['pt-pt'] = "Opção";
+
+	$text['option-date']['en-us'] = "Date";
+	$text['option-date']['es-cl'] = "Fecha";
+	$text['option-date']['fr-fr'] = "Date";
+	$text['option-date']['pt-pt'] = "Data";
+
+	$text['option-email']['en-us'] = "Email";
+	$text['option-email']['es-cl'] = "Email";
+	$text['option-email']['fr-fr'] = "Courriel";
+	$text['option-email']['pt-pt'] = "Email";
+
+	$text['option-false']['en-us'] = "False";
+	$text['option-false']['es-cl'] = "Falso";
+	$text['option-false']['fr-fr'] = "Non";
+	$text['option-false']['pt-pt'] = "Não";
+
+	$text['option-file_upload']['en-us'] = "File Upload";
+	$text['option-file_upload']['es-cl'] = "Subir archivo";
+	$text['option-file_upload']['fr-fr'] = "Télécharger un Fichier";
+	$text['option-file_upload']['pt-pt'] = "Carregar Ficheiro";
+
+	$text['option-fusionpbx']['en-us'] = "FSCloud";
+	$text['option-fusionpbx']['es-cl'] = "FSCloud";
+	$text['option-fusionpbx']['fr-fr'] = "FSCloud";
+	$text['option-fusionpbx']['pt-pt'] = "FSCloud";
+
+	$text['option-hidden']['en-us'] = "Hidden";
+	$text['option-hidden']['es-cl'] = "Escondido";
+	$text['option-hidden']['fr-fr'] = "Caché";
+	$text['option-hidden']['pt-pt'] = "Escondido";
+
+	$text['option-image_upload']['en-us'] = "Image Upload";
+	$text['option-image_upload']['es-cl'] = "Subir imágem";
+	$text['option-image_upload']['fr-fr'] = "Télécharger une Image";
+	$text['option-image_upload']['pt-pt'] = "Carregar Imagem";
+
+	$text['option-label']['en-us'] = "Label";
+	$text['option-label']['es-cl'] = "Etiqueta";
+	$text['option-label']['fr-fr'] = "Label";
+	$text['option-label']['pt-pt'] = "Etiqueta";
+
+	$text['option-modified_date']['en-us'] = "Modified Date";
+	$text['option-modified_date']['es-cl'] = "Fecha de modificación";
+	$text['option-modified_date']['fr-fr'] = "Date de Modification";
+	$text['option-modified_date']['pt-pt'] = "Data de Alteração";
+
+	$text['option-modified_user']['en-us'] = "Modified User";
+	$text['option-modified_user']['es-cl'] = "Modificado por";
+	$text['option-modified_user']['fr-fr'] = "Usager Modifié";
+	$text['option-modified_user']['pt-pt'] = "Utilizador Alterado";
+
+	$text['option-number']['en-us'] = "Number";
+	$text['option-number']['es-cl'] = "Número";
+	$text['option-number']['fr-fr'] = "Numéro";
+	$text['option-number']['pt-pt'] = "Número";
+
+	$text['option-other']['en-us'] = "Other";
+	$text['option-other']['es-cl'] = "Otro";
+	$text['option-other']['fr-fr'] = "Autre";
+	$text['option-other']['pt-pt'] = "Outro";
+
+	$text['option-password']['en-us'] = "Password";
+	$text['option-password']['es-cl'] = "Contraseña";
+	$text['option-password']['fr-fr'] = "Mot de Passe";
+	$text['option-password']['pt-pt'] = "Password";
+
+	$text['option-phone']['en-us'] = "Phone";
+	$text['option-phone']['es-cl'] = "Teléfono";
+	$text['option-phone']['fr-fr'] = "Téléphone";
+	$text['option-phone']['pt-pt'] = "Telefone";
+
+	$text['option-pin_number']['en-us'] = "PIN Number";
+	$text['option-pin_number']['es-cl'] = "Número PIN";
+	$text['option-pin_number']['fr-fr'] = "Code PIN";
+	$text['option-pin_number']['pt-pt'] = "Código PIN";
+
+	$text['option-select']['en-us'] = "Select";
+	$text['option-select']['es-cl'] = "Seleccionar";
+	$text['option-select']['fr-fr'] = "Choisir";
+	$text['option-select']['pt-pt'] = "Escolher";
+
+	$text['option-text']['en-us'] = "Text";
+	$text['option-text']['es-cl'] = "Texto";
+	$text['option-text']['fr-fr'] = "Texte";
+	$text['option-text']['pt-pt'] = "Texto";
+
+	$text['option-text_area']['en-us'] = "Text Area";
+	$text['option-text_area']['es-cl'] = "Campo de texto";
+	$text['option-text_area']['fr-fr'] = "Zone de Texte";
+	$text['option-text_area']['pt-pt'] = "Área de Texto";
+
+	$text['option-true']['en-us'] = "True";
+	$text['option-true']['es-cl'] = "Verdadero";
+	$text['option-true']['fr-fr'] = "Oui";
+	$text['option-true']['pt-pt'] = "Sim";
+
+	$text['option-url']['en-us'] = "URL";
+	$text['option-url']['es-cl'] = "URL";
+	$text['option-url']['fr-fr'] = "URL";
+	$text['option-url']['pt-pt'] = "URL";
+
+	$text['option-uuid']['en-us'] = "UUID";
+	$text['option-uuid']['es-cl'] = "UUID";
+	$text['option-uuid']['fr-fr'] = "UUID";
+	$text['option-uuid']['pt-pt'] = "UUID";
+
+	$text['option-visible']['en-us'] = "Visible";
+	$text['option-visible']['es-cl'] = "Visible";
+	$text['option-visible']['fr-fr'] = "Visible";
+	$text['option-visible']['pt-pt'] = "Visível";
+
+	$text['title-data']['en-us'] = "Schema Data";
+	$text['title-data']['es-cl'] = "Datos de Esquema";
+	$text['title-data']['fr-fr'] = "Données";
+	$text['title-data']['pt-pt'] = "Esquema de Dados";
+
+	$text['title-data_view']['en-us'] = "Schema Data View";
+	$text['title-data_view']['es-cl'] = "Ver de Datos de Esquema";
+	$text['title-data_view']['fr-fr'] = "Affichage des données";
+	$text['title-data_view']['pt-pt'] = "Visualização do Esquema de Dados";
+
+	$text['title-field']['en-us'] = "Field";
+	$text['title-field']['es-cl'] = "Campo";
+	$text['title-field']['fr-fr'] = "Champs";
+	$text['title-field']['pt-pt'] = "Campo";
+
+	$text['title-import']['en-us'] = "Schema Import";
+	$text['title-import']['es-cl'] = "Importar Esquema";
+	$text['title-import']['fr-fr'] = "Importer Schéma";
+	$text['title-import']['pt-pt'] = "Importar Estrutura";
+
+	$text['title-import_results']['en-us'] = "Schema Import Results";
+	$text['title-import_results']['es-cl'] = "Resultados de importación de Esquema";
+	$text['title-import_results']['fr-fr'] = "Résultat de l'import";
+	$text['title-import_results']['pt-pt'] = "Resutlados da Importação da Estrutura";
+
+	$text['title-name_value']['en-us'] = "Select Box Option";
+	$text['title-name_value']['es-cl'] = "Seleccione un campo";
+	$text['title-name_value']['fr-fr'] = "Choisir l'Option";
+	$text['title-name_value']['pt-pt'] = "Escolha a Opção";
+
+	$text['title-schema']['en-us'] = "Schema";
+	$text['title-schema']['es-cl'] = "Esquema";
+	$text['title-schema']['fr-fr'] = "Schéma";
+	$text['title-schema']['pt-pt'] = "Estruturas Virtuais";
+
+	$text['title-schemas']['en-us'] = "Schemas";
+	$text['title-schemas']['es-cl'] = "Esquemas";
+	$text['title-schemas']['fr-fr'] = "Schémas";
+	$text['title-schemas']['pt-pt'] = "Estruturas Virtuais";
+
+?>

+ 20 - 0
schemas/app_menu.php

@@ -0,0 +1,20 @@
+<?php
+
+	$apps[$x]['menu'][0]['title']['en-us'] = "Schemas";
+	$apps[$x]['menu'][0]['title']['es-cl'] = "Esquemas";
+	$apps[$x]['menu'][0]['title']['es-mx'] = "";
+	$apps[$x]['menu'][0]['title']['de-de'] = "";
+	$apps[$x]['menu'][0]['title']['de-ch'] = "";
+	$apps[$x]['menu'][0]['title']['de-at'] = "";
+	$apps[$x]['menu'][0]['title']['fr-fr'] = "Schémas";
+	$apps[$x]['menu'][0]['title']['fr-ca'] = "";
+	$apps[$x]['menu'][0]['title']['fr-ch'] = "";
+	$apps[$x]['menu'][0]['title']['pt-pt'] = "Tabelas";
+	$apps[$x]['menu'][0]['title']['pt-br'] = "";
+	$apps[$x]['menu'][0]['uuid'] = "6be94b46-2126-947f-2365-0bea23651a6b";
+	$apps[$x]['menu'][0]['parent_uuid'] = "fd29e39c-c936-f5fc-8e2b-611681b266b5";
+	$apps[$x]['menu'][0]['category'] = "internal";
+	$apps[$x]['menu'][0]['path'] = "/app/schemas/schemas.php";
+	$apps[$x]['menu'][0]['groups'][] = "superadmin";
+
+?>

+ 50 - 0
schemas/root.php

@@ -0,0 +1,50 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+// make sure the PATH_SEPARATOR is defined
+	if (!defined("PATH_SEPARATOR")) {
+		if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
+	}
+
+// make sure the document_root is set
+	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
+	$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
+	//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
+	//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
+	//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
+
+// if the project directory exists then add it to the include path otherwise add the document root to the include path
+	if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
+	}
+	else {
+		if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
+		set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
+	}
+
+?>

+ 102 - 0
schemas/schema_data_delete.php

@@ -0,0 +1,102 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_delete')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+if (count($_GET)>0) {
+
+	//declare variable(s)
+		$schema_parent_id = '';
+
+	//get the http get and set them as php variables
+		$data_row_uuid = check_str($_GET["data_row_uuid"]);
+		$data_parent_row_uuid = check_str($_GET["data_parent_row_uuid"]);
+		$schema_uuid = check_str($_GET["schema_uuid"]);
+
+	//show the results and redirect
+		require_once "resources/header.php";
+
+	//get the schema_parent_id from the child table
+		if (strlen($schema_parent_id) == 0) {
+			$sql = "select * from v_schemas ";
+			$sql .= "where domain_uuid = '$domain_uuid' ";
+			$sql .= "and schema_uuid = '$schema_uuid' ";
+			$prep_statement = $db->prepare($sql);
+			$prep_statement->execute();
+			$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+			foreach ($result as &$row) {
+				$schema_parent_id = $row["schema_parent_id"];
+			}
+		}
+
+	//delete the child data
+		$sql = "delete from v_schema_data ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and data_parent_row_uuid = '$data_row_uuid' ";
+		$db->exec(check_sql($sql));
+		unset($sql);
+
+	//delete the data
+		$sql = "delete from v_schema_data ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and data_row_uuid = '$data_row_uuid' ";
+		$db->exec(check_sql($sql));
+		unset($sql);
+
+	//mark the the item as deleted and who deleted it
+		//$sql  = "update v_schema_data set ";
+		//$sql .= "data_del_date = now(), ";
+		//$sql .= "data_del_user = '".$_SESSION["username"]."' ";
+		//$sql .= "where domain_uuid = '$domain_uuid' ";
+		//$sql .= "and data_row_uuid = '$data_row_uuid' ";
+		//$db->exec(check_sql($sql));
+		//$lastinsertid = $db->lastInsertId($id);
+		//unset($sql);
+
+	//redirect user
+		$_SESSION["message"] = $text['message-delete'];
+		if (strlen($data_parent_row_uuid) == 0) {
+			header("Location: schema_data_view.php?id=".$schema_uuid."&data_row_uuid=".$data_row_uuid);
+		}
+		else {
+			header("Location: schema_data_edit.php?schema_uuid=".$schema_parent_id."&data_row_uuid=".$data_parent_row_uuid);
+		}
+		return;
+}
+
+?>

+ 975 - 0
schemas/schema_data_edit.php

@@ -0,0 +1,975 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_data_add') || permission_exists('schema_data_edit')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//set http get variables to php variables
+	$search_all = strtolower(check_str($_GET["search_all"]));
+	$schema_uuid = check_str($_GET["schema_uuid"]);
+	if (strlen($_GET["data_row_uuid"])>0) { //update
+		$data_row_uuid = check_str($_GET["data_row_uuid"]);
+		$action = "update";
+	}
+	else {
+		if (strlen($search_all) > 0) {
+			$action = "update";
+		}
+		else {
+			$action = "add";
+		}
+	}
+	if (strlen($_GET["id"]) > 0) {
+		$schema_uuid = check_str($_GET["id"]);
+	}
+	if (strlen($_GET["data_parent_row_uuid"])>0) {
+		$data_parent_row_uuid = check_str($_GET["data_parent_row_uuid"]);
+	}
+
+//get schema information
+	$sql = "select * from v_schemas ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and schema_uuid = '$schema_uuid' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	foreach ($result as &$row) {
+		$schema_category = $row["schema_category"];
+		$schema_label = $row["schema_label"];
+		$schema_name = $row["schema_name"];
+		$schema_auth = $row["schema_auth"];
+		$schema_captcha = $row["schema_captcha"];
+		$schema_parent_id = $row["schema_parent_id"];
+		$schema_description = $row["schema_description"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+
+//process the data submitted to by the html form
+	if (count($_POST)>0) { //add
+		$schema_uuid = check_str($_POST["schema_uuid"]);
+		$schema_name = check_str($_POST["schema_name"]);
+		$rcount = check_str($_POST["rcount"]);
+
+		//get the field information
+			$db_field_name_array = array();
+			$db_value_array = array();
+			$db_names .= "<tr>\n";
+			$sql = "select * from v_schema_fields ";
+			$sql .= "where domain_uuid = '$domain_uuid' ";
+			$sql .= "and schema_uuid = '$schema_uuid' ";
+			$sql .= "order by field_order asc ";
+			$prep_statement = $db->prepare($sql);
+			$prep_statement->execute();
+			$result_names = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
+			$result_count = count($result);
+			foreach($result_names as $row) {
+				$field_label = $row["field_label"];
+				$field_name = $row["field_name"];
+				$field_type = $row["field_type"];
+				$field_value = $row["field_value"];
+				$field_list_hidden = $row["field_list_hidden"];
+				$field_column = $row["field_column"];
+				$field_required = $row["field_required"];
+				$field_order = $row["field_order"];
+				$field_order_tab = $row["field_order_tab"];
+				$field_description = $row["field_description"];
+
+				$name_array[$field_name]['field_label'] = $row["field_label"];
+				$name_array[$field_name]['field_type'] = $row["field_type"];
+				$name_array[$field_name]['field_list_hidden'] = $row["field_list_hidden"];
+				$name_array[$field_name]['field_column'] = $row["field_column"];
+				$name_array[$field_name]['field_required'] = $row["field_required"];
+				$name_array[$field_name]['field_order'] = $row["field_order"];
+				$name_array[$field_name]['field_order_tab'] = $row["field_order_tab"];
+				$name_array[$field_name]['field_description'] = $row["field_description"];
+			}
+			unset($sql, $prep_statement, $row);
+			$fieldcount = count($name_array);
+
+		$i = 1;
+		while($i <= $rcount){
+			$field_name = check_str($_POST[$i."field_name"]);
+			$data_field_value = check_str($_POST[$i."field_value"]);
+			if ($i==1) {
+				$unique_temp_id = md5('7k3j2m'.date('r')); //used to find the first item
+				$data_row_uuid = $unique_temp_id;
+			}
+			$sql = "select field_type, field_name from v_schema_fields ";
+			$sql .= "where domain_uuid  = '$domain_uuid' ";
+			$sql .= "and schema_uuid  = '$schema_uuid' ";
+			$sql .= "and field_name = '$field_name' ";
+			$prep_statement = $db->prepare($sql);
+			$prep_statement->execute();
+			while($row = $prep_statement->fetch()){
+				$field_type = $row['field_type'];
+			}
+
+			if ($field_type == "upload_file" || $field_type == "uploadimage") {
+				//print_r($_FILES);
+				$upload_temp_dir = $_ENV["TEMP"]."\\";
+				ini_set('upload_tmp_dir', $upload_temp_dir);
+				//$uploaddir = "";
+				if ($field_type == "upload_file") {
+					$upload_file = $filedir . $_FILES[$i.'field_value']['name'];
+				}
+				if ($field_type == "uploadimage") {
+					$upload_file = $imagedir . $_FILES[$i.'field_value']['name'];
+				}
+				//  $_POST[$i."field_name"]
+				//print_r($_FILES);
+				//echo "upload_file $upload_file<br>\n";
+				//echo "upload_temp_dir $upload_temp_dir<br>\n";
+
+				$data_field_value = $_FILES[$i.'field_value']['name'];
+				//echo "name $data_field_value<br>\n";
+				//echo "field_name $field_name<br>\n";
+				//$i."field_value"
+				//echo "if (move_uploaded_file(\$_FILES[$i.'field_value']['tmp_name'], $upload_file)) ";
+				//if (strlen($_FILES[$i.'field_value']['name'])>0) { //only do the following if there is a file name
+					//foreach($_FILES as $file)
+					//{
+						//[$i.'field_value']
+						//print_r($file);
+						if($_FILES[$i.'field_value']['error'] == 0 && $_FILES[$i.'field_value']['size'] > 0) {
+								if (move_uploaded_file($_FILES[$i.'field_value']['tmp_name'], $upload_file)) {
+									//echo $_FILES['userfile']['name'] ." <br>";
+									//echo "was successfully uploaded. ";
+									//echo "<br><br>";
+									//print "<pre>";
+									//print_r($_FILES);
+									//print "</pre>";
+								}
+								else {
+									//echo "Upload Error.  Here's some debugging info:\n";
+									//print "<pre>\n";
+									//print_r($_FILES);
+									//print "</pre>\n";
+									//exit;
+								}
+						}
+					//}
+				//}
+			} //end if file or image
+
+			if ($action == "add" && permission_exists('schema_data_add')) {
+				//get a unique id for the data_row_uuid
+					if ($i==1) {
+						$data_row_uuid = uuid();
+					}
+
+				//insert the field data
+					$sql = "insert into v_schema_data ";
+					$sql .= "(";
+					$sql .= "schema_data_uuid, ";
+					$sql .= "domain_uuid, ";
+					$sql .= "data_row_uuid, ";
+					if(strlen($data_parent_row_uuid)>0) {
+						$sql .= "data_parent_row_uuid, ";
+					}
+					$sql .= "schema_uuid, ";
+					if (strlen($schema_parent_id) > 0) {
+						$sql .= "schema_parent_id, ";
+					}
+					$sql .= "field_name, ";
+					$sql .= "data_field_value, ";
+					$sql .= "data_add_user, ";
+					$sql .= "data_add_date ";
+					$sql .= ")";
+					$sql .= "values ";
+					$sql .= "(";
+					$sql .= "'".uuid()."', ";
+					$sql .= "'$domain_uuid', ";
+					$sql .= "'$data_row_uuid', ";
+					if(strlen($data_parent_row_uuid)>0) {
+						$sql .= "'$data_parent_row_uuid', ";
+					}
+					$sql .= "'$schema_uuid', ";
+					if (strlen($schema_parent_id) > 0) {
+						$sql .= "'$schema_parent_id', ";
+					}
+					$sql .= "'$field_name', ";
+					switch ($name_array[$field_name]['field_type']) {
+						case "phone":
+							$tmp_phone = preg_replace('{\D}', '', $data_field_value);
+							$sql .= "'$tmp_phone', ";
+							break;
+						case "add_user":
+							$sql .= "'".$_SESSION["username"]."', ";
+							break;
+						case "add_date":
+							$sql .= "now(), ";
+							break;
+						case "mod_user":
+							$sql .= "'".$_SESSION["username"]."', ";
+							break;
+						case "mod_date":
+							$sql .= "now(), ";
+							break;
+						default:
+							$sql .= "'$data_field_value', ";
+					}
+					$sql .= "'".$_SESSION["username"]."', ";
+					$sql .= "now() ";
+					$sql .= ")";
+					$db->exec(check_sql($sql));
+					$lastinsertid = $db->lastInsertId($id);
+					unset($sql);
+			} //end action add
+
+			if ($action == "update" && permission_exists('schema_data_edit')) {
+					$data_row_uuid = $_POST["data_row_uuid"];
+
+					$sql_update  = "update v_schema_data set ";
+					switch ($name_array[$field_name]['field_type']) {
+						case "phone":
+							$tmp_phone = preg_replace('{\D}', '', $data_field_value);
+							$sql_update .= "data_field_value = '$tmp_phone' ";
+							break;
+						case "add_user":
+							$sql_update .= "data_field_value = '".$_SESSION["username"]."' ";
+							break;
+						case "add_date":
+							$sql_update .= "data_field_value = now() ";
+							break;
+						case "mod_user":
+							$sql_update .= "data_field_value = '".$_SESSION["username"]."' ";
+							break;
+						case "mod_date":
+							$sql_update .= "data_field_value = now() ";
+							break;
+						default:
+							$sql_update .= "data_field_value = '$data_field_value' ";
+					}
+					$sql_update .= "where domain_uuid = '$domain_uuid' ";
+					$sql_update .= "and schema_uuid = '$schema_uuid' ";
+					if (strlen($schema_parent_id) > 0) {
+						$sql_update .= "and schema_parent_id = '$schema_parent_id' ";
+					}
+					$sql_update .= "and data_row_uuid = '$data_row_uuid' ";
+					if(strlen($data_parent_row_uuid)>0) {
+						$sql_update .= "and data_parent_row_uuid = '$data_parent_row_uuid' ";
+					}
+					$sql_update .= "and field_name = '$field_name' ";
+					$count = $db->exec(check_sql($sql_update));
+					unset ($sql_update);
+					if ($count > 0) {
+						//do nothing the update was successfull
+					}
+					else {
+						//no value to update so insert new value
+						$sql = "insert into v_schema_data ";
+						$sql .= "(";
+						$sql .= "domain_uuid, ";
+						$sql .= "data_row_uuid, ";
+						if(strlen($data_parent_row_uuid)>0) {
+							$sql .= "data_parent_row_uuid, ";
+						}
+						$sql .= "schema_uuid, ";
+						$sql .= "schema_parent_id, ";
+						$sql .= "field_name, ";
+						$sql .= "data_field_value, ";
+						$sql .= "data_add_user, ";
+						$sql .= "data_add_date ";
+						$sql .= ")";
+						$sql .= "values ";
+						$sql .= "(";
+						$sql .= "'$domain_uuid', ";
+						$sql .= "'$data_row_uuid', ";
+						if(strlen($data_parent_row_uuid)>0) {
+							$sql .= "'$data_parent_row_uuid', ";
+						}
+						$sql .= "'$schema_uuid', ";
+						$sql .= "'$schema_parent_id', ";
+						$sql .= "'$field_name', ";
+						switch ($name_array[$field_name]['field_type']) {
+							case "phone":
+								$tmp_phone = preg_replace('{\D}', '', $data_field_value);
+								$sql .= "'$tmp_phone', ";
+								break;
+							case "add_user":
+								$sql .= "'".$_SESSION["username"]."', ";
+								break;
+							case "add_date":
+								$sql .= "now(), ";
+								break;
+							case "mod_user":
+								$sql .= "'".$_SESSION["username"]."', ";
+								break;
+							case "mod_date":
+								$sql .= "now(), ";
+								break;
+							default:
+								$sql .= "'$data_field_value', ";
+						}
+						$sql .= "'".$_SESSION["username"]."', ";
+						$sql .= "now() ";
+						$sql .= ")";
+
+						$db->exec(check_sql($sql));
+						$lastinsertid = $db->lastInsertId($id);
+						unset($sql);
+					}
+			}
+			$i++;
+		}
+
+		//redirect user
+			if ($action == "add") {
+				$_SESSION["message"] = $text['message-add'];
+			}
+			else if ($action == "update") {
+				$_SESSION["message"] = $text['message-update'];
+			}
+
+			if (strlen($data_parent_row_uuid) == 0) {
+				header("Location: schema_data_edit.php?id=".$schema_uuid."&data_row_uuid=".$data_row_uuid);
+			}
+			else {
+				header("Location: schema_data_edit.php?schema_uuid=".$schema_parent_id."&data_row_uuid=".$data_parent_row_uuid);
+			}
+			return;
+	}
+
+//show the header
+	require_once "resources/header.php";
+	$document['title'] = $text['title-data'];
+
+//pre-populate the form
+	if ($action == "update") {
+		//get the field values
+			$sql = "";
+			$sql .= "select * from v_schema_data ";
+			$sql .= "where domain_uuid = '".$domain_uuid."' ";
+			if (strlen($search_all) == 0) {
+				$sql .= "and schema_uuid = '$schema_uuid' ";
+				if (strlen($data_parent_row_uuid) > 0) {
+					$sql .= " and data_parent_row_uuid = '$data_parent_row_uuid' ";
+				}
+			}
+			else {
+				$sql .= "and data_row_uuid in (";
+				$sql .= "select data_row_uuid from v_schema_data \n";
+				$sql .= "where domain_uuid = '".$domain_uuid."' ";
+				$sql .= "and schema_uuid = '$schema_uuid' ";
+				if (strlen($data_parent_row_uuid) > 0) {
+					$sql .= " and data_parent_row_uuid = '$data_parent_row_uuid' ";
+				}
+				else {
+					//$sql .= "and data_field_value like '%$search_all%' )\n";
+					$tmp_digits = preg_replace('{\D}', '', $search_all);
+					if (is_numeric($tmp_digits) && strlen($tmp_digits) > 5) {
+						if (strlen($tmp_digits) == '11' ) {
+							$sql .= "and data_field_value like '%".substr($tmp_digits, -10)."%' )\n";
+						}
+						else {
+							$sql .= "and data_field_value like '%$tmp_digits%' )\n";
+						}
+					}
+					else {
+						$sql .= "and lower(data_field_value) like '%$search_all%' )\n";
+					}
+				}
+			}
+			$sql .= "order by data_row_uuid asc ";
+
+			$row_id = '';
+			$row_id_found = false;
+			$next_row_id_found = false;
+			$prep_statement = $db->prepare($sql);
+			$prep_statement->execute();
+			$x=0;
+			while($row = $prep_statement->fetch()) {
+				//set the last last row id
+					if ($x==0) {
+						if (strlen($data_row_uuid) == 0) {
+							$data_row_uuid = $row['data_row_uuid'];
+						}
+						$first_data_row_uuid = $row['data_row_uuid'];
+					}
+				//get the data for the specific row id
+					if ($data_row_uuid == $row['data_row_uuid']) {
+						//set the data and save it to an array
+							$data_row[$row['field_name']] = $row['data_field_value'];
+						//set the previous row id
+							if ($previous_row_id != $row['data_row_uuid']) {
+								$previous_data_row_uuid = $previous_row_id;
+								$row_id_found = true;
+							}
+					}
+				//detect a new row id
+					if ($previous_row_id != $row['data_row_uuid']) {
+						if ($row_id_found) {
+							if (!$next_row_id_found) {
+								//make sure it is not the current row id
+								if ($data_row_uuid != $row['data_row_uuid']) {
+									$next_data_row_uuid = $row['data_row_uuid'];
+									$next_row_id_found = true;
+								}
+							}
+						}
+
+						//set the last last row id
+							$last_data_row_uuid = $row['data_row_uuid'];
+
+						//set the temporary previous row id
+							$previous_row_id = $row['data_row_uuid'];
+
+						//set the record number array
+							$record_number_array[$row['data_row_uuid']] = $x+1;
+
+						$x++;
+					}
+			}
+
+			//save the total number of records
+				$total_records = $x;
+
+			//set record number
+				if (strlen($_GET["n"]) == 0) {
+					$n = 1;
+				}
+				else {
+					$n = $_GET["n"];
+				}
+			unset($sql, $prep_statement, $row);
+	}
+
+//use this when the calendar is needed
+	//echo "<script language='javascript' src=\"/resources/calendar_popcalendar.js\"></script>\n";
+	//echo "<script language=\"javascript\" src=\"/resources/calendar_lw_layers.js\"></script>\n";
+	//echo "<script language=\"javascript\" src=\"/resources/calendar_lw_menu.js\"></script>";
+
+//begin creating the content
+	echo "<br />";
+
+//get the title and description of the schema
+	echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
+	echo "	<tr>\n";
+	echo "		<td width='50%' valign='top' nowrap='nowrap'>\n";
+	echo 	"	<b>$schema_label ";
+	if ($action == "add") {
+		echo $text['button-add']."\n";
+	}
+	else {
+		echo $text['button-edit']."\n";
+	}
+	echo "	</b>\n";
+	echo "	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
+	if ($action == "update" && permission_exists('schema_data_edit')) {
+		echo "	<input type='button' class='btn' name='' alt='".$text['button-add']."' onclick=\"window.location='schema_data_edit.php?schema_uuid=$schema_uuid'\" value='".$text['button-add']."'>\n";
+	}
+	echo "			<br />\n";
+	echo "			$schema_description\n";
+	echo "			<br />\n";
+	echo "			<br />\n";
+	echo "		</td>\n";
+
+	if (strlen($data_parent_row_uuid) == 0) {
+		echo "<td align='center' valign='top' nowrap='nowrap'>\n";
+
+		if ($action == "update" && permission_exists('schema_data_edit')) {
+			if (strlen($previous_data_row_uuid) == 0) {
+				echo "		<input type='button' class='btn' name='' alt='".$text['button-prev']."' disabled='disabled' value='".$text['button-prev']."'>\n";
+			}
+			else {
+				echo "		<input type='button' class='btn' name='' alt='".$text['button-prev']."' onclick=\"window.location='schema_data_edit.php?schema_uuid=$schema_uuid&data_row_uuid=".$previous_data_row_uuid."&search_all=$search_all&n=".($n-1)."'\" value='".$text['button-prev']." ".$previous_record_id."'>\n";
+			}
+			echo "		<input type='button' class='btn' name='' alt='".$text['button-prev']."' value='".$record_number_array[$data_row_uuid]." (".$total_records.")'>\n";
+			if (strlen($next_data_row_uuid) == 0) {
+				echo "		<input type='button' class='btn' name='' alt='".$text['button-next']."' disabled='disabled' value='".$text['button-next']."'>\n";
+			}
+			else {
+				echo "		<input type='button' class='btn' name='' alt='".$text['button-next']."' onclick=\"window.location='schema_data_edit.php?schema_uuid=$schema_uuid&data_row_uuid=".$next_data_row_uuid."&search_all=$search_all&n=".($n+1)."'\" value='".$text['button-next']." ".$next_record_id."'>\n";
+			}
+		}
+		echo "		&nbsp;&nbsp;&nbsp;";
+		echo "		&nbsp;&nbsp;&nbsp;";
+		echo "		&nbsp;&nbsp;&nbsp;";
+		echo "</td>\n";
+
+		echo "<td width='45%' align='right' valign='top' nowrap='nowrap'>\n";
+		echo "	<form method='GET' name='frm_search' action='schema_data_edit.php'>\n";
+		echo "	<input type='hidden' name='schema_uuid' value='$schema_uuid'>\n";
+		//echo "	<input type='hidden' name='id' value='$schema_uuid'>\n";
+		//echo "	<input type='hidden' name='data_parent_row_uuid' value='$data_parent_row_uuid'>\n";
+		//echo "	<input type='hidden' name='data_row_uuid' value='$first_data_row_uuid'>\n";
+		echo "	<input class='formfld' type='text' name='search_all' value='$search_all'>\n";
+		echo "	<input class='btn' type='submit' name='submit' value='".$text['button-search_all']."'>\n";
+		echo "	<input type='button' class='btn' alt='".$text['button-back']."' onclick=\"window.location='schema_data_view.php?id=$schema_uuid'\" value='".$text['button-back']."'>\n";
+		echo "	</form>\n";
+		echo "</td>\n";
+	}
+	else {
+		echo "	<td width='50%' align='right'>\n";
+		//echo "		<input type='button' class='btn' name='' alt='".$text['button-prev']."' onclick=\"window.location='schema_data_edit.php?schema_uuid=$schema_parent_id&data_row_uuid=$data_parent_row_uuid'\" value='".$text['button-prev']."'>\n";
+		//echo "		<input type='button' class='btn' name='' alt='".$text['button-next']."' onclick=\"window.location='schema_data_edit.php?schema_uuid=$schema_parent_id&data_row_uuid=$data_parent_row_uuid'\" value='".$text['button-next']."'>\n";
+		echo "		<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='schema_data_edit.php?schema_uuid=$schema_parent_id&data_row_uuid=$data_parent_row_uuid'\" value='".$text['button-back']."'>\n";
+		echo "	</td>\n";
+	}
+	echo "  </tr>\n";
+	echo "</table>\n";
+
+//begin the table that will hold the html form
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='10'>\n";
+
+//determine if a file should be uploaded
+	$sql = "SELECT * FROM v_schema_fields ";
+	$sql .= "where domain_uuid  = '$domain_uuid ' ";
+	$sql .= "and schema_uuid  = '$schema_uuid ' ";
+	$sql .= "and field_type = 'uploadimage' ";
+	$sql .= "or domain_uuid  = '$domain_uuid ' ";
+	$sql .= "and schema_uuid  = '$schema_uuid ' ";
+	$sql .= "and field_type = 'upload_file' ";
+	$prep_statement = $db->prepare($sql);
+	$prep_statement->execute();
+	if (count($prep_statement->fetchAll(PDO::FETCH_NAMED)) > 0) {
+		echo "<form method='post' name='frm' enctype='multipart/form-data' action=''>\n";
+		echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"104857600\" />\n";
+	}
+	else {
+		echo "<form method='post' name='frm' action=''>\n";
+	}
+
+//get the fields and then display them
+	$sql = "select * from v_schema_fields ";
+	$sql .= "where domain_uuid  = '$domain_uuid' ";
+	$sql .= "and schema_uuid  = '$schema_uuid' ";
+	$sql .= "order by field_column asc, field_order asc ";
+	$prep_statement = $db->prepare($sql);
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$result_count = count($result);
+
+	echo "<input type='hidden' name='rcount' value='$result_count'>\n";
+	echo "<input type='hidden' name='schema_uuid' value='$schema_uuid'>\n";
+
+	if ($result_count == 0) { //no results
+		echo "<tr><td class='vncell'>&nbsp;</td></tr>\n";
+	}
+	else { //received results
+		$x=1;
+		$field_column_previous = '';
+		$column_schema_cell_status = '';
+		foreach($result as $row) {
+			//handle more than one column
+				$field_column = $row[field_column];
+				//echo "<!--[column: $field_column]-->\n";
+				if ($field_column != $field_column_previous) {
+					$column_schema_cell_status = 'open';
+					//do the following except for the first time through the loop
+						if ($x != 1) {
+							//close the table
+								echo "</td>\n";
+								echo "</tr>\n";
+								echo "</table>\n";
+							//close the row
+								echo "</td>\n";
+						}
+					//open a new row
+						echo "<td valign='top'>\n";
+					//start a table in the new row
+						echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+				}
+
+			//display the fields
+					if ($row['field_type'] != "hidden"){
+						switch ($row['field_type']) {
+						case "add_user":
+							break;
+						case "add_date":
+							break;
+						case "mod_user":
+							break;
+						case "mod_date":
+							break;
+						default:
+							echo "<tr>\n";
+							if ($row['field_type'] == "label") {
+								echo "<td valign='bottom' align='left' class='' style='padding-top:10px;padding-bottom:7px;padding-right:5px;padding-left:0px;' nowrap='nowrap'>\n";
+								echo "	<strong>".$row['field_label']."</strong>\n";
+								echo "</td>\n";
+							}
+							else {
+								if ($row['field_required'] == "yes") {
+									echo "<td valign='top' align='left' class='vncellreq' style='padding-top:3px;' nowrap='nowrap'>\n";
+								}
+								else {
+									echo "<td valign='top' align='left' class='vncell' style='padding-top:3px;' nowrap='nowrap'>\n";
+								}
+								echo "".$row['field_label']."\n";
+								echo "</td>\n";
+							}
+						}
+					}
+					switch ($row['field_type']) {
+						case "checkbox":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							if (strlen($data_row[$row['field_name']])>0) {
+								echo "<input tabindex='".$row['field_order_tab']."' class='' type='checkbox' name='".$x."field_value' maxlength='50' value=\"".$row['field_value']."\" checked='checked'/>\n";
+							}
+							else {
+								echo "<input tabindex='".$row['field_order_tab']."' class='' type='checkbox' name='".$x."field_value' maxlength='50' value=\"".$row['field_value']."\" />\n";
+							}
+							echo "</td>\n";
+							break;
+						case "text":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%' type='text' name='".$x."field_value' maxlength='50' value=\"".$data_row[$row['field_name']]."\">\n";
+							echo "</td>\n";
+							break;
+						case "email":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='text' name='".$x."field_value' maxlength='50' value=\"".$data_row[$row['field_name']]."\">\n";
+							echo "</td>\n";
+							break;
+						case "label":
+							break;
+						case "password":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%' type='password' name='".$x."field_value' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" maxlength='50' value=\"".$data_row[$row['field_name']]."\">\n";
+							echo "</td>\n";
+							break;
+						case "pin_number":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value=\"".$row['field_name']."\">\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%' type='password' name='".$x."field_value' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" maxlength='50' value=\"".$data_row[$row['field_name']]."\">\n";
+							echo "</td>\n";
+							break;
+						case "hidden":
+							echo "<input type='hidden' name='".$x."field_name' value=\"".$row['field_name']."\">\n";
+							echo "<input type='hidden' name='".$x."field_value' value=\"".$data_row[$row['field_name']]."\">\n";
+							break;
+						case "url":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value=\"".$row['field_name']."\">\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='text' name='".$x."field_value' maxlength='50' value='".$data_row[$row['field_name']]."'>\n";
+							echo "</td>\n";
+							break;
+						case "date":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value=\"".$row['field_name']."\">\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='text' name='".$x."field_value' maxlength='50' value='".$data_row[$row['field_name']]."'>\n";
+
+							//echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							//echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
+							//echo "<tr>";
+							//echo "<td valign='top'><input tabindex='".$row['field_order_tab']."' name='".$x."field_value' readonly class='formfld' style='width:90%'  value='".$data_row[$row['field_name']]."' type='text' class='frm' onclick='popUpCalendar(this, this, \"mm/dd/yyyy\");'></td>\n";
+							//echo "<td valign='middle' width='20' align='right'><img src='/images/icon_calendar.gif' onclick='popUpCalendar(this, frm.".$x."field_value, \"mm/dd/yyyy\");'></td>	\n";
+							//echo "</tr>";
+							//echo "</table>";
+							//echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='text' name='".$x."field_value' maxlength='50' value='".$data_row[$row['field_name']]."'>\n";
+							echo "</td>\n";
+							break;
+						case "truefalse":
+							//checkbox
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value=\"".$row['field_name']."\">\n";
+							echo "<table border='0'>\n";
+							echo "<tr>\n";
+							switch ($row['field_name']) {
+								case "true":
+									echo "<td>".$text['option-true']."</td><td width='50'><input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='checkbox' name='".$x."field_value' checked='checked' value='true' /></td>\n";
+									echo "<td>".$text['option-false']."</td><td><input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='checkbox' name='".$x."field_value' value='false'></td>\n";
+									break;
+								case "false":
+									echo "<td>".$text['option-true']."</td><td width='50'><input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='checkbox' name='".$x."field_value' value='true' /></td>\n";
+									echo "<td>".$text['option-false']."</td><td><input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='checkbox' name='".$x."field_value' checked='checked' value='false' /></td>\n";
+									break;
+								default:
+									echo "<td>".$text['option-true']."</td><td width='50'><input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='checkbox' name='".$x."field_value' value='true' /></td>\n";
+									echo "<td>".$text['option-false']."</td><td><input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='checkbox' name='".$x."field_value' value='false' /></td>\n";
+							}
+
+							echo "</tr>\n";
+							echo "</table>\n";
+							echo "</td>\n";
+							break;
+						case "textarea":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<textarea tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  name='".$x."field_value' rows='4'>".$data_row[$row['field_name']]."</textarea>\n";
+							echo "</td>\n";
+							break;
+						case "radiobutton":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name=\"".$x."field_name\" value=\"".$row['field_name']."\">\n";
+
+							$sqlselect = "SELECT data_types_name, data_types_value ";
+							$sqlselect .= "FROM v_schema_name_values ";
+							$sqlselect .= "where domain_uuid = '".$domain_uuid."' ";
+							$sqlselect .= "and schema_field_uuid = '".$row["schema_field_uuid"]."' ";
+							$prep_statement_2 = $db->prepare($sqlselect);
+							$prep_statement_2->execute();
+							$result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
+							$result_count2 = count($result2);
+
+							echo "<table>";
+							if ($result_count > 0) {
+								foreach($result2 as $row2) {
+										echo "<tr><td>".$row2["data_types_name"]."</td><td><input tabindex='".$row['field_order_tab']."' type='radio' name='".$x."field_value' value='".$row2["data_types_select_value"]."'";
+										if ($row2["data_types_value"] == $data_row[$row['field_name']]) { echo " checked>"; } else { echo ">"; }
+										echo "</td></tr>";
+								} //end foreach
+							} //end if results
+							unset($sqlselect, $result2, $result_count2);
+							echo "</table>";
+							//echo "</select>\n";
+							echo "</td>\n";
+							break;
+						case "select":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+
+							$sqlselect = "SELECT data_types_name, data_types_value ";
+							$sqlselect .= "FROM v_schema_name_values ";
+							$sqlselect .= "where domain_uuid = '".$domain_uuid."' ";
+							$sqlselect .= "and schema_field_uuid = '".$row["schema_field_uuid"]."' ";
+							$prep_statement_2 = $db->prepare($sqlselect);
+							$prep_statement_2->execute();
+							$result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
+							$result_count2 = count($result2);
+
+							echo "<select tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  name='".$x."field_value'>\n";
+							echo "<option value=''></option>\n";
+							if ($result_count > 0) {
+								foreach($result2 as $row2) {
+										echo "<option value=\"" . $row2["data_types_value"] . "\"";
+										if (strtolower($row2["data_types_value"]) == strtolower($data_row[$row['field_name']])) { echo " selected='selected' "; }
+										echo ">" . $row2["data_types_name"] . "</option>\n";
+								} //end foreach
+							} //end if results
+							unset($sqlselect, $result2, $result_count2);
+							echo "</select>\n";
+							echo "</td>\n";
+							break;
+						case "ipv4":
+							//max 15
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='text' name='".$x."field_value' maxlength='15' value=\"".$data_row[$row['field_name']]."\">\n";
+							echo "</td>\n";
+							break;
+						case "ipv6":
+							//maximum number of characters 39
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='text' name='".$x."field_value' maxlength='39' value=\"".$data_row[$row['field_name']]."\">\n";
+							echo "</td>\n";
+							break;
+						case "phone":
+							$tmp_phone = $data_row[$row['field_name']];
+							$tmp_phone = format_phone($tmp_phone);
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='text' name='".$x."field_value' maxlength='20' value=\"".$tmp_phone."\">\n";
+							echo "</td>\n";
+							break;
+						case "money":
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='text' name=".$x."field_value' maxlength='255' value=\"".$data_row[$row['field_name']]."\">\n";
+							echo "</td>\n";
+							break;
+						case "add_user":
+							//echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input type='hidden' name='".$x."field_value' maxlength='255' value=\"".$data_row[$row['field_name']]."\">\n";
+							//echo "</td>\n";
+							break;
+						case "add_date":
+							//echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input type='hidden' name='".$x."field_value' maxlength='255' value=\"".$data_row[$row['field_name']]."\">\n";
+							//echo "</td>\n";
+							break;
+						case "mod_user":
+							//echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input type='hidden' name='".$x."field_value' maxlength='255' value=\"".$data_row[$row['field_name']]."\">\n";
+							//echo "</td>\n";
+							break;
+						case "mod_date":
+							//echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input type='hidden' name='".$x."field_value' maxlength='255' value=\"".$data_row[$row['field_name']]."\">\n";
+							//echo "</td>\n";
+							break;
+						case "uploadimage":
+							if (strlen($data_row[$row['field_name']]) > 0) {
+								echo "<td valign='top' align='left' class='vtable'>\n";
+								echo "<script type=\"text/javascript\">\n";
+								echo $row['field_name']." = \"\<input type=\'hidden\' name=\'".$x."field_name\' value=\'".$row['field_name']."\'>\\n\";\n";
+								echo $row['field_name']." += \"\<input tabindex='".$row['field_order_tab']."' class=\'formfld fileinput\' type=\'file\' name='".$x."field_value\' value=\'".$data_row[$row['field_name']]."\'>\\n\";\n";
+								echo "</script>\n";
+
+								echo "<div id='".$row['field_name']."id'>";
+								echo "<table border='0' width='100%'>";
+								echo "<tr>";
+								echo "<td align='left'>";
+									echo "".$data_row[$row['field_name']]."";
+								echo "</td>";
+								echo "<td align='right'>";
+									echo "<input tabindex='".$row['field_order_tab']."' type='button' class='btn' title='delete' onclick=\"document.getElementById('".$row['field_name']."id').innerHTML=".$row['field_name']."\" value='x'>\n";
+									//echo "<input type='button' class='btn' title='delete' onclick=\"addField('".$row['field_name']."id','".$x."field_name', 'hidden', '".$row['field_name']."',1);addField('".$row['field_name']."id','".$x."field_value', 'file', '',1);//'".$row['field_name']."'\" value='x'>\n";
+								echo "</td>";
+								echo "</tr>";
+								echo "<tr>";
+								echo "<td colspan='2' align='center'>";
+								if (file_exists($imagetempdir.$data_row[$row['field_name']])) {
+									echo "<img src='/images/cache/".$data_row[$row['field_name']]."'>";
+								}
+								else {
+									echo "<img src='imagelo.php?max=125&img=".$data_row[$row['field_name']]."'>";
+								}
+								echo "</td>";
+								echo "</tr>";
+
+								echo "</table>";
+								echo "<div>";
+								echo "</td>\n";
+							}
+							else {
+								echo "<td valign='top' align='left' class='vtable'>\n";
+								echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+								echo "<input tabindex='".$row['field_order_tab']."' class='formfld fileinput' style='width:90%'  type='file' name='".$x."field_value' value=\"".$data_row[$row['field_name']]."\">\n";
+								echo "</td>\n";
+							}
+							break;
+						case "upload_file":
+							if (strlen($data_row[$row['field_name']]) > 0) {
+								echo "<td valign='top' align='left' class='vtable'>\n";
+								echo "<script type=\"text/javascript\">\n";
+								echo $row['field_name']." = \"<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\";\n";
+								echo $row['field_name']." += \"<input tabindex='".$row['field_order_tab']."' class='formfld fileinput' style='width:90%'  type='file' name='".$x."field_value' value='".$data_row[$row['field_name']]."'>\";\n";
+								echo "</script>\n";
+
+								echo "<span id='".$row['field_name']."'>";
+								echo "<table width='100%'>";
+								echo "<tr>";
+								echo "<td>";
+								echo "<a href='download.php?f=".$data_row[$row['field_name']]."'>".$data_row[$row['field_name']]."</a>";
+								echo "</td>";
+								echo "<td align='right'>";
+									echo "<input tabindex='".$row['field_order_tab']."' type='button' class='btn' title='".$text['button-delete']."' onclick=\"document.getElementById('".$row['field_name']."').innerHTML=".$row['field_name']."\" value='x'>\n";
+								echo "</td>";
+								echo "</tr>";
+								echo "</table>";
+								echo "<span>";
+								echo "</td>\n";
+							}
+							else {
+								echo "<td valign='top' align='left' class='vtable'>\n";
+								echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+								echo "<input tabindex='".$row['field_order_tab']."' class='formfld fileinput' style='width:90%'  type='file' name='".$x."field_value' value=\"".$data_row[$row['field_name']]."\">\n";
+								echo "</td>\n";
+							}
+
+							break;
+						default:
+							echo "<td valign='top' align='left' class='vtable'>\n";
+							echo "<input type='hidden' name='".$x."field_name' value='".$row['field_name']."'>\n";
+							echo "<input tabindex='".$row['field_order_tab']."' class='formfld' style='width:90%'  type='text' style='' name='".$x."field_value' maxlength='255' value=\"".$data_row[$row['field_name']]."\">\n";
+							echo "</td>\n";
+						}
+					if ($row['field_type'] != "hidden"){
+						echo "</tr>\n";
+					}
+
+			//set the current value to the previous value
+				$field_column_previous = $field_column;
+
+			$x++;
+
+		} //end foreach
+		unset($sql, $result, $row_count);
+
+		if ($column_schema_cell_status == 'open') {
+			$column_schema_cell_status = 'closed';
+		}
+	} //end if results
+
+	echo "	<tr>\n";
+	echo "		<td colspan='999' align='right'>\n";
+		if ($action == "add" && permission_exists('schema_data_add')) {
+			echo "			<input type='submit' class='btn' name='submit' value='".$text['button-save']."'>\n";
+		}
+		if ($action == "update" && permission_exists('schema_data_edit')) {
+			echo "			<input type='hidden' name='data_row_uuid' value='$data_row_uuid'>\n";
+			echo "			<input type='submit' tabindex='9999999' class='btn' name='submit' value='".$text['button-save']."'>\n";
+		}
+	echo "		</td>\n";
+	echo "	</tr>\n";
+	echo "</table>\n";
+
+	echo "	</td>\n";
+	echo "	</tr>\n";
+	echo "</form>\n";
+
+	if ($action == "update" && permission_exists('schema_data_edit')) {
+		//get the child schema_uuid and use it to show the list of data
+			$sql = "select * from v_schemas ";
+			$sql .= "where domain_uuid = '$domain_uuid' ";
+			$sql .= "and schema_parent_uuid = '$schema_uuid' ";
+			$prep_statement = $db->prepare($sql);
+			$prep_statement->execute();
+			$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+			foreach ($result as &$row) {
+				echo "<tr class='border'>\n";
+				echo "	<td colspan='999' align=\"left\">\n";
+				echo "		<br>";
+				$_GET["id"] = $row["schema_uuid"];
+				$schema_label = $row["schema_label"];
+				$_GET["data_parent_row_uuid"] = $data_row_uuid;
+
+				//show button
+				//echo "<input type='button' class='btn' name='' alt='".$schema_label."' onclick=\"window.location='schema_data_view.php?id=".$row["schema_uuid"]."&data_parent_row_uuid=".$data_row_uuid."'\" value='".$schema_label."'>\n";
+
+				//show list
+				require_once "schema_data_view.php";
+				echo "	</td>";
+				echo "	</tr>";
+			}
+	}
+	echo "</table>\n";
+
+require_once "resources/footer.php";
+?>

+ 399 - 0
schemas/schema_data_view.php

@@ -0,0 +1,399 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_data_view')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+if (strlen($_GET["id"]) > 0) {
+	$schema_uuid = check_str($_GET["id"]);
+	if (strlen($_GET["data_parent_row_uuid"])>0) {
+		$data_parent_row_uuid = $_GET["data_parent_row_uuid"];
+	}
+	$search_all = strtolower(check_str($_GET["search_all"]));
+}
+
+//used for changing the order
+	$order_by = $_GET["order_by"];
+	$order = $_GET["order"];
+
+//used to alternate colors when paging
+	$c = 0;
+	$row_style["0"] = "row_style0";
+	$row_style["1"] = "row_style1";
+
+//show the header
+	require_once "resources/header.php";
+	$document['title'] = $text['title-data_view'];
+
+//get the information about the schema by using the id
+	$sql = "select * from v_schemas ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and schema_uuid = '$schema_uuid' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
+	foreach ($result as &$row) {
+		$schema_category = $row["schema_category"];
+		$schema_label = $row["schema_label"];
+		$schema_name = $row["schema_name"];
+		$schema_auth = $row["schema_auth"];
+		$schema_captcha = $row["schema_captcha"];
+		$schema_parent_uuid = $row["schema_parent_uuid"];
+		$schema_description = $row["schema_description"];
+		break; //limit to 1 row
+	}
+	unset ($prep_statement);
+
+//get the field information
+	$db_field_name_array = array();
+	$db_value_array = array();
+	$db_names .= "<tr>\n";
+	$sql = "select * from v_schema_fields ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and schema_uuid = '$schema_uuid' ";
+	$sql .= "order by field_order asc ";
+	$prep_statement = $db->prepare($sql);
+	$prep_statement->execute();
+	$result_names = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
+	$result_count = count($result);
+	foreach($result_names as $row) {
+		$field_label = $row["field_label"];
+		$field_name = $row["field_name"];
+		$field_type = $row["field_type"];
+		$field_value = $row["field_value"];
+		$field_list_hidden = $row["field_list_hidden"];
+		$field_column = $row["field_column"];
+		$field_required = $row["field_required"];
+		$field_order = $row["field_order"];
+		$field_order_tab = $row["field_order_tab"];
+		$field_description = $row["field_description"];
+
+		$name_array[$field_name]['field_label'] = $row["field_label"];
+		$name_array[$field_name]['field_type'] = $row["field_type"];
+		$name_array[$field_name]['field_list_hidden'] = $row["field_list_hidden"];
+		$name_array[$field_name]['field_column'] = $row["field_column"];
+		$name_array[$field_name]['field_required'] = $row["field_required"];
+		$name_array[$field_name]['field_order'] = $row["field_order"];
+		$name_array[$field_name]['field_order_tab'] = $row["field_order_tab"];
+		$name_array[$field_name]['field_description'] = $row["field_description"];
+	}
+	unset($sql, $prep_statement, $row);
+	$fieldcount = count($name_array);
+
+//get the data
+	$sql = "";
+	$sql .= "select * from v_schema_data ";
+	$sql .= "where domain_uuid = '".$domain_uuid."' ";
+	if (strlen($search_all) == 0) {
+		$sql .= "and schema_uuid = '$schema_uuid' ";
+		if (strlen($data_parent_row_uuid) > 0) {
+			$sql .= "and data_parent_row_uuid = '$data_parent_row_uuid' ";
+		}
+	}
+	else {
+		$sql .= "and data_row_uuid in (";
+		$sql .= "select data_row_uuid from v_schema_data \n";
+		$sql .= "where domain_uuid = '".$domain_uuid."' ";
+		$sql .= "and schema_uuid = '$schema_uuid' ";
+		if (strlen($data_parent_row_uuid) == 0) {
+			$tmp_digits = preg_replace('{\D}', '', $search_all);
+			if (is_numeric($tmp_digits) && strlen($tmp_digits) > 5) {
+				if (strlen($tmp_digits) == '11' ) {
+					$sql .= "and data_field_value like '%".substr($tmp_digits, -10)."%' \n";
+				}
+				else {
+					$sql .= "and data_field_value like '%$tmp_digits%' \n";
+				}
+			}
+			else {
+				$sql .= "and lower(data_field_value) like '%$search_all%' \n";
+			}
+		}
+		else {
+			$sql .= "and data_parent_row_uuid = '$data_parent_row_uuid' ";
+		}
+		$sql .= ")\n";
+	}
+	$sql .= "limit 20000\n";
+	$prep_statement = $db->prepare($sql);
+	$prep_statement->execute();
+	$result_values = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
+	foreach($result_values as $row) {
+		//set a php variable
+			$field_name = $row[field_name];
+			$data_row_uuid = $row[data_row_uuid];
+
+		//restructure the data by setting it the value_array
+			$value_array[$data_row_uuid][$field_name] = $row[data_field_value];
+			$value_array[$data_row_uuid]['schema_uuid'] = $row["schema_uuid"];
+			$value_array[$data_row_uuid]['data_row_uuid'] = $row[data_row_uuid];
+			$value_array[$data_row_uuid]['schema_parent_uuid'] = $row[schema_parent_uuid];
+			$value_array[$data_row_uuid]['data_parent_row_uuid'] = $row[data_parent_row_uuid];
+	}
+	$num_rows = count($value_array);
+
+//create the connection to the memory dbase_add_record
+	try {
+		$db_memory = new PDO('sqlite::memory:'); //sqlite 3
+	}
+	catch (PDOException $error) {
+		print "error: " . $error->getMessage() . "<br/>";
+		die();
+	}
+
+//create a memory database and add the fields to the table
+	$sql = "CREATE TABLE memory_table ";
+	$sql .= "(";
+	$sql .= "'id' INTEGER PRIMARY KEY, ";
+	$sql .= "'schema_uuid' TEXT, ";
+	$sql .= "'data_row_uuid' TEXT, ";
+	$sql .= "'schema_parent_uuid' TEXT, ";
+	$sql .= "'data_parent_row_uuid' TEXT, ";
+	foreach($result_names as $row) {
+		if ($row["field_type"] != "label") {
+			if ($row["field_name"] != "domain_uuid") {
+				//$row["field_label"];
+				//$row["field_name"];
+				//$row["field_type"];
+				if ($row["field_name"] == "number") {
+					$sql .= "'".$row["field_name"]."' NUMERIC, ";
+				}
+				else {
+					$sql .= "'".$row["field_name"]."' TEXT, ";
+				}
+			}
+		}
+	}
+	$sql .= "'domain_uuid' TEXT ";
+	$sql .= ");";
+	$prep_statement = $db_memory->prepare($sql);
+	$prep_statement->execute();
+	unset ($prep_statement, $sql);
+
+//list the values from the array
+	$x = 0;
+	foreach($value_array as $array) {
+		//insert the data into the memory table
+			$sql = "insert into memory_table ";
+			$sql .= "(";
+			$sql .= "'schema_uuid', ";
+			$sql .= "'data_row_uuid', ";
+			$sql .= "'schema_parent_uuid', ";
+			$sql .= "'data_parent_row_uuid', ";
+			//foreach($array as $key => $value) {
+			//	$sql .= "'$key', ";
+			foreach($result_names as $row) {
+				$field_name = $row["field_name"];
+				$sql .= "'$field_name', ";
+			}
+			$sql .= "'domain_uuid' ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'".$array['schema_uuid']."', ";
+			$sql .= "'".$array['data_row_uuid']."', ";
+			$sql .= "'".$array['schema_parent_uuid']."', ";
+			$sql .= "'".$array['data_parent_row_uuid']."', ";
+			//foreach($array as $key => $value) {
+			//	$sql .= "'$value', ";
+			foreach($result_names as $row) {
+				$field_name = $row["field_name"];
+				$sql .= "'".check_str($array[$field_name])."', ";
+			}
+			$sql .= "'$domain_uuid' ";
+			$sql .= ");";
+			//echo "$sql <br /><br />\n";
+			$db_memory->exec(check_sql($sql));
+			unset($sql);
+			unset($array);
+		//unset the row of data
+			unset($value_array[$x]);
+		//increment the value
+			$x++;
+	}
+
+//set the title and description of the table
+	echo "<br />\n";
+	echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
+	echo "  <tr>\n";
+	echo "	<td align='left' valign='top'><strong>$schema_label</strong><br>\n";
+	echo "		$schema_description\n";
+	echo "	</td>\n";
+	echo "	<td align='right' valign='top'>\n";
+	if (strlen($data_parent_row_uuid) == 0) {
+		$search_all = str_replace("''", "'", $search_all);
+		echo "<form method='GET' name='frm_search' action=''>\n";
+		echo "	<input class='formfld' type='text' name='search_all' value=\"$search_all\">\n";
+		echo "	<input type='hidden' name='id' value='$schema_uuid'>\n";
+		echo "	<input type='hidden' name='data_parent_row_uuid' value='$data_parent_row_uuid'>\n";
+		echo "	<input class='btn' type='submit' name='submit' value='".$text['button-search_all']."'>\n";
+		echo "</form>\n";
+	}
+	echo "	</td>\n";
+	echo "  </tr>\n";
+	echo "</table>\n";
+	echo "<br />";
+
+//prepare for paging the results
+	require_once "resources/paging.php";
+	$rows_per_page = 100;
+	$param = "";
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
+	if (strlen($schema_parent_uuid) > 0) {
+		$param = "&id=$schema_parent_uuid&data_row_uuid=$data_row_uuid";
+	}
+	else {
+		$param = "&id=$schema_uuid&data_row_uuid=$data_row_uuid";
+	}
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
+	$offset = $rows_per_page * $page;
+
+//list the data in the database
+	$sql = "select * from memory_table \n";
+	$sql .= "where domain_uuid = '$domain_uuid' \n";
+	$sql .= "limit $rows_per_page offset $offset \n";
+	//$sql .= "order by field_order asc \n";
+	$prep_statement = $db_memory->prepare($sql);
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
+
+//begin the list
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	foreach($result_names as $row) {
+		if ($row['field_list_hidden'] != "hide") {
+			echo "<th valign='top' nowrap>&nbsp; ".$row['field_label']." &nbsp;</th>\n";
+		}
+	}
+	echo "<td class='list_control_icons'>";
+	if (permission_exists('schema_data_add')) {
+		echo "<a href='schema_data_edit.php?schema_uuid=".$schema_uuid."&data_parent_row_uuid=$data_parent_row_uuid' alt='".$text['button-add']."'>$v_link_label_add</a>";
+	}
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	$db_values = '';
+	$x = 0;
+	foreach ($result as &$row) {
+		echo "<tr>\n";
+		foreach($result_names as $row2) {
+			$field_name = $row2[field_name];
+
+			//get the values from the array and set as php variables
+				$field_label = $name_array[$field_name]['field_label'];
+				$field_type = $name_array[$field_name]['field_type'];
+				$field_list_hidden = $name_array[$field_name]['field_list_hidden'];
+				$field_column = $name_array[$field_name]['field_column'];
+				$field_required = $name_array[$field_name]['field_required'];
+				$field_order = $name_array[$field_name]['field_order'];
+				$field_order_tab = $name_array[$field_name]['field_order_tab'];
+				$field_description = $name_array[$field_name]['field_description'];
+
+			if ($field_list_hidden != "hide") {
+				switch ($field_type) {
+					case "textarea":
+						$tmp_value = str_replace("\n", "<br />\n", $row[$field_name]);
+						echo "<td valign='top' class='".$row_style[$c]."'>".$tmp_value."&nbsp;</td>\n";
+						unset($tmp_value);
+						break;
+					case "email":
+						echo "<td valign='top' class='".$row_style[$c]."'><a href='mailto:".$row[$field_name]."'>".$row[$field_name]."</a>&nbsp;</td>\n";
+						break;
+					case "phone":
+						$tmp_phone = $row[$field_name];
+						$tmp_phone = format_phone($tmp_phone);
+						echo "<td valign='top' class='".$row_style[$c]."'>".$tmp_phone."&nbsp;</td>\n";
+						break;
+					case "url":
+						$url = $row[$field_name];
+						if (substr($url,0,4) != "http") {
+							$url = 'http://'.$url;
+						}
+						echo "<td valign='top' class='".$row_style[$c]."'><a href='".$url."' target='_blank'>".$row[$field_name]."</a>&nbsp;</td>\n";
+						break;
+					default:
+						echo "<td valign='top' class='".$row_style[$c]."'>".$row[$field_name]."&nbsp;</td>\n";
+						break;
+				}
+			}
+		}
+
+		echo "<td class='list_control_icons'>";
+		if (permission_exists('schema_data_edit')) {
+			if (strlen($data_parent_row_uuid) == 0) {
+				echo "<a href='schema_data_edit.php?schema_uuid=".$row["schema_uuid"]."&data_parent_row_uuid=$data_parent_row_uuid&data_row_uuid=".$row['data_row_uuid']."&search_all=$search_all' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
+			}
+			else {
+				echo "<a href='schema_data_edit.php?schema_uuid=".$row["schema_uuid"]."&data_parent_row_uuid=$data_parent_row_uuid&data_row_uuid=".$row['data_row_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
+			}
+		}
+		if (permission_exists('schema_delete')) {
+			echo"<a href='schema_delete.php?data_row_uuid=".$row['data_row_uuid']."&data_parent_row_uuid=$data_parent_row_uuid&schema_uuid=".$schema_uuid."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
+		}
+		echo "</td>\n";
+
+		echo "</tr>\n";
+		if ($c==0) { $c=1; } else { $c=0; }
+	}
+
+//show the paging tools and final add button
+	echo "<tr>\n";
+	echo "<td colspan='999' align='left'>\n";
+	echo "	<table border='0' width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td class='list_control_icons'>";
+	if (permission_exists('schema_data_add')) {
+		echo "<a href='schema_data_edit.php?schema_uuid=".$schema_uuid."&data_parent_row_uuid=$data_parent_row_uuid' alt='".$text['button-add']."'>$v_link_label_add</a>";
+	}
+	echo "		</td>\n";
+	echo "	</tr>\n";
+	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "</table>\n";
+	echo "<br><br>\n";
+    echo "</div>";
+
+//show the header
+    echo "<br><br>";
+    require_once "resources/footer.php";
+
+?>

+ 60 - 0
schemas/schema_delete.php

@@ -0,0 +1,60 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_delete')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//get the http get variable
+	if (count($_GET)>0) {
+		$id = check_str($_GET["id"]);
+	}
+
+if (strlen($id) > 0) {
+	$sql = "delete from v_schemas ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and schema_uuid = '$id' ";
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	unset($sql);
+}
+
+//redirect the user
+	$_SESSION["message"] = $text['message-delete'];
+	header("Location: schemas.php");
+	return;
+
+?>

+ 318 - 0
schemas/schema_edit.php

@@ -0,0 +1,318 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_add') || permission_exists('schema_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";
+		$schema_uuid = check_str($_REQUEST["id"]);
+	}
+	else {
+		$action = "add";
+	}
+
+//get the http post variables
+	if (count($_POST)>0) {
+		$schema_category = check_str($_POST["schema_category"]);
+		$schema_category_other = check_str($_POST["schema_category_other"]);
+		if (strlen($schema_category_other) > 0) { $schema_category = $schema_category_other; }
+		$schema_label = check_str($_POST["schema_label"]);
+		$schema_name = check_str($_POST["schema_name"]);
+		$schema_auth = check_str($_POST["schema_auth"]);
+		$schema_captcha = check_str($_POST["schema_captcha"]);
+		$schema_parent_uuid = check_str($_POST["schema_parent_uuid"]);
+		$schema_description = check_str($_POST["schema_description"]);
+	}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+	if ($action == "update") {
+		$schema_uuid = check_str($_POST["schema_uuid"]);
+	}
+
+	//check for all required data
+		if (strlen($schema_name) == 0) { $msg .= $text['message-required'].$text['label-schema_name']."<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "resources/header.php";
+			require_once "resources/persist_form_var.php";
+			echo "<div align='center'>\n";
+			echo "<table><tr><td>\n";
+			echo $msg."<br />";
+			echo "</td></tr></table>\n";
+			persistformvar($_POST);
+			echo "</div>\n";
+			require_once "resources/footer.php";
+			return;
+		}
+
+	//add or update the database
+		if ($_POST["persistformvar"] != "true") {
+			if ($action == "add") {
+				$schema_uuid = uuid();
+				$sql = "insert into v_schemas ";
+				$sql .= "(";
+				$sql .= "domain_uuid, ";
+				$sql .= "schema_uuid, ";
+				$sql .= "schema_category, ";
+				$sql .= "schema_label, ";
+				$sql .= "schema_name, ";
+				$sql .= "schema_auth, ";
+				$sql .= "schema_captcha, ";
+				$sql .= "schema_parent_uuid, ";
+				$sql .= "schema_description ";
+				$sql .= ")";
+				$sql .= "values ";
+				$sql .= "(";
+				$sql .= "'$domain_uuid', ";
+				$sql .= "'$schema_uuid', ";
+				$sql .= "'$schema_category', ";
+				$sql .= "'$schema_label', ";
+				$sql .= "'$schema_name', ";
+				$sql .= "'$schema_auth', ";
+				$sql .= "'$schema_captcha', ";
+				if (strlen($schema_parent_uuid) == 0) {
+					$sql .= "null, ";
+				}
+				else {
+					$sql .= "'$schema_parent_uuid', ";
+				}
+				$sql .= "'$schema_description' ";
+				$sql .= ")";
+				$db->exec(check_sql($sql));
+				unset($sql);
+
+				$_SESSION["message"] = $text['message-add'];
+				header("Location: schemas.php");
+				return;
+			} //if ($action == "add")
+
+			if ($action == "update") {
+				$sql = "update v_schemas set ";
+				$sql .= "domain_uuid = '$domain_uuid', ";
+				$sql .= "schema_category = '$schema_category', ";
+				$sql .= "schema_label = '$schema_label', ";
+				$sql .= "schema_name = '$schema_name', ";
+				$sql .= "schema_auth = '$schema_auth', ";
+				$sql .= "schema_captcha = '$schema_captcha', ";
+				if (strlen($schema_parent_uuid) == 0) {
+					$sql .= "schema_parent_uuid = null, ";
+				}
+				else {
+					$sql .= "schema_parent_uuid = '$schema_parent_uuid', ";
+				}
+				$sql .= "schema_description = '$schema_description' ";
+				$sql .= "where schema_uuid = '$schema_uuid'";
+				$db->exec(check_sql($sql));
+				unset($sql);
+
+				$_SESSION["message"] = $text['message-update'];
+				header("Location: schemas.php");
+				return;
+			} //if ($action == "update")
+		} //if ($_POST["persistformvar"] != "true")
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+	if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+		$schema_uuid = $_GET["id"];
+		$sql = "select * from v_schemas ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and schema_uuid = '$schema_uuid' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$schema_category = $row["schema_category"];
+			$schema_label = $row["schema_label"];
+			$schema_name = $row["schema_name"];
+			$schema_auth = $row["schema_auth"];
+			$schema_captcha = $row["schema_captcha"];
+			$schema_parent_uuid = $row["schema_parent_uuid"];
+			$schema_description = $row["schema_description"];
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+
+//show the header
+	require_once "resources/header.php";
+	$document['title'] = $text['title-schema'];
+
+//show the content
+	echo "<form method='post' name='frm' action=''>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo "<td align='left' width='30%' nowrap='nowrap'><b>".$text['header-schema']."</b></td>\n";
+	echo "<td width='70%' align='right'>\n";
+	echo "	<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='schemas.php'\" value='".$text['button-back']."'>\n";
+	if (strlen($schema_uuid) > 0) {
+		echo "	<input type='button' class='btn' name='' alt='".$text['button-view']."' onclick=\"window.location='schema_data_view.php?id=".$row["schema_uuid"]."'\" value='".$text['button-view']."'>\n";
+		echo "	<input type='button' class='btn' name='' alt='".$text['button-import']."' onclick=\"window.location='schema_import.php?id=".$row["schema_uuid"]."'\" value='".$text['button-import']."'>\n";
+	}
+	include "export/index.php";
+	echo "	<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td align=\"left\" colspan='2'>\n";
+	echo $text['description-schema']."<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "	".$text['label-category']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	$select_name = 'v_schemas';$field_name = 'schema_category';$sql_where_optional = "";$field_current_value = $schema_category;
+	echo html_select_other($db, $select_name, $field_name, $sql_where_optional, $field_current_value);
+	echo $text['description-category']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "	".$text['label-label']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='schema_label' maxlength='255' value=\"$schema_label\">\n";
+	echo "<br />\n";
+	echo $text['description-label']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "	".$text['label-name']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='schema_name' maxlength='255' value=\"$schema_name\">\n";
+	echo "<br />\n";
+	echo $text['description-name']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "	".$text['label-authentication']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<select class='formfld' name='schema_auth'>\n";
+	echo "	<option value=''></option>\n";
+	if ($schema_auth == "yes") {
+		echo "	<option value='yes' SELECTED >".$text['option-true']."</option>\n";
+	}
+	else {
+		echo "	<option value='yes'>".$text['option-true']."</option>\n";
+	}
+	if ($schema_auth == "no") {
+		echo "	<option value='no' SELECTED >".$text['option-false']."</option>\n";
+	}
+	else {
+		echo "	<option value='no'>".$text['option-false']."</option>\n";
+	}
+	echo "	</select>\n";
+	echo "<br />\n";
+	echo $text['description-authentication']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "	".$text['label-parent_schema']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+
+	echo "			<select name='schema_parent_uuid' class='formfld'>\n";
+	echo "			<option value=''></option>\n";
+	$sql = "select * from v_schemas ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and schema_name not like '".$schema_name."'";
+	$prep_statement = $db->prepare($sql);
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	foreach ($result as &$row) {
+		if ($row["schema_uuid"] == $schema_parent_uuid) {
+			echo "			<option value='".$row["schema_uuid"]."' selected>".$row["schema_name"]."</option>\n";
+		}
+		else {
+			echo "			<option value='".$row["schema_uuid"]."'>".$row["schema_name"]."</option>\n";
+		}
+	}
+	echo "			</select>\n";
+
+	echo "<br />\n";
+	echo $text['description-parent_schema']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "	".$text['label-description']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<textarea class='formfld' name='schema_description' rows='4'>$schema_description</textarea>\n";
+	echo "<br />\n";
+	echo $text['description-description']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	if ($action == "update") {
+		echo "		<input type='hidden' name='schema_uuid' value='$schema_uuid'>\n";
+	}
+	echo "			<input type='hidden' name='schema_captcha' value='$schema_captcha'>\n";
+	echo "			<br>";
+	echo "			<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "<br><br>";
+	echo "</form>";
+
+	if ($action == "update") {
+		require "schema_fields.php";
+	}
+
+
+//show the footer
+	require_once "resources/footer.php";
+?>

+ 62 - 0
schemas/schema_field_delete.php

@@ -0,0 +1,62 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_delete')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//get the http values
+	if (count($_GET) > 0) {
+		$id = check_str($_GET["id"]);
+		$schema_uuid = check_str($_GET["schema_uuid"]);
+	}
+
+//delete the data
+	if (strlen($id) > 0) {
+		$sql = "delete from v_schema_fields ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and schema_field_uuid = '$id' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		unset($sql);
+	}
+
+//redirect the user
+	$_SESSION["message"] = $text['message-delete'];
+	header("Location: schema_edit.php?id=".$schema_uuid);
+	return;
+
+?>

+ 514 - 0
schemas/schema_field_edit.php

@@ -0,0 +1,514 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_add') || permission_exists('schema_edit')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//set the action as an add or update
+if (isset($_REQUEST["id"])) {
+	$action = "update";
+	$schema_field_uuid = check_str($_REQUEST["id"]);
+}
+else {
+	$action = "add";
+}
+
+//get the http variables
+	if (strlen($_GET["schema_uuid"]) > 0) {
+		$schema_uuid = check_str($_GET["schema_uuid"]);
+	}
+
+//get the http post variables
+if (count($_POST)>0) {
+	$field_label = check_str($_POST["field_label"]);
+	$field_name = check_str($_POST["field_name"]);
+	$field_type = check_str($_POST["field_type"]);
+	$field_value = check_str($_POST["field_value"]);
+	$field_list_hidden = check_str($_POST["field_list_hidden"]);
+	$field_search_by = check_str($_POST["field_search_by"]);
+	$field_column = check_str($_POST["field_column"]);
+	$field_required = check_str($_POST["field_required"]);
+	$field_order = check_str($_POST["field_order"]);
+	$field_order_tab = check_str($_POST["field_order_tab"]);
+	$field_description = check_str($_POST["field_description"]);
+}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+	if ($action == "update") {
+		$schema_field_uuid = check_str($_POST["schema_field_uuid"]);
+	}
+
+	//check for all required data
+		if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
+		if (strlen($field_name) == 0 && $field_type != "label") { $msg .= $text['message-required'].$text['label-field_name']."<br>\n"; }
+		if (strlen($field_type) == 0) { $msg .= $text['message-required'].$text['label-field_type']."<br>\n"; }
+		if (strlen($field_list_hidden) == 0) { $msg .= $text['message-required'].$text['label-field_visibility']."<br>\n"; }
+		if (strlen($field_column) == 0) { $msg .= $text['message-required'].$text['label-field_column']."<br>\n"; }
+		if (strlen($field_required) == 0) { $msg .= $text['message-required'].$text['label-field_required']."<br>\n"; }
+		if (strlen($field_order) == 0) { $msg .= $text['message-required'].$text['label-field_order']."<br>\n"; }
+		if (strlen($field_order_tab) == 0) { $msg .= $text['message-required'].$text['label-field_tab_order']."<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "resources/header.php";
+			require_once "resources/persist_form_var.php";
+			echo "<div align='center'>\n";
+			echo "<table><tr><td>\n";
+			echo $msg."<br />";
+			echo "</td></tr></table>\n";
+			persistformvar($_POST);
+			echo "</div>\n";
+			require_once "resources/footer.php";
+			return;
+		}
+
+	//add or update the database
+	if ($_POST["persistformvar"] != "true") {
+		if ($action == "add" && permission_exists('schema_add')) {
+			$schema_field_uuid = uuid();
+			$sql = "insert into v_schema_fields ";
+			$sql .= "(";
+			$sql .= "domain_uuid, ";
+			$sql .= "schema_uuid, ";
+			$sql .= "schema_field_uuid, ";
+			$sql .= "field_label, ";
+			$sql .= "field_name, ";
+			$sql .= "field_type, ";
+			$sql .= "field_value, ";
+			$sql .= "field_list_hidden, ";
+			$sql .= "field_search_by, ";
+			$sql .= "field_column, ";
+			$sql .= "field_required, ";
+			$sql .= "field_order, ";
+			$sql .= "field_order_tab, ";
+			$sql .= "field_description ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'$domain_uuid', ";
+			$sql .= "'$schema_uuid', ";
+			$sql .= "'$schema_field_uuid', ";
+			$sql .= "'$field_label', ";
+			$sql .= "'$field_name', ";
+			$sql .= "'$field_type', ";
+			$sql .= "'$field_value', ";
+			$sql .= "'$field_list_hidden', ";
+			$sql .= "'$field_search_by', ";
+			$sql .= "'$field_column', ";
+			$sql .= "'$field_required', ";
+			$sql .= "'$field_order', ";
+			$sql .= "'$field_order_tab', ";
+			$sql .= "'$field_description' ";
+			$sql .= ")";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			$_SESSION["message"] = $text['message-add'];
+			header("Location: schema_edit.php?id=".$schema_uuid);
+			return;
+		} //if ($action == "add")
+
+		if ($action == "update" && permission_exists('schema_edit')) {
+			$sql = "update v_schema_fields set ";
+			$sql .= "field_label = '$field_label', ";
+			$sql .= "field_name = '$field_name', ";
+			$sql .= "field_type = '$field_type', ";
+			$sql .= "field_value = '$field_value', ";
+			$sql .= "field_list_hidden = '$field_list_hidden', ";
+			$sql .= "field_search_by = '$field_search_by', ";
+			$sql .= "field_column = '$field_column', ";
+			$sql .= "field_required = '$field_required', ";
+			$sql .= "field_order = '$field_order', ";
+			$sql .= "field_order_tab = '$field_order_tab', ";
+			$sql .= "field_description = '$field_description' ";
+			$sql .= "where domain_uuid = '$domain_uuid' ";
+			$sql .= "and schema_uuid = '$schema_uuid'";
+			$sql .= "and schema_field_uuid = '$schema_field_uuid' ";
+			$db->exec(check_sql($sql));
+			unset($sql);
+
+			$_SESSION["message"] = $text['message-update'];
+			header("Location: schema_edit.php?id=".$schema_uuid);
+			return;
+		} //if ($action == "update")
+	} //if ($_POST["persistformvar"] != "true")
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+	if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+		$schema_uuid = $_GET["schema_uuid"];
+		$schema_field_uuid = $_GET["id"];
+
+		$sql = "select * from v_schema_fields ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and schema_uuid = '$schema_uuid' ";
+		$sql .= "and schema_field_uuid = '$schema_field_uuid' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$field_label = $row["field_label"];
+			$field_name = $row["field_name"];
+			$field_type = $row["field_type"];
+			$field_value = $row["field_value"];
+			$field_list_hidden = $row["field_list_hidden"];
+			$field_search_by = $row["field_search_by"];
+			$field_column = $row["field_column"];
+			$field_required = $row["field_required"];
+			$field_order = $row["field_order"];
+			$field_order_tab = $row["field_order_tab"];
+			$field_description = $row["field_description"];
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+
+//show the header
+	require_once "resources/header.php";
+	$document['title'] = $text['title-field'];
+
+//begin the content
+	echo "<form method='post' name='frm' action=''>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo "<td align='left' width='30%' nowrap=\"nowrap\"><b>".$text['header-field']."</b></td>\n";
+	echo "<td width='70%' align='right'>";
+	echo "	<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='schema_edit.php?id=$schema_uuid'\" value='".$text['button-back']."'>";
+	echo "	<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td align=\"left\" colspan=\"2\">\n";
+	echo $text['description-field']."<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_label']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='field_label' maxlength='255' value=\"$field_label\">\n";
+	echo "<br />\n";
+	echo $text['description-field_label']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_name']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='field_name' maxlength='255' value=\"$field_name\">\n";
+	echo "<br />\n";
+	echo $text['description-field_name']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_type']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<select class='formfld' name='field_type'>\n";
+	echo "	<option value=''></option>\n";
+	if ($field_type == "text") {
+		echo "	<option value='text' selected='selected'>".$text['option-text']."</option>\n";
+	}
+	else {
+		echo "	<option value='text'>".$text['option-text']."</option>\n";
+	}
+	if ($field_type == "numeric") {
+		echo "	<option value='numeric' selected='selected'>".$text['option-number']."</option>\n";
+	}
+	else {
+		echo "	<option value='numeric'>".$text['option-number']."</option>\n";
+	}
+	if ($field_type == "date") {
+		echo "	<option value='date' selected='selected'>".$text['option-date']."</option>\n";
+	}
+	else {
+		echo "	<option value='date'>".$text['option-date']."</option>\n";
+	}
+	if ($field_type == "email") {
+		echo "	<option value='email' selected='selected'>".$text['option-email']."</option>\n";
+	}
+	else {
+		echo "	<option value='email'>".$text['option-email']."</option>\n";
+	}
+	if ($field_type == "label") {
+		echo "	<option value='label' selected='selected'>".$text['option-label']."</option>\n";
+	}
+	else {
+		echo "	<option value='label'>".$text['option-label']."</option>\n";
+	}
+	if ($field_type == "phone") {
+		echo "	<option value='phone' selected='selected'>".$text['option-phone']."</option>\n";
+	}
+	else {
+		echo "	<option value='phone'>".$text['option-phone']."</option>\n";
+	}
+	if ($field_type == "checkbox") {
+		echo "	<option value='checkbox' selected='selected'>".$text['option-check_box']."</option>\n";
+	}
+	else {
+		echo "	<option value='checkbox'>".$text['option-check_box']."</option>\n";
+	}
+	if ($field_type == "textarea") {
+		echo "	<option value='textarea' selected='selected'>".$text['option-text_area']."</option>\n";
+	}
+	else {
+		echo "	<option value='textarea'>".$text['option-text_area']."</option>\n";
+	}
+	if ($field_type == "select") {
+		echo "	<option value='select' selected='selected'>".$text['option-select']."</option>\n";
+	}
+	else {
+		echo "	<option value='select'>".$text['option-select']."</option>\n";
+	}
+	if ($field_type == "hidden") {
+		echo "	<option value='hidden' selected='selected'>".$text['option-hidden']."</option>\n";
+	}
+	else {
+		echo "	<option value='hidden'>".$text['option-hidden']."</option>\n";
+	}
+	if ($field_type == "uuid") {
+		echo "	<option value='uuid' selected='selected'>".$text['option-uuid']."</option>\n";
+	}
+	else {
+		echo "	<option value='uuid'>".$text['option-uuid']."</option>\n";
+	}
+	if ($field_type == "password") {
+		echo "	<option value='password' selected='selected'>".$text['option-password']."</option>\n";
+	}
+	else {
+		echo "	<option value='password'>".$text['option-password']."</option>\n";
+	}
+	if ($field_type == "pin_number") {
+		echo "	<option value='pin_number' selected='selected'>".$text['option-pin_number']."</option>\n";
+	}
+	else {
+		echo "	<option value='pin_number'>".$text['option-pin_number']."</option>\n";
+	}
+	if ($field_type == "image") {
+		echo "	<option value='image' selected='selected'>".$text['option-image_upload']."</option>\n";
+	}
+	else {
+		echo "	<option value='image'>".$text['option-image_upload']."</option>\n";
+	}
+	if ($field_type == "file") {
+		echo "	<option value='upload_file' selected='selected'>".$text['option-file_upload']."</option>\n";
+	}
+	else {
+		echo "	<option value='file'>".$text['option-file_upload']."</option>\n";
+	}
+	if ($field_type == "url") {
+		echo "	<option value='url' selected='selected'>".$text['option-url']."</option>\n";
+	}
+	else {
+		echo "	<option value='url'>".$text['option-url']."</option>\n";
+	}
+	if ($field_type == "mod_date") {
+		echo "	<option value='mod_date' selected='selected'>".$text['option-modified_date']."</option>\n";
+	}
+	else {
+		echo "	<option value='mod_date'>".$text['option-modified_date']."</option>\n";
+	}
+	if ($field_type == "mod_user") {
+		echo "	<option value='mod_user' selected='selected'>".$text['option-modified_user']."</option>\n";
+	}
+	else {
+		echo "	<option value='mod_user'>".$text['option-modified_user']."</option>\n";
+	}
+	echo "	</select>\n";
+	echo "<br />\n";
+	echo $text['description-field_type']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_value']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='field_value' maxlength='255' value=\"$field_value\">\n";
+	echo "<br />\n";
+	echo $text['description-field_value']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_visibility']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<select class='formfld' name='field_list_hidden'>\n";
+	echo "	<option value=''></option>\n";
+	if ($field_list_hidden == "show") {
+		echo "	<option value='show'  selected='selected'>".$text['option-visible']."</option>\n";
+	}
+	else {
+		echo "	<option value='show'>".$text['option-visible']."</option>\n";
+	}
+	if ($field_list_hidden == "hide") {
+		echo "	<option value='hide'  selected='selected'>".$text['option-hidden']."</option>\n";
+	}
+	else {
+		echo "	<option value='hide'>".$text['option-hidden']."</option>\n";
+	}
+	echo "	</select>\n";
+	echo "<br />\n";
+	echo $text['description-field_visibility']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_search_by']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<select class='formfld' name='field_search_by'>\n";
+	echo "	<option value=''></option>\n";
+	if ($field_search_by == "yes") {
+		echo "	<option value='yes'  selected='selected'>".$text['option-true']."</option>\n";
+	}
+	else {
+		echo "	<option value='yes'>".$text['option-true']."</option>\n";
+	}
+	if ($field_search_by == "no") {
+		echo "	<option value='no' selected='selected'>".$text['option-false']."</option>\n";
+	}
+	else {
+		echo "	<option value='no'>".$text['option-false']."</option>\n";
+	}
+	echo "	</select>\n";
+	echo "<br />\n";
+	echo $text['description-field_search_by']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_column']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='field_column' maxlength='255' value=\"$field_column\">\n";
+	echo "<br />\n";
+	echo $text['description-field_column']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_required']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<select class='formfld' name='field_required'>\n";
+	echo "	<option value=''></option>\n";
+	if ($field_required == "yes") {
+		echo "	<option value='yes'  selected='selected'>".$text['option-true']."</option>\n";
+	}
+	else {
+		echo "	<option value='yes'>".$text['option-true']."</option>\n";
+	}
+	if ($field_required == "no") {
+		echo "	<option value='no' selected='selected'>".$text['option-false']."</option>\n";
+	}
+	else {
+		echo "	<option value='no'>".$text['option-false']."</option>\n";
+	}
+	echo "	</select>\n";
+	echo "<br />\n";
+	echo $text['description-field_required']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_order']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "  <input class='formfld' type='text' name='field_order' maxlength='255' value='$field_order'>\n";
+	echo "<br />\n";
+	echo $text['description-field_order']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_tab_order']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "  <input class='formfld' type='text' name='field_order_tab' maxlength='255' value='$field_order_tab'>\n";
+	echo "<br />\n";
+	echo $text['description-field_tab_order']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-field_description']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='field_description' maxlength='255' value=\"$field_description\">\n";
+	echo "<br />\n";
+	echo $text['description-field_description']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	echo "			<input type='hidden' name='schema_uuid' value='$schema_uuid'>\n";
+	if ($action == "update") {
+		echo "		<input type='hidden' name='schema_field_uuid' value='$schema_field_uuid'>\n";
+	}
+	echo "			<br>";
+	echo "			<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "<br><br>";
+	echo "</form>";
+
+	if ($action == "update") {
+		if ($field_type == "select") {
+			require "schema_name_values.php";
+		}
+	}
+
+//show the footer
+	require_once "resources/footer.php";
+?>

+ 202 - 0
schemas/schema_fields.php

@@ -0,0 +1,202 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_view')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//require_once "resources/header.php";
+require_once "resources/paging.php";
+
+$order_by = $_GET["order_by"];
+$order = $_GET["order"];
+
+//show the content
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr class='border'>\n";
+	echo "	<td align=\"center\">\n";
+	echo "		<br>";
+
+	echo "<table width='100%' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' align=\"left\" nowrap=\"nowrap\"><b>".$text['header-fields']."</b></td>\n";
+	echo "<td width='50%'  align=\"right\">&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td align=\"left\" colspan=\"2\">\n";
+	echo $text['description-fields']."<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</table>\n";
+
+	if (strlen($order_by) == 0) {
+		$order_by = 'field_order';
+		$order = 'asc';
+	}
+
+	$sql = "select * from v_schema_fields ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and schema_uuid = '$schema_uuid' ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$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 "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo th_order_by('field_label', $text['label-field_label'], $order_by, $order);
+	echo th_order_by('field_name', $text['label-field_name'], $order_by, $order);
+	echo th_order_by('field_type', $text['label-field_type'], $order_by, $order);
+	echo th_order_by('field_column', $text['label-field_column'], $order_by, $order);
+	echo th_order_by('field_required', $text['label-field_required'], $order_by, $order);
+	echo th_order_by('field_list_hidden', $text['label-field_visibility'], $order_by, $order);
+	echo th_order_by('field_search_by', $text['label-field_search_by'], $order_by, $order);
+	echo th_order_by('field_order', $text['label-field_order'], $order_by, $order);
+	echo th_order_by('field_order_tab', $text['label-field_tab_order'], $order_by, $order);
+	echo th_order_by('field_description', $text['label-field_description'], $order_by, $order);
+	echo "<td class='list_control_icons'>";
+	if (permission_exists('schema_view')) {
+		echo "<a href='schema_field_edit.php?schema_uuid=".$schema_uuid."' alt='".$text['button-add']."'>$v_link_label_add</a>";
+	}
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	if ($result_count > 0) {
+		foreach($result as $row) {
+			$tr_link = (permission_exists('schema_edit')) ? "href='schema_field_edit.php?schema_uuid=".$row['schema_uuid']."&id=".$row['schema_field_uuid']."'" : null;
+			echo "<tr ".$tr_link.">\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['field_label']."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>";
+			if (permission_exists('schema_edit')) {
+				echo "<a href='schema_field_edit.php?schema_uuid=".$row['schema_uuid']."&id=".$row['schema_field_uuid']."'>".$row['field_name']."</a>";
+			}
+			else {
+				echo $row['field_name'];
+			}
+			echo "	</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>";
+			switch ($row['field_type']) {
+				case "text" : echo $text['option-text']; break;
+				case "numeric" : echo $text['option-number']; break;
+				case "date" : echo $text['option-date']; break;
+				case "email" : echo $text['option-email']; break;
+				case "label" : echo $text['option-label']; break;
+				case "phone" : echo $text['option-phone']; break;
+				case "checkbox" : echo $text['option-check_box']; break;
+				case "textarea" : echo $text['option-text_area']; break;
+				case "select" : echo $text['option-select']; break;
+				case "hidden" : echo $text['option-hidden']; break;
+				case "uuid" : echo $text['option-uuid']; break;
+				case "password" : echo $text['option-password']; break;
+				case "pin_number" : echo $text['option-pin_number']; break;
+				case "image" : echo $text['option-image_upload']; break;
+				case "upload_file" : echo $text['option-file_upload']; break;
+				case "url" : echo $text['option-url']; break;
+				case "mod_date" : echo $text['option-modified_date']; break;
+				case "mod_user" : echo $text['option-modified_user']; break;
+				default : echo $row['field_type'];
+			}
+			echo "	</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['field_column']."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>";
+			if ($row['field_required'] == 'yes') {
+				echo $text['option-true'];
+			}
+			else if ($row['field_required'] == 'no') {
+				echo $text['option-false'];
+			}
+			echo "	</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>";
+			if ($row['field_list_hidden'] == 'show') {
+				echo $text['option-visible'];
+			}
+			else if ($row['field_list_hidden'] == 'hide') {
+				echo $text['option-hidden'];
+			}
+			echo "	</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>";
+			if ($row['field_search_by'] == 'yes') {
+				echo $text['option-true'];
+			}
+			else if ($row['field_search_by'] == 'no') {
+				echo $text['option-false'];
+			}
+			echo "	</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['field_order']."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['field_order_tab']."</td>\n";
+			echo "	<td valign='top' class='row_stylebg'>".$row['field_description']."&nbsp;</td>\n";
+			echo "	<td class='list_control_icons'>";
+			if (permission_exists('schema_edit')) {
+				echo "<a href='schema_field_edit.php?schema_uuid=".$row['schema_uuid']."&id=".$row['schema_field_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
+			}
+			if (permission_exists('schema_delete')) {
+				echo "<a href='schema_field_delete.php?schema_uuid=".$row['schema_uuid']."&id=".$row['schema_field_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
+			}
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+	echo "<tr>\n";
+	echo "<td colspan='11' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>&nbsp;</td>\n";
+	echo "		<td class='list_control_icons'>";
+	if (permission_exists('schema_add')) {
+		echo 		"<a href='schema_field_edit.php?schema_uuid=".$schema_uuid."' alt='".$text['button-add']."'>$v_link_label_add</a>";
+	}
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</table>";
+
+	echo "</td>";
+	echo "</tr>";
+	echo "</table>";
+	echo "<br><br>";
+
+//include the footer
+//	require_once "resources/footer.php";
+
+?>

+ 369 - 0
schemas/schema_import.php

@@ -0,0 +1,369 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+include "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_edit')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+if (count($_POST)>0) {
+	$schema_uuid = trim($_REQUEST["id"]);
+	$data = trim($_POST["data"]);
+	$data_delimiter = trim($_POST["data_delimiter"]);
+	$data_enclosure = trim($_POST["data_enclosure"]);
+}
+
+//define the php class
+	class v_schema_fields {
+		var $domain_uuid;
+		var $schema_uuid;
+		var $field_label;
+		var $field_name;
+		var $field_type;
+		var $field_value;
+		var $field_list_hidden;
+		var $field_column;
+		var $field_required;
+		var $field_order;
+		var $field_order_tab;
+		var $field_description;
+
+		function db_field_exists() {
+			global $db;
+			$sql = "select count(*) as num_rows from v_schema_fields ";
+			$sql .= "where domain_uuid = '$this->domain_uuid' ";
+			$sql .= "and schema_uuid ='$this->schema_uuid' ";
+			$sql .= "and field_name = '$this->field_name' ";
+			$prep_statement = $db->prepare($sql);
+			if ($prep_statement) {
+				$prep_statement->execute();
+				$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
+				if ($row['num_rows'] > 0) {
+					return true;
+				}
+				else {
+					return false;
+				}
+			}
+		}
+
+		function db_insert() {
+			global $db;
+			$sql = "insert into v_schema_fields ";
+			$sql .= "(";
+			$sql .= "schema_field_uuid, ";
+			$sql .= "domain_uuid, ";
+			$sql .= "schema_uuid, ";
+			$sql .= "field_label, ";
+			$sql .= "field_name, ";
+			$sql .= "field_type, ";
+			$sql .= "field_value, ";
+			$sql .= "field_list_hidden, ";
+			$sql .= "field_search_by, ";
+			$sql .= "field_column, ";
+			$sql .= "field_required, ";
+			$sql .= "field_order, ";
+			$sql .= "field_order_tab, ";
+			$sql .= "field_description ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'".uuid()."', ";
+			$sql .= "'$this->domain_uuid', ";
+			$sql .= "'$this->schema_uuid', ";
+			$sql .= "'$this->field_label', ";
+			$sql .= "'$this->field_name', ";
+			$sql .= "'$this->field_type', ";
+			$sql .= "'$this->field_value', ";
+			$sql .= "'$this->field_list_hidden', ";
+			$sql .= "'no', ";
+			$sql .= "'$this->field_column', ";
+			$sql .= "'$this->field_required', ";
+			$sql .= "'$this->field_order', ";
+			$sql .= "'$this->field_order_tab', ";
+			$sql .= "'$this->field_description' ";
+			$sql .= ")";
+			if (!$this->db_field_exists()) {
+				$db->exec(check_sql($sql));
+			}
+			unset($sql);
+		}
+	}
+
+	class v_schema_data {
+		var $domain_uuid;
+		var $schema_uuid;
+		var $data_row_uuid;
+		var $field_name;
+		var $data_field_value;
+		var $last_insert_id;
+		var $schema_data_uuid;
+
+		function db_unique_id() {
+			global $db;
+			$sql = "insert into v_schema_data_row_id ";
+			$sql .= "(";
+			$sql .= "domain_uuid ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'$this->domain_uuid' ";
+			$sql .= ")";
+			$db->exec($sql);
+			unset($sql);
+			return $db->lastInsertId($id);
+		}
+
+		function db_insert() {
+			global $db;
+			$sql = "insert into v_schema_data ";
+			$sql .= "(";
+			$sql .= "schema_data_uuid, ";
+			$sql .= "domain_uuid, ";
+			$sql .= "data_row_uuid, ";
+			$sql .= "schema_uuid, ";
+			$sql .= "field_name, ";
+			$sql .= "data_field_value, ";
+			$sql .= "data_add_user, ";
+			$sql .= "data_add_date ";
+			$sql .= ")";
+			$sql .= "values ";
+			$sql .= "(";
+			$sql .= "'".uuid()."', ";
+			$sql .= "'$this->domain_uuid', ";
+			$sql .= "'$this->data_row_uuid', ";
+			$sql .= "'$this->schema_uuid', ";
+			$sql .= "'$this->field_name', ";
+			$sql .= "'$this->data_field_value', ";
+			$sql .= "'".$_SESSION["username"]."', ";
+			$sql .= "now() ";
+			$sql .= ")";
+			$db->exec($sql);
+			$this->last_insert_id = $db->lastInsertId($id);
+			unset($sql);
+		}
+
+		function db_update() {
+			global $db;
+			$sql  = "update v_schema_data set ";
+			$sql .= "data_row_uuid = '$this->data_row_uuid', ";
+			$sql .= "field_name = '$this->field_name', ";
+			$sql .= "data_field_value = '$this->data_field_value', ";
+			$sql .= "data_add_user = '".$_SESSION["username"]."', ";
+			$sql .= "data_add_date = now() ";
+			$sql .= "where domain_uuid = '$this->domain_uuid' ";
+			$sql .= "and schema_data_uuid = '$this->schema_data_uuid' ";
+			$db->exec($sql);
+			unset($sql);
+		}
+	}
+
+//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher
+	if(!function_exists('str_getcsv')) {
+		function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
+			$fp = fopen("php://memory", 'r+');
+			fputs($fp, $input);
+			rewind($fp);
+			$data = fgetcsv($fp, null, $delimiter, $enclosure); // $escape only got added in 5.3.0
+			fclose($fp);
+			return $data;
+		}
+	}
+
+	//POST to PHP variables
+		if (count($_POST)>0) {
+
+			//show the header
+				require_once "resources/header.php";
+				$document['title'] = $text['title-import_results'];
+
+			echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+			echo "<tr>\n";
+			echo "<td width='30%' nowrap='nowrap' align='left' valign='top'><b>".$text['header-import_results']."</b></td>\n";
+			echo "<td width='70%' align='right' valign='top'>\n";
+			echo "	<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='schema_import.php?id=$schema_uuid'\" value='".$text['button-back']."'>\n";
+			echo "	<br /><br />\n";
+			echo "</td>\n";
+			echo "</tr>\n";
+
+			echo "	<tr>\n";
+			echo "		<td colspan='2' align='left'>\n";
+
+			//import data
+				if (strlen($data) > 0) {
+					$line_array = explode("\n",$data);
+					$name_array = explode(",",$line_array[0]);
+					$x = 0;
+					$db->beginTransaction();
+					foreach($name_array as $key => $val) {
+						$field_label = trim($val);
+						$field_name = trim($val);
+						$field_name = str_replace(" ", "_", $field_name);
+						$field_name = str_replace("-", "_", $field_name);
+						$field_name = strtolower($field_name);
+
+						$fields = new v_schema_fields;
+						$fields->domain_uuid = $domain_uuid;
+						$fields->schema_uuid = $schema_uuid;
+						$fields->field_label = $field_label;
+						$fields->field_name = $field_name;
+						$fields->field_type = 'text';
+						$fields->field_value = '';
+						$fields->field_list_hidden = 'show';
+						$fields->field_column = '1';
+						$fields->field_required = 'yes';
+						$fields->field_order = $x;
+						$fields->field_order_tab = $x;
+						$fields->field_description = $field_label;
+						$fields->db_insert();
+						unset($fields);
+						$x++;
+					}
+
+					foreach($line_array as $key => $line) {
+						if ($key > 0) {
+							$value_array = str_getcsv($line, $data_delimiter, $data_enclosure);
+							$x=0;
+							foreach($value_array as $key => $val) {
+
+								$field_label = trim($name_array[$x]);
+								$field_name = trim($name_array[$x]);
+								$field_name = str_replace(" ", "_", $field_name);
+								$field_name = str_replace("-", "_", $field_name);
+								$field_name = strtolower($field_name);
+
+								$field_value = trim($val);
+
+								$data = new v_schema_data;
+								$data->domain_uuid = $domain_uuid;
+								$data->schema_uuid = $schema_uuid;
+								if ($x == 0) {
+									$data_row_uuid = uuid();
+									//echo "id: ".$data_row_uuid."<br />\n";
+								}
+								$data->data_row_uuid = $data_row_uuid;
+								$data->field_name = $field_name;
+								$data->data_field_value = $field_value;
+								$data->db_insert();
+								unset($data);
+
+								echo "<strong>$field_name:</strong> $field_value<br/>\n";
+								$x++;
+							}
+							echo "<hr size='1' />\n";
+						}
+					}
+					$db->commit();
+				} //if (strlen($data) > 0)
+
+			echo "		</td>\n";
+			echo "	</tr>";
+			echo "	</table>";
+			echo "<br><br>";
+
+			//show the footer
+				require_once "resources/footer.php";
+				exit;
+		}
+
+
+//show the header
+	require_once "resources/header.php";
+	$document['title'] = $text['title-import'];
+
+//show the content
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='30%' nowrap='nowrap' align='left' valign='top'><b>".$text['header-import']."</b></td>\n";
+	echo "<td width='70%' align='right' valign='top'>\n";
+	echo "	<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</table>\n";
+
+	echo "<form method='post' name='frm' action=''>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "    ".$text['label-import_data']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "    <textarea name='data' id='data' rows='7' class='formfld' style='width: 100%;' wrap='off'>$data</textarea>\n";
+	echo "<br />\n";
+	echo $text['description-import_data']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "    ".$text['label-import_delimiter']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "    <select class='formfld' style='width: 100px;' name='data_delimiter'>\n";
+	echo "    <option value=','>, (Comma)</option>\n";
+	echo "    <option value='|'>| (Pipe)</option>\n";
+	echo "    </select>\n";
+	echo "<br />\n";
+	echo $text['description-import_delimiter']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
+	echo "    ".$text['label-import_enclosure']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "    <select class='formfld' style='width: 150px;' name='data_enclosure'>\n";
+	echo "    <option value='\"'>\" (Double-Quote)</option>\n";
+	echo "    <option value=''>(Nothing)</option>\n";
+	echo "    </select>\n";
+	echo "<br />\n";
+	echo $text['description-import_enclosure']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	echo "			<br>";
+	echo "			<input type='submit' name='import' class='btn' value='".$text['button-import']."'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "<br><br>";
+	echo "</form>";
+
+require_once "resources/footer.php";
+?>

+ 63 - 0
schemas/schema_name_value_delete.php

@@ -0,0 +1,63 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_delete')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//get the http values
+	if (count($_GET) > 0) {
+		$id = check_str($_GET["id"]);
+		$schema_uuid = check_str($_GET["schema_uuid"]);
+		$schema_field_uuid = check_str($_GET["schema_field_uuid"]);
+	}
+
+//delete the data
+	if (strlen($id) > 0) {
+		$sql .= "delete from v_schema_name_values ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		$sql .= "and schema_name_value_uuid = '$id' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		unset($sql);
+	}
+
+//redirect the user
+	$_SESSION["message"] = $text['message-delete'];
+	header("Location: schema_field_edit.php?schema_uuid=".$schema_uuid."&id=".$schema_field_uuid);
+	return;
+
+?>

+ 220 - 0
schemas/schema_name_value_edit.php

@@ -0,0 +1,220 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_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";
+		$schema_name_value_uuid = check_str($_REQUEST["id"]);
+	}
+	else {
+		$action = "add";
+	}
+
+if (strlen($_GET["schema_field_uuid"]) > 0) {
+	$schema_field_uuid = check_str($_GET["schema_field_uuid"]);
+}
+
+//POST to PHP variables
+	if (count($_POST)>0) {
+		//$domain_uuid = check_str($_POST["domain_uuid"]);
+		$data_types_name = check_str($_POST["data_types_name"]);
+		$data_types_value = check_str($_POST["data_types_value"]);
+		$schema_uuid = $_REQUEST["schema_uuid"];
+		$schema_field_uuid = $_REQUEST["schema_field_uuid"];
+	}
+
+if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+
+	$msg = '';
+	if ($action == "update") {
+		$schema_name_value_uuid = check_str($_POST["schema_name_value_uuid"]);
+	}
+
+	//check for all required data
+		if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
+		if (strlen($schema_uuid) == 0) { $msg .= $text['message-required']."schema_uuid<br>\n"; }
+		if (strlen($schema_field_uuid) == 0) { $msg .= $text['message-required']."schema_field_uuid<br>\n"; }
+		if (strlen($data_types_name) == 0) { $msg .= $text['message-required'].$text['label-name_value_name']."<br>\n"; }
+		if (strlen($data_types_value) == 0) { $msg .= $text['message-required'].$text['label-name_value_value']."<br>\n"; }
+		if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+			require_once "resources/header.php";
+			require_once "resources/persist_form_var.php";
+			echo "<div align='center'>\n";
+			echo "<table><tr><td>\n";
+			echo $msg."<br />";
+			echo "</td></tr></table>\n";
+			persistformvar($_POST);
+			echo "</div>\n";
+			require_once "resources/footer.php";
+			return;
+		}
+
+	//add or update the database
+		if ($_POST["persistformvar"] != "true") {
+			if ($action == "add") {
+				$sql = "insert into v_schema_name_values ";
+				$sql .= "(";
+				$sql .= "schema_name_value_uuid, ";
+				$sql .= "domain_uuid, ";
+				$sql .= "schema_uuid, ";
+				$sql .= "schema_field_uuid, ";
+				$sql .= "data_types_name, ";
+				$sql .= "data_types_value ";
+				$sql .= ") ";
+				$sql .= "values ";
+				$sql .= "(";
+				$sql .= "'".uuid()."', ";
+				$sql .= "'".$_SESSION['domain_uuid']."', ";
+				$sql .= "'$schema_uuid', ";
+				$sql .= "'$schema_field_uuid', ";
+				$sql .= "'$data_types_name', ";
+				$sql .= "'$data_types_value' ";
+				$sql .= ")";
+				$db->exec(check_sql($sql));
+				unset($sql);
+
+				$_SESSION["message"] = $text['message-add'];
+				header("Location: schema_field_edit.php?schema_uuid=".$schema_uuid."&id=".$schema_field_uuid);
+				return;
+			} //if ($action == "add")
+
+			if ($action == "update") {
+				$sql = "update v_schema_name_values set ";
+				$sql .= "data_types_name = '$data_types_name', ";
+				$sql .= "data_types_value = '$data_types_value' ";
+				$sql .= "where domain_uuid = '$domain_uuid' ";
+				$sql .= "and schema_uuid = '$schema_uuid' ";
+				$sql .= "and schema_field_uuid = '$schema_field_uuid' ";
+				$sql .= "and schema_name_value_uuid = '$schema_name_value_uuid' ";
+				$db->exec(check_sql($sql));
+				unset($sql);
+
+				$_SESSION["message"] = $text['message-update'];
+				header("Location: schema_field_edit.php?schema_uuid=".$schema_uuid."&id=".$schema_field_uuid);
+				return;
+			} //if ($action == "update")
+		} //if ($_POST["persistformvar"] != "true")
+} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+
+//pre-populate the form
+	if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
+		$schema_uuid = $_GET["schema_uuid"];
+		$schema_field_uuid = $_GET["schema_field_uuid"];
+		$schema_name_value_uuid = $_GET["id"];
+		$sql = "select * from v_schema_name_values ";
+		$sql .= "where domain_uuid = '$domain_uuid' ";
+		//$sql .= "and schema_uuid = '$schema_uuid' ";
+		$sql .= "and schema_field_uuid = '$schema_field_uuid' ";
+		$sql .= "and schema_name_value_uuid = '$schema_name_value_uuid' ";
+		$prep_statement = $db->prepare(check_sql($sql));
+		$prep_statement->execute();
+		$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+		foreach ($result as &$row) {
+			$data_types_name = $row["data_types_name"];
+			$data_types_value = $row["data_types_value"];
+			break; //limit to 1 row
+		}
+		unset ($prep_statement);
+	}
+
+//show the header
+	require_once "resources/header.php";
+	$document['title'] = $text['title-name_value'];
+
+//show the content
+	echo "<form method='post' name='frm' action=''>\n";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+
+	echo "<tr>\n";
+	if ($action == "add") {
+		echo "<td align='left' width='30%' nowrap=\"nowrap\"><b>".$text['header-name_value']." ".$text['button-add']."</b></td>\n";
+	}
+	if ($action == "update") {
+		echo "<td align='left' width='30%' nowrap=\"nowrap\"><b>".$text['header-name_value']." ".$text['button-edit']."</b></td>\n";
+	}
+	echo "<td width='70%' align=\"right\">";
+	echo "	<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"history.go(-1);return true;\" value='".$text['button-back']."'>";
+	echo "	<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td align=\"left\" colspan='2'>\n";
+	echo $text['description-name_value']."<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-name_value_name']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='data_types_name' maxlength='255' value=\"$data_types_name\">\n";
+	echo "<br />\n";
+	echo $text['description-name_value_name']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "<tr>\n";
+	echo "<td class='vncellreq' valign='top' align='left' nowrap=\"nowrap\">\n";
+	echo "	".$text['label-name_value_value']."\n";
+	echo "</td>\n";
+	echo "<td class='vtable' align='left'>\n";
+	echo "	<input class='formfld' type='text' name='data_types_value' maxlength='255' value=\"$data_types_value\">\n";
+	echo "<br />\n";
+	echo $text['description-name_value_value']."\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "	<tr>\n";
+	echo "		<td colspan='2' align='right'>\n";
+	echo "			<input type='hidden' name='schema_uuid' value='$schema_uuid'>\n";
+	echo "			<input type='hidden' name='schema_field_uuid' value='$schema_field_uuid'>\n";
+	if ($action == "update") {
+		echo "		<input type='hidden' name='schema_name_value_uuid' value='$schema_name_value_uuid'>\n";
+	}
+	echo "			<br>";
+	echo "			<input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
+	echo "		</td>\n";
+	echo "	</tr>";
+	echo "</table>";
+	echo "<br><br>";
+	echo "</form>";
+
+require_once "resources/footer.php";
+?>

+ 133 - 0
schemas/schema_name_values.php

@@ -0,0 +1,133 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_edit')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+require_once "resources/header.php";
+require_once "resources/paging.php";
+
+//get the http values
+	$order_by = $_GET["order_by"];
+	$order = $_GET["order"];
+
+//show the content
+	echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' align=\"left\" nowrap=\"nowrap\"><b>".$text['header-name_values']."</b></td>\n";
+	echo "<td width='50%' align=\"right\">&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td align=\"left\" nowrap=\"nowrap\" colspan='2'>\n";
+	echo $text['description-name_values']."<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</tr></table>\n";
+
+	//$sql = "select * from v_schema_name_values ";
+	//$sql .= "where domain_uuid = '$domain_uuid' ";
+	//$sql .= "and schema_field_uuid = '$schema_field_uuid' ";
+	//if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	//$prep_statement = $db->prepare(check_sql($sql));
+	//$prep_statement->execute();
+	//$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	//$num_rows = count($result);
+	//unset ($prep_statement, $result, $sql);
+	//$rows_per_page = 10;
+	//$param = "";
+	//$page = $_GET['page'];
+	//if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
+	//list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
+	//$offset = $rows_per_page * $page;
+
+	$sql = "select * from v_schema_name_values ";
+	$sql .= "where domain_uuid = '$domain_uuid' ";
+	$sql .= "and schema_field_uuid = '$schema_field_uuid' ";
+	if (strlen($order_by)> 0) { $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 "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo th_order_by('data_types_name', $text['label-name_value_name'], $order_by, $order);
+	echo th_order_by('data_types_value', $text['label-name_value_value'], $order_by, $order);
+	echo "<td align='right' width='42'>\n";
+	echo "	<a href='schema_name_value_edit.php?schema_uuid=".$row["schema_uuid"]."&schema_field_uuid=".$row["schema_field_uuid"]."' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
+	echo "</td>\n";
+	echo "<tr>\n";
+
+	if ($result_count > 0) {
+		foreach($result as $row) {
+			echo "<tr >\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[data_types_name]."</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row[data_types_value]."</td>\n";
+			echo "	<td valign='top' align='right'>\n";
+			echo "		<a href='schema_name_value_edit.php?schema_uuid=".$row["schema_uuid"]."&schema_field_uuid=".$row["schema_field_uuid"]."&id=".$row["schema_name_value_uuid"]."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
+			echo "		<a href='schema_name_value_delete.php?schema_uuid=".$row["schema_uuid"]."&schema_field_uuid=".$row["schema_field_uuid"]."&id=".$row["schema_name_value_uuid"]."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
+			echo "	</td>\n";
+			echo "</tr>\n";
+			$c = ($c==0) ? 1 : 0;
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+	echo "<tr>\n";
+	echo "<td colspan='3' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	//echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td width='33.3%' align='right'>\n";
+	echo "			<a href='schema_name_value_edit.php?schema_uuid=".$row["schema_uuid"]."&schema_field_uuid=".$row["schema_field_uuid"]."' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "</table>";
+	echo "<br><br>";
+	echo "</div>";
+
+//show the footer
+	require_once "resources/footer.php";
+
+?>

+ 172 - 0
schemas/schemas.php

@@ -0,0 +1,172 @@
+<?php
+/*
+	FusionPBX
+	Version: MPL 1.1
+
+	The contents of this file are subject to the Mozilla Public License Version
+	1.1 (the "License"); you may not use this file except in compliance with
+	the License. You may obtain a copy of the License at
+	http://www.mozilla.org/MPL/
+
+	Software distributed under the License is distributed on an "AS IS" basis,
+	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+	for the specific language governing rights and limitations under the
+	License.
+
+	The Original Code is FusionPBX
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+require_once "root.php";
+require_once "resources/require.php";
+require_once "resources/check_auth.php";
+if (permission_exists('schema_view')) {
+	//access granted
+}
+else {
+	echo "access denied";
+	exit;
+}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+require_once "resources/header.php";
+$document['title'] = $text['title-schemas'];
+
+require_once "resources/paging.php";
+
+//get the http get variables
+	$order_by = $_GET["order_by"];
+	$order = $_GET["order"];
+
+//show the content
+
+	echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
+	echo "<tr>\n";
+	echo "<td width='50%' align='left' nowrap='nowrap'><b>".$text['header-schemas']."</b></td>\n";
+	echo "<td width='50%' align='right'>&nbsp;</td>\n";
+	echo "</tr>\n";
+	echo "<tr>\n";
+	echo "<td align='left' colspan='2'>\n";
+	echo $text['description-schemas']."\n";
+	echo "<br /><br />\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</tr></table>\n";
+
+	$sql = " select * from v_schemas ";
+	$sql .= " where domain_uuid = '$domain_uuid' ";
+	if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
+	$prep_statement = $db->prepare(check_sql($sql));
+	$prep_statement->execute();
+	$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+	$num_rows = count($result);
+	unset ($prep_statement, $result, $sql);
+	$rows_per_page = 100;
+	$param = "";
+	$page = $_GET['page'];
+	if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
+	list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
+	$offset = $rows_per_page * $page;
+
+	$sql = " select * from v_schemas ";
+	$sql .= " where domain_uuid = '$domain_uuid' ";
+	if (strlen($order_by)> 0) { $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 "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<tr>\n";
+	echo th_order_by('schema_label', $text['label-label'], $order_by, $order);
+	echo th_order_by('schema_name', $text['label-schema_name'], $order_by, $order);
+	echo th_order_by('schema_auth', $text['label-authentication'], $order_by, $order);
+	echo th_order_by('schema_description', $text['label-description'], $order_by, $order);
+	//echo "<th align='center'>View</th>\n";
+	echo "<td class='list_control_icons'>";
+	if (permission_exists('schema_add')) {
+		echo "<a href='schema_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
+	}
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	if ($result_count == 0) {
+		//no results
+	}
+	else { //received results
+		foreach($result as $row) {
+			$tr_link = (permission_exists('schema_edit')) ? "href='schema_edit.php?id=".$row['schema_uuid']."'" : null;
+			echo "<tr ".$tr_link.">\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['schema_label']."&nbsp;</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>";
+			if (permission_exists('schema_edit')) {
+				echo "<a href='schema_edit.php?id=".$row['schema_uuid']."'>".$row['schema_name']."</a>";
+			}
+			else {
+				echo $row['schema_name'];
+			}
+			echo "	</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'>";
+			if ($row['schema_auth'] == 'yes') {
+				echo $text['option-true'];
+			}
+			else if ($row['schema_auth'] == 'no') {
+				echo $text['option-false'];
+			}
+			else {
+				echo "&nbsp;";
+			}
+			echo "	</td>\n";
+			echo "	<td valign='top' class='row_stylebg'>".$row['schema_description']."&nbsp;</td>\n";
+			echo "	<td class='list_control_icons'>";
+			if (permission_exists('schema_edit')) {
+				echo "<a href='schema_edit.php?id=".$row['schema_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
+			}
+			if (permission_exists('schema_delete')) {
+				echo "<a href='schema_delete.php?id=".$row['schema_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
+			}
+			echo "	</td>\n";
+			echo "</tr>\n";
+			if ($c==0) { $c=1; } else { $c=0; }
+		} //end foreach
+		unset($sql, $result, $row_count);
+	} //end if results
+
+	echo "<tr>\n";
+	echo "<td colspan='6' align='left'>\n";
+	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
+	echo "	<tr>\n";
+	echo "		<td width='33.3%' nowrap>&nbsp;</td>\n";
+	echo "		<td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
+	echo "		<td class='list_control_icons'>";
+	if (permission_exists('schema_add')) {
+		echo 		"<a href='schema_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
+	}
+	echo "		</td>\n";
+	echo "	</tr>\n";
+ 	echo "	</table>\n";
+	echo "</td>\n";
+	echo "</tr>\n";
+
+	echo "</table>";
+	echo "<br><br>";
+
+//show the footer
+	require_once "resources/footer.php";
+
+?>