Upgrade: Divides Upgrade Schema into separate processes. Complete translation forthcoming. (Still under construction...)

This commit is contained in:
Nate Jones
2014-07-10 06:05:22 +00:00
parent d9f6d900e4
commit 8bd5b7112b
7 changed files with 377 additions and 101 deletions

View File

@@ -1,12 +1,12 @@
<?php
//application details
$apps[$x]['name'] = "Upgrade Schema";
$apps[$x]['name'] = "Upgrade";
$apps[$x]['uuid'] = "8b1d7eb5-1009-052c-e1a8-d1f4887a3f5c";
$apps[$x]['category'] = "Core";
$apps[$x]['subcategory'] = "";
$apps[$x]['version'] = "";
$apps[$x]['url'] = "http://www.fusionpbx.com";
$apps[$x]['description']['en-us'] = "Upgrade the database schema.";
$apps[$x]['description']['en-us'] = "Update or restore various system settings.";
$apps[$x]['description']['es-cl'] = "Actualiza el esquema de la base de datos";
$apps[$x]['description']['de-de'] = "";
$apps[$x]['description']['de-ch'] = "";
@@ -18,12 +18,12 @@
$apps[$x]['description']['pt-br'] = "";
//menu details
$apps[$x]['menu'][0]['title']['en-us'] = "Upgrade Schema";
$apps[$x]['menu'][0]['title']['es-cl'] = "Actualizar Esquema";
$apps[$x]['menu'][0]['title']['en-us'] = "Upgrade";
$apps[$x]['menu'][0]['title']['es-cl'] = "Actualizar";
$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'] = "MàJ BDD";
$apps[$x]['menu'][0]['title']['fr-fr'] = "Mise à jour";
$apps[$x]['menu'][0]['title']['fr-ca'] = "";
$apps[$x]['menu'][0]['title']['fr-ch'] = "";
$apps[$x]['menu'][0]['title']['pt-pt'] = "Actualizar BD";
@@ -31,15 +31,27 @@
$apps[$x]['menu'][0]['uuid'] = "8c826e92-be3c-0944-669a-24e5b915d562";
$apps[$x]['menu'][0]['parent_uuid'] = "594d99c5-6128-9c88-ca35-4b33392cec0f";
$apps[$x]['menu'][0]['category'] = "internal";
$apps[$x]['menu'][0]['path'] = "/core/upgrade/upgrade_schema.php";
$apps[$x]['menu'][0]['path'] = "/core/upgrade/index.php";
$apps[$x]['menu'][0]['groups'][] = "superadmin";
//permission details
$apps[$x]['permissions'][0]['name'] = "upgrade_schema";
$apps[$x]['permissions'][0]['menu']['uuid'] = "8c826e92-be3c-0944-669a-24e5b915d562";
$apps[$x]['permissions'][0]['groups'][] = "superadmin";
$apps[$x]['permissions'][1]['name'] = "upgrade_svn";
$y = 0;
$apps[$x]['permissions'][$y]['name'] = "upgrade_svn";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "71051909-81ff-4301-9997-52b11206b3a6";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "upgrade_schema";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "8c826e92-be3c-0944-669a-24e5b915d562";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "upgrade_domains";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "e7bb1296-3141-48c9-a95a-82d2768d0ae4";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "upgrade_datatypes";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "9c82d494-c248-4f74-a82b-2af15064d6fc";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
//schema details
$y = 0; //table array index

View File

@@ -5,11 +5,26 @@
$text['title-upgrade_schema']['pt-pt'] = "Actualizar Esquema de Base de Dados";
$text['title-upgrade_schema']['fr-fr'] = "Mise à jour du Schéma";
$text['title-upgrade']['en-us'] = "Upgrade";
$text['title-upgrade']['es-cl'] = "Actualizar";
$text['title-upgrade']['pt-pt'] = "Actualizar";
$text['title-upgrade']['fr-fr'] = "Mise à jour";
$text['header-upgrade_schema_results']['en-us'] = "Upgrade Schema Results";
$text['header-upgrade_schema_results']['es-cl'] = "Actualiza Esquema Resultados";
$text['header-upgrade_schema_results']['pt-pt'] = "Resultados Atualização do Esquema";
$text['header-upgrade_schema_results']['fr-fr'] = "Résultats Mise à Jour du Schéma";
$text['header-database_type']['en-us'] = "Database Type";
$text['header-database_type']['es-cl'] = "Tipo de base de datos";
$text['header-database_type']['pt-pt'] = "Tipo de Base de Dados";
$text['header-database_type']['fr-fr'] = "Type de base de données";
$text['header-upgrade']['en-us'] = "Upgrade";
$text['header-upgrade']['es-cl'] = "Actualizar";
$text['header-upgrade']['pt-pt'] = "Actualizar";
$text['header-upgrade']['fr-fr'] = "Mise à jour";
$text['header-message']['en-us'] = "Message";
$text['header-message']['es-cl'] = "Mensaje";
$text['header-message']['pt-pt'] = "Mensagem";

236
core/upgrade/index.php Normal file
View File

@@ -0,0 +1,236 @@
<?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 <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
set_time_limit(600); //sec (10 min)
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check the permission
if (
!permission_exists('upgrade_svn') &&
!permission_exists('upgrade_schema') &&
!permission_exists('upgrade_domains') &&
!permission_exists('upgrade_datatypes') &&
!permission_exists('menu_restore') &&
!permission_exists('group_edit')
) {
echo "access denied";
exit;
}
if (sizeof($_POST) > 0) {
$do = $_POST['do'];
// run svn update
if ($do["svn"] && permission_exists("upgrade_svn")) {
$response_message[] = "SVN Updated";
}
// load the default database into memory and compare it with the active database
if ($do["schema"] && permission_exists("upgrade_schema")) {
$included = true;
$response_output = "return";
$response_format = "html";
require_once "core/upgrade/upgrade_schema.php";
if ($response_upgrade_schema != '') {
$_SESSION["response_upgrade_schema"] = $response_upgrade_schema;
}
unset($apps);
$response_message[] = "Schema Upgraded";
}
// upgrade the domains
if ($do["domains"] && permission_exists("upgrade_domains")) {
$included = true;
$domain_language_code = $_SESSION['domain']['language']['code'];
require_once "core/upgrade/upgrade_domains.php";
$_SESSION['domain']['language']['code'] = $domain_language_code;
unset($domain_language_code);
$response_message[] = "Domain(s) Upgraded";
}
// syncronize data types
if ($do["datatypes"] && permission_exists("upgrade_datatypes")) {
$response_message[] = "Data Types Syncronized";
}
// restore defaults of the selected menu
if ($do["menu"] && permission_exists("menu_restore")) {
$sel_menu = explode('|', $_POST["sel_menu"]);
$menu_uuid = $sel_menu[0];
$menu_language = $sel_menu[1];
$included = true;
require_once("core/menu/menu_restore_default.php");
unset($sel_menu);
$response_message[] = "Menu Restored";
}
// restore default permissions
if ($do["permissions"] && permission_exists("group_edit")) {
$included = true;
require_once("core/users/permissions_default.php");
$response_message[] = "Permissions Restored";
}
$_SESSION["message"] = implode("<br />", $response_message);
header("Location: ".PROJECT_PATH."/core/upgrade/index.php");
exit;
} // if
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
require_once "resources/header.php";
$document['title'] = $text['title-upgrade'];
//set defaults
$display_type = 'html';
echo "<b>".$text['header-upgrade']."</b><br>";
echo "Select the upgrade/update/restore actions below you wish to perform.";
echo "<br><br><br>";
echo "<form name='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
if (permission_exists("upgrade_svn")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " SVN Update";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[svn]' id='do_svn' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("upgrade_schema")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Upgrade Schema";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[schema]' id='do_schema' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("upgrade_domains")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Upgrade Domain(s)";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[domains]' id='do_domains' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("upgrade_datatypes")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Syncronize Data Types";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[datatypes]' id='do_datatypes' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("menu_restore")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Restore Menu Defaults";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <table cellpadding='0' cellspacing='0' border='0'>";
echo " <tr><td>";
echo " <input type='checkbox' class='formfld' name='do[menu]' id='do_menu' value='1' onclick=\"$('#sel_menu').fadeToggle('fast');\">";
echo " </td><td>";
echo " <select name='sel_menu' id='sel_menu' class='formfld' style='display: none; margin-left: 15px;'>\n";
$sql = "select * from v_menus ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
echo "<option value='".$row["menu_uuid"]."|".$row["menu_language"]."'>".$row["menu_name"]."</option>\n";
}
unset ($sql, $result, $prep_statement);
echo " </select>\n";
echo " </td></tr>";
echo " </table>";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("group_edit")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Restore Permission Defaults";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[permissions]' id='do_permissions' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo " <td colspan='2' style='text-align: right;'>\n";
echo " <input type='submit' class='btn' value='Execute'>\n";
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
// output result of upgrade schema
if ($_SESSION["response_upgrade_schema"] != '') {
echo "<br /><br /><br />";
echo "<b>".$text['header-upgrade_schema_results']."</b>";
echo "<br /><br />";
echo $_SESSION["response_upgrade_schema"];
unset($_SESSION["response_upgrade_schema"]);
}
require_once "resources/footer.php";
?>

View File

@@ -32,7 +32,7 @@
set_include_path($document_root);
require_once "resources/require.php";
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$display_type = 'text'; //html, text
$response_format = 'text'; //html, text
//add multi-lingual support
require_once "app_languages.php";
@@ -61,16 +61,16 @@
}
//set the default
if (!isset($display_results)) {
$display_results = false;
if (!isset($response_output)) {
$response_output = "echo";
}
//include the header
if ($display_results) {
if ($response_output == "echo") {
require_once "resources/header.php";
}
if ($display_type == 'text') {
if ($response_format == 'text') {
echo "\n";
echo $text['label-upgrade']."\n";
echo "-----------------------------------------\n";
@@ -82,7 +82,7 @@ if ($display_type == 'text') {
require_once "core/upgrade/upgrade_schema.php";
//show the content
if ($display_type == 'html') {
if ($response_format == 'html') {
echo "<div align='center'>\n";
echo "<table width='40%'>\n";
echo "<tr>\n";
@@ -102,12 +102,12 @@ if ($display_type == 'text') {
echo "<br />\n";
echo "<br />\n";
}
elseif ($display_type == 'text') {
elseif ($response_format == 'text') {
echo "\n";
}
//include the footer
if ($display_results) {
if ($response_output == "echo") {
require_once "resources/footer.php";
}
?>

View File

@@ -24,6 +24,9 @@
Mark J Crane <markjcrane@fusionpbx.com>
*/
// set included, if not
if (!isset($included)) { $included = false; }
//check the permission
if(defined('STDIN')) {
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
@@ -34,7 +37,7 @@
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$display_type = 'text'; //html, text
}
else {
else if (!$included) {
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";

View File

@@ -24,6 +24,10 @@
Mark J Crane <markjcrane@fusionpbx.com>
*/
// set included, if not
if (!isset($included)) { $included = false; }
//check the permission
if(defined('STDIN')) {
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
@@ -32,15 +36,9 @@
set_include_path($document_root);
require_once "resources/require.php";
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$display_type = 'text'; //html, text
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
$response_format = 'text'; //html, text
}
else {
else if (!$included) {
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
@@ -52,35 +50,33 @@
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
require_once "resources/header.php";
$document['title'] = $text['title-upgrade_schema'];
$display_type = 'html'; //html, text
$response_format = 'html'; //html, text
}
//set the default
if (!isset($display_results)) {
$display_results = true;
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//set the default
if (!isset($response_output)) {
$response_output = "echo";
}
//load the default database into memory and compare it with the active database
require_once "resources/schema.php";
db_upgrade_schema ($db, $db_type, $db_name, $display_results);
$response_upgrade_schema = db_upgrade_schema($db, $db_type, $db_name, $response_output);
unset($apps);
//upgrade the domains
$domain_language_code = $_SESSION['domain']['language']['code'];
require_once "core/upgrade/upgrade_domains.php";
$_SESSION['domain']['language']['code'] = $domain_language_code;
unset($domain_language_code);
if ($display_results && $display_type == "html") {
if (!$included && $response_output == 'echo' && $response_format == 'html') {
echo "<br />\n";
echo "<br />\n";
require_once "resources/footer.php";