Update fax_to_email.php

Make the code more consistent with the rest of the project.
This commit is contained in:
FusionPBX 2018-02-02 00:06:11 -07:00 committed by GitHub
parent 294800b042
commit 1b3a824978
1 changed files with 74 additions and 78 deletions

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016
Portions created by the Initial Developer are Copyright (C) 2008-2018
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -88,7 +88,6 @@ if(!function_exists('path_join')) {
}
$paths = array_filter($paths);
return $prefix . join('/', $paths);
}
}
@ -209,38 +208,38 @@ if(!function_exists('fax_enqueue')) {
if ($db_type == "sqlite") {
$date_utc_now_sql = "datetime('now')";
}
$sql = <<<HERE
INSERT INTO v_fax_tasks( fax_task_uuid, fax_uuid,
task_next_time, task_lock_time,
task_fax_file, task_wav_file, task_uri, task_dial_string, task_dtmf,
task_interrupted, task_status, task_no_answer_counter, task_no_answer_retry_counter, task_retry_counter,
task_reply_address, task_description)
VALUES (?, ?,
$date_utc_now_sql, NULL,
?, ?, ?, ?, ?,
'false', 0, 0, 0, 0,
?, ?);
HERE;
$stmt = $db->prepare($sql);
$i = 0;
$stmt->bindValue(++$i, $fax_task_uuid);
$stmt->bindValue(++$i, $fax_uuid);
$stmt->bindValue(++$i, $fax_file);
$stmt->bindValue(++$i, $wav_file);
$stmt->bindValue(++$i, $fax_uri);
$stmt->bindValue(++$i, $dial_string);
$stmt->bindValue(++$i, $fax_dtmf);
$stmt->bindValue(++$i, $reply_address);
$stmt->bindValue(++$i, $description);
if ($stmt->execute()) {
$response = 'Enqueued';
$sql = "INSERT INTO v_fax_tasks (fax_task_uuid, fax_uuid, ";
$sql .= " task_next_time, task_lock_time, ";
$sql .= " task_fax_file, task_wav_file, task_uri, task_dial_string, task_dtmf, ";
$sql .= " task_interrupted, task_status, task_no_answer_counter, task_no_answer_retry_counter, task_retry_counter, ";
$sql .= " task_reply_address, task_description) ";
$sql .= "VALUES ( ";
$sql .= " :fax_task_uuid, :fax_uuid, ";
$sql .= " ".$date_utc_now_sql.", NULL, ";
$sql .= " :fax_file, :wav_file, :fax_uri, :dial_string, :fax_dtmf, ";
$sql .= " 'false', 0, 0, 0, 0, ";
$sql .= " :reply_address, :description, ";
$sql .= "); ";
$statement = $db->prepare($sql);
$statement->bindParam(':fax_task_uuid', $fax_task_uuid);
$statement->bindParam(':fax_uuid', $fax_uuid);
$statement->bindParam(':fax_file', $fax_file);
$statement->bindParam(':wav_file', $wav_file);
$statement->bindParam(':fax_uri', $fax_uri);
$statement->bindParam(':dial_string', $dial_string);
$statement->bindParam(':fax_dtmf', $fax_dtmf);
$statement->bindParam(':reply_address', $reply_address);
$statement->bindParam(':description', $description);
if ($statement->execute()) {
$response = 'Success';
}
else{
//! @todo log error
$response = 'Fail enqueue';
$response = 'Failed';
var_dump($db->errorInfo());
}
unset($stmt);
unset($statement);
return $response;
}
}
@ -334,7 +333,6 @@ if(!function_exists('fax_split_dtmf')) {
//$destination_number = $tmp_array[1];
//unset($tmp_array);
}
$mailto_address = $fax_email;
//get the fax file name (only) if a full path
@ -376,16 +374,16 @@ if(!function_exists('fax_split_dtmf')) {
$smtp['username'] = $_SESSION['email']['smtp_username']['var'];
$smtp['password'] = $_SESSION['email']['smtp_password']['var'];
if (isset($_SESSION['voicemail']['smtp_from'])) {
$smtp['from'] = (strlen($_SESSION['fax']['smtp_from']['var'])?$_SESSION['fax']['smtp_from']['var']:'fusionpbx@example.com');
if (strlen($_SESSION['fax']['smtp_from']) > 0) {
$smtp['from'] = $_SESSION['fax']['smtp_from']['var'];
} else {
$smtp['from'] = (strlen($_SESSION['email']['smtp_from']['var'])?$_SESSION['email']['smtp_from']['var']:'fusionpbx@example.com');
$smtp['from'] = $_SESSION['email']['smtp_from']['var'];
}
if (isset($_SESSION['voicemail']['smtp_from_name'])) {
$smtp['from_name'] = (strlen($_SESSION['fax']['smtp_from_name']['var'])?$_SESSION['fax']['smtp_from_name']['var']:'FusionPBX Voicemail');
if (strlen($_SESSION['fax']['smtp_from_name']) > 0) {
$smtp['from_name'] = $_SESSION['fax']['smtp_from_name']['var'];
} else {
$smtp['from_name'] = (strlen($_SESSION['email']['smtp_from_name']['var'])?$_SESSION['email']['smtp_from_name']['var']:'FusionPBX Voicemail');
$smtp['from_name'] = $_SESSION['email']['smtp_from_name']['var'];
}
// overwrite with domain-specific smtp server settings, if any
@ -393,8 +391,8 @@ if(!function_exists('fax_split_dtmf')) {
$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' ";
$sql .= "or domain_setting_category = 'fax' ";
$sql .= "and (domain_setting_category = 'email' ";
$sql .= "or domain_setting_category = 'fax') ";
$sql .= "and domain_setting_name = 'var' ";
$sql .= "and domain_setting_enabled = 'true' ";
$prep_statement = $db->prepare($sql);
@ -446,7 +444,6 @@ if(!function_exists('fax_split_dtmf')) {
$dir_fax = $_SESSION['switch']['storage']['dir'].'/fax/'.$fax_extension.'/inbox';
}
}
$fax_file = path_join($dir_fax, $fax_file_only);
//used for debug
@ -610,7 +607,6 @@ if(!function_exists('fax_split_dtmf')) {
}
}
if ($smtp['auth'] == "true") {
$mail->SMTPAuth = $smtp['auth']; // turn on/off SMTP authentication
}