Check the missing array has content before processing it.

This commit is contained in:
markjcrane
2016-05-04 00:22:35 -06:00
parent 37e46ed2c9
commit 097a5d8ade
10 changed files with 63 additions and 58 deletions

View File

@@ -70,7 +70,7 @@ if ($domains_processed == 1) {
}
//add the missing default settings
foreach ($missing as $row) {
if (count($missing) > 0) foreach ($missing as $row) {
//add the default settings
$orm = new orm;
$orm->name('default_settings');

View File

@@ -137,6 +137,7 @@ if ($domains_processed == 1) {
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = 'Delay before next call sequence';
$x++;
//get an array of the default settings
$sql = "select * from v_default_settings ";
$prep_statement = $db->prepare($sql);
@@ -160,7 +161,7 @@ if ($domains_processed == 1) {
}
//add the missing default settings
foreach ($missing as $row) {
if (count($missing) > 0) foreach ($missing as $row) {
//add the default settings
$orm = new orm;
$orm->name('default_settings');

View File

@@ -39,7 +39,7 @@ if ($domains_processed == 1) {
//iterate and add each, if necessary
foreach ($array as $index => $default_settings) {
//add default settings
//add default settings
$sql = "select count(*) as num_rows from v_default_settings ";
$sql .= "where default_setting_category = '".$default_settings['default_setting_category']."' ";
$sql .= "and default_setting_subcategory = '".$default_settings['default_setting_subcategory']."' ";

View File

@@ -287,7 +287,7 @@
}
//add the missing default settings
foreach ($missing as $row) {
if (count($missing) > 0) foreach ($missing as $row) {
//add the default settings
$orm = new orm;
$orm->name('default_settings');

View File

@@ -66,7 +66,7 @@ if ($domains_processed == 1) {
}
//add the missing default settings
foreach ($missing as $row) {
if (count($missing) > 0) foreach ($missing as $row) {
//add the default settings
$orm = new orm;
$orm->name('default_settings');

View File

@@ -101,7 +101,7 @@ EOD;
function set_country_vars($db, $x) {
require "resources/countries.php";
// $country_iso=$_SESSION['domain']['country']['iso_code'];
//$country_iso=$_SESSION['domain']['country']['iso_code'];
$sql = "select default_setting_value as value from v_default_settings ";
$sql .= "where default_setting_name = 'iso_code' ";

View File

@@ -77,7 +77,7 @@
$default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$x = 0;
foreach ($array as $row) {
if (isset($array)) foreach ($array as $row) {
$found = false;
foreach ($default_settings as $field) {
if ($row['default_setting_subcategory'] == $field['default_setting_subcategory']) {

View File

@@ -330,33 +330,35 @@ if ($domains_processed == 1) {
$missing_count = $i;
//add the missing default settings
$sql = "insert into v_default_settings (";
$sql .= "default_setting_uuid, ";
$sql .= "default_setting_category, ";
$sql .= "default_setting_subcategory, ";
$sql .= "default_setting_name, ";
$sql .= "default_setting_value, ";
$sql .= "default_setting_enabled, ";
$sql .= "default_setting_description ";
$sql .= ") values \n";
$i = 1;
foreach ($missing as $row) {
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "'".check_str($row['default_setting_category'])."', ";
$sql .= "'".check_str($row['default_setting_subcategory'])."', ";
$sql .= "'".check_str($row['default_setting_name'])."', ";
$sql .= "'".check_str($row['default_setting_value'])."', ";
$sql .= "'".check_str($row['default_setting_enabled'])."', ";
$sql .= "'".check_str($row['default_setting_description'])."' ";
$sql .= ")";
if ($missing_count != $i) {
$sql .= ",\n";
if (count($missing) > 0) {
$sql = "insert into v_default_settings (";
$sql .= "default_setting_uuid, ";
$sql .= "default_setting_category, ";
$sql .= "default_setting_subcategory, ";
$sql .= "default_setting_name, ";
$sql .= "default_setting_value, ";
$sql .= "default_setting_enabled, ";
$sql .= "default_setting_description ";
$sql .= ") values \n";
$i = 1;
foreach ($missing as $row) {
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "'".check_str($row['default_setting_category'])."', ";
$sql .= "'".check_str($row['default_setting_subcategory'])."', ";
$sql .= "'".check_str($row['default_setting_name'])."', ";
$sql .= "'".check_str($row['default_setting_value'])."', ";
$sql .= "'".check_str($row['default_setting_enabled'])."', ";
$sql .= "'".check_str($row['default_setting_description'])."' ";
$sql .= ")";
if ($missing_count != $i) {
$sql .= ",\n";
}
$i++;
}
$i++;
$db->exec(check_sql($sql));
unset($missing);
}
$db->exec(check_sql($sql));
unset($missing);
//move the dynamic provision variables that from v_vars table to v_default_settings
if (count($_SESSION['provision']) == 0) {

View File

@@ -239,7 +239,7 @@ if (!class_exists('switch_settings')) {
}
//add the missing default settings
if (is_array($missing)) {
if (count($missing) > 0) {
$sql = "insert into v_default_settings (";
$sql .= "default_setting_uuid, ";
$sql .= "default_setting_category, ";

View File

@@ -1346,33 +1346,35 @@ if ($domains_processed == 1) {
$missing_count = $i;
//add the missing default settings
$sql = "insert into v_default_settings (";
$sql .= "default_setting_uuid, ";
$sql .= "default_setting_category, ";
$sql .= "default_setting_subcategory, ";
$sql .= "default_setting_name, ";
$sql .= "default_setting_value, ";
$sql .= "default_setting_enabled, ";
$sql .= "default_setting_description ";
$sql .= ") values \n";
$i = 1;
foreach ($missing as $row) {
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "'".check_str($row['default_setting_category'])."', ";
$sql .= "'".check_str($row['default_setting_subcategory'])."', ";
$sql .= "'".check_str($row['default_setting_name'])."', ";
$sql .= "'".check_str($row['default_setting_value'])."', ";
$sql .= "'".check_str($row['default_setting_enabled'])."', ";
$sql .= "'".check_str($row['default_setting_description'])."' ";
$sql .= ")";
if ($missing_count != $i) {
$sql .= ",\n";
if (count($missing) > 0) {
$sql = "insert into v_default_settings (";
$sql .= "default_setting_uuid, ";
$sql .= "default_setting_category, ";
$sql .= "default_setting_subcategory, ";
$sql .= "default_setting_name, ";
$sql .= "default_setting_value, ";
$sql .= "default_setting_enabled, ";
$sql .= "default_setting_description ";
$sql .= ") values \n";
$i = 1;
foreach ($missing as $row) {
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "'".check_str($row['default_setting_category'])."', ";
$sql .= "'".check_str($row['default_setting_subcategory'])."', ";
$sql .= "'".check_str($row['default_setting_name'])."', ";
$sql .= "'".check_str($row['default_setting_value'])."', ";
$sql .= "'".check_str($row['default_setting_enabled'])."', ";
$sql .= "'".check_str($row['default_setting_description'])."' ";
$sql .= ")";
if ($missing_count != $i) {
$sql .= ",\n";
}
$i++;
}
$i++;
$db->exec(check_sql($sql));
unset($missing);
}
$db->exec(check_sql($sql));
unset($missing);
//unset the array variable
unset($array);