From c900edb7683ab77d7e3587d1831d7d9671ee720d Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Thu, 26 Feb 2015 04:18:16 +0000 Subject: [PATCH] Emails: Initial build of failed email log. Still under construction. --- app/emails/app_config.php | 89 ++++++++++++++++++++ app/emails/app_languages.php | 88 ++++++++++++++++++++ app/emails/app_menu.php | 21 +++++ app/emails/email_delete.php | 59 ++++++++++++++ app/emails/emails.php | 153 +++++++++++++++++++++++++++++++++++ app/emails/root.php | 50 ++++++++++++ app/fax/fax_logs.php | 2 +- core/upgrade/app_config.php | 47 ----------- 8 files changed, 461 insertions(+), 48 deletions(-) create mode 100644 app/emails/app_config.php create mode 100644 app/emails/app_languages.php create mode 100644 app/emails/app_menu.php create mode 100644 app/emails/email_delete.php create mode 100644 app/emails/emails.php create mode 100644 app/emails/root.php diff --git a/app/emails/app_config.php b/app/emails/app_config.php new file mode 100644 index 0000000000..1fdc5c780a --- /dev/null +++ b/app/emails/app_config.php @@ -0,0 +1,89 @@ + \ No newline at end of file diff --git a/app/emails/app_languages.php b/app/emails/app_languages.php new file mode 100644 index 0000000000..52b3cdeb02 --- /dev/null +++ b/app/emails/app_languages.php @@ -0,0 +1,88 @@ + \ No newline at end of file diff --git a/app/emails/app_menu.php b/app/emails/app_menu.php new file mode 100644 index 0000000000..e3383c2b4f --- /dev/null +++ b/app/emails/app_menu.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/app/emails/email_delete.php b/app/emails/email_delete.php new file mode 100644 index 0000000000..b8528e5477 --- /dev/null +++ b/app/emails/email_delete.php @@ -0,0 +1,59 @@ + + Copyright (C) 2008-2012 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('email_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get posted values, if any + $email_uuid = $_REQUEST["id"]; + + if ($email_uuid != '') { + $sql = "delete from v_emails "; + $sql .= "where email_uuid = '".$email_uuid."' "; + $sql .= "and domain_uuid = '".$domain_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql, $prep_statement); + + //set message + $_SESSION["message"] = $text['message-delete']; + } + +//redirect user + header("Location: emails.php"); + +?> \ No newline at end of file diff --git a/app/emails/emails.php b/app/emails/emails.php new file mode 100644 index 0000000000..25abc68ef5 --- /dev/null +++ b/app/emails/emails.php @@ -0,0 +1,153 @@ +get(); + +//get variables used to control the order + $order_by = ($_GET["order_by"] != '') ? $_GET["order_by"] : 'sent_date'; + $order = ($_GET["order"] != '') ? $_GET["order"] : 'desc'; + +//get the fax_uuid + if (count($_GET) > 0) { + $email_uuid = check_str($_GET["id"]); + } + +//additional includes + $document['title'] = $text['title-emails']; + require_once "resources/header.php"; + require_once "resources/paging.php"; + +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
"; + echo " ".$text['header-emails'].""; + echo "

"; + echo " ".$text['description-emails']; + echo "
\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + + //prepare to page the results + $sql = "select count(*) as num_rows from v_emails "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + $num_rows = ($row['num_rows'] > 0) ? $row['num_rows'] : 0; + } + + //prepare to page the results + $rows_per_page = 50; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = "select * from v_emails "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + if (strlen($order_by)> 0) { $sql .= "order by ".$order_by." ".$order." "; } + $sql .= "limit ".$rows_per_page." offset ".$offset." "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "\n"; + + echo "\n"; + echo th_order_by('sent_date', $text['label-sent'], $order_by, $order); + echo th_order_by('type', $text['label-type'], $order_by, $order); + echo th_order_by('status', $text['label-status'], $order_by, $order); + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + + //get call details + $sql = "select caller_id_name, caller_id_number, destination_number from v_xml_cdr "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and uuid = '".$row['call_uuid']."' "; + //echo ""; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result2 = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result2 as $row2) { + $caller_id_name = ($row2['caller_id_name'] != '') ? $row2['caller_id_name'] : null; + $caller_id_number = ($row2['caller_id_number'] != '') ? $row2['caller_id_number'] : null; + $destination_number = ($row2['destination_number'] != '') ? $row2['destination_number'] : null; + } + unset($prep_statement, $sql); + + $tr_link = "href='email_view.php?id=".$row['email_uuid']."'"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
".$text['label-message']."".$text['label-attachment']."".$text['label-reference']." 
".$sql."
"; + $sent_date = explode('.', $row['sent_date']); + echo $sent_date[0]; + echo " ".$text['label-type_'.$row['type']]."".$text['label-status_'.$row['status']]."".$text['label-message_view'].""; + echo "$v_link_label_view"; + if (permission_exists('email_delete')) { + echo "$v_link_label_delete"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls 
\n"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; +?> \ No newline at end of file diff --git a/app/emails/root.php b/app/emails/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/emails/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fax/fax_logs.php b/app/fax/fax_logs.php index 6a06a8fa5e..958eec1d51 100755 --- a/app/fax/fax_logs.php +++ b/app/fax/fax_logs.php @@ -107,7 +107,7 @@ else { echo ""; echo " \n"; echo "\n"; - echo "\n"; + echo "\n"; if ($result_count > 0) { foreach($result as $row) { diff --git a/core/upgrade/app_config.php b/core/upgrade/app_config.php index bf3c261805..c244ef1a27 100644 --- a/core/upgrade/app_config.php +++ b/core/upgrade/app_config.php @@ -66,53 +66,6 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - //schema details - $y = 1; //table array index - $z = 0; //field array index - $apps[$x]['db'][$y]['table'] = "v_emails"; - $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"; - $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; - $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "call_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_xml_cdr"; - $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "uuid"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - $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"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "sent_date"; - $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "timestamp"; - $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "date"; - $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "timestamp"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "type"; - $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "status"; - $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - $z++; - $apps[$x]['db'][$y]['fields'][$z]['name'] = "email"; - $apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; - $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; - /* $y = 0; //table array index $z = 0; //field array index