Only add sofia global settings that are not in the database
This commit is contained in:
parent
ccf59f4a0c
commit
c0946a03ce
|
|
@ -1,6 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ($domains_processed == 1) {
|
if ($domains_processed == 1) {
|
||||||
|
|
||||||
|
//get all of the sofia global default settings
|
||||||
|
$sql = "select sofia_global_setting_uuid ";
|
||||||
|
$sql .= "from v_sofia_global_settings \n";
|
||||||
|
$database = new database;
|
||||||
|
$sofia_global_settings = $database->select($sql, null, 'all');
|
||||||
|
|
||||||
//build array
|
//build array
|
||||||
$x = 0;
|
$x = 0;
|
||||||
|
|
@ -28,19 +34,35 @@ if ($domains_processed == 1) {
|
||||||
$array['sofia_global_settings'][$x]['global_setting_enabled'] = 'false';
|
$array['sofia_global_settings'][$x]['global_setting_enabled'] = 'false';
|
||||||
$array['sofia_global_settings'][$x]['global_setting_description'] = '';
|
$array['sofia_global_settings'][$x]['global_setting_description'] = '';
|
||||||
|
|
||||||
//grant temporary permissions
|
//removes settings from the array that are already in the database
|
||||||
$p = new permissions;
|
$x = 0;
|
||||||
$p->add('sofia_global_setting_add', 'temp');
|
foreach($sofia_global_settings as $row) {
|
||||||
|
$x = 0;
|
||||||
|
foreach ($array['sofia_global_settings'] as $sub_row) {
|
||||||
|
if ($row['sofia_global_setting_uuid'] == $sub_row['sofia_global_setting_uuid']) {
|
||||||
|
unset($array['sofia_global_settings'][$x]);
|
||||||
|
}
|
||||||
|
$x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//execute insert
|
//add settings that are not in the database
|
||||||
$database = new database;
|
if (count($array['sofia_global_settings']) > 0) {
|
||||||
$database->app_name = 'sofia_global_settings';
|
//grant temporary permissions
|
||||||
$database->app_uuid = '240c25a3-a2cf-44ea-a300-0626eca5b945';
|
$p = new permissions;
|
||||||
$database->save($array, false);
|
$p->add('sofia_global_setting_add', 'temp');
|
||||||
unset($array);
|
|
||||||
|
//execute insert
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = 'sofia_global_settings';
|
||||||
|
$database->app_uuid = '240c25a3-a2cf-44ea-a300-0626eca5b945';
|
||||||
|
$database->save($array, false);
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//revoke temporary permissions
|
||||||
|
$p->delete('sofia_global_setting_add', 'temp');
|
||||||
|
}
|
||||||
|
|
||||||
//revoke temporary permissions
|
|
||||||
$p->delete('sofia_global_setting_add', 'temp');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue