Add the email_queue.

This commit is contained in:
markjcrane 2022-04-22 13:00:38 -06:00
parent f73f9b706f
commit 133c51bfcf
13 changed files with 2995 additions and 0 deletions

View File

@ -0,0 +1,216 @@
<?php
//application details
$apps[$x]['name'] = 'Email Queue';
$apps[$x]['uuid'] = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
$apps[$x]['category'] = 'system';
$apps[$x]['subcategory'] = 'email';
$apps[$x]['version'] = '2.10';
$apps[$x]['license'] = 'Member';
$apps[$x]['url'] = 'http://www.fusionpbx.com';
$apps[$x]['description']['en-us'] = '';
//default settings
$y=0;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "35c40afc-8b08-45f1-a96c-2f8a5352cd2d";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "email_queue";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "enabled";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Enable or disable the email queue.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "237efdc4-ba71-4c8f-8040-28d0e3a3d6bf";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "email_queue";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "limit";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "30";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Limit the records to process at one time.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "c4905655-2d67-4eda-9df0-029931c12c6f";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "email_queue";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "interval";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "120";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "How often to process the email queue. Default 120 seconds.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "d945ed66-39c1-44eb-b596-49c9399d8018";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "email_queue";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "retry_limit";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "3";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Number of tries to send an email before giving up.";
$y++;
//$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "a9eb5a16-e018-4a83-975e-eee2ed31f923";
//$apps[$x]['default_settings'][$y]['default_setting_category'] = "email_queue";
//$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "retry_interval";
//$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
//$apps[$x]['default_settings'][$y]['default_setting_value'] = "300";
//$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
//$apps[$x]['default_settings'][$y]['default_setting_description'] = "Time in seconds to wait before trying to email again. Default 300 seconds";
//permission details
$y = 0;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_add';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_edit';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_attachment_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_attachment_add';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_attachment_edit';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_attachment_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'email_queue_attachment_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
//email queue
$y = 0;
$apps[$x]['db'][$y]['table']['name'] = 'v_email_queue';
$apps[$x]['db'][$y]['table']['parent'] = '';
$z = 0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_queue_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hostname';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_date';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'false';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_from';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_to';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_subject';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_body';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_status';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_retry_count';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'false';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_action_before';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_action_after';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_transcription';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'email_debug';
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'email_substatus';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
//$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
//attachments
$y = 6;
$apps[$x]['db'][$y]['table']['name'] = 'v_email_queue_attachments';
$apps[$x]['db'][$y]['table']['parent'] = 'v_email_queue';
$z = 0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_queue_attachment_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_queue_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_email_queue';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'email_queue_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_attachment_type';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_attachment_path';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_attachment_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'email_attachment_base64';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$z++;
?>

View File

@ -0,0 +1,504 @@
<?php
//Email Queue
$text['title-email_queue']['en-us'] = 'Email Queue';
$text['title-email_queue']['ar-eg'] = '';
$text['title-email_queue']['de-at'] = '';
$text['title-email_queue']['de-ch'] = '';
$text['title-email_queue']['de-de'] = '';
$text['title-email_queue']['es-cl'] = '';
$text['title-email_queue']['es-mx'] = '';
$text['title-email_queue']['fr-ca'] = '';
$text['title-email_queue']['fr-fr'] = '';
$text['title-email_queue']['he-il'] = '';
$text['title-email_queue']['it-it'] = '';
$text['title-email_queue']['nl-nl'] = '';
$text['title-email_queue']['pl-pl'] = '';
$text['title-email_queue']['pt-br'] = '';
$text['title-email_queue']['pt-pt'] = '';
$text['title-email_queue']['ro-ro'] = '';
$text['title-email_queue']['ru-ru'] = '';
$text['title-email_queue']['sv-se'] = '';
$text['title-email_queue']['uk-ua'] = '';
$text['title-email_queue']['en-us'] = 'Email Queue';
$text['title-email_queue']['ar-eg'] = '';
$text['title-email_queue']['de-at'] = '';
$text['title-email_queue']['de-ch'] = '';
$text['title-email_queue']['de-de'] = '';
$text['title-email_queue']['es-cl'] = '';
$text['title-email_queue']['es-mx'] = '';
$text['title-email_queue']['fr-ca'] = '';
$text['title-email_queue']['fr-fr'] = '';
$text['title-email_queue']['he-il'] = '';
$text['title-email_queue']['it-it'] = '';
$text['title-email_queue']['nl-nl'] = '';
$text['title-email_queue']['pl-pl'] = '';
$text['title-email_queue']['pt-br'] = '';
$text['title-email_queue']['pt-pt'] = '';
$text['title-email_queue']['ro-ro'] = '';
$text['title-email_queue']['ru-ru'] = '';
$text['title-email_queue']['sv-se'] = '';
$text['title-email_queue']['uk-ua'] = '';
$text['title_description-email_queue']['en-us'] = '';
$text['title_description-email_queue']['ar-eg'] = '';
$text['title_description-email_queue']['de-at'] = '';
$text['title_description-email_queue']['de-ch'] = '';
$text['title_description-email_queue']['de-de'] = '';
$text['title_description-email_queue']['es-cl'] = '';
$text['title_description-email_queue']['es-mx'] = '';
$text['title_description-email_queue']['fr-ca'] = '';
$text['title_description-email_queue']['fr-fr'] = '';
$text['title_description-email_queue']['he-il'] = '';
$text['title_description-email_queue']['it-it'] = '';
$text['title_description-email_queue']['nl-nl'] = '';
$text['title_description-email_queue']['pl-pl'] = '';
$text['title_description-email_queue']['pt-br'] = '';
$text['title_description-email_queue']['pt-pt'] = '';
$text['title_description-email_queue']['ro-ro'] = '';
$text['title_description-email_queue']['ru-ru'] = '';
$text['title_description-email_queue']['sv-se'] = '';
$text['title_description-email_queue']['uk-ua'] = '';
$text['label-email_date']['en-us'] = 'Date';
$text['label-email_date']['ar-eg'] = '';
$text['label-email_date']['de-at'] = '';
$text['label-email_date']['de-ch'] = '';
$text['label-email_date']['de-de'] = '';
$text['label-email_date']['es-cl'] = '';
$text['label-email_date']['es-mx'] = '';
$text['label-email_date']['fr-ca'] = '';
$text['label-email_date']['fr-fr'] = '';
$text['label-email_date']['he-il'] = '';
$text['label-email_date']['it-it'] = '';
$text['label-email_date']['nl-nl'] = '';
$text['label-email_date']['pl-pl'] = '';
$text['label-email_date']['pt-br'] = '';
$text['label-email_date']['pt-pt'] = '';
$text['label-email_date']['ro-ro'] = '';
$text['label-email_date']['ru-ru'] = '';
$text['label-email_date']['sv-se'] = '';
$text['label-email_date']['uk-ua'] = '';
$text['description-email_date']['en-us'] = 'Enter the email date.';
$text['description-email_date']['ar-eg'] = '';
$text['description-email_date']['de-at'] = '';
$text['description-email_date']['de-ch'] = '';
$text['description-email_date']['de-de'] = '';
$text['description-email_date']['es-cl'] = '';
$text['description-email_date']['es-mx'] = '';
$text['description-email_date']['fr-ca'] = '';
$text['description-email_date']['fr-fr'] = '';
$text['description-email_date']['he-il'] = '';
$text['description-email_date']['it-it'] = '';
$text['description-email_date']['nl-nl'] = '';
$text['description-email_date']['pl-pl'] = '';
$text['description-email_date']['pt-br'] = '';
$text['description-email_date']['pt-pt'] = '';
$text['description-email_date']['ro-ro'] = '';
$text['description-email_date']['ru-ru'] = '';
$text['description-email_date']['sv-se'] = '';
$text['description-email_date']['uk-ua'] = '';
$text['label-email_from']['en-us'] = 'From';
$text['label-email_from']['ar-eg'] = '';
$text['label-email_from']['de-at'] = '';
$text['label-email_from']['de-ch'] = '';
$text['label-email_from']['de-de'] = '';
$text['label-email_from']['es-cl'] = '';
$text['label-email_from']['es-mx'] = '';
$text['label-email_from']['fr-ca'] = '';
$text['label-email_from']['fr-fr'] = '';
$text['label-email_from']['he-il'] = '';
$text['label-email_from']['it-it'] = '';
$text['label-email_from']['nl-nl'] = '';
$text['label-email_from']['pl-pl'] = '';
$text['label-email_from']['pt-br'] = '';
$text['label-email_from']['pt-pt'] = '';
$text['label-email_from']['ro-ro'] = '';
$text['label-email_from']['ru-ru'] = '';
$text['label-email_from']['sv-se'] = '';
$text['label-email_from']['uk-ua'] = '';
$text['description-email_from']['en-us'] = 'Enter the email from.';
$text['description-email_from']['ar-eg'] = '';
$text['description-email_from']['de-at'] = '';
$text['description-email_from']['de-ch'] = '';
$text['description-email_from']['de-de'] = '';
$text['description-email_from']['es-cl'] = '';
$text['description-email_from']['es-mx'] = '';
$text['description-email_from']['fr-ca'] = '';
$text['description-email_from']['fr-fr'] = '';
$text['description-email_from']['he-il'] = '';
$text['description-email_from']['it-it'] = '';
$text['description-email_from']['nl-nl'] = '';
$text['description-email_from']['pl-pl'] = '';
$text['description-email_from']['pt-br'] = '';
$text['description-email_from']['pt-pt'] = '';
$text['description-email_from']['ro-ro'] = '';
$text['description-email_from']['ru-ru'] = '';
$text['description-email_from']['sv-se'] = '';
$text['description-email_from']['uk-ua'] = '';
$text['label-email_to']['en-us'] = 'To';
$text['label-email_to']['ar-eg'] = '';
$text['label-email_to']['de-at'] = '';
$text['label-email_to']['de-ch'] = '';
$text['label-email_to']['de-de'] = '';
$text['label-email_to']['es-cl'] = '';
$text['label-email_to']['es-mx'] = '';
$text['label-email_to']['fr-ca'] = '';
$text['label-email_to']['fr-fr'] = '';
$text['label-email_to']['he-il'] = '';
$text['label-email_to']['it-it'] = '';
$text['label-email_to']['nl-nl'] = '';
$text['label-email_to']['pl-pl'] = '';
$text['label-email_to']['pt-br'] = '';
$text['label-email_to']['pt-pt'] = '';
$text['label-email_to']['ro-ro'] = '';
$text['label-email_to']['ru-ru'] = '';
$text['label-email_to']['sv-se'] = '';
$text['label-email_to']['uk-ua'] = '';
$text['description-email_to']['en-us'] = 'Enter the email to.';
$text['description-email_to']['ar-eg'] = '';
$text['description-email_to']['de-at'] = '';
$text['description-email_to']['de-ch'] = '';
$text['description-email_to']['de-de'] = '';
$text['description-email_to']['es-cl'] = '';
$text['description-email_to']['es-mx'] = '';
$text['description-email_to']['fr-ca'] = '';
$text['description-email_to']['fr-fr'] = '';
$text['description-email_to']['he-il'] = '';
$text['description-email_to']['it-it'] = '';
$text['description-email_to']['nl-nl'] = '';
$text['description-email_to']['pl-pl'] = '';
$text['description-email_to']['pt-br'] = '';
$text['description-email_to']['pt-pt'] = '';
$text['description-email_to']['ro-ro'] = '';
$text['description-email_to']['ru-ru'] = '';
$text['description-email_to']['sv-se'] = '';
$text['description-email_to']['uk-ua'] = '';
$text['label-email_cc']['en-us'] = 'CC';
$text['label-email_cc']['ar-eg'] = '';
$text['label-email_cc']['de-at'] = '';
$text['label-email_cc']['de-ch'] = '';
$text['label-email_cc']['de-de'] = '';
$text['label-email_cc']['es-cl'] = '';
$text['label-email_cc']['es-mx'] = '';
$text['label-email_cc']['fr-ca'] = '';
$text['label-email_cc']['fr-fr'] = '';
$text['label-email_cc']['he-il'] = '';
$text['label-email_cc']['it-it'] = '';
$text['label-email_cc']['nl-nl'] = '';
$text['label-email_cc']['pl-pl'] = '';
$text['label-email_cc']['pt-br'] = '';
$text['label-email_cc']['pt-pt'] = '';
$text['label-email_cc']['ro-ro'] = '';
$text['label-email_cc']['ru-ru'] = '';
$text['label-email_cc']['sv-se'] = '';
$text['label-email_cc']['uk-ua'] = '';
$text['description-email_cc']['en-us'] = 'Enter the email cc.';
$text['description-email_cc']['ar-eg'] = '';
$text['description-email_cc']['de-at'] = '';
$text['description-email_cc']['de-ch'] = '';
$text['description-email_cc']['de-de'] = '';
$text['description-email_cc']['es-cl'] = '';
$text['description-email_cc']['es-mx'] = '';
$text['description-email_cc']['fr-ca'] = '';
$text['description-email_cc']['fr-fr'] = '';
$text['description-email_cc']['he-il'] = '';
$text['description-email_cc']['it-it'] = '';
$text['description-email_cc']['nl-nl'] = '';
$text['description-email_cc']['pl-pl'] = '';
$text['description-email_cc']['pt-br'] = '';
$text['description-email_cc']['pt-pt'] = '';
$text['description-email_cc']['ro-ro'] = '';
$text['description-email_cc']['ru-ru'] = '';
$text['description-email_cc']['sv-se'] = '';
$text['description-email_cc']['uk-ua'] = '';
$text['label-email_bcc']['en-us'] = 'BCC';
$text['label-email_bcc']['ar-eg'] = '';
$text['label-email_bcc']['de-at'] = '';
$text['label-email_bcc']['de-ch'] = '';
$text['label-email_bcc']['de-de'] = '';
$text['label-email_bcc']['es-cl'] = '';
$text['label-email_bcc']['es-mx'] = '';
$text['label-email_bcc']['fr-ca'] = '';
$text['label-email_bcc']['fr-fr'] = '';
$text['label-email_bcc']['he-il'] = '';
$text['label-email_bcc']['it-it'] = '';
$text['label-email_bcc']['nl-nl'] = '';
$text['label-email_bcc']['pl-pl'] = '';
$text['label-email_bcc']['pt-br'] = '';
$text['label-email_bcc']['pt-pt'] = '';
$text['label-email_bcc']['ro-ro'] = '';
$text['label-email_bcc']['ru-ru'] = '';
$text['label-email_bcc']['sv-se'] = '';
$text['label-email_bcc']['uk-ua'] = '';
$text['description-email_bcc']['en-us'] = 'Enter the email bcc.';
$text['description-email_bcc']['ar-eg'] = '';
$text['description-email_bcc']['de-at'] = '';
$text['description-email_bcc']['de-ch'] = '';
$text['description-email_bcc']['de-de'] = '';
$text['description-email_bcc']['es-cl'] = '';
$text['description-email_bcc']['es-mx'] = '';
$text['description-email_bcc']['fr-ca'] = '';
$text['description-email_bcc']['fr-fr'] = '';
$text['description-email_bcc']['he-il'] = '';
$text['description-email_bcc']['it-it'] = '';
$text['description-email_bcc']['nl-nl'] = '';
$text['description-email_bcc']['pl-pl'] = '';
$text['description-email_bcc']['pt-br'] = '';
$text['description-email_bcc']['pt-pt'] = '';
$text['description-email_bcc']['ro-ro'] = '';
$text['description-email_bcc']['ru-ru'] = '';
$text['description-email_bcc']['sv-se'] = '';
$text['description-email_bcc']['uk-ua'] = '';
$text['label-email_subject']['en-us'] = 'Subject';
$text['label-email_subject']['ar-eg'] = '';
$text['label-email_subject']['de-at'] = '';
$text['label-email_subject']['de-ch'] = '';
$text['label-email_subject']['de-de'] = '';
$text['label-email_subject']['es-cl'] = '';
$text['label-email_subject']['es-mx'] = '';
$text['label-email_subject']['fr-ca'] = '';
$text['label-email_subject']['fr-fr'] = '';
$text['label-email_subject']['he-il'] = '';
$text['label-email_subject']['it-it'] = '';
$text['label-email_subject']['nl-nl'] = '';
$text['label-email_subject']['pl-pl'] = '';
$text['label-email_subject']['pt-br'] = '';
$text['label-email_subject']['pt-pt'] = '';
$text['label-email_subject']['ro-ro'] = '';
$text['label-email_subject']['ru-ru'] = '';
$text['label-email_subject']['sv-se'] = '';
$text['label-email_subject']['uk-ua'] = '';
$text['description-email_subject']['en-us'] = 'Enter the email subject.';
$text['description-email_subject']['ar-eg'] = '';
$text['description-email_subject']['de-at'] = '';
$text['description-email_subject']['de-ch'] = '';
$text['description-email_subject']['de-de'] = '';
$text['description-email_subject']['es-cl'] = '';
$text['description-email_subject']['es-mx'] = '';
$text['description-email_subject']['fr-ca'] = '';
$text['description-email_subject']['fr-fr'] = '';
$text['description-email_subject']['he-il'] = '';
$text['description-email_subject']['it-it'] = '';
$text['description-email_subject']['nl-nl'] = '';
$text['description-email_subject']['pl-pl'] = '';
$text['description-email_subject']['pt-br'] = '';
$text['description-email_subject']['pt-pt'] = '';
$text['description-email_subject']['ro-ro'] = '';
$text['description-email_subject']['ru-ru'] = '';
$text['description-email_subject']['sv-se'] = '';
$text['description-email_subject']['uk-ua'] = '';
$text['label-email_body']['en-us'] = 'Body';
$text['label-email_body']['ar-eg'] = '';
$text['label-email_body']['de-at'] = '';
$text['label-email_body']['de-ch'] = '';
$text['label-email_body']['de-de'] = '';
$text['label-email_body']['es-cl'] = '';
$text['label-email_body']['es-mx'] = '';
$text['label-email_body']['fr-ca'] = '';
$text['label-email_body']['fr-fr'] = '';
$text['label-email_body']['he-il'] = '';
$text['label-email_body']['it-it'] = '';
$text['label-email_body']['nl-nl'] = '';
$text['label-email_body']['pl-pl'] = '';
$text['label-email_body']['pt-br'] = '';
$text['label-email_body']['pt-pt'] = '';
$text['label-email_body']['ro-ro'] = '';
$text['label-email_body']['ru-ru'] = '';
$text['label-email_body']['sv-se'] = '';
$text['label-email_body']['uk-ua'] = '';
$text['description-email_body']['en-us'] = 'Enter the email body.';
$text['description-email_body']['ar-eg'] = '';
$text['description-email_body']['de-at'] = '';
$text['description-email_body']['de-ch'] = '';
$text['description-email_body']['de-de'] = '';
$text['description-email_body']['es-cl'] = '';
$text['description-email_body']['es-mx'] = '';
$text['description-email_body']['fr-ca'] = '';
$text['description-email_body']['fr-fr'] = '';
$text['description-email_body']['he-il'] = '';
$text['description-email_body']['it-it'] = '';
$text['description-email_body']['nl-nl'] = '';
$text['description-email_body']['pl-pl'] = '';
$text['description-email_body']['pt-br'] = '';
$text['description-email_body']['pt-pt'] = '';
$text['description-email_body']['ro-ro'] = '';
$text['description-email_body']['ru-ru'] = '';
$text['description-email_body']['sv-se'] = '';
$text['description-email_body']['uk-ua'] = '';
$text['label-email_status']['en-us'] = 'Status';
$text['label-email_status']['ar-eg'] = '';
$text['label-email_status']['de-at'] = '';
$text['label-email_status']['de-ch'] = '';
$text['label-email_status']['de-de'] = '';
$text['label-email_status']['es-cl'] = '';
$text['label-email_status']['es-mx'] = '';
$text['label-email_status']['fr-ca'] = '';
$text['label-email_status']['fr-fr'] = '';
$text['label-email_status']['he-il'] = '';
$text['label-email_status']['it-it'] = '';
$text['label-email_status']['nl-nl'] = '';
$text['label-email_status']['pl-pl'] = '';
$text['label-email_status']['pt-br'] = '';
$text['label-email_status']['pt-pt'] = '';
$text['label-email_status']['ro-ro'] = '';
$text['label-email_status']['ru-ru'] = '';
$text['label-email_status']['sv-se'] = '';
$text['label-email_status']['uk-ua'] = '';
$text['description-email_status']['en-us'] = 'Enter the email status.';
$text['description-email_status']['ar-eg'] = '';
$text['description-email_status']['de-at'] = '';
$text['description-email_status']['de-ch'] = '';
$text['description-email_status']['de-de'] = '';
$text['description-email_status']['es-cl'] = '';
$text['description-email_status']['es-mx'] = '';
$text['description-email_status']['fr-ca'] = '';
$text['description-email_status']['fr-fr'] = '';
$text['description-email_status']['he-il'] = '';
$text['description-email_status']['it-it'] = '';
$text['description-email_status']['nl-nl'] = '';
$text['description-email_status']['pl-pl'] = '';
$text['description-email_status']['pt-br'] = '';
$text['description-email_status']['pt-pt'] = '';
$text['description-email_status']['ro-ro'] = '';
$text['description-email_status']['ru-ru'] = '';
$text['description-email_status']['sv-se'] = '';
$text['description-email_status']['uk-ua'] = '';
$text['label-email_action_before']['en-us'] = 'Before Email';
$text['label-email_action_before']['ar-eg'] = '';
$text['label-email_action_before']['de-at'] = '';
$text['label-email_action_before']['de-ch'] = '';
$text['label-email_action_before']['de-de'] = '';
$text['label-email_action_before']['es-cl'] = '';
$text['label-email_action_before']['es-mx'] = '';
$text['label-email_action_before']['fr-ca'] = '';
$text['label-email_action_before']['fr-fr'] = '';
$text['label-email_action_before']['he-il'] = '';
$text['label-email_action_before']['it-it'] = '';
$text['label-email_action_before']['nl-nl'] = '';
$text['label-email_action_before']['pl-pl'] = '';
$text['label-email_action_before']['pt-br'] = '';
$text['label-email_action_before']['pt-pt'] = '';
$text['label-email_action_before']['ro-ro'] = '';
$text['label-email_action_before']['ru-ru'] = '';
$text['label-email_action_before']['sv-se'] = '';
$text['label-email_action_before']['uk-ua'] = '';
$text['description-email_action_before']['en-us'] = 'Enter the action before sending the email.';
$text['description-email_action_before']['ar-eg'] = '';
$text['description-email_action_before']['de-at'] = '';
$text['description-email_action_before']['de-ch'] = '';
$text['description-email_action_before']['de-de'] = '';
$text['description-email_action_before']['es-cl'] = '';
$text['description-email_action_before']['es-mx'] = '';
$text['description-email_action_before']['fr-ca'] = '';
$text['description-email_action_before']['fr-fr'] = '';
$text['description-email_action_before']['he-il'] = '';
$text['description-email_action_before']['it-it'] = '';
$text['description-email_action_before']['nl-nl'] = '';
$text['description-email_action_before']['pl-pl'] = '';
$text['description-email_action_before']['pt-br'] = '';
$text['description-email_action_before']['pt-pt'] = '';
$text['description-email_action_before']['ro-ro'] = '';
$text['description-email_action_before']['ru-ru'] = '';
$text['description-email_action_before']['sv-se'] = '';
$text['description-email_action_before']['uk-ua'] = '';
$text['label-email_action_after']['en-us'] = 'After Email';
$text['label-email_action_after']['ar-eg'] = '';
$text['label-email_action_after']['de-at'] = '';
$text['label-email_action_after']['de-ch'] = '';
$text['label-email_action_after']['de-de'] = '';
$text['label-email_action_after']['es-cl'] = '';
$text['label-email_action_after']['es-mx'] = '';
$text['label-email_action_after']['fr-ca'] = '';
$text['label-email_action_after']['fr-fr'] = '';
$text['label-email_action_after']['he-il'] = '';
$text['label-email_action_after']['it-it'] = '';
$text['label-email_action_after']['nl-nl'] = '';
$text['label-email_action_after']['pl-pl'] = '';
$text['label-email_action_after']['pt-br'] = '';
$text['label-email_action_after']['pt-pt'] = '';
$text['label-email_action_after']['ro-ro'] = '';
$text['label-email_action_after']['ru-ru'] = '';
$text['label-email_action_after']['sv-se'] = '';
$text['label-email_action_after']['uk-ua'] = '';
$text['description-email_action_after']['en-us'] = 'Enter the action after sending the email.';
$text['description-email_action_after']['ar-eg'] = '';
$text['description-email_action_after']['de-at'] = '';
$text['description-email_action_after']['de-ch'] = '';
$text['description-email_action_after']['de-de'] = '';
$text['description-email_action_after']['es-cl'] = '';
$text['description-email_action_after']['es-mx'] = '';
$text['description-email_action_after']['fr-ca'] = '';
$text['description-email_action_after']['fr-fr'] = '';
$text['description-email_action_after']['he-il'] = '';
$text['description-email_action_after']['it-it'] = '';
$text['description-email_action_after']['nl-nl'] = '';
$text['description-email_action_after']['pl-pl'] = '';
$text['description-email_action_after']['pt-br'] = '';
$text['description-email_action_after']['pt-pt'] = '';
$text['description-email_action_after']['ro-ro'] = '';
$text['description-email_action_after']['ru-ru'] = '';
$text['description-email_action_after']['sv-se'] = '';
$text['description-email_action_after']['uk-ua'] = '';
$text['label-email_retry_count']['en-us'] = 'Retry';
$text['label-email_retry_count']['ar-eg'] = '';
$text['label-email_retry_count']['de-at'] = '';
$text['label-email_retry_count']['de-ch'] = '';
$text['label-email_retry_count']['de-de'] = '';
$text['label-email_retry_count']['es-cl'] = '';
$text['label-email_retry_count']['es-mx'] = '';
$text['label-email_retry_count']['fr-ca'] = '';
$text['label-email_retry_count']['fr-fr'] = '';
$text['label-email_retry_count']['he-il'] = '';
$text['label-email_retry_count']['it-it'] = '';
$text['label-email_retry_count']['nl-nl'] = '';
$text['label-email_retry_count']['pl-pl'] = '';
$text['label-email_retry_count']['pt-br'] = '';
$text['label-email_retry_count']['pt-pt'] = '';
$text['label-email_retry_count']['ro-ro'] = '';
$text['label-email_retry_count']['ru-ru'] = '';
$text['label-email_retry_count']['sv-se'] = '';
$text['label-email_retry_count']['uk-ua'] = '';
$text['description-email_retry_count']['en-us'] = 'Enter the email retry.';
$text['description-email_retry_count']['ar-eg'] = '';
$text['description-email_retry_count']['de-at'] = '';
$text['description-email_retry_count']['de-ch'] = '';
$text['description-email_retry_count']['de-de'] = '';
$text['description-email_retry_count']['es-cl'] = '';
$text['description-email_retry_count']['es-mx'] = '';
$text['description-email_retry_count']['fr-ca'] = '';
$text['description-email_retry_count']['fr-fr'] = '';
$text['description-email_retry_count']['he-il'] = '';
$text['description-email_retry_count']['it-it'] = '';
$text['description-email_retry_count']['nl-nl'] = '';
$text['description-email_retry_count']['pl-pl'] = '';
$text['description-email_retry_count']['pt-br'] = '';
$text['description-email_retry_count']['pt-pt'] = '';
$text['description-email_retry_count']['ro-ro'] = '';
$text['description-email_retry_count']['ru-ru'] = '';
$text['description-email_retry_count']['sv-se'] = '';
$text['description-email_retry_count']['uk-ua'] = '';
?>

View File

@ -0,0 +1,19 @@
<?php
$apps[$x]['menu'][0]['title']['en-us'] = 'Email Queue';
$apps[$x]['menu'][0]['title']['es-cl'] = '';
$apps[$x]['menu'][0]['title']['fr-fr'] = '';
$apps[$x]['menu'][0]['title']['fr-ca'] = '';
$apps[$x]['menu'][0]['title']['pl'] = '';
$apps[$x]['menu'][0]['title']['sv-se'] = '';
$apps[$x]['menu'][0]['title']['uk'] = '';
$apps[$x]['menu'][0]['title']['de-at'] = '';
$apps[$x]['menu'][0]['uuid'] = 'dfa6a878-e2b0-4051-acaf-f6ffc13b9abf';
$apps[$x]['menu'][0]['parent_uuid'] = '594d99c5-6128-9c88-ca35-4b33392cec0f';
$apps[$x]['menu'][0]['category'] = 'internal';
$apps[$x]['menu'][0]['path'] = '/app/email_queue/email_queue.php';
$apps[$x]['menu'][0]['groups'][] = 'superadmin';
//$apps[$x]['menu'][0]['groups'][] = 'admin';
//$apps[$x]['menu'][0]['groups'][] = 'user';
?>

View File

@ -0,0 +1,289 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('email_queue_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the http post data
if (is_array($_POST['email_queue'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$email_queue = $_POST['email_queue'];
}
//process the http post data by action
if ($action != '' && is_array($email_queue) && @sizeof($email_queue) != 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: email_queue.php');
exit;
}
//prepare the array
foreach($email_queue as $row) {
//email class queue uuid
$array[$x]['checked'] = $row['checked'];
$array[$x]['uuid'] = $row['email_queue_uuid'];
// database class uuid
//$array['email_queue'][$x]['checked'] = $row['checked'];
//$array['email_queue'][$x]['email_queue_uuid'] = $row['email_queue_uuid'];
$x++;
}
//prepare the database object
$database = new database;
$database->app_name = 'email_queue';
$database->app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
//send the array to the database class
switch ($action) {
case 'copy':
//if (permission_exists('email_queue_add')) {
// $database->copy($array);
//}
break;
case 'toggle':
//if (permission_exists('email_queue_edit')) {
// $database->toggle($array);
//}
break;
case 'delete':
if (permission_exists('email_queue_delete')) {
$obj = new email_queue;
$obj->delete($array);
//$database->delete($array);
}
break;
}
//redirect the user
header('Location: email_queue.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
}
//get order and order by
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//add the search
if (isset($_GET["search"])) {
$search = strtolower($_GET["search"]);
}
//get the count
$sql = "select count(email_queue_uuid) ";
$sql .= "from v_email_queue ";
if (isset($search)) {
$sql .= "where (";
$sql .= " lower(email_from) like :search ";
$sql .= " or lower(email_to) like :search ";
$sql .= " or lower(email_subject) like :search ";
$sql .= " or lower(email_body) like :search ";
$sql .= " or lower(email_status) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
//else {
// $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
// $parameters['domain_uuid'] = $domain_uuid;
//}
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = $search ? "&search=".$search : null;
$param = ($_GET['show'] == 'all' && permission_exists('email_queue_all')) ? "&show=all" : null;
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
//get the list
$sql = "select ";
$sql .= "email_date, ";
$sql .= "email_queue_uuid, ";
$sql .= "hostname, ";
$sql .= "email_from, ";
$sql .= "email_to, ";
$sql .= "email_subject, ";
$sql .= "email_body, ";
//$sql .= "email_action_before, ";
$sql .= "email_action_after, ";
$sql .= "email_status, ";
$sql .= "email_retry_count ";
$sql .= "from v_email_queue ";
if (isset($_GET["search"])) {
$sql .= "where (";
$sql .= " lower(email_from) like :search ";
$sql .= " or lower(email_to) like :search ";
$sql .= " or lower(email_subject) like :search ";
$sql .= " or lower(email_body) like :search ";
$sql .= " or lower(email_status) like :search ";
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
$sql .= order_by($order_by, $order, 'email_date', 'desc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$email_queue = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//additional includes
$document['title'] = $text['title-email_queue'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-email_queue']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
//if (permission_exists('email_queue_add')) {
// echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'email_queue_edit.php']);
//}
//if (permission_exists('email_queue_add') && $email_queue) {
// echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
//}
//if (permission_exists('email_queue_edit') && $email_queue) {
// echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
//}
if (permission_exists('email_queue_delete') && $email_queue) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
echo "<form id='form_search' class='inline' method='get'>\n";
//if (permission_exists('email_queue_all')) {
// if ($_GET['show'] == 'all') {
// echo " <input type='hidden' name='show' value='all'>\n";
// }
// else {
// echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all']);
// }
//}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'email_queue.php','style'=>($search == '' ? 'display: none;' : null)]);
if ($paging_controls_mini != '') {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('email_queue_add') && $email_queue) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('email_queue_edit') && $email_queue) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('email_queue_delete') && $email_queue) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('email_queue_add') || permission_exists('email_queue_edit') || permission_exists('email_queue_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".($email_queue ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('email_queue_all')) {
// echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
//}
echo th_order_by('email_date', $text['label-email_date'], $order_by, $order);
echo th_order_by('hostname', $text['label-hostname'], $order_by, $order);
echo th_order_by('email_from', $text['label-email_from'], $order_by, $order);
echo th_order_by('email_to', $text['label-email_to'], $order_by, $order);
echo th_order_by('email_subject', $text['label-email_subject'], $order_by, $order);
echo th_order_by('email_body', $text['label-email_body'], $order_by, $order);
echo th_order_by('email_status', $text['label-email_status'], $order_by, $order);
echo th_order_by('email_retry_count', $text['label-email_retry_count'], $order_by, $order);
//echo th_order_by('email_action_before', $text['label-email_action_before'], $order_by, $order);
echo th_order_by('email_action_after', $text['label-email_action_after'], $order_by, $order);
if (permission_exists('email_queue_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (is_array($email_queue) && @sizeof($email_queue) != 0) {
$x = 0;
foreach ($email_queue as $row) {
if (permission_exists('email_queue_edit')) {
$list_row_url = "email_queue_edit.php?id=".urlencode($row['email_queue_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('email_queue_add') || permission_exists('email_queue_edit') || permission_exists('email_queue_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='email_queue[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='email_queue[$x][email_queue_uuid]' value='".escape($row['email_queue_uuid'])."' />\n";
echo " </td>\n";
}
//if ($_GET['show'] == 'all' && permission_exists('email_queue_all')) {
// echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
//}
echo " <td>\n";
if (permission_exists('email_queue_edit')) {
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['email_date'])."</a>\n";
}
else {
echo " ".escape($row['email_date']);
}
echo " </td>\n";
echo " <td>".escape($row['hostname'])."</td>\n";
echo " <td>".escape($row['email_from'])."</td>\n";
echo " <td>".escape($row['email_to'])."</td>\n";
echo " <td>".iconv_mime_decode($row['email_subject'])."</td>\n";
echo " <td>".escape($row['email_body'])."</td>\n";
echo " <td>".escape($row['email_status'])."</td>\n";
echo " <td>".escape($row['email_retry_count'])."</td>\n";
//echo " <td>".escape($row['email_action_before'])."</td>\n";
echo " <td>".escape($row['email_action_after'])."</td>\n";
if (permission_exists('email_queue_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($email_queue);
}
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>

View File

@ -0,0 +1,41 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('email_queue_delete')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//delete the message
message::add($text['message-delete']);
//delete the data
if (isset($_GET["id"]) && is_uuid($_GET["id"])) {
//get the id
$id = $_GET["id"];
//delete the data
$array['email_queue'][]['email_queue_uuid'] = $id;
$database = new database;
$database->delete($array);
unset($array);
//redirect the user
header('Location: email_queues.php');
}
?>

View File

@ -0,0 +1,322 @@
<?php
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('email_queue_add') || permission_exists('email_queue_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//action add or update
if (is_uuid($_REQUEST["id"])) {
$action = "update";
$email_queue_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http post variables and set them to php variables
if (is_array($_POST)) {
$email_date = $_POST["email_date"];
$email_from = $_POST["email_from"];
$email_to = $_POST["email_to"];
$email_subject = $_POST["email_subject"];
$email_body = $_POST["email_body"];
$email_status = $_POST["email_status"];
$email_retry_count = $_POST["email_retry_count"];
//$email_action_before = $_POST["email_action_before"];
$email_action_after = $_POST["email_action_after"];
}
//process the user data and save it to the database
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: email_queue.php');
exit;
}
//process the http post data by submitted action
if ($_POST['action'] != '' && strlen($_POST['action']) > 0) {
//prepare the array(s)
//send the array to the database class
switch ($_POST['action']) {
case 'copy':
if (permission_exists('email_queue_add')) {
$obj = new database;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('email_queue_delete')) {
$obj = new database;
$obj->delete($array);
}
break;
case 'toggle':
if (permission_exists('email_queue_update')) {
$obj = new database;
$obj->toggle($array);
}
break;
}
//redirect the user
if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) {
header('Location: email_queue_edit.php?id='.$id);
exit;
}
}
//check for all required data
$msg = '';
//if (strlen($email_date) == 0) { $msg .= $text['message-required']." ".$text['label-email_date']."<br>\n"; }
//if (strlen($email_from) == 0) { $msg .= $text['message-required']." ".$text['label-email_from']."<br>\n"; }
//if (strlen($email_to) == 0) { $msg .= $text['message-required']." ".$text['label-email_to']."<br>\n"; }
//if (strlen($email_subject) == 0) { $msg .= $text['message-required']." ".$text['label-email_subject']."<br>\n"; }
//if (strlen($email_body) == 0) { $msg .= $text['message-required']." ".$text['label-email_body']."<br>\n"; }
//if (strlen($email_status) == 0) { $msg .= $text['message-required']." ".$text['label-email_status']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add the email_queue_uuid
if (!is_uuid($_POST["email_queue_uuid"])) {
$email_queue_uuid = uuid();
}
//prepare the array
$array['email_queue'][0]['email_queue_uuid'] = $email_queue_uuid;
$array['email_queue'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['email_queue'][0]['email_date'] = $email_date;
$array['email_queue'][0]['email_from'] = $email_from;
$array['email_queue'][0]['email_to'] = $email_to;
$array['email_queue'][0]['email_subject'] = $email_subject;
$array['email_queue'][0]['email_body'] = $email_body;
$array['email_queue'][0]['email_status'] = $email_status;
$array['email_queue'][0]['email_retry_count'] = $email_retry_count;
//$array['email_queue'][0]['email_action_before'] = $email_action_before;
$array['email_queue'][0]['email_action_after'] = $email_action_after;
//save the data
$database = new database;
$database->app_name = 'email queue';
$database->app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
$database->save($array);
//redirect the user
if (isset($action)) {
if ($action == "add") {
$_SESSION["message"] = $text['message-add'];
}
if ($action == "update") {
$_SESSION["message"] = $text['message-update'];
}
//header('Location: email_queue.php');
header('Location: email_queue_edit.php?id='.urlencode($email_queue_uuid));
return;
}
}
//pre-populate the form
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
$sql = "select * from v_email_queue ";
$sql .= "where email_queue_uuid = :email_queue_uuid ";
//$sql .= "and domain_uuid = :domain_uuid ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['email_queue_uuid'] = $email_queue_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && @sizeof($row) != 0) {
$email_date = $row["email_date"];
$email_from = $row["email_from"];
$email_to = $row["email_to"];
$email_subject = $row["email_subject"];
$email_body = $row["email_body"];
$email_status = $row["email_status"];
$email_retry_count = $row["email_retry_count"];
//$email_action_before = $row["email_action_before"];
$email_action_after = $row["email_action_after"];
}
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
$document['title'] = $text['title-email_queue'];
require_once "resources/header.php";
//show the content
echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input class='formfld' type='hidden' name='email_queue_uuid' value='".escape($email_queue_uuid)."'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-email_queue']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'email_queue.php']);
if ($action == 'update') {
if (permission_exists('_add')) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('_delete')) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'hide-xs']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['title_description-email_queue']."\n";
echo "<br /><br />\n";
if ($action == 'update') {
if (permission_exists('email_queue_add')) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'copy','onclick'=>"modal_close();"])]);
}
if (permission_exists('email_queue_delete')) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]);
}
}
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_date']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='email_date' maxlength='255' value='".escape($email_date)."'>\n";
echo "<br />\n";
echo $text['description-email_date']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_from']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='email_from' maxlength='255' value='".escape($email_from)."'>\n";
echo "<br />\n";
echo $text['description-email_from']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_to']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='email_to' maxlength='255' value='".escape($email_to)."'>\n";
echo "<br />\n";
echo $text['description-email_to']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_subject']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='email_subject' maxlength='255' value='".escape($email_subject)."'>\n";
echo "<br />\n";
echo $text['description-email_subject']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_body']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='email_body' maxlength='255' value='".escape($email_body)."'>\n";
echo "<br />\n";
echo $text['description-email_body']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_status']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='email_status' maxlength='255' value='".escape($email_status)."'>\n";
echo "<br />\n";
echo $text['description-email_status']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_retry_count']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='email_retry_count' maxlength='255' value='".escape($email_retry_count)."'>\n";
echo "<br />\n";
echo $text['description-email_retry_count']."\n";
echo "</td>\n";
echo "</tr>\n";
//echo "<tr>\n";
//echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-email_action_before']."\n";
//echo "</td>\n";
//echo "<td class='vtable' style='position: relative;' align='left'>\n";
//echo " <input class='formfld' type='text' name='email_action_before' maxlength='255' value='".escape($email_action_before)."'>\n";
//echo "<br />\n";
//echo $text['description-email_action_before']."\n";
//echo "</td>\n";
//echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email_action_after']."\n";
echo "</td>\n";
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <input class='formfld' type='text' name='email_action_after' maxlength='255' value='".escape($email_action_after)."'>\n";
echo "<br />\n";
echo $text['description-email_action_after']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br /><br />";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>

View File

@ -0,0 +1,240 @@
<?php
/**
* email_queue class
*
* @method null delete
* @method null toggle
* @method null copy
*/
if (!class_exists('email_queue')) {
class email_queue {
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
private $name;
private $table;
private $toggle_field;
private $toggle_values;
private $location;
/**
* called when the object is created
*/
public function __construct() {
//assign the variables
$this->app_name = 'email_queue';
$this->app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
$this->name = 'email_queue';
$this->table = 'email_queue';
$this->toggle_field = '';
$this->toggle_values = ['true','false'];
$this->location = 'email_queue.php';
}
/**
* called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* delete rows from the database
*/
public function delete($records) {
if (permission_exists($this->name.'_delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
$x = 0;
foreach ($records as $record) {
//add to the array
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->name.'_uuid'] = $record['uuid'];
$array['email_queue_attachments'][$x][$this->name.'_uuid'] = $record['uuid'];
//$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
}
//increment the id
$x++;
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
/**
* toggle a field between two values
*/
public function toggle($records) {
if (permission_exists($this->name.'_edit')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state
foreach($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
}
}
unset($sql, $parameters, $rows, $row);
}
//build update array
$x = 0;
foreach($states as $uuid => $state) {
//create the array
$array[$this->table][$x][$this->name.'_uuid'] = $uuid;
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
//increment the id
$x++;
}
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
unset($array);
//set message
message::add($text['message-toggle']);
}
unset($records, $states);
}
}
}
/**
* copy rows from the database
*/
public function copy($records) {
if (permission_exists($this->name.'_add')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//copy the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get checked records
foreach($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
//create the array from existing data
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0;
foreach ($rows as $row) {
//copy data
$array[$this->table][$x] = $row;
//add copy to the description
$array[$this->table][$x][$this->name.'_uuid'] = uuid();
//increment the id
$x++;
}
}
unset($sql, $parameters, $rows, $row);
}
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
unset($array);
//set message
message::add($text['message-copy']);
}
unset($records);
}
}
}
}
}
?>

View File

@ -0,0 +1,229 @@
<?php
if (!function_exists('transcribe')) {
function transcribe ($file_path, $file_name, $file_extension) {
//transcription variables
$transcribe_provider = $_SESSION['voicemail']['transcribe_provider']['text'];
$transcribe_language = $_SESSION['voicemail']['transcribe_language']['text'];
//transribe - watson
if ($transcribe_provider == 'watson') {
$api_key = $_SESSION['voicemail']['watson_key']['text'];
$api_url = $_SESSION['voicemail']['watson_url']['text'];
if ($file_extension == "mp3") {
$content_type = 'audio/mp3';
}
if ($file_extension == "wav") {
$content_type = 'audio/wav';
}
if (isset($api_key) && $api_key != '') {
//check if the file exists
if (!file_exists($file_path.'/'.$file_name)) {
echo "file not found ".$file_path.'/'.$file_name;
exit;
}
//start output buffer
ob_start();
$out = fopen('php://output', 'w');
//create the curl resource
$ch = curl_init();
//set the curl options
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, 'apikey' . ':' . $api_key);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); //set the authentication type
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: '.$content_type]);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($file_path.'/'.$file_name));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); //The number of seconds to wait while trying to connect.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); //To follow any "Location: " header that the server sends as part of the HTTP header.
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); //To automatically set the Referer: field in requests where it follows a Location: redirect.
curl_setopt($ch, CURLOPT_TIMEOUT, 300); //The maximum number of seconds to allow cURL functions to execute.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); //To stop cURL from verifying the peer's certificate.
curl_setopt($ch, CURLOPT_HEADER, 0); //hide the headers when set to 0
//add verbose for debugging
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, $out);
//execute the curl with the options
$http_content = curl_exec($ch);
//return the error
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
//close the curl resource
curl_close($ch);
//show the debug information
fclose($out);
$debug = ob_get_clean();
echo $debug;
//$command = "curl -X POST -silent -u \"apikey:".$api_key."\" --header \"Content-type: ".$content_type."\" --data-binary @".$file_path."/".$file_name." \"".$api_url."\"";
//echo "command: ".$command."\n";
//ob_start();
//$result = passthru($command);
//$json_result = ob_get_contents();
//ob_end_clean();
//run the command
//$http_response = shell_exec($command);
//echo "http_response:\n".$http_response."\n";
//remove headers and return the http content
//$http_response = trim(str_ireplace("HTTP/1.1 100 Continue", "", $http_response));
//$temp_array = explode("HTTP/1.1 200 OK", $http_response);
//$http_array = explode("\r\n\r\n", $temp_array[1]);
//$http_content = trim($http_array[1]);
echo "http_content:\n".$http_content."\n";
//validate the json
$ob = json_decode($http_content);
if($ob === null) {
echo "invalid json\n";
return false;
}
$message = '';
$json = json_decode($http_content, true);
//echo "json; ".$json."\n";
foreach($json['results'] as $row) {
$message .= $row['alternatives'][0]['transcript'];
}
$message = str_replace("%HESITATION", " ", trim($message));
$message = ucfirst($message);
$array['provider'] = $transcribe_provider;
$array['language'] = $transcribe_language;
//$array['command'] = $command;
$array['message'] = $message;
return $array;
}
}
//transribe - google
if ($transcribe_provider == 'google') {
$api_key = $_SESSION['voicemail']['google_key']['text'];
$api_url = $_SESSION['voicemail']['google_url']['text'];
$transcribe_language = $_SESSION['voicemail']['transcribe_language']['text'];
$transcribe_alternate_language = $_SESSION['voicemail']['transcribe_alternate_language']['text'];
if (!isset($transcribe_language) && strlen($transcribe_language) == 0) {
$transcribe_language = 'en-Us';
}
if (!isset($transcribe_alternate_language) && strlen($transcribe_alternate_language) == 0) {
$transcribe_alternate_language = 'es-Us';
}
if ($file_extension == "mp3") {
$content_type = 'audio/mp3';
}
if ($file_extension == "wav") {
$content_type = 'audio/wav';
}
if (isset($api_key) && $api_key != '') {
//$command = "curl -X POST -silent -u \"apikey:".$api_key."\" --header \"Content-type: ".$content_type."\" --data-binary @".$file_path."/".$file_name." \"".$api_url."\"";
//echo "command: ".$command."\n";
$command = "sox ".$file_path."/".$file_name." ".$file_path."/".$file_name.".flac trim 0 00:59 ";
$command .= "&& echo \"{ 'config': { 'languageCode': '".$transcribe_language."', 'enableWordTimeOffsets': false , 'enableAutomaticPunctuation': true , 'alternativeLanguageCodes': '".$transcribe_alternate_language."' }, 'audio': { 'content': '`base64 -w 0 ".$file_path."/".$file_name.".flac`' } }\" ";
$command .= "| curl -X POST -H \"Content-Type: application/json\" -d @- ".$api_url.":recognize?key=".$api_key." ";
$command .= "&& rm -f ".$file_path."/".$file_name.".flac";
echo $command."\n";
//ob_start();
//$result = passthru($command);
//$json_result = ob_get_contents();
//ob_end_clean();
//run the command
$http_response = shell_exec($command);
//validate the json
$ob = json_decode($http_response);
if($ob === null) {
echo "invalid json\n";
return false;
}
$message = '';
$json = json_decode($http_response, true);
//echo "json; ".$json."\n";
foreach($json['results'] as $row) {
$message .= $row['alternatives'][0]['transcript'];
}
//build the response
$array['provider'] = $transcribe_provider;
$array['language'] = $transcribe_language;
$array['command'] = $command;
$array['message'] = $message;
//print_r($array);
return $array;
}
}
//transribe - azure
if ($transcribe_provider == 'azure') {
$api_key = $_SESSION['voicemail']['azure_key']['text'];
$api_url = $_SESSION['voicemail']['azure_server_region']['text'];
if (strlen($transcribe_language) == 0) {
$transcribe_language = 'en-US';
}
if ($file_extension == "mp3") {
$content_type = 'audio/mp3';
}
if ($file_extension == "wav") {
$content_type = 'audio/wav';
}
if (isset($api_key) && $api_key != '') {
$command = "curl -X POST \"https://".$api_url.".api.cognitive.microsoft.com/sts/v1.0/issueToken\" -H \"Content-type: application/x-www-form-urlencoded\" -H \"Content-Length: 0\" -H \"Ocp-Apim-Subscription-Key: ".$api_key."\"";
$access_token_result = shell_exec($command);
if (strlen($access_token_result) == 0) {
return false;
}
else {
$file_path = $file_path.'/'.$file_name;
$command = "curl -X POST \"https://".$api_url.".stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=".$transcribe_language."&format=detailed\" -H 'Authorization: Bearer ".$access_token_result."' -H 'Content-type: audio/wav; codec=\"audio/pcm\"; samplerate=8000; trustsourcerate=false' --data-binary @".$file_path;
echo $command."\n";
$http_response = shell_exec($command);
$array = json_decode($http_response, true);
if ($array === null) {
return false;
}
else {
$message = $array['NBest'][0]['Display'];
}
}
$array['provider'] = $transcribe_provider;
$array['language'] = $transcribe_language;
$array['api_key'] = $api_key;
$array['command'] = $command;
$array['message'] = $message;
return $array;
}
}
}
}
?>

View File

@ -0,0 +1,198 @@
<?php
//check the permission
if (defined('STDIN')) {
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
preg_match("/^(.*)\/app\/.*$/", $document_root, $matches);
$document_root = $matches[1];
set_include_path($document_root);
$_SERVER["DOCUMENT_ROOT"] = $document_root;
require_once "resources/require.php";
require_once "resources/pdo.php";
}
else {
exit;
include "root.php";
require_once "resources/require.php";
require_once "resources/pdo.php";
}
//increase limits
set_time_limit(0);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '512M');
//save the arguments to variables
$script_name = $argv[0];
if (!empty($argv[1])) {
parse_str($argv[1], $_GET);
}
//print_r($_GET);
//set the variables
if (isset($_GET['hostname'])) {
$hostname = urldecode($_GET['hostname']);
}
if (isset($_GET['debug'])) {
$debug = $_GET['debug'];
}
//includes
if (!defined('STDIN')) { include_once "root.php"; }
require_once "resources/require.php";
include "resources/classes/permissions.php";
require $document_root."/app/email_queue/resources/functions/transcribe.php";
//define the process id file
$pid_file = "/var/run/fusionpbx/".basename( $argv[0], ".php") .".pid";
//echo "pid_file: ".$pid_file."\n";
//function to check if the process exists
function process_exists($file = false) {
//set the default exists to false
$exists = false;
//check to see if the process is running
if (file_exists($file)) {
$pid = file_get_contents($file);
if (posix_getsid($pid) === false) {
//process is not running
$exists = false;
}
else {
//process is running
$exists = true;
}
}
//return the result
return $exists;
}
//check to see if the process exists
$pid_exists = process_exists($pid_file);
//prevent the process running more than once
if ($pid_exists) {
echo "Cannot lock pid file {$pid_file}\n";
exit;
}
//email queue enabled
if ($_SESSION['email_queue']['enabled']['boolean'] != 'true') {
echo "Email Queue is disabled in Default Settings\n";
exit;
}
//make sure the /var/run/fusionpbx directory exists
if (!file_exists('/var/run/fusionpbx')) {
$result = mkdir('/var/run/fusionpbx', 0777, true);
if (!$result) {
die('Failed to create /var/run/fusionpbx');
}
}
//create the process id file if the process doesn't exist
if (!$pid_exists) {
//remove the old pid file
if (file_exists($file)) {
unlink($pid_file);
}
//show the details to the user
//echo "The process id is ".getmypid()."\n";
//echo "pid_file: ".$pid_file."\n";
//save the pid file
file_put_contents($pid_file, getmypid());
}
//get the call center settings
$interval = $_SESSION['email_queue']['interval']['numeric'];
//set the defaults
if (!is_numeric($interval)) { $interval = 30; }
//set the email queue limit
if (isset($_SESSION['email_queue']['limit']['numeric'])) {
$email_queue_limit = $_SESSION['email_queue']['limit']['numeric'];
}
else {
$email_queue_limit = '30';
}
if (isset($_SESSION['email_queue']['debug']['boolean'])) {
$debug = $_SESSION['email_queue']['debug']['boolean'];
}
//get the messages waiting in the email queue
$sql = "select * from v_email_queue ";
$sql .= "where (email_status = 'waiting' or email_status = 'trying') ";
$sql .= "and hostname = :hostname ";
$sql .= "order by domain_uuid asc ";
$sql .= "limit :limit ";
if (isset($hostname)) {
$parameters['hostname'] = $hostname;
}
else {
$parameters['hostname'] = gethostname();
}
$parameters['limit'] = $email_queue_limit;
$database = new database;
$email_queue = $database->select($sql, $parameters, 'all');
unset($parameters);
//process the messages
if (is_array($email_queue) && @sizeof($email_queue) != 0) {
foreach($email_queue as $row) {
$command = "/usr/bin/php /var/www/fusionpbx/app/email_queue/resources/job/email_send.php ";
$command .= "'action=send&email_queue_uuid=".$row["email_queue_uuid"]."&hostname=".$hostname."'";
if (isset($debug)) {
//run process inline to see debug info
echo $command."\n";
$result = system($command);
echo $result."\n";
}
else {
//starts process rapidly doesn't wait for previous process to finish (used for production)
$handle = popen($command." > /dev/null &", 'r');
echo "'$handle'; " . gettype($handle) . "\n";
$read = fread($handle, 2096);
echo $read;
pclose($handle);
}
}
}
//remove the old pid file
if (file_exists($file)) {
unlink($pid_file);
}
//save output to
//$fp = fopen(sys_get_temp_dir()."/mailer-app.log", "a");
//prepare the output buffers
//ob_end_clean();
//ob_start();
//message divider for log file
//echo "\n\n=============================================================================================================================================\n\n";
//get and save the output from the buffer
//$content = ob_get_contents(); //get the output from the buffer
//$content = str_replace("<br />", "", $content);
//ob_end_clean(); //clean the buffer
//fwrite($fp, $content);
//fclose($fp);
//notes
//echo __line__."\n";
// if not keeping the email then need to delete it after the voicemail is emailed
//how to use this feature
// cd /var/www/fusionpbx; /usr/bin/php /var/www/fusionpbx/app/email_queue/resources/send.php
?>

View File

@ -0,0 +1,637 @@
<?php
//check the permission
if (defined('STDIN')) {
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
preg_match("/^(.*)\/app\/.*$/", $document_root, $matches);
$document_root = $matches[1];
set_include_path($document_root);
$_SERVER["DOCUMENT_ROOT"] = $document_root;
require_once "resources/require.php";
}
else {
exit;
include "root.php";
require_once "resources/require.php";
require_once "resources/pdo.php";
}
//increase limits
set_time_limit(0);
//ini_set('max_execution_time',1800); //30 minutes
ini_set('memory_limit', '512M');
//save the arguments to variables
$script_name = $argv[0];
if (!empty($argv[1])) {
parse_str($argv[1], $_GET);
}
//print_r($_GET);
//set the variables
if (isset($_GET['hostname'])) {
$hostname = urldecode($_GET['hostname']);
}
if (isset($_GET['debug'])) {
$debug = $_GET['debug'];
}
//includes
if (!defined('STDIN')) { include_once "root.php"; }
require_once "resources/require.php";
include "resources/classes/permissions.php";
require $document_root."/app/email_queue/resources/functions/transcribe.php";
//define a function to remove html tags
if (!function_exists('remove_tags')) {
function remove_tags($string) {
//remove HTML tags
$string = preg_replace ('/<[^>]*>/', ' ', $string);
//remove control characters
$string = str_replace("\r", '', $string); // --- replace with empty space
$string = str_replace("\n", ' ', $string); // --- replace with space
$string = str_replace("\t", ' ', $string); // --- replace with space
//remove multiple spaces
$string = trim(preg_replace('/ {2,}/', ' ', $string));
return $string;
}
}
//includes
include_once "resources/phpmailer/class.phpmailer.php";
include_once "resources/phpmailer/class.smtp.php";
//set the GET array
if (!empty($argv[1])) {
parse_str($argv[1], $_GET);
}
//get the primary key
$email_queue_uuid = $_GET['email_queue_uuid'];
$hostname = $_GET['hostname'];
//get the email details to send
$sql = "select * from v_email_queue ";
$sql .= "where email_queue_uuid = :email_queue_uuid ";
$parameters['email_queue_uuid'] = $email_queue_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
$domain_uuid = $row["domain_uuid"];
$email_date = $row["email_date"];
$email_from = $row["email_from"];
$email_to = $row["email_to"];
$email_subject = $row["email_subject"];
$email_body = $row["email_body"];
$email_status = $row["email_status"];
$email_retry_count = $row["email_retry_count"];
$email_uuid = $row["email_uuid"];
//$email_action_before = $row["email_action_before"];
$email_action_after = $row["email_action_after"];
}
unset($parameters);
//get the call center settings
$retry_limit = $_SESSION['email_queue']['retry_limit']['numeric'];
//$retry_interval = $_SESSION['email_queue']['retry_interval']['numeric'];
//set defaults
if (strlen($email_retry_count) == 0) {
$email_retry_count = 0;
}
//create the email object
/*
$mail = new PHPMailer();
if (isset($_SESSION['email']['method'])) {
switch ($_SESSION['email']['method']['text']) {
case 'sendmail': $mail->IsSendmail(); break;
case 'qmail': $mail->IsQmail(); break;
case 'mail': $mail->IsMail(); break;
default: $mail->IsSMTP(); break;
}
}
else {
$mail->IsSMTP();
}
*/
//load default smtp settings
/*
if ($_SESSION['email']['smtp_hostname']['text'] != '') {
$smtp['hostname'] = $_SESSION['email']['smtp_hostname']['text'];
}
$smtp['host'] = (strlen($_SESSION['email']['smtp_host']['text']) ? $_SESSION['email']['smtp_host']['text']: '127.0.0.1');
if (isset($_SESSION['email']['smtp_port'])) {
$smtp['port'] = (int) $_SESSION['email']['smtp_port']['numeric'];
}
else {
$smtp['port'] = 0;
}
$smtp['secure'] = $_SESSION['email']['smtp_secure']['text'];
$smtp['auth'] = $_SESSION['email']['smtp_auth']['text'];
$smtp['username'] = $_SESSION['email']['smtp_username']['text'];
$smtp['password'] = $_SESSION['email']['smtp_password']['text'];
$smtp['from'] = $_SESSION['email']['smtp_from']['text'];
$smtp['from_name'] = $_SESSION['email']['smtp_from_name']['text'];
if (isset($_SESSION['voicemail']['smtp_from']) && strlen($_SESSION['voicemail']['smtp_from']['text']) > 0) {
$smtp['from'] = $_SESSION['voicemail']['smtp_from']['text'];
}
if (isset($_SESSION['voicemail']['smtp_from_name']) && strlen($_SESSION['voicemail']['smtp_from_name']['text']) > 0) {
$smtp['from_name'] = $_SESSION['voicemail']['smtp_from_name']['text'];
}
*/
//overwrite with domain-specific smtp server settings, if any
$sql = "select domain_setting_subcategory, domain_setting_value ";
$sql .= "from v_domain_settings ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and (domain_setting_category = 'email' or domain_setting_category = 'voicemail') ";
$sql .= "and domain_setting_enabled = 'true' ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$result = $database->select($sql, $parameters, 'all');
if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as $row) {
if ($row['domain_setting_value'] != '') {
$smtp[str_replace('smtp_','',$row["domain_setting_subcategory"])] = $row['domain_setting_value'];
}
}
}
unset($sql, $parameters, $result, $row);
//value adjustments
$smtp['auth'] = ($smtp['auth'] == "true") ? true : false;
$smtp['password'] = ($smtp['password'] != '') ? $smtp['password'] : null;
$smtp['secure'] = ($smtp['secure'] != "none") ? $smtp['secure'] : null;
$smtp['username'] = ($smtp['username'] != '') ? $smtp['username'] : null;
//option to disable smtp ssl or tls validation
/*
if (isset($_SESSION['email']['smtp_validate_certificate'])) {
if ($_SESSION['email']['smtp_validate_certificate']['boolean'] == "false") {
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
}
}
*/
//add smtp authentication
/*
$mail->SMTPAuth = $smtp['auth'];
if (isset($smtp['hostname'])) {
$mail->Hostname = $smtp['hostname'];
}
$mail->Host = $smtp['host'];
if ($smtp['port'] != 0) {
$mail->Port = $smtp['port'];
}
if ($smtp['secure'] != '') {
$mail->SMTPSecure = $smtp['secure'];
}
if ($smtp['auth']) {
$mail->Username = $smtp['username'];
$mail->Password = $smtp['password'];
}
$mail->SMTPDebug = 4;
*/
//get the voicemail details
$sql = "select * from v_voicemails ";
$sql .= "where voicemail_uuid in ( ";
$sql .= " select voicemail_uuid from v_voicemail_messages ";
$sql .= " where voicemail_message_uuid = :voicemail_message_uuid ";
$sql .= ") ";
$parameters['voicemail_message_uuid'] = $email_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row)) {
//$domain_uuid = $row["domain_uuid"];
//$voicemail_uuid = $row["voicemail_uuid"];
$voicemail_id = $row["voicemail_id"];
//$voicemail_password = $row["voicemail_password"];
//$greeting_id = $row["greeting_id"];
//$voicemail_alternate_greet_id = $row["voicemail_alternate_greet_id"];
//$voicemail_mail_to = $row["voicemail_mail_to"];
//$voicemail_sms_to = $row["voicemail_sms_to "];
$voicemail_transcription_enabled = $row["voicemail_transcription_enabled"];
//$voicemail_attach_file = $row["voicemail_attach_file"];
//$voicemail_file = $row["voicemail_file"];
//$voicemail_local_after_email = $row["voicemail_local_after_email"];
//$voicemail_enabled = $row["voicemail_enabled"];
//$voicemail_description = $row["voicemail_description"];
//$voicemail_name_base64 = $row["voicemail_name_base64"];
//$voicemail_tutorial = $row["voicemail_tutorial"];
echo "transcribe enabled: ".$voicemail_transcription_enabled."\n";
}
unset($parameters);
//get the attachments and add to the email
$sql = "select * from v_email_queue_attachments ";
$sql .= "where email_queue_uuid = :email_queue_uuid ";
$parameters['email_queue_uuid'] = $email_queue_uuid;
$database = new database;
$email_queue_attachments = $database->select($sql, $parameters, 'all');
if (is_array($email_queue_attachments) && @sizeof($email_queue_attachments) != 0) {
foreach($email_queue_attachments as $field) {
$email_queue_attachment_uuid = $field['email_queue_attachment_uuid'];
$domain_uuid = $field['domain_uuid'];
$email_attachment_type = $field['email_attachment_type'];
$email_attachment_path = $field['email_attachment_path'];
$email_attachment_name = $field['email_attachment_name'];
//$email_attachment_base64= $field['email_attachment_base64'];
switch ($email_attachment_type) {
case "wav":
$mime_type = "audio/x-wav";
break;
case "mp3":
$mime_type = "audio/x-mp3";
break;
case "pdf":
$mime_type = "application/pdf";
break;
case "tif":
$mime_type = "image/tiff";
break;
case "tiff":
$mime_type = "image/tiff";
break;
default:
$mime_type = "binary/octet-stream";
break;
}
if (isset($voicemail_transcription_enabled) && $voicemail_transcription_enabled == 'true') {
//transcribe the attachment
if ($email_attachment_type == 'wav' || $email_attachment_type == 'mp3') {
$field = transcribe($email_attachment_path, $email_attachment_name, $email_attachment_type);
echo "transcribe path: ".$email_attachment_path."\n";
echo "transcribe name: ".$email_attachment_name."\n";
echo "transcribe type: ".$email_attachment_type."\n";
echo "transcribe command: ".$field['command']."\n";
echo "transcribe message: ".$field['message']."\n";
$transcribe_message = $field['message'];
}
//echo "email_body before: ".$email_body."\n";
$email_body = str_replace('${message_text}', $transcribe_message, $email_body);
//$email_debug = $field['message'];
//echo "email_body after: ".$email_body."\n";
//unset($field);
}
else {
$email_body = str_replace('${message_text}', '', $email_body);
}
//base64 encode the file
//$file_contents = base64_encode(file_get_contents($email_attachment_path.'/'.$email_attachment_name));
//add an attachment
//public addAttachment ( string $path, string $name = '', string $encoding = 'base64', string $type = '', string $disposition = 'attachment' ) : boolean
//$mail->AddAttachment($email_attachment_path.'/'.$email_attachment_name, $email_attachment_name, 'base64', 'attachment');
//add email attachments as a string for the send_email function
//$email_attachments[0]['type'] = 'string';
//$email_attachments[0]['name'] = $email_attachment_path.'/'.$email_attachment_name;
//$email_attachments[0]['value'] = base64_encode(file_get_contents($email_attachment_path.'/'.$email_attachment_name));
//add email attachment as a file for the send_email function
$email_attachments[0]['type'] = 'file';
$email_attachments[0]['name'] = $email_attachment_name;
$email_attachments[0]['value'] = $email_attachment_path.'/'.$email_attachment_name;
}
}
unset($parameters);
//send context to the temp log
echo "Subject: ".$email_subject."\n";
echo "From: ".$email_from."\n";
echo "Reply-to: ".$email_from."\n";
echo "To: ".$email_to."\n";
echo "Date: ".$email_date."\n";
//echo "Transcript: ".$array['message']."\n";
//echo "Body: ".$email_body."\n";
//update the message transcription
if (isset($voicemail_transcription_enabled) && $voicemail_transcription_enabled == 'true' && isset($transcribe_message)) {
$sql = "update v_voicemail_messages ";
$sql .= "set message_transcription = :message_transcription ";
$sql .= "where voicemail_message_uuid = :voicemail_message_uuid; ";
$parameters['voicemail_message_uuid'] = $email_uuid;
$parameters['message_transcription'] = $transcribe_message;
//echo $sql."\n";
//print_r($parameters);
$database = new database;
$database->execute($sql, $parameters);
unset($parameters);
}
//send email
//ob_start();
//$sent = !send_email($email_to, $email_subject, $email_body, $email_error, null, null, null, null, $email_attachments) ? false : true;
//$response = ob_get_clean();
//echo $response;
//send the email
$email = new email;
$email->from_address = $email_from_address;
$email->from_name = $email_from_name;
$email->recipients = $email_to;
$email->subject = $email_subject;
$email->body = $email_body;
$email->attachments = $email_attachments;
$email->method = 'direct';
$sent = $email->send();
//$response = $email->email_error;
//add to, from, fromname, custom headers and subject to the email
/*
$mail->From = $smtp['from'] ;
$mail->FromName = $smtp['from_name'];
$mail->Subject = $email_subject;
$email_to = trim($email_to, "<> ");
$email_to = str_replace(";", ",", $email_to);
$email_to_array = explode(",", $email_to);
if (count($email_to_array) == 0) {
$mail->AddAddress($email_to);
}
else {
foreach ($email_to_array as $email_address) {
if (strlen($email_address) > 0) {
echo "Add Address: $email_address\n";
$mail->AddAddress(trim($email_address));
}
}
}
*/
//add the body to the email
/*
$body_plain = remove_tags($email_body);
//echo "body_plain = $body_plain\n";
if ((substr($email_body, 0, 5) == "<html") || (substr($email_body, 0, 9) == "<!doctype")) {
//$mail->ContentType = "text/html; charset=utf-8";
$mail->Body = $email_body."<br><br>";
$mail->AltBody = $body_plain."\n";
$mail->isHTML(true);
}
else {
//$mail->Body = ($body != '') ? $body : $body_plain;
$mail->Body = $body_plain."\n";
$mail->AltBody = $body_plain."\n";
$mail->isHTML(false);
}
$mail->CharSet = "utf-8";
*/
//send the email
if ($sent) {
//if ($mail->Send()) {
/*
$sql = "delete from v_email_queue_attachments ";
$sql .= "where email_queue_uuid = :email_queue_uuid; ";
$parameters['email_queue_uuid'] = $email_queue_uuid;
$database = new database;
$database->select($sql, $parameters);
$sql = "delete from v_email_queue ";
$sql .= "where email_queue_uuid = :email_queue_uuid; ";
$parameters['email_queue_uuid'] = $email_queue_uuid;
$database = new database;
$database->select($sql, $parameters);
*/
/*
//build insert array
$email_log_uuid = uuid();
$array['email_queue'][0]['email_queue_uuid'] = $email_queue_uuid;
$array['email_queue'][0]['email_status'] = 'sent';
if (isset($field['message'])) {
$array['email_queue'][0]['email_transcription'] = $field['message'];
}
//grant temporary permissions
$p = new permissions;
$p->add('email_queue_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'email_queue';
$database->app_uuid = 'ba41954e-9d21-4b10-bbc2-fa5ceabeb184';
$database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('email_queue_add', 'temp');
*/
//set the email status to sent
$sql = "update v_email_queue ";
$sql .= "set email_status = 'sent' ";
//$sql .= "set email_status = 'waiting' "; //debug
if (isset($transcribe_message)) {
$sql .= ", email_transcription = :email_transcription ";
}
$sql .= "where email_queue_uuid = :email_queue_uuid; ";
$parameters['email_queue_uuid'] = $email_queue_uuid;
if (isset($transcribe_message)) {
$parameters['email_transcription'] = $transcribe_message;
}
//echo $sql."\n";
//print_r($parameters);
$database = new database;
$database->execute($sql, $parameters);
unset($parameters);
//delete the email after it is sent
if ($email_action_after == 'delete') {
//remove the email file after it has been sent
if (is_array($email_queue_attachments) && @sizeof($email_queue_attachments) != 0) {
foreach($email_queue_attachments as $field) {
$email_attachment_path = $field['email_attachment_path'];
$email_attachment_name = $field['email_attachment_name'];
if (file_exists($email_attachment_path.'/'.$email_attachment_name)) {
unlink($email_attachment_path.'/'.$email_attachment_name);
}
}
}
//delete the voicemail message from the database
$sql = "delete from v_voicemail_messages ";
$sql .= "where voicemail_message_uuid = :voicemail_message_uuid; ";
$parameters['voicemail_message_uuid'] = $email_uuid;
//echo $sql."\n";
//print_r($parameters);
$database = new database;
$database->execute($sql, $parameters);
unset($parameters);
//get the domain_name
$sql = "select domain_name from v_domains ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$domain_name = $database->select($sql, $parameters, 'column');
//send the message waiting status
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
//$switch_cmd .= "luarun app.lua voicemail mwi ".$voicemail_id."@".$domain_name;
$switch_cmd .= "luarun app/voicemail/resources/scripts/mwi_notify.lua ".$voicemail_id." ".$domain_name." 0 0";
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
echo $switch_cmd."\n";
}
else {
echo "event socket connection failed\n";
}
}
/*
//build insert array
$array['email_queue'][0]['email_queue_uuid'] = $email_queue_uuid;
//$array['email_queue'][0]['sent_date'] = 'now()';
$array['email_queue'][0]['email_status'] = 'sent';
//grant temporary permissions
$p = new permissions;
$p->add('email_queue_add', 'temp');
$p->add('email_queue_update', 'temp');
//execute insert
$database = new database;
$database->app_name = 'email_queue';
$database->app_uuid = '5befdf60-a242-445f-91b3-2e9ee3e0ddf7';
print_r($array);
$message = $database->save($array);
print_r($message);
unset($array);
//revoke temporary permissions
$p->delete('email_queue_add', 'temp');
$p->delete('email_queue_update', 'temp');
*/
//send a message to the console
echo "Message sent!\n";
}
else {
$mailer_error = $mail->ErrorInfo;
echo "Mailer Error: ".$mailer_error."\n\n";
/*
//build insert array
$email_log_uuid = uuid();
$array['email_queue'][0]['email_queue_uuid'] = $email_queue_uuid;
$array['email_queue'][0]['email_status'] = 'failed';
//grant temporary permissions
$p = new permissions;
$p->add('email_queue_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'email_queue';
$database->app_uuid = 'ba41954e-9d21-4b10-bbc2-fa5ceabeb184';
$database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('email_queue_add', 'temp');
*/
//set the email retry count
$email_retry_count++;
//set the email status to failed
$sql = "update v_email_queue ";
if ($email_retry_count >= $retry_limit) {
$sql .= "set email_status = 'failed', ";
}
else {
$sql .= "set email_status = 'trying', ";
}
$sql .= "email_retry_count = :email_retry_count ";
//$sql .= ", email_debug = :email_debug ";
$sql .= "where email_queue_uuid = :email_queue_uuid; ";
$parameters['email_queue_uuid'] = $email_queue_uuid;
//$parameters['email_debug'] = $mailer_error;
$parameters['email_retry_count'] = $email_retry_count;
//echo $sql."\n";
//print_r($parameters);
$database = new database;
$database->execute($sql, $parameters);
unset($parameters);
/*
$call_uuid = $headers["X-FusionPBX-Call-UUID"];
if ($resend == true) {
echo "Retained in v_email_logs \n";
}
else {
// log/store message in database for review
if (!isset($email_log_uuid)) {
//build insert array
$email_log_uuid = uuid();
$array['email_logs'][0]['email_log_uuid'] = $email_log_uuid;
if (is_uuid($call_uuid)) {
$array['email_logs'][0]['call_uuid'] = $call_uuid;
}
$array['email_logs'][0]['domain_uuid'] = $headers["X-FusionPBX-Domain-UUID"];
$array['email_logs'][0]['sent_date'] = 'now()';
$array['email_logs'][0]['type'] = $headers["X-FusionPBX-Email-Type"];
$array['email_logs'][0]['status'] = 'failed';
$array['email_logs'][0]['email'] = str_replace("'", "''", $msg);
//grant temporary permissions
$p = new permissions;
$p->add('email_log_add', 'temp');
//execute insert
$database = new database;
$database->app_name = 'v_mailto';
$database->app_uuid = 'ba41954e-9d21-4b10-bbc2-fa5ceabeb184';
$database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('email_log_add', 'temp');
}
echo "Retained in v_email_logs as email_log_uuid = ".$email_log_uuid."\n";
}
*/
}
//unset the php mail object
unset($mail);
//save output to
//$fp = fopen(sys_get_temp_dir()."/mailer-app.log", "a");
//prepare the output buffers
//ob_end_clean();
//ob_start();
//message divider for log file
//echo "\n\n====================================================\n\n";
//get and save the output from the buffer
//$content = ob_get_contents(); //get the output from the buffer
//$content = str_replace("<br />", "", $content);
//ob_end_clean(); //clean the buffer
//fwrite($fp, $content);
//fclose($fp);
?>

View File

@ -0,0 +1,30 @@
; Author: Mark J Crane <markjcrane@fusionpbx.com>
; cp /var/www/fusionpbx/app/email_queue/resources/service/debian.service /etc/systemd/system/email_queue.service
; systemctl enable email_queue
; systemctl start email_queue
; systemctl daemon-reload
[Unit]
Description=FusionPBX Email Queue
Wants=network-online.target
Requires=network.target local-fs.target postgresql.service
After=network.target network-online.target local-fs.target postgresql.service
StartLimitIntervalSec=0
[Service]
Type=simple
;Type=forking
PIDFile=/var/run/fusionpbx/email_queue.pid
WorkingDirectory=/var/www/fusionpbx
;Environment="USER=www-data"
;Environment="GROUP=www-data"
;EnvironmentFile=-/etc/default/fusionpbx
ExecStartPre=/bin/mkdir -p /var/run/fusionpbx
;ExecStartPre=/bin/chown -R ${USER}:${GROUP} /var/www/fusionpbx
ExecStart=/usr/bin/php /var/www/fusionpbx/app/email_queue/resources/service/email_queue.php
TimeoutSec=55s
Restart=always
[Install]
WantedBy=multi-user.target
Also=

View File

@ -0,0 +1,204 @@
<?php
//check the permission
if (defined('STDIN')) {
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
preg_match("/^(.*)\/app\/.*$/", $document_root, $matches);
$document_root = $matches[1];
set_include_path($document_root);
$_SERVER["DOCUMENT_ROOT"] = $document_root;
require_once "resources/require.php";
}
else {
exit;
include "root.php";
require_once "resources/require.php";
require_once "resources/pdo.php";
}
//increase limits
set_time_limit(0);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '512M');
//save the arguments to variables
$script_name = $argv[0];
if (!empty($argv[1])) {
parse_str($argv[1], $_GET);
}
//print_r($_GET);
//set the variables
if (isset($_GET['hostname'])) {
$hostname = urldecode($_GET['hostname']);
}
if (isset($_GET['debug'])) {
$debug = $_GET['debug'];
}
//includes
if (!defined('STDIN')) { include_once "root.php"; }
require_once "resources/require.php";
include "resources/classes/permissions.php";
require $document_root."/app/email_queue/resources/functions/transcribe.php";
//define the process id file
$pid_file = "/var/run/fusionpbx/".basename( $argv[0], ".php") .".pid";
//echo "pid_file: ".$pid_file."\n";
//function to check if the process exists
function process_exists($file = false) {
//set the default exists to false
$exists = false;
//check to see if the process is running
if (file_exists($file)) {
$pid = file_get_contents($file);
if (posix_getsid($pid) === false) {
//process is not running
$exists = false;
}
else {
//process is running
$exists = true;
}
}
//return the result
return $exists;
}
//check to see if the process exists
$pid_exists = process_exists($pid_file);
//prevent the process running more than once
if ($pid_exists) {
echo "Cannot lock pid file {$pid_file}\n";
exit;
}
//email queue enabled
if ($_SESSION['email_queue']['enabled']['boolean'] != 'true') {
echo "Email Queue is disabled in Default Settings\n";
exit;
}
//make sure the /var/run/fusionpbx directory exists
if (!file_exists('/var/run/fusionpbx')) {
$result = mkdir('/var/run/fusionpbx', 0777, true);
if (!$result) {
die('Failed to create /var/run/fusionpbx');
}
}
//create the process id file if the process doesn't exist
if (!$pid_exists) {
//remove the old pid file
if (file_exists($file)) {
unlink($pid_file);
}
//show the details to the user
//echo "The process id is ".getmypid()."\n";
//echo "pid_file: ".$pid_file."\n";
//save the pid file
file_put_contents($pid_file, getmypid());
}
//get the call center settings
$interval = $_SESSION['email_queue']['interval']['numeric'];
//set the defaults
if (!is_numeric($interval)) { $interval = 30; }
//set the email queue limit
if (isset($_SESSION['email_queue']['limit']['numeric'])) {
$email_queue_limit = $_SESSION['email_queue']['limit']['numeric'];
}
else {
$email_queue_limit = '30';
}
if (isset($_SESSION['email_queue']['debug']['boolean'])) {
$debug = $_SESSION['email_queue']['debug']['boolean'];
}
//get the messages waiting in the email queue
while (true) {
//get the messages that are waiting to send
$sql = "select * from v_email_queue ";
$sql .= "where (email_status = 'waiting' or email_status = 'trying') ";
$sql .= "and hostname = :hostname ";
$sql .= "order by domain_uuid asc ";
$sql .= "limit :limit ";
if (isset($hostname)) {
$parameters['hostname'] = $hostname;
}
else {
$parameters['hostname'] = gethostname();
}
$parameters['limit'] = $email_queue_limit;
$database = new database;
$email_queue = $database->select($sql, $parameters, 'all');
unset($parameters);
//process the messages
if (is_array($email_queue) && @sizeof($email_queue) != 0) {
foreach($email_queue as $row) {
$command = "/usr/bin/php /var/www/fusionpbx/app/email_queue/resources/jobs/email_send.php ";
$command .= "'action=send&email_queue_uuid=".$row["email_queue_uuid"]."&hostname=".$hostname."'";
if (isset($debug)) {
//run process inline to see debug info
echo $command."\n";
$result = system($command);
echo $result."\n";
}
else {
//starts process rapidly doesn't wait for previous process to finish (used for production)
$handle = popen($command." > /dev/null &", 'r');
echo "'$handle'; " . gettype($handle) . "\n";
$read = fread($handle, 2096);
echo $read;
pclose($handle);
}
}
}
//pause to prevent excessive database queries
sleep($interval);
}
//remove the old pid file
if (file_exists($file)) {
unlink($pid_file);
}
//save output to
//$fp = fopen(sys_get_temp_dir()."/mailer-app.log", "a");
//prepare the output buffers
//ob_end_clean();
//ob_start();
//message divider for log file
//echo "\n\n=============================================================================================================================================\n\n";
//get and save the output from the buffer
//$content = ob_get_contents(); //get the output from the buffer
//$content = str_replace("<br />", "", $content);
//ob_end_clean(); //clean the buffer
//fwrite($fp, $content);
//fclose($fp);
//notes
//echo __line__."\n";
// if not keeping the email then need to delete it after the voicemail is emailed
//how to use this feature
// cd /var/www/fusionpbx; /usr/bin/php /var/www/fusionpbx/app/email_queue/resources/send.php
?>

66
app/email_queue/root.php Normal file
View File

@ -0,0 +1,66 @@
<?php
// make sure the PATH_SEPARATOR is defined
umask(2);
if (!defined("PATH_SEPARATOR")) {
if (strpos($_ENV["OS"], "Win") !== false) {
define("PATH_SEPARATOR", ";");
} else {
define("PATH_SEPARATOR", ":");
}
}
if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
// make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
if(PHP_SAPI == 'cli'){
chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
if (file_exists('/project_root.php')) {
$path = '/';
} else {
$i = 1;
$path = '';
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
}
$_SERVER["DOCUMENT_ROOT"] = $path;
}else{
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
}
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
// try to detect if a project path is being used
if (!defined('PROJECT_PATH')) {
if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
define('PROJECT_PATH', '/fusionpbx');
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
define('PROJECT_PATH', '');
} else {
$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
$i = 1;
$path = $_SERVER["DOCUMENT_ROOT"];
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
if(!file_exists($path. '/project_root.php')){
die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
}
$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
define('PROJECT_PATH', $project_path);
}
$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
}
?>