Add destination number to the fax server.

This commit is contained in:
Mark Crane 2012-09-15 16:26:21 +00:00
parent ffbc0ba95d
commit 00f175321f
2 changed files with 140 additions and 17 deletions

View File

@ -110,6 +110,10 @@
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'fax_destination_number';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'fax_name';
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'faxname';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
@ -138,7 +142,7 @@
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_forward_number';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'fax_description';
@ -187,4 +191,98 @@
$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]['description']['en'] = '';
$y = 2; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = 'v_fax_logs';
//$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_log_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'] = '';
//$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'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_name';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_success';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_result_code';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_result_text';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_file';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = '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]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_ecm_used';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_local_station_id';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_document_transferred_pages';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_document_total_pages';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_image_resolution';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_image_size';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_bad_rows';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_transfer_rate';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_retry_attempts';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_retry_limit';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_retry_sleep';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'fax_uri';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = '';
?>

View File

@ -90,14 +90,24 @@ else {
//get the http post values and set them as php variables
if (count($_POST)>0) {
$fax_name = check_str($_POST["fax_name"]);
$fax_extension = check_str($_POST["fax_extension"]);
$fax_destination_number = check_str($_POST["fax_destination_number"]);
$fax_email = check_str($_POST["fax_email"]);
$fax_pin_number = check_str($_POST["fax_pin_number"]);
$fax_caller_id_name = check_str($_POST["fax_caller_id_name"]);
$fax_caller_id_number = check_str($_POST["fax_caller_id_number"]);
$fax_forward_number = check_str($_POST["fax_forward_number"]);
if (strlen($fax_forward_number) > 0) {
if (strlen($fax_destination_number) == 0) {
$fax_destination_number = $fax_extension;
}
if (strlen($fax_forward_number) > 3) {
$fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number);
}
if (strripos($fax_forward_number, '$1') === false) {
$fax_prefix = ''; //not found
} else {
$fax_prefix = $fax_forward_number.'#'; //found
}
$fax_description = check_str($_POST["fax_description"]);
}
@ -199,6 +209,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "fax_uuid, ";
$sql .= "dialplan_uuid, ";
$sql .= "fax_extension, ";
$sql .= "fax_destination_number, ";
$sql .= "fax_name, ";
$sql .= "fax_email, ";
$sql .= "fax_pin_number, ";
@ -215,6 +226,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "'$fax_uuid', ";
$sql .= "'$dialplan_uuid', ";
$sql .= "'$fax_extension', ";
$sql .= "'$fax_destination_number', ";
$sql .= "'$fax_name', ";
$sql .= "'$fax_email', ";
$sql .= "'$fax_pin_number', ";
@ -240,6 +252,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "dialplan_uuid = '".$dialplan_uuid."', ";
}
$sql .= "fax_extension = '$fax_extension', ";
$sql .= "fax_destination_number = '$fax_destination_number', ";
$sql .= "fax_name = '$fax_name', ";
$sql .= "fax_email = '$fax_email', ";
$sql .= "fax_pin_number = '$fax_pin_number', ";
@ -289,7 +302,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//<condition field="destination_number" expression="^\*9978$">
$dialplan_detail_tag = 'condition'; //condition, action, antiaction
$dialplan_detail_type = 'destination_number';
$dialplan_detail_data = '^'.$fax_extension.'$';
$dialplan_detail_data = '^'.$fax_destination_number.'$';
$dialplan_detail_order = '000';
$dialplan_detail_group = '';
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
@ -300,7 +313,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php ";
$dialplan_detail_data .= "email=".$fax_email." ";
$dialplan_detail_data .= "extension=".$fax_extension." ";
$dialplan_detail_data .= "name=\\\\\\\${last_fax} ";
$dialplan_detail_data .= "name=".$fax_prefix."\\\\\\\${last_fax} ";
$dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' ";
$dialplan_detail_data .= "domain=".$_SESSION['domain_name']." ";
$dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' ";
@ -348,10 +361,10 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan_detail_type = 'rxfax';
if (count($_SESSION["domains"]) > 1) {
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/inbox/${last_fax}.tif';
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/inbox/'.$fax_prefix.'${last_fax}.tif';
}
else {
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$fax_extension.'/inbox/${last_fax}.tif';
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$fax_extension.'/inbox/'.$fax_prefix.'${last_fax}.tif';
}
$dialplan_detail_order = '035';
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
@ -380,7 +393,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//update dialplan detail condition
$sql = "update v_dialplan_details set ";
$sql .= "dialplan_detail_data = '^".$fax_extension."$' ";
$sql .= "dialplan_detail_data = '^".$fax_destination_number."$' ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and dialplan_detail_tag = 'condition' ";
$sql .= "and dialplan_detail_type = 'destination_number' ";
@ -390,10 +403,10 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//update dialplan detail action
if (count($_SESSION["domains"]) > 1) {
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/inbox/${last_fax}.tif';
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/inbox/'.$fax_prefix.'${last_fax}.tif';
}
else {
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$fax_extension.'/inbox/${last_fax}.tif';
$dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$fax_extension.'/inbox/'.$fax_prefix.'${last_fax}.tif';
}
$sql = "update v_dialplan_details set ";
$sql .= "dialplan_detail_data = '".$dialplan_detail_data."' ";
@ -409,7 +422,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php ";
$dialplan_detail_data .= "email=".$fax_email." ";
$dialplan_detail_data .= "extension=".$fax_extension." ";
$dialplan_detail_data .= "name=\\\\\\\${last_fax} ";
$dialplan_detail_data .= "name=".$fax_prefix."\\\\\\\${last_fax} ";
$dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' ";
$dialplan_detail_data .= "domain=".$_SESSION['domain_name']." ";
$dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' ";
@ -463,6 +476,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
foreach ($result as &$row) {
$dialplan_uuid = $row["dialplan_uuid"];
$fax_extension = $row["fax_extension"];
$fax_destination_number = $row["fax_destination_number"];
$fax_name = $row["fax_name"];
$fax_email = $row["fax_email"];
$fax_pin_number = $row["fax_pin_number"];
@ -506,7 +520,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_name' maxlength='255' value=\"$fax_name\">\n";
echo "<br />\n";
echo "Enter the name here.\n";
echo "Enter the name.\n";
echo "</td>\n";
echo "</tr>\n";
@ -517,7 +531,18 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_extension' maxlength='255' value=\"$fax_extension\">\n";
echo "<br />\n";
echo "Enter the fax extension here.\n";
echo "Enter the fax extension number.\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " Destination Number:\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_destination_number' maxlength='255' value=\"$fax_destination_number\">\n";
echo "<br />\n";
echo "Enter the fax destination number.\n";
echo "</td>\n";
echo "</tr>\n";
@ -539,7 +564,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_pin_number' maxlength='255' value=\"$fax_pin_number\">\n";
echo "<br />\n";
echo "Enter the PIN number here.\n";
echo "Enter the PIN number.\n";
echo "</td>\n";
echo "</tr>\n";
@ -550,7 +575,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_caller_id_name' maxlength='255' value=\"$fax_caller_id_name\">\n";
echo "<br />\n";
echo "Enter the Caller ID name here.\n";
echo "Enter the Caller ID Name.\n";
echo "</td>\n";
echo "</tr>\n";
@ -561,7 +586,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_caller_id_number' maxlength='255' value=\"$fax_caller_id_number\">\n";
echo "<br />\n";
echo "Enter the Caller ID number here.\n";
echo "Enter the Caller ID Number.\n";
echo "</td>\n";
echo "</tr>\n";
@ -572,7 +597,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_forward_number' maxlength='255' value=\"".format_phone($fax_forward_number)."\">\n";
echo "<br />\n";
echo "Enter the forward number here. Used to forward the fax to a registered extension or external number.\n";
echo "Enter the forward number. Used to forward the fax to a registered extension or external number.\n";
echo "</td>\n";
echo "</tr>\n";
@ -630,7 +655,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_description' maxlength='255' value=\"$fax_description\">\n";
echo "<br />\n";
echo "Enter the description here.\n";
echo "Enter the description.\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";