app_defaults.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. //add fax email templates
  3. if ($domains_processed == 1) {
  4. //build the array
  5. $x = 0;
  6. $array['email_templates'][$x]['email_template_uuid'] = 'f91bbd91-46a6-4805-9fa3-e622bbb22989';
  7. $array['email_templates'][$x]['template_language'] = 'en-us';
  8. $array['email_templates'][$x]['template_category'] = 'message';
  9. $array['email_templates'][$x]['template_subcategory'] = 'inbound';
  10. $array['email_templates'][$x]['template_subject'] = "New message received from \${message_from}";
  11. $array['email_templates'][$x]['template_body'] = "<html>\n";
  12. $array['email_templates'][$x]['template_body'] .= "<body>\n";
  13. $array['email_templates'][$x]['template_body'] .= "Message from <a href='tel:\${message_from}'>\${message_from}</a><br><br>\n";
  14. $array['email_templates'][$x]['template_body'] .= "To: \${message_to}<br>\n";
  15. $array['email_templates'][$x]['template_body'] .= "Received: \${message_date}<br>\n";
  16. $array['email_templates'][$x]['template_body'] .= "Message: \${message_text}<br>\n";
  17. $array['email_templates'][$x]['template_body'] .= "</body>\n";
  18. $array['email_templates'][$x]['template_body'] .= "</html>\n";
  19. $array['email_templates'][$x]['template_type'] = "html";
  20. $array['email_templates'][$x]['template_enabled'] = "true";
  21. $x++;
  22. //build array of email template uuids
  23. foreach ($array['email_templates'] as $row) {
  24. if (is_uuid($row['email_template_uuid'])) {
  25. $uuids[] = $row['email_template_uuid'];
  26. }
  27. }
  28. //add the email templates to the database
  29. if (!empty($uuids)) {
  30. $sql = "select * from v_email_templates where ";
  31. foreach ($uuids as $index => $uuid) {
  32. $sql_where[] = "email_template_uuid = :email_template_uuid_".$index;
  33. $parameters['email_template_uuid_'.$index] = $uuid;
  34. }
  35. $sql .= implode(' or ', $sql_where);
  36. $email_templates = $database->select($sql, $parameters, 'all');
  37. unset($sql, $sql_where, $parameters);
  38. //remove templates that already exist from the array
  39. foreach ($array['email_templates'] as $index => $row) {
  40. if (is_array($email_templates) && @sizeof($email_templates) != 0) {
  41. foreach($email_templates as $email_template) {
  42. if ($row['email_template_uuid'] == $email_template['email_template_uuid']) {
  43. unset($array['email_templates'][$index]);
  44. }
  45. }
  46. }
  47. }
  48. unset($email_templates, $index);
  49. }
  50. //add the missing email templates
  51. if (!empty($array['email_templates'])) {
  52. //add the temporary permission
  53. $p = new permissions;
  54. $p->add("email_template_add", 'temp');
  55. $p->add("email_template_edit", 'temp');
  56. //save the data
  57. $database->app_name = 'email_templates';
  58. $database->app_uuid = '8173e738-2523-46d5-8943-13883befd2fd';
  59. $database->save($array);
  60. //$message = $database->message;
  61. //remove the temporary permission
  62. $p->delete("email_template_add", 'temp');
  63. $p->delete("email_template_edit", 'temp');
  64. }
  65. //remove the array
  66. unset($array);
  67. }
  68. ?>