Update app_defaults.php
This commit is contained in:
parent
3630ec2d24
commit
ef59376717
|
|
@ -27,12 +27,6 @@
|
|||
//if the number of rows is 0 then read the sip profile xml into the database
|
||||
if ($domains_processed == 1) {
|
||||
|
||||
//add the email templates to the database
|
||||
$sql = "select count(*) as num_rows from v_email_templates ";
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
if ($row['num_rows'] == 0) {
|
||||
|
||||
//build the array
|
||||
$x = 0;
|
||||
$array['email_templates'][$x]['email_template_uuid'] = '5256e0aa-10a3-41a9-a7d9-47240823a186';
|
||||
|
|
@ -307,24 +301,55 @@
|
|||
$array['email_templates'][$x]['template_description'] = '';
|
||||
$x++;
|
||||
|
||||
//build array of email template uuids
|
||||
foreach ($array['email_templates'] as $row) {
|
||||
if (is_uuid($row['email_template_uuid'])) {
|
||||
$uuids[] = $row['email_template_uuid'];
|
||||
}
|
||||
}
|
||||
|
||||
//implode the array into a string
|
||||
$string = "'".implode("','", $uuids)."'";
|
||||
|
||||
//add the email templates to the database
|
||||
$sql = "select * from v_email_templates ";
|
||||
$sql .= "where email_template_uuid in (".$string.") ";
|
||||
$database = new database;
|
||||
$email_templates = $database->select($sql, null, 'all');
|
||||
|
||||
//remove templates that already exist from the array
|
||||
$x = 0;
|
||||
foreach ($array['email_templates'] as $row) {
|
||||
foreach($email_templates as $email_template) {
|
||||
if ($row['email_template_uuid'] == $email_template['email_template_uuid']) {
|
||||
unset($array['email_templates'][$x]);
|
||||
}
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
|
||||
//add the missing email templates
|
||||
if (is_array($array['email_templates'])) {
|
||||
//add the temporary permission
|
||||
$p = new permissions;
|
||||
$p->add("email_template_add", 'temp');
|
||||
$p->add("email_template_edit", 'temp');
|
||||
|
||||
//save to the data
|
||||
//save the data
|
||||
$database = new database;
|
||||
$database->app_name = 'email_templates';
|
||||
$database->app_uuid = '8173e738-2523-46d5-8943-13883befd2fd';
|
||||
$database->save($array);
|
||||
//$message = $database->message;
|
||||
unset($array);
|
||||
|
||||
//remove the temporary permission
|
||||
$p->delete("email_template_add", 'temp');
|
||||
$p->delete("email_template_edit", 'temp');
|
||||
}
|
||||
|
||||
//remove the array
|
||||
unset($array);
|
||||
|
||||
} //if ($row['num_rows'] == 0)
|
||||
} //if ($domains_processed == 1)
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue