diff --git a/app/destinations/app_languages.php b/app/destinations/app_languages.php
index a93fab7376..323cd848e4 100644
--- a/app/destinations/app_languages.php
+++ b/app/destinations/app_languages.php
@@ -152,7 +152,6 @@
$text['description-monthly_price']['pt-pt'] = "Digite o preço mensal de conta para este destino (somente quando entrada)";
$text['description-monthly_price']['fr-fr'] = "Entrez prix mensuel de projet de loi pour cette destination (uniquement lorsque entrant)";
-
$text['label-accountcode']['en-us'] = "Account code";
$text['label-accountcode']['es-cl'] = "Código de cuenta";
$text['label-accountcode']['pt-pt'] = "Codigo de cuenta";
@@ -163,7 +162,6 @@
$text['description-accountcode']['pt-pt'] = "";
$text['description-accountcode']['fr-fr'] = "Entrez nom de client. Il est utilisé en casu ou vous utilisez le billing";
-
$text['label-carrier']['en-us'] = "Carrier name";
$text['label-carrier']['es-cl'] = "Nombre del carrier";
$text['label-carrier']['pt-pt'] = "Nombre del carrier";
diff --git a/app/dialplan_inbound/dialplan_inbound_add.php b/app/dialplan_inbound/dialplan_inbound_add.php
index 474f6beef0..993db90567 100644
--- a/app/dialplan_inbound/dialplan_inbound_add.php
+++ b/app/dialplan_inbound/dialplan_inbound_add.php
@@ -103,7 +103,7 @@ require_once "resources/paging.php";
}
if (permission_exists("inbound_route_advanced") && $action == "advanced") {
- //Allow users with group advanced control, not always superadmin. You may change this in group permitions
+ //allow users with group advanced control, not always superadmin. You may change this in group permissions
}
else {
if (strlen($condition_field_1) == 0) { $condition_field_1 = "destination_number"; }
diff --git a/resources/classes/domains.php b/resources/classes/domains.php
index ebe7d94512..034f683034 100644
--- a/resources/classes/domains.php
+++ b/resources/classes/domains.php
@@ -182,6 +182,155 @@
}
}
}
+
+ public function upgrade() {
+
+ //set the variable
+ $db = $this->db;
+
+ //get the list of installed apps from the core and mod directories
+ $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
+ $x=0;
+ foreach ($config_list as &$config_path) {
+ include($config_path);
+ $x++;
+ }
+
+ //get the domain_uuid
+ $sql = "select * from v_domains ";
+ $prep_statement = $db->prepare($sql);
+ $prep_statement->execute();
+ $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+ foreach($result as $row) {
+ if (count($result) == 1) {
+ $_SESSION["domain_uuid"] = $row["domain_uuid"];
+ $_SESSION["domain_name"] = $row['domain_name'];
+ }
+ else {
+ if ($row['domain_name'] == $domain_array[0] || $row['domain_name'] == 'www.'.$domain_array[0]) {
+ $_SESSION["domain_uuid"] = $row["domain_uuid"];
+ $_SESSION["domain_name"] = $row['domain_name'];
+ }
+ $_SESSION['domains'][$row['domain_uuid']]['domain_uuid'] = $row['domain_uuid'];
+ $_SESSION['domains'][$row['domain_uuid']]['domain_name'] = $row['domain_name'];
+ }
+ }
+ unset($result, $prep_statement);
+
+ //get the default settings
+ $sql = "select * from v_default_settings ";
+ $sql .= "where default_setting_enabled = 'true' ";
+ $prep_statement = $db->prepare($sql);
+ $prep_statement->execute();
+ $result_default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+
+ //get the default recordings directory
+ foreach($result_default_settings as $row) {
+ $name = $row['default_setting_name'];
+ $category = $row['default_setting_category'];
+ $subcategory = $row['default_setting_subcategory'];
+ if ($category == 'switch' && $subcategory == 'recordings' && $name == 'dir') {
+ $switch_recordings_dir = $row['default_setting_value'];
+ }
+ }
+
+ //loop through all domains
+ $sql = "select * from v_domains ";
+ $v_prep_statement = $db->prepare(check_sql($sql));
+ $v_prep_statement->execute();
+ $main_result = $v_prep_statement->fetchAll(PDO::FETCH_ASSOC);
+ $domain_count = count($main_result);
+ $domains_processed = 1;
+ foreach ($main_result as &$row) {
+ //get the values from database and set them as php variables
+ $domain_uuid = $row["domain_uuid"];
+ $domain_name = $row["domain_name"];
+
+ //get the context
+ if ($domain_count == 1) {
+ $context = "default";
+ }
+ else {
+ $context = $domain_name;
+ }
+
+ //show the domain when display_type is set to text
+ if ($display_type == "text") {
+ echo "\n";
+ echo $domain_name;
+ echo "\n";
+ }
+
+ //get the default settings - this needs to be done to reset the session values back to the defaults for each domain in the loop
+ foreach($result_defaults_settings as $row) {
+ $name = $row['default_setting_name'];
+ $category = $row['default_setting_category'];
+ $subcategory = $row['default_setting_subcategory'];
+ if (strlen($subcategory) == 0) {
+ if ($name == "array") {
+ $_SESSION[$category][] = $row['default_setting_value'];
+ }
+ else {
+ $_SESSION[$category][$name] = $row['default_setting_value'];
+ }
+ } else {
+ if ($name == "array") {
+ $_SESSION[$category][$subcategory][] = $row['default_setting_value'];
+ }
+ else {
+ $_SESSION[$category][$subcategory]['uuid'] = $row['default_setting_uuid'];
+ $_SESSION[$category][$subcategory][$name] = $row['default_setting_value'];
+ }
+ }
+ }
+
+ //get the domains settings
+ $sql = "select * from v_domain_settings ";
+ $sql .= "where domain_uuid = '".$domain_uuid."' ";
+ $sql .= "and domain_setting_enabled = 'true' ";
+ $prep_statement = $db->prepare($sql);
+ $prep_statement->execute();
+ $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+ foreach($result as $row) {
+ $name = $row['domain_setting_name'];
+ $category = $row['domain_setting_category'];
+ $subcategory = $row['domain_setting_subcategory'];
+ if (strlen($subcategory) == 0) {
+ //$$category[$name] = $row['domain_setting_value'];
+ $_SESSION[$category][$name] = $row['domain_setting_value'];
+ }
+ else {
+ //$$category[$subcategory][$name] = $row['domain_setting_value'];
+ $_SESSION[$category][$subcategory][$name] = $row['domain_setting_value'];
+ }
+ }
+
+ //set the recordings directory
+ if (strlen($switch_recordings_dir) > 1 && count($_SESSION["domains"]) > 1) {
+ $_SESSION['switch']['recordings']['dir'] = $switch_recordings_dir."/".$domain_name;
+ }
+
+ //get the list of installed apps from the core and mod directories and execute the php code in app_defaults.php
+ $default_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_defaults.php");
+ foreach ($default_list as &$default_path) {
+ include($default_path);
+ }
+
+ //track of the number of domains processed
+ $domains_processed++;
+ }
+ unset ($v_prep_statement);
+
+ //synchronize the dialplan
+ if (function_exists('save_dialplan_xml')) {
+ save_dialplan_xml();
+ }
+
+ //clear the session variables
+ unset($_SESSION['domain']);
+ unset($_SESSION['switch']);
+
+ }
}
-?>
+?>
\ No newline at end of file
diff --git a/resources/classes/menu.php b/resources/classes/menu.php
index f80e78a2cb..94eb43b357 100644
--- a/resources/classes/menu.php
+++ b/resources/classes/menu.php
@@ -392,7 +392,8 @@
}
if (strlen($sql) == 0) { //default sql for base of the menu
- $sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_uuid, i.menu_item_parent_uuid from v_menu_items as i, v_menu_languages as l ";
+ $sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_uuid, i.menu_item_parent_uuid ";
+ $sql .= "from v_menu_items as i, v_menu_languages as l ";
$sql .= "where i.menu_item_uuid = l.menu_item_uuid ";
$sql .= "and l.menu_language = '".$_SESSION['domain']['language']['code']."' ";
$sql .= "and l.menu_uuid = '".$this->menu_uuid."' ";
diff --git a/resources/schema.php b/resources/schema.php
index ea8b29512b..54e3dbfd9c 100644
--- a/resources/schema.php
+++ b/resources/schema.php
@@ -31,646 +31,6 @@ include "root.php";
//$db->db_type = $db_type;
//$db->add();
-function db_table_exists_alternate ($db, $db_type, $table_name) {
- $sql = "select count(*) from $table_name ";
- $result = $db->query($sql);
- if ($result > 0) {
- return true; //table exists
- }
- else {
- return false; //table doesn't exist
- }
-}
-function db_table_exists ($db, $db_type, $db_name, $table_name) {
- $sql = "";
- if ($db_type == "sqlite") {
- $sql .= "SELECT * FROM sqlite_master WHERE type='table' and name='$table_name' ";
- }
- if ($db_type == "pgsql") {
- $sql .= "select * from pg_tables where schemaname='public' and tablename = '$table_name' ";
- }
- if ($db_type == "mysql") {
- $sql .= "SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = '$db_name' and TABLE_NAME = '$table_name' ";
- }
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (count($result) > 0) {
- return true; //table exists
- }
- else {
- return false; //table doesn't exist
- }
-}
-
-function db_table_info($db, $db_name, $db_type, $table_name) {
- if (strlen($table_name) == 0) { return false; }
- if ($db_type == "sqlite") {
- $sql = "PRAGMA table_info(".$table_name.");";
- }
- if ($db_type == "pgsql") {
- $sql = "SELECT ordinal_position, ";
- $sql .= "column_name, ";
- $sql .= "data_type, ";
- $sql .= "column_default, ";
- $sql .= "is_nullable, ";
- $sql .= "character_maximum_length, ";
- $sql .= "numeric_precision ";
- $sql .= "FROM information_schema.columns ";
- $sql .= "WHERE table_name = '".$table_name."' ";
- $sql .= "and table_catalog = '".$db_name."' ";
- $sql .= "ORDER BY ordinal_position; ";
- }
- if ($db_type == "mysql") {
- $sql = "describe ".$table_name.";";
- }
- $prep_statement = $db->prepare($sql);
- $prep_statement->execute();
- return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
-}
-
-function db_data_type($db_type, $table_info, $column_name) {
- if ($db_type == "sqlite") {
- foreach ($table_info as $key => &$row) {
- if ($row['name'] == $column_name) {
- return $row['type'];
- }
- }
- }
- if ($db_type == "pgsql") {
- foreach ($table_info as $key => &$row) {
- if ($row['column_name'] == $column_name) {
- return $row['data_type'];
- }
- }
- }
- if ($db_type == "mysql") {
- foreach ($table_info as $key => &$row) {
- if ($row['Field'] == $column_name) {
- return $row['Type'];
- }
- }
- }
-}
-
-function db_sqlite_column_exists($table_info, $column_name) {
- foreach ($table_info as $key => &$row) {
- if ($row['name'] == $column_name) {
- return true;
- }
- }
- return $false;
-}
-
-function db_column_exists ($db, $db_type, $db_name, $table_name, $column_name) {
- global $display_type;
-
- if ($db_type == "sqlite") {
- $table_info = db_table_info($db, $db_name, $db_type, $table_name);
- if (db_sqlite_column_exists($table_info, $column_name)) {
- return true;
- }
- else {
- return false;
- }
- }
- if ($db_type == "pgsql") {
- $sql = "SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = '$table_name') AND attname = '$column_name'; ";
- }
- if ($db_type == "mysql") {
- //$sql .= "SELECT * FROM information_schema.COLUMNS where TABLE_SCHEMA = '$db_name' and TABLE_NAME = '$table_name' and COLUMN_NAME = '$column_name' ";
- $sql = "show columns from $table_name where field = '$column_name' ";
- }
- if ($sql) {
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (!$result) {
- return false;
- }
- if (count($result) > 0) {
- return true;
- }
- else {
- return false;
- }
- unset ($prep_statement);
- }
-}
-
-function db_column_data_type ($db, $db_type, $db_name, $table_name, $column_name) {
- $table_info = db_table_info($db, $db_name, $db_type, $table_name);
- return db_data_type($db_type, $table_info, $column_name);
-}
-
-function db_create_table ($apps, $db_type, $table) {
- foreach ($apps as $x => &$app) {
- foreach ($app['db'] as $y => $row) {
- if ($row['table'] == $table) {
- $sql = "CREATE TABLE " . $row['table'] . " (\n";
- $field_count = 0;
- foreach ($row['fields'] as $field) {
- if ($field['deprecated'] == "true") {
- //skip this row
- }
- else {
- if ($field_count > 0 ) { $sql .= ",\n"; }
- if (is_array($field['name'])) {
- $sql .= $field['name']['text'] . " ";
- }
- else {
- $sql .= $field['name'] . " ";
- }
- if (is_array($field['type'])) {
- $sql .= $field['type'][$db_type];
- }
- else {
- $sql .= $field['type'];
- }
- if ($field['key']['type'] == "primary") {
- $sql .= " PRIMARY KEY";
- }
- $field_count++;
- }
- }
- $sql .= ");\n\n";
- return $sql;
- }
- }
- }
-}
-
-function db_insert_into ($apps, $db_type, $table) {
- global $db, $db_name;
- foreach ($apps as $x => &$app) {
- foreach ($app['db'] as $y => $row) {
- if ($row['table'] == $table) {
- $sql = "INSERT INTO " . $row['table'] . " (";
- $field_count = 0;
- foreach ($row['fields'] as $field) {
- if ($field['deprecated'] == "true") {
- //skip this field
- }
- else {
- if ($field_count > 0 ) { $sql .= ","; }
- if (is_array($field['name'])) {
- $sql .= $field['name']['text'];
- }
- else {
- $sql .= $field['name'];
- }
- $field_count++;
- }
- }
- $sql .= ")\n";
- $sql .= "SELECT ";
- $field_count = 0;
- foreach ($row['fields'] as $field) {
- if ($field['deprecated'] == "true") {
- //skip this field
- }
- else {
- if ($field_count > 0 ) { $sql .= ","; }
- if (is_array($field['name'])) {
- if ($field['exists'] == "false") {
- if (is_array($field['name']['deprecated'])) {
- $found = false;
- foreach ($field['name']['deprecated'] as $row) {
- if (db_column_exists ($db, $db_type, $db_name, 'tmp_'.$table, $row)) {
- $sql .= $row;
- $found = true;
- break;
- }
- }
- if (!$found) { $sql .= "''"; }
- }
- else {
- if (db_column_exists ($db, $db_type, $db_name, 'tmp_'.$table, $field['name']['deprecated'])) {
- $sql .= $field['name']['deprecated'];
- }
- else {
- $sql .= "''";
- }
- }
- }
- else {
- $sql .= $field['name']['text'];
- }
- }
- else {
- $sql .= $field['name'];
- }
- $field_count++;
- }
- }
- $sql .= " FROM tmp_".$table.";\n\n";
- return $sql;
- }
- }
- }
-}
-
-function db_upgrade_schema ($db, $db_type, $db_name, $response_output) {
- global $text; // pulls in language variable array
- global $response_format;
- global $upgrade_data_types;
-
- //PHP PDO check if table or column exists
- //check if table exists
- // SELECT * FROM sqlite_master WHERE type='table' AND name='v_cdr'
- //check if column exists
- // SELECT * FROM sqlite_master WHERE type='table' AND name='v_cdr' AND sql LIKE '%caller_id_name TEXT,%'
- //aditional information
- // http://www.sqlite.org/faq.html#q9
-
- //postgresql
- //list all tables in the database
- // SELECT table_name FROM pg_tables WHERE schemaname='public';
- //check if table exists
- // SELECT * FROM pg_tables WHERE schemaname='public' AND table_name = 'v_groups'
- //check if column exists
- // SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'v_cdr') AND attname = 'caller_id_name';
- //mysql
- //list all tables in the database
- // SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'fusionpbx'
- //check if table exists
- // SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'fusionpbx' AND TABLE_NAME = 'v_groups'
- //check if column exists
- // SELECT * FROM information_schema.COLUMNS where TABLE_SCHEMA = 'fusionpbx' AND TABLE_NAME = 'v_cdr' AND COLUMN_NAME = 'context'
- //oracle
- //check if table exists
- // SELECT TABLE_NAME FROM ALL_TABLES
-
- //get the $apps array from the installed apps from the core and mod directories
- $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
- $x=0;
- foreach ($config_list as &$config_path) {
- include($config_path);
- $x++;
- }
-
- //update the app db array add exists true or false
- $sql = '';
- foreach ($apps as $x => &$app) {
- foreach ($app['db'] as $y => &$row) {
- if (is_array($row['table'])) {
- $table_name = $row['table']['text'];
- }
- else {
- $table_name = $row['table'];
- }
- if (strlen($table_name) > 0) {
- //check if the table exists
- if (db_table_exists($db, $db_type, $db_name, $table_name)) {
- $apps[$x]['db'][$y]['exists'] = 'true';
- }
- else {
- $apps[$x]['db'][$y]['exists'] = 'false';
- }
- //check if the column exists
- foreach ($row['fields'] as $z => $field) {
- if ($field['deprecated'] == "true") {
- //skip this field
- }
- else {
- if (is_array($field['name'])) {
- $field_name = $field['name']['text'];
- }
- else {
- $field_name = $field['name'];
- }
- if (strlen(field_name) > 0) {
- if (db_column_exists ($db, $db_type, $db_name, $table_name, $field_name)) {
- //found
- $apps[$x]['db'][$y]['fields'][$z]['exists'] = 'true';
- }
- else {
- //not found
- $apps[$x]['db'][$y]['fields'][$z]['exists'] = 'false';
- }
- }
- unset($field_name);
- }
- }
- unset($table_name);
- }
- }
- }
-
- //prepare the variables
- $sql_update = '';
- $var_uuid = $_GET["id"];
-
- //add missing tables and fields
- foreach ($apps as $x => &$app) {
- foreach ($app['db'] as $y => &$row) {
- if (is_array($row['table'])) {
- $table_name = $row['table']['text'];
- if (!db_table_exists($db, $db_type, $db_name, $row['table']['text'])) {
- $row['exists'] = "true"; //testing
- //if (db_table_exists($db, $db_type, $db_name, $row['table']['deprecated'])) {
- if ($db_type == "pgsql") {
- $sql_update .= "ALTER TABLE ".$row['table']['deprecated']." RENAME TO ".$row['table']['text'].";\n";
- }
- if ($db_type == "mysql") {
- $sql_update .= "RENAME TABLE ".$row['table']['deprecated']." TO ".$row['table']['text'].";\n";
- }
- if ($db_type == "sqlite") {
- $sql_update .= "ALTER TABLE ".$row['table']['deprecated']." RENAME TO ".$row['table']['text'].";\n";
- }
- //}
- }
- }
- else {
- $table_name = $row['table'];
- }
- //check if the table exists
- if ($row['exists'] == "true") {
- if (count($row['fields']) > 0) {
- foreach ($row['fields'] as $z => $field) {
- if ($field['deprecated'] == "true") {
- //skip this field
- }
- else {
- //get the data type
- if (is_array($field['type'])) {
- $field_type = $field['type'][$db_type];
- }
- else {
- $field_type = $field['type'];
- }
- //get the field name
- if (is_array($field['name'])) {
- $field_name = $field['name']['text'];
- }
- else {
- $field_name = $field['name'];
- }
- //find missing fields and add them
- if ($field['deprecated'] == "true") {
- //skip this row
- }
- else {
- if (!is_array($field['name'])) {
- if ($field['exists'] == "false") {
- $sql_update .= "ALTER TABLE ".$table_name." ADD ".$field['name']." ".$field_type.";\n";
- }
- }
- }
- //rename fields where the name has changed
- if (is_array($field['name'])) {
- if (db_column_exists ($db, $db_type, $db_name, $table_name, $field['name']['deprecated'])) {
- if ($db_type == "pgsql") {
- $sql_update .= "ALTER TABLE ".$table_name." RENAME COLUMN ".$field['name']['deprecated']." to ".$field['name']['text'].";\n";
- }
- if ($db_type == "mysql") {
- $field_type = str_replace("AUTO_INCREMENT PRIMARY KEY", "", $field_type);
- $sql_update .= "ALTER TABLE ".$table_name." CHANGE ".$field['name']['deprecated']." ".$field['name']['text']." ".$field_type.";\n";
- }
- if ($db_type == "sqlite") {
- //a change has been made to the field name
- $apps[$x]['db'][$y]['rebuild'] = 'true';
- }
- }
- }
- //change the data type if it has been changed
- //if the data type in the app db array is different than the type in the database then change the data type
- if ($upgrade_data_types) {
- $db_field_type = db_column_data_type ($db, $db_type, $db_name, $table_name, $field_name);
- $field_type_array = explode("(", $field_type);
- $field_type = $field_type_array[0];
- if (trim($db_field_type) != trim($field_type) && strlen($db_field_type) > 0) {
- if ($db_type == "pgsql") {
- if (strtolower($field_type) == "uuid") {
- $sql_update .= "ALTER TABLE ".$table_name." ALTER COLUMN ".$field_name." TYPE uuid USING\n";
- $sql_update .= "CAST(regexp_replace(".$field_name.", '([A-Z0-9]{4})([A-Z0-9]{12})', E'\\1-\\2')\n";
- $sql_update .= "AS uuid);\n";
- }
- else {
- if ($db_field_type = "integer" && strtolower($field_type) == "serial") {
- //field type has not changed
- } elseif ($db_field_type = "timestamp without time zone" && strtolower($field_type) == "timestamp") {
- //field type has not changed
- } elseif ($db_field_type = "timestamp without time zone" && strtolower($field_type) == "datetime") {
- //field type has not changed
- } elseif ($db_field_type = "integer" && strtolower($field_type) == "numeric") {
- //field type has not changed
- } elseif ($db_field_type = "character" && strtolower($field_type) == "char") {
- //field type has not changed
- }
- else {
- //$sql_update .= "-- $db_type, $db_name, $table_name, $field_name ".db_column_data_type ($db, $db_type, $db_name, $table_name, $field_name)."
";
- $sql_update .= "ALTER TABLE ".$table_name." ALTER COLUMN ".$field_name." TYPE ".$field_type.";\n";
- }
- }
- }
- if ($db_type == "mysql") {
- $type = explode("(", $db_field_type);
- if ($type[0] == $field_type) {
- //do nothing
- }
- elseif ($field_type == "numeric" && $type[0] == "decimal") {
- //do nothing
- }
- else {
- $sql_update .= "ALTER TABLE ".$table_name." modify ".$field_name." ".$field_type.";\n";
- }
- unset($type);
- }
- if ($db_type == "sqlite") {
- //a change has been made to the field type
- $apps[$x]['db'][$y]['rebuild'] = 'true';
- }
- }
- }
-
- }
- }
- unset($column_array);
- }
- }
- else {
- //create table
- if (!is_array($row['table'])) {
- $sql_update .= db_create_table($apps, $db_type, $row['table']);
- }
- }
- }
- }
- //rebuild and populate the table
- foreach ($apps as $x => &$app) {
- foreach ($app['db'] as $y => &$row) {
- if (is_array($row['table'])) {
- $table_name = $row['table']['text'];
- }
- else {
- $table_name = $row['table'];
- }
- if ($row['rebuild'] == "true") {
- if ($db_type == "sqlite") {
- //start the transaction
- //$sql_update .= "BEGIN TRANSACTION;\n";
- //rename the table
- $sql_update .= "ALTER TABLE ".$table_name." RENAME TO tmp_".$table_name.";\n";
- //create the table
- $sql_update .= db_create_table($apps, $db_type, $table_name);
- //insert the data into the new table
- $sql_update .= db_insert_into($apps, $db_type, $table_name);
- //drop the old table
- $sql_update .= "DROP TABLE tmp_".$table_name.";\n";
- //commit the transaction
- //$sql_update .= "COMMIT;\n";
- }
- }
- }
- }
-
- // initialize response variable
- $response = '';
-
- //display results as html
- if ($response_output != '' && $response_format == "html") {
- //show the database type
- $response .= "".$text['header-database_type'].": ".$db_type. "
";
- //start the table
- $response .= "
| \n";
- $response .= " \n"; - $response .= "".$text['label-sql_changes'].": \n"; - $response .= " \n"; - $response .= $sql_update; - $response .= "\n"; - $response .= " \n"; - $response .= " | \n";
- $response .= "||||||||||||||
| ".$text['label-table']." | \n"; - $response .= "".$text['label-exists']." | \n"; - $response .= "".$text['label-details']." | \n"; - $response .= "||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ".$table_name." | \n"; - $response .= "".$text['option-true']." | \n"; - - if (count($row['fields']) > 0) { - $response .= "\n";
- //show the list of columns
- $response .= "
| \n";
- }
- }
- else {
- $response .= "$table_name | \n"; - $response .= "".$text['label-exists']." ".$text['option-false']." | \n";
- $response .= "\n"; - } - $response .= " | |||||||||