diff --git a/app/fax/fax_edit.php b/app/fax/fax_edit.php
index 08c8a7ce8b..65934c263e 100644
--- a/app/fax/fax_edit.php
+++ b/app/fax/fax_edit.php
@@ -196,167 +196,168 @@
//clear file status cache
clearstatcache();
-if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
+//process the data
+ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
- $msg = '';
- if ($action == "update" && permission_exists('fax_extension_edit')) {
- $fax_uuid = $_POST["fax_uuid"];
- }
-
- //check for all required data
- if (strlen($fax_extension) == 0) { $msg .= "".$text['confirm-ext']."
\n"; }
- if (strlen($fax_name) == 0) { $msg .= "".$text['confirm-fax']."
\n"; }
- if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
- require_once "resources/header.php";
- require_once "resources/persist_form_var.php";
- echo "
\n";
- echo "
\n";
- echo $msg." ";
- echo " |
\n";
- persistformvar($_POST);
- echo "
\n";
- require_once "resources/footer.php";
- return;
+ $msg = '';
+ if ($action == "update" && permission_exists('fax_extension_edit')) {
+ $fax_uuid = $_POST["fax_uuid"];
}
- //replace the spaces with a dash
- $fax_name = str_replace(" ", "-", $fax_name);
-
- //escape the commas with a backslash and remove the spaces
- $fax_email = str_replace(" ", "", $fax_email);
-
- //set the $php_bin
- //if (file_exists(PHP_BINDIR."/php")) { $php_bin = 'php'; }
- if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
- $php_bin = 'php.exe';
- }
- elseif (file_exists(PHP_BINDIR."/php5")) {
- $php_bin = 'php5';
- }
- else {
- $php_bin = 'php';
- }
-
- //add or update the database
- if ($_POST["persistformvar"] != "true") {
-
- //prep authorized senders
- if (sizeof($fax_email_outbound_authorized_senders) > 0) {
- foreach ($fax_email_outbound_authorized_senders as $sender_num => $sender) {
- if ($sender == '' || !valid_email($sender)) { unset($fax_email_outbound_authorized_senders[$sender_num]); }
- }
- $fax_email_outbound_authorized_senders = implode(',', $fax_email_outbound_authorized_senders);
- }
-
- if ($action == "add" && permission_exists('fax_extension_add')) {
- //prepare the unique identifiers
- $fax_uuid = uuid();
- $dialplan_uuid = uuid();
-
- //begin insert array
- $array['fax'][0]['fax_uuid'] = $fax_uuid;
- $array['fax'][0]['dialplan_uuid'] = $dialplan_uuid;
-
- //assign temp permission
- $p = new permissions;
- $p->add('fax_add', 'temp');
-
- //set the dialplan action
- $dialplan_type = "add";
- }
-
- if ($action == "update" && permission_exists('fax_extension_edit')) {
- //begin update array
- $array['fax'][0]['fax_uuid'] = $fax_uuid;
-
- //assign temp permission
- $p = new permissions;
- $p->add('fax_edit', 'temp');
- }
-
- if (is_array($array) && @sizeof($array) != 0) {
- //add common columns to array
- $array['fax'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
- $array['fax'][0]['fax_extension'] = $fax_extension;
- $array['fax'][0]['accountcode'] = $fax_accountcode;
- $array['fax'][0]['fax_destination_number'] = $fax_destination_number;
- $array['fax'][0]['fax_prefix'] = $fax_prefix;
- $array['fax'][0]['fax_name'] = $fax_name;
- $array['fax'][0]['fax_email'] = $fax_email;
- if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) {
- $array['fax'][0]['fax_email_connection_type'] = $fax_email_connection_type;
- $array['fax'][0]['fax_email_connection_host'] = $fax_email_connection_host;
- $array['fax'][0]['fax_email_connection_port'] = $fax_email_connection_port;
- $array['fax'][0]['fax_email_connection_security'] = $fax_email_connection_security;
- $array['fax'][0]['fax_email_connection_validate'] = $fax_email_connection_validate;
- $array['fax'][0]['fax_email_connection_username'] = $fax_email_connection_username;
- $array['fax'][0]['fax_email_connection_password'] = $fax_email_connection_password;
- $array['fax'][0]['fax_email_connection_mailbox'] = $fax_email_connection_mailbox;
- $array['fax'][0]['fax_email_inbound_subject_tag'] = $fax_email_inbound_subject_tag;
- $array['fax'][0]['fax_email_outbound_subject_tag'] = $fax_email_outbound_subject_tag;
- $array['fax'][0]['fax_email_outbound_authorized_senders'] = $fax_email_outbound_authorized_senders;
- }
- $array['fax'][0]['fax_caller_id_name'] = $fax_caller_id_name;
- $array['fax'][0]['fax_caller_id_number'] = $fax_caller_id_number;
- if ($action == "add" && strlen($fax_forward_number) > 0) {
- $array['fax'][0]['fax_forward_number'] = $fax_forward_number;
- }
- if ($action == "update") {
- $array['fax'][0]['fax_forward_number'] = strlen($fax_forward_number) > 0 ? $fax_forward_number : null;
- }
- if (permission_exists('fax_send_greeting')) {
- $array['fax'][0]['fax_send_greeting'] = strlen($fax_send_greeting) != 0 ? $fax_send_greeting : null;
- }
- $array['fax'][0]['fax_send_channels'] = strlen($fax_send_channels) != 0 ? $fax_send_channels : null;
- $array['fax'][0]['fax_description'] = $fax_description;
-
- //execute
- $database = new database;
- $database->app_name = 'fax';
- $database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
- $database->save($array);
- unset($array);
-
- //revoke temp permissions
- $p->delete('fax_add', 'temp');
- $p->delete('fax_edit', 'temp');
- }
-
- //get the dialplan_uuid
- $sql = "select dialplan_uuid from v_fax ";
- $sql .= "where domain_uuid = :domain_uuid ";
- $sql .= "and fax_uuid = :fax_uuid ";
- $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
- $parameters['fax_uuid'] = $fax_uuid;
- $database = new database;
- $dialplan_uuid = $database->select($sql, $parameters, 'column');
- unset($sql, $parameters);
-
- //dialplan add or update
- $c = new fax;
- $c->db = $db;
- $c->domain_uuid = $_SESSION['domain_uuid'];
- $c->dialplan_uuid = $dialplan_uuid;
- $c->fax_name = $fax_name;
- $c->fax_uuid = $fax_uuid;
- $c->fax_extension = $fax_extension;
- $c->fax_forward_number = $fax_forward_number;
- $c->destination_number = $fax_destination_number;
- $c->fax_description = $fax_description;
- $a = $c->dialplan();
-
- //redirect the browser
- if ($action == "update" && permission_exists('fax_extension_edit')) {
- message::add($text['confirm-update']);
- }
- if ($action == "add" && permission_exists('fax_extension_add')) {
- message::add($text['confirm-add']);
- }
- header("Location: fax.php");
+ //check for all required data
+ if (strlen($fax_extension) == 0) { $msg .= "".$text['confirm-ext']."
\n"; }
+ if (strlen($fax_name) == 0) { $msg .= "".$text['confirm-fax']."
\n"; }
+ if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+ require_once "resources/header.php";
+ require_once "resources/persist_form_var.php";
+ echo "\n";
+ echo "
\n";
+ echo $msg." ";
+ echo " |
\n";
+ persistformvar($_POST);
+ echo "
\n";
+ require_once "resources/footer.php";
return;
+ }
- }
-}
+ //replace the spaces with a dash
+ $fax_name = str_replace(" ", "-", $fax_name);
+
+ //escape the commas with a backslash and remove the spaces
+ $fax_email = str_replace(" ", "", $fax_email);
+
+ //set the $php_bin
+ //if (file_exists(PHP_BINDIR."/php")) { $php_bin = 'php'; }
+ if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
+ $php_bin = 'php.exe';
+ }
+ elseif (file_exists(PHP_BINDIR."/php5")) {
+ $php_bin = 'php5';
+ }
+ else {
+ $php_bin = 'php';
+ }
+
+ //add or update the database
+ if ($_POST["persistformvar"] != "true") {
+
+ //prep authorized senders
+ if (sizeof($fax_email_outbound_authorized_senders) > 0) {
+ foreach ($fax_email_outbound_authorized_senders as $sender_num => $sender) {
+ if ($sender == '' || !valid_email($sender)) { unset($fax_email_outbound_authorized_senders[$sender_num]); }
+ }
+ $fax_email_outbound_authorized_senders = implode(',', $fax_email_outbound_authorized_senders);
+ }
+
+ if ($action == "add" && permission_exists('fax_extension_add')) {
+ //prepare the unique identifiers
+ $fax_uuid = uuid();
+ $dialplan_uuid = uuid();
+
+ //begin insert array
+ $array['fax'][0]['fax_uuid'] = $fax_uuid;
+ $array['fax'][0]['dialplan_uuid'] = $dialplan_uuid;
+
+ //assign temp permission
+ $p = new permissions;
+ $p->add('fax_add', 'temp');
+
+ //set the dialplan action
+ $dialplan_type = "add";
+ }
+
+ if ($action == "update" && permission_exists('fax_extension_edit')) {
+ //begin update array
+ $array['fax'][0]['fax_uuid'] = $fax_uuid;
+
+ //assign temp permission
+ $p = new permissions;
+ $p->add('fax_edit', 'temp');
+ }
+
+ if (is_array($array) && @sizeof($array) != 0) {
+ //add common columns to array
+ $array['fax'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
+ $array['fax'][0]['fax_extension'] = $fax_extension;
+ $array['fax'][0]['accountcode'] = $fax_accountcode;
+ $array['fax'][0]['fax_destination_number'] = $fax_destination_number;
+ $array['fax'][0]['fax_prefix'] = $fax_prefix;
+ $array['fax'][0]['fax_name'] = $fax_name;
+ $array['fax'][0]['fax_email'] = $fax_email;
+ if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) {
+ $array['fax'][0]['fax_email_connection_type'] = $fax_email_connection_type;
+ $array['fax'][0]['fax_email_connection_host'] = $fax_email_connection_host;
+ $array['fax'][0]['fax_email_connection_port'] = $fax_email_connection_port;
+ $array['fax'][0]['fax_email_connection_security'] = $fax_email_connection_security;
+ $array['fax'][0]['fax_email_connection_validate'] = $fax_email_connection_validate;
+ $array['fax'][0]['fax_email_connection_username'] = $fax_email_connection_username;
+ $array['fax'][0]['fax_email_connection_password'] = $fax_email_connection_password;
+ $array['fax'][0]['fax_email_connection_mailbox'] = $fax_email_connection_mailbox;
+ $array['fax'][0]['fax_email_inbound_subject_tag'] = $fax_email_inbound_subject_tag;
+ $array['fax'][0]['fax_email_outbound_subject_tag'] = $fax_email_outbound_subject_tag;
+ $array['fax'][0]['fax_email_outbound_authorized_senders'] = $fax_email_outbound_authorized_senders;
+ }
+ $array['fax'][0]['fax_caller_id_name'] = $fax_caller_id_name;
+ $array['fax'][0]['fax_caller_id_number'] = $fax_caller_id_number;
+ if ($action == "add" && strlen($fax_forward_number) > 0) {
+ $array['fax'][0]['fax_forward_number'] = $fax_forward_number;
+ }
+ if ($action == "update") {
+ $array['fax'][0]['fax_forward_number'] = strlen($fax_forward_number) > 0 ? $fax_forward_number : null;
+ }
+ if (permission_exists('fax_send_greeting')) {
+ $array['fax'][0]['fax_send_greeting'] = strlen($fax_send_greeting) != 0 ? $fax_send_greeting : null;
+ }
+ $array['fax'][0]['fax_send_channels'] = strlen($fax_send_channels) != 0 ? $fax_send_channels : null;
+ $array['fax'][0]['fax_description'] = $fax_description;
+
+ //execute
+ $database = new database;
+ $database->app_name = 'fax';
+ $database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
+ $database->save($array);
+ unset($array);
+
+ //revoke temp permissions
+ $p->delete('fax_add', 'temp');
+ $p->delete('fax_edit', 'temp');
+ }
+
+ //get the dialplan_uuid
+ $sql = "select dialplan_uuid from v_fax ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and fax_uuid = :fax_uuid ";
+ $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['fax_uuid'] = $fax_uuid;
+ $database = new database;
+ $dialplan_uuid = $database->select($sql, $parameters, 'column');
+ unset($sql, $parameters);
+
+ //dialplan add or update
+ $c = new fax;
+ $c->db = $db;
+ $c->domain_uuid = $_SESSION['domain_uuid'];
+ $c->dialplan_uuid = $dialplan_uuid;
+ $c->fax_name = $fax_name;
+ $c->fax_uuid = $fax_uuid;
+ $c->fax_extension = $fax_extension;
+ $c->fax_forward_number = $fax_forward_number;
+ $c->destination_number = $fax_destination_number;
+ $c->fax_description = $fax_description;
+ $a = $c->dialplan();
+
+ //redirect the browser
+ if ($action == "update" && permission_exists('fax_extension_edit')) {
+ message::add($text['confirm-update']);
+ }
+ if ($action == "add" && permission_exists('fax_extension_add')) {
+ message::add($text['confirm-add']);
+ }
+ header("Location: fax.php");
+ return;
+
+ }
+ }
//pre-populate the form
if (is_uuid($_GET['id']) && $_POST["persistformvar"] != "true") {
@@ -400,9 +401,38 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$fax_send_channels = 10;
}
+//get the fax users
+ $sql = "select * from v_fax_users as e, v_users as u ";
+ $sql .= "where e.user_uuid = u.user_uuid ";
+ $sql .= "and e.domain_uuid = :domain_uuid ";
+ $sql .= "and e.fax_uuid = :fax_uuid ";
+ $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['fax_uuid'] = $fax_uuid;
+ $database = new database;
+ $fax_users = $database->select($sql, $parameters, 'all');
+ unset($sql, $parameters);
+
+//get the users that are not assigned to this fax server
+ $sql = "select * from v_users \n";
+ $sql .= "where domain_uuid = :domain_uuid \n";
+ $sql .= "and user_uuid not in (\n";
+ $sql .= " select user_uuid from v_fax_users ";
+ $sql .= " where domain_uuid = :domain_uuid ";
+ $sql .= " and fax_uuid = :fax_uuid ";
+ $sql .= " and user_uuid is not null ";
+ $sql .= ")\n";
+ $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['fax_uuid'] = $fax_uuid;
+ $database = new database;
+ $available_users = $database->select($sql, $parameters, 'all');
+ unset($sql, $parameters);
+
//replace the dash with a space
$fax_name = str_replace("-", " ", $fax_name);
+//build the fax_emails array
+ $fax_emails = explode(',',$fax_email);
+
//set the dialplan_uuid
if (!is_uuid($dialplan_uuid)) {
$dialplan_uuid = uuid();
@@ -519,7 +549,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "\n";
echo "\n";
echo "\n";
- $fax_emails = explode(',',$fax_email);
$x = 0;
foreach($fax_emails as $email) {
echo "\n";
@@ -581,51 +610,29 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo " | ".$text['label-user-list']." | ";
echo " ";
- $sql = "select * from v_fax_users as e, v_users as u ";
- $sql .= "where e.user_uuid = u.user_uuid ";
- $sql .= "and e.domain_uuid = :domain_uuid ";
- $sql .= "and e.fax_uuid = :fax_uuid ";
- $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
- $parameters['fax_uuid'] = $fax_uuid;
- $database = new database;
- $result = $database->select($sql, $parameters, 'all');
- if (is_array($result) && @sizeof($result) != 0) {
+ if (is_array($fax_users) && @sizeof($fax_users) != 0) {
echo " \n";
- foreach($result as $field) {
+ foreach($fax_users as $field) {
echo " \n";
echo " | ".escape($field['username'])." | \n";
echo " \n";
echo " $v_link_label_delete\n";
echo " | \n";
echo " \n";
- $assigned_user_uuids[] = $field['user_uuid'];
}
echo " \n";
echo " \n";
}
- unset($sql, $parameters, $result, $field);
- $sql = "select * from v_users ";
- $sql .= "where domain_uuid = :domain_uuid ";
- if (is_array($assigned_user_uuids) && @sizeof($assigned_user_uuids) != 0) {
- foreach($assigned_user_uuids as $index => $assigned_user_uuid) {
- if (is_uuid($assigned_user_uuid)) {
- $sql .= "and user_uuid <> :user_uuid_".$index;
- $parameters['user_uuid_'.$index] = $assigned_user_uuid;
- }
- }
- unset($assigned_user_uuids, $index, $assigned_user_uuid);
- }
- $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
- $database = new database;
- $result = $database->select($sql, $parameters, 'all');
+ unset($fax_users);
+
echo " ";
echo " \n";
echo " \n";
| |