diff --git a/app/fax/app_languages.php b/app/fax/app_languages.php
index 714b051919..d7feb08cfa 100644
--- a/app/fax/app_languages.php
+++ b/app/fax/app_languages.php
@@ -3381,46 +3381,6 @@ $text['confirm-ext']['ru-ru'] = "Пожалуйста, укажите: Номе
$text['confirm-ext']['sv-se'] = "Por favor indique: Extensión ";
$text['confirm-ext']['uk-ua'] = "";
-$text['confirm-copy-info']['en-us'] = "Do you really want to copy this?";
-$text['confirm-copy-info']['ar-eg'] = "";
-$text['confirm-copy-info']['de-at'] = "Wollen Sie das wirklich kopieren?"; //copied from de-de
-$text['confirm-copy-info']['de-ch'] = "Wollen Sie das wirklich kopieren?"; //copied from de-de
-$text['confirm-copy-info']['de-de'] = "Wollen Sie das wirklich kopieren?";
-$text['confirm-copy-info']['es-cl'] = "¿Desea realmente copiar esto?";
-$text['confirm-copy-info']['es-mx'] = "¿Desea realmente copiar esto?"; //copied from es-cl
-$text['confirm-copy-info']['fr-ca'] = "Voulez-vous vraiment copier cela?"; //copied from fr-fr
-$text['confirm-copy-info']['fr-fr'] = "Voulez-vous vraiment copier cela?";
-$text['confirm-copy-info']['he-il'] = "";
-$text['confirm-copy-info']['it-it'] = "Vuoi veramente copiarlo?";
-$text['confirm-copy-info']['nl-nl'] = "";
-$text['confirm-copy-info']['pl-pl'] = "Podgląd ";
-$text['confirm-copy-info']['pt-br'] = " Você realmente deseja copiar isso?";
-$text['confirm-copy-info']['pt-pt'] = "Deseja realmente copiar isto?";
-$text['confirm-copy-info']['ro-ro'] = "";
-$text['confirm-copy-info']['ru-ru'] = "Вы действительно хотите скопировать это?";
-$text['confirm-copy-info']['sv-se'] = "Vill du verkligen kopiera detta?";
-$text['confirm-copy-info']['uk-ua'] = "";
-
-$text['confirm-copy']['en-us'] = "Copy complete";
-$text['confirm-copy']['ar-eg'] = "";
-$text['confirm-copy']['de-at'] = "Erfolgreich kopiert"; //copied from de-de
-$text['confirm-copy']['de-ch'] = "Erfolgreich kopiert"; //copied from de-de
-$text['confirm-copy']['de-de'] = "Erfolgreich kopiert";
-$text['confirm-copy']['es-cl'] = "Copia Completada";
-$text['confirm-copy']['es-mx'] = "Copia Completada"; //copied from es-cl
-$text['confirm-copy']['fr-ca'] = "Copié"; //copied from fr-fr
-$text['confirm-copy']['fr-fr'] = "Copié";
-$text['confirm-copy']['he-il'] = "העתקה הושלמה";
-$text['confirm-copy']['it-it'] = "Copia Completata";
-$text['confirm-copy']['nl-nl'] = "";
-$text['confirm-copy']['pl-pl'] = "Czy na pewno chcesz to skopiować?";
-$text['confirm-copy']['pt-br'] = "Deseja realmente copiar isto?";
-$text['confirm-copy']['pt-pt'] = "Cópia Efectuada";
-$text['confirm-copy']['ro-ro'] = "";
-$text['confirm-copy']['ru-ru'] = "Копирование завершено";
-$text['confirm-copy']['sv-se'] = "Kopiering Slutförd";
-$text['confirm-copy']['uk-ua'] = "";
-
$text['confirm-add']['en-us'] = "Add complete";
$text['confirm-add']['ar-eg'] = "";
$text['confirm-add']['de-at'] = "Erfolgreich hinzugefügt"; //copied from de-de
diff --git a/app/fax/fax.php b/app/fax/fax.php
index 729a3fa2f0..7c8e09691a 100644
--- a/app/fax/fax.php
+++ b/app/fax/fax.php
@@ -28,6 +28,7 @@
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
+ require_once "resources/paging.php";
//check permissions
if (permission_exists('fax_extension_view')) {
@@ -38,23 +39,67 @@
exit;
}
-//additional includes
- require_once "resources/header.php";
- require_once "resources/paging.php";
-
//add multi-lingual support
$language = new text;
$text = $language->get();
-//get the http get values and set them as php variables
+//get posted data
+ if (is_array($_POST['fax_servers'])) {
+ $action = $_POST['action'];
+ $search = $_POST['search'];
+ $fax_servers = $_POST['fax_servers'];
+ }
+
+//copy the fax servers
+ if (permission_exists('fax_extension_copy')) {
+ if ($action == 'copy' && is_array($fax_servers) && @sizeof($fax_servers) != 0) {
+ //copy
+ $obj = new fax;
+ $obj->copy($fax_servers);
+ //redirect
+ header('Location: fax.php'.($search != '' ? '?search='.urlencode($search) : null));
+ exit;
+ }
+ }
+
+//delete the fax servers
+ if (permission_exists('fax_extension_delete')) {
+ if ($action == 'delete' && is_array($fax_servers) && @sizeof($fax_servers) != 0) {
+ //delete
+ $obj = new fax;
+ $obj->delete($fax_servers);
+ //redirect
+ header('Location: fax.php'.($search != '' ? '?search='.urlencode($search) : null));
+ exit;
+ }
+ }
+
+//get order and order by
$order_by = $_GET["order_by"];
$order = $_GET["order"];
+//add the search term
+ $search = strtolower($_GET["search"]);
+ if (strlen($search) > 0) {
+ $sql_search = "and (";
+ $sql_search .= "lower(fax_name) like :search ";
+ $sql_search .= "or lower(fax_email) like :search ";
+ $sql_search .= "or lower(fax_extension) like :search ";
+ $sql_search .= "or lower(fax_destination_number) like :search ";
+ $sql_search .= "or lower(fax_caller_id_name) like :search ";
+ $sql_search .= "or lower(fax_caller_id_number) like :search ";
+ $sql_search .= "or lower(fax_forward_number) like :search ";
+ $sql_search .= "or lower(fax_description) like :search ";
+ $sql_search .= ") ";
+ $parameters['search'] = '%'.$search.'%';
+ }
+
//get record counts
if (if_group("superadmin") || if_group("admin")) {
//show all fax extensions
$sql = "select count(*) from v_fax as f ";
$sql .= "where f.domain_uuid = :domain_uuid ";
+ $sql .= $sql_search;
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
else {
@@ -63,6 +108,7 @@
$sql .= "where f.fax_uuid = u.fax_uuid ";
$sql .= "and f.domain_uuid = :domain_uuid ";
$sql .= "and u.user_uuid = :user_uuid ";
+ $sql .= $sql_search;
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['user_uuid'] = $_SESSION['user_uuid'];
}
@@ -71,10 +117,10 @@
//prepare paging
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
- $param = "";
- $page = check_str($_GET['page']);
- if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
- list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
+ $param = "&search=".$search;
+ $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 records
@@ -85,115 +131,131 @@
$result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
+//create token
+ $object = new token;
+ $token = $object->create($_SERVER['PHP_SELF']);
+
+//additional includes
+ require_once "resources/header.php";
+
//show the content
- echo "
\n";
- echo " \n";
- echo " \n";
- echo " ".$text['title-fax']." (".$num_rows.")";
- echo "
\n";
- echo " ".$text['description']."\n";
- echo " | \n";
- echo "
\n";
- echo "
\n";
- echo "
\n";
+ echo "\n";
+ echo "
".$text['title-fax']." (".$num_rows.")
\n";
+ echo "
\n";
+ if (permission_exists('fax_extension_add')) {
+ echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'fax_edit.php']);
+ }
+ if (permission_exists('fax_extension_add') && $result) {
+ echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
+ }
+ if (permission_exists('fax_extension_delete') && $result) {
+ echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
+ }
+ echo "\n";
+ echo "
\n";
+ echo "
\n";
+ echo "
\n";
- $c = 0;
- $row_style["0"] = "row_style0";
- $row_style["1"] = "row_style1";
+ echo $text['description']."\n";
+ echo "
\n";
- echo "\n";
- echo "\n";
+ echo "
\n";
+ echo "
\n";
+ echo "".$paging_controls."
\n";
-//show the footer
+ echo "\n";
+
+ echo "\n";
+
+//include the footer
require_once "resources/footer.php";
?>
diff --git a/app/fax/fax_copy.php b/app/fax/fax_copy.php
index b7a5dd8d0d..b9058df334 100644
--- a/app/fax/fax_copy.php
+++ b/app/fax/fax_copy.php
@@ -120,7 +120,7 @@
$p->delete('fax_add', 'temp');
//set message
- message::add($text['confirm-copy']);
+ message::add($text['message-copy']);
}
//redirect
diff --git a/app/fax/fax_edit.php b/app/fax/fax_edit.php
index 69b4345bf8..03d11ca9a8 100644
--- a/app/fax/fax_edit.php
+++ b/app/fax/fax_edit.php
@@ -477,7 +477,7 @@
echo " \n";
echo " \n";
if (permission_exists('fax_extension_copy') && $action == "update") {
- echo " \n";
+ echo " \n";
}
echo " \n";
echo " | \n";
diff --git a/app/fax/resources/classes/fax.php b/app/fax/resources/classes/fax.php
index 23572699ae..8e32ba81c6 100644
--- a/app/fax/resources/classes/fax.php
+++ b/app/fax/resources/classes/fax.php
@@ -45,11 +45,31 @@
public $destination_number;
private $forward_prefix;
+ /**
+ * declare private variables
+ */
+ private $app_name;
+ private $app_uuid;
+ private $permission_prefix;
+ private $list_page;
+ private $table;
+ private $uuid_prefix;
+ private $toggle_field;
+ private $toggle_values;
+
/**
* Called when the object is created
*/
public function __construct() {
- //place holder
+
+ //assign private variables
+ $this->app_name = 'fax';
+ $this->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
+ $this->permission_prefix = 'fax_extension_';
+ $this->list_page = 'fax.php';
+ $this->table = 'fax';
+ $this->uuid_prefix = 'fax_';
+
}
/**
@@ -191,7 +211,209 @@
return $dialplan_response;
}
- }
+
+ /**
+ * delete records
+ */
+ public function delete($records) {
+ if (permission_exists($this->permission_prefix.'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->list_page);
+ exit;
+ }
+
+ //delete multiple records
+ if (is_array($records) && @sizeof($records) != 0) {
+
+ //build the delete array
+ foreach ($records as $x => $record) {
+ if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
+
+ //primary record
+ $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
+ $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
+ $array['fax_users'][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
+ $array['fax_users'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
+
+ //include the dialplan record
+ $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'] = $record['uuid'];
+ $database = new database;
+ $dialplan_uuid = $database->select($sql, $parameters, 'column');
+ if (is_uuid($dialplan_uuid)) {
+ // dialplan entry
+ $array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid;
+ $array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
+
+ //dialplan details
+ $array['dialplan_details'][$x]['dialplan_uuid'] = $dialplan_uuid;
+ $array['dialplan_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
+ }
+ unset($sql, $parameters);
+
+ }
+ }
+
+ //delete the checked rows
+ if (is_array($array) && @sizeof($array) != 0) {
+
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('fax_delete', 'temp');
+ $p->add('dialplan_delete', 'temp');
+ $p->add('dialplan_detail_delete', 'temp');
+
+ //execute delete
+ $database = new database;
+ $database->app_name = $this->app_name;
+ $database->app_uuid = $this->app_uuid;
+ $database->delete($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('fax_delete', 'temp');
+ $p->delete('dialplan_delete', 'temp');
+ $p->delete('dialplan_detail_delete', 'temp');
+
+ //syncrhonize configuration
+ save_dialplan_xml();
+
+ //apply settings reminder
+ $_SESSION["reload_xml"] = true;
+
+ //clear the cache
+ $cache = new cache;
+ $cache->delete("dialplan:".$_SESSION["context"]);
+
+ //set message
+ message::add($text['message-delete']);
+ }
+ unset($records);
+ }
+ }
+ }
+
+ /**
+ * copy records
+ */
+ public function copy($records) {
+ if (permission_exists($this->permission_prefix.'copy')) {
+
+ //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->list_page);
+ exit;
+ }
+
+ //copy the checked records
+ if (is_array($records) && @sizeof($records) != 0) {
+
+ //get checked records
+ foreach($records as $x => $record) {
+ if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
+ $record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
+ }
+ }
+
+ //create insert array from existing data
+ if (is_array($record_uuids) && @sizeof($record_uuids) != 0) {
+ $sql = "select * from v_".$this->table." ";
+ $sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
+ $sql .= "and ( ".implode(' or ', $record_uuids)." ) ";
+ $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $database = new database;
+ $rows = $database->select($sql, $parameters, 'all');
+ if (is_array($rows) && @sizeof($rows) != 0) {
+ $y = 0;
+ foreach ($rows as $x => $row) {
+ $primary_uuid = uuid();
+
+ //copy data
+ $array[$this->table][$x] = $row;
+
+ //overwrite
+ $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $primary_uuid;
+ $array[$this->table][$x]['dialplan_uuid'] = uuid();
+ if ($row['fax_forward_number'] == '') {
+ unset($array[$this->table][$x]['fax_forward_number']);
+ }
+ $array[$this->table][$x]['fax_description'] = trim($row['fax_description'].' ('.$text['label-copy'].')');
+
+ //fax users sub table
+ $sql_2 = "select e.* from v_fax_users as e, v_users as u ";
+ $sql_2 .= "where e.user_uuid = u.user_uuid ";
+ $sql_2 .= "and e.domain_uuid = :domain_uuid ";
+ $sql_2 .= "and e.fax_uuid = :fax_uuid ";
+ $parameters_2['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters_2['fax_uuid'] = $row['fax_uuid'];
+ $database = new database;
+ $rows_2 = $database->select($sql_2, $parameters_2, 'all');
+ if (is_array($rows_2) && @sizeof($rows_2) != 0) {
+ foreach ($rows_2 as $row_2) {
+
+ //copy data
+ $array['fax_users'][$y] = $row_2;
+
+ //overwrite
+ $array['fax_users'][$y]['fax_user_uuid'] = uuid();
+ $array['fax_users'][$y]['fax_uuid'] = $primary_uuid;
+
+ //increment
+ $y++;
+
+ }
+ }
+ unset($sql_2, $parameters_2, $rows_2, $row_2);
+ }
+ }
+ unset($sql, $parameters, $rows, $row);
+ }
+
+ //save the changes and set the message
+ if (is_array($array) && @sizeof($array) != 0) {
+
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('fax_add', 'temp');
+
+ //save the array
+ $database = new database;
+ $database->app_name = $this->app_name;
+ $database->app_uuid = $this->app_uuid;
+ $database->save($array);
+ unset($array);
+
+ //revoke temporary permissions
+ $p->delete('fax_add', 'temp');
+
+ //set message
+ message::add($text['message-copy']);
+
+ }
+ unset($records);
+ }
+
+ }
+ } //method
+
+ } //class
}
/*