Merge pull request #3 from fusionpbx/master

Merge from master
This commit is contained in:
Mafoo 2015-11-17 16:59:50 +00:00
commit 09db455c3a
45 changed files with 1536 additions and 1244 deletions

View File

@ -43,59 +43,60 @@ else {
$id = check_str($_GET["id"]);
}
if (strlen($id) > 0) {
//delete the data
if (strlen($id) > 0) {
//get the dialplan uuid
$sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and call_center_queue_uuid = '$id' ";
$prep_statement = $db->prepare($sql);
$prep_statement->execute();
while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
$queue_name = $row['queue_name'];
$dialplan_uuid = $row['dialplan_uuid'];
}
//get the dialplan uuid
$sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and call_center_queue_uuid = '$id' ";
$prep_statement = $db->prepare($sql);
$prep_statement->execute();
while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
$queue_name = $row['queue_name'];
$dialplan_uuid = $row['dialplan_uuid'];
}
//delete the tier from the database
$sql = "delete from v_call_center_tiers ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and queue_name = '$queue_name' ";
$db->query($sql);
unset($sql);
//delete the tier from the database
$sql = "delete from v_call_center_tiers ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and queue_name = '$queue_name' ";
$db->query($sql);
unset($sql);
//delete the call center queue
$sql = "delete from v_call_center_queues ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
$db->query($sql);
unset($sql);
//delete the call center queue
$sql = "delete from v_call_center_queues ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and call_center_queue_uuid = '$id' ";
$db->query($sql);
unset($sql);
//delete the dialplan entry
$sql = "delete from v_dialplans ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
$db->query($sql);
unset($sql);
//delete the dialplan entry
$sql = "delete from v_dialplans ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
$db->query($sql);
unset($sql);
//delete the dialplan details
$sql = "delete from v_dialplan_details ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
$db->query($sql);
unset($sql);
//delete the dialplan details
$sql = "delete from v_dialplan_details ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
$db->query($sql);
unset($sql);
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$_SESSION["context"]);
remove_config_from_cache('configuration:callcenter.conf');
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$_SESSION["context"]);
remove_config_from_cache('configuration:callcenter.conf');
//synchronize configuration
save_dialplan_xml();
save_call_center_xml();
//synchronize configuration
save_dialplan_xml();
save_call_center_xml();
//apply settings reminder
$_SESSION["reload_xml"] = true;
}
//apply settings reminder
$_SESSION["reload_xml"] = true;
}
//redirect the browser
$_SESSION["message"] = $text['message-delete'];

View File

@ -255,7 +255,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$db->exec(check_sql($sql));
unset($sql);
//syncrhonize the configuration
//synchronize the configuration
save_call_center_xml();
remove_config_from_cache('configuration:callcenter.conf');
@ -311,20 +311,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
unset ($prep_statement);
//dialplan add or update
$c = new call_center;
$c->db = $db;
$c->domain_uuid = $_SESSION['domain_uuid'];
$c->call_center_queue_uuid = $call_center_queue_uuid;
$c->dialplan_uuid = $dialplan_uuid;
$c->queue_name = $queue_name;
$c->queue_name = $queue_name;
$c->queue_cid_prefix = $queue_cid_prefix;
$c->queue_timeout_action = $queue_timeout_action;
$c->queue_description = $queue_description;
$c->destination_number = $queue_extension;
$a = $c->dialplan();
//synchronize the configuration
save_call_center_xml();
remove_config_from_cache('configuration:callcenter.conf');
@ -337,6 +323,20 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$_SESSION["message"] = $text['message-update'];
} //if ($action == "update")
//dialplan add or update
$c = new call_center;
$c->db = $db;
$c->domain_uuid = $_SESSION['domain_uuid'];
$c->call_center_queue_uuid = $call_center_queue_uuid;
$c->dialplan_uuid = $dialplan_uuid;
$c->queue_name = $queue_name;
$c->queue_name = $queue_name;
$c->queue_cid_prefix = $queue_cid_prefix;
$c->queue_timeout_action = $queue_timeout_action;
$c->queue_description = $queue_description;
$c->destination_number = $queue_extension;
$a = $c->dialplan();
//add agent/tier to queue
$agent_name = check_str($_POST["agent_name"]);
$tier_level = check_str($_POST["tier_level"]);
@ -399,8 +399,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
//redirect
header("Location: call_center_queue_edit.php?id=".$call_center_queue_uuid);
return;
header("Location: call_center_queue_edit.php?id=".$call_center_queue_uuid);
return;
} //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)

View File

@ -543,7 +543,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo " if (document.getElementById('tr_caller_id_name')) { document.getElementById('tr_caller_id_name').style.display = 'none'; }\n";
echo " if (document.getElementById('tr_caller_id_number')) { document.getElementById('tr_caller_id_number').style.display = 'none'; }\n";
echo " document.getElementById('tr_actions').style.display = 'none';\n";
echo " document.getElementById('tr_fax_detection').style.display = 'none';\n";
echo " if (document.getElementById('tr_fax_detection')) { document.getElementById('tr_fax_detection').style.display = 'none'; }\n";
echo " document.getElementById('tr_cid_name_prefix').style.display = 'none';\n";
echo " if (document.getElementById('tr_sell')) { document.getElementById('tr_sell').style.display = 'none'; }\n";
echo " if (document.getElementById('tr_buy')) { document.getElementById('tr_buy').style.display = 'none'; }\n";
@ -555,7 +555,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo " if (document.getElementById('tr_caller_id_name')) { document.getElementById('tr_caller_id_name').style.display = ''; }\n";
echo " if (document.getElementById('tr_caller_id_number')) { document.getElementById('tr_caller_id_number').style.display = ''; }\n";
echo " document.getElementById('tr_actions').style.display = '';\n";
echo " document.getElementById('tr_fax_detection').style.display = '';\n";
echo " if (document.getElementById('tr_fax_detection')) { document.getElementById('tr_fax_detection').style.display = ''; }\n";
echo " document.getElementById('tr_cid_name_prefix').style.display = '';\n";
echo " if (document.getElementById('tr_sell')) { document.getElementById('tr_sell').style.display = ''; }\n";
echo " if (document.getElementById('tr_buy')) { document.getElementById('tr_buy').style.display = ''; }\n";

View File

@ -39,6 +39,18 @@
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_mac_address';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_label';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_template';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = "device_extension_view";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
@ -105,6 +117,15 @@
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_domain';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_username_password';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_alternate';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = "device_profile_view";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
@ -127,6 +148,25 @@
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_vendor';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_model';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_firmware';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_enable';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'device_description';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
//schema details
$y = 0; //table array index

View File

@ -789,17 +789,17 @@ $text['label-orbit']['de-at'] = "Park + Orbit";
$text['label-orbit']['ar-eg'] = "";
$text['label-orbit']['he'] = "";
$text['label-normal']['en-us'] = "normal";
$text['label-normal']['es-cl'] = "normal";
$text['label-normal']['pt-pt'] = "normal";
$text['label-normal']['fr-fr'] = "normal";
$text['label-normal']['en-us'] = "Normal";
$text['label-normal']['es-cl'] = "Normal";
$text['label-normal']['pt-pt'] = "Normal";
$text['label-normal']['fr-fr'] = "Normal";
$text['label-normal']['pt-br'] = "Normal";
$text['label-normal']['pl'] = "normalny";
$text['label-normal']['uk'] = "звичайно";
$text['label-normal']['sv-se'] = "normal";
$text['label-normal']['de-at'] = "normal";
$text['label-normal']['ar-eg'] = "";
$text['label-normal']['he'] = "";
$text['label-normal']['pl'] = "Normalny";
$text['label-normal']['uk'] = "Звичайно";
$text['label-normal']['sv-se'] = "Normal";
$text['label-normal']['de-at'] = "Normal";
$text['label-normal']['ar-eg'] = "Normal";
$text['label-normal']['he'] = "Normal";
$text['label-none']['en-us'] = "None";
$text['label-none']['es-cl'] = "Ninguno";
@ -1715,18 +1715,109 @@ $text['label-xfer']['de-at'] = "";
$text['label-xfer']['ar-eg'] = "";
$text['label-xfer']['he'] = "";
$text['label-automata']['en-us'] = "automata";
$text['label-automata']['es-cl'] = "automata";
$text['label-automata']['pt-pt'] = "automata";
$text['label-automata']['fr-fr'] = "automata";
$text['label-automata']['en-us'] = "Automata";
$text['label-automata']['es-cl'] = "Automata";
$text['label-automata']['pt-pt'] = "Automata";
$text['label-automata']['fr-fr'] = "Automata";
$text['label-automata']['pt-br'] = "Automata";
$text['label-automata']['pl'] = "automaty";
$text['label-automata']['uk'] = "";
$text['label-automata']['pl'] = "Automaty";
$text['label-automata']['uk'] = "Automata";
$text['label-automata']['sv-se'] = "Automata";
$text['label-automata']['ro'] = "";
$text['label-automata']['de-at'] = "automata";
$text['label-automata']['ar-eg'] = "";
$text['label-automata']['he'] = "";
$text['label-automata']['ro'] = "Automata";
$text['label-automata']['de-at'] = "Automata";
$text['label-automata']['ar-eg'] = "Automata";
$text['label-automata']['he'] = "Automata";
$text['label-messages']['en-us'] = "Messages";
$text['label-messages']['es-cl'] = "Messages";
$text['label-messages']['pt-pt'] = "Messages";
$text['label-messages']['fr-fr'] = "Messages";
$text['label-messages']['pt-br'] = "Messages";
$text['label-messages']['pl'] = "Messages";
$text['label-messages']['uk'] = "Messages";
$text['label-messages']['sv-se'] = "Messages";
$text['label-messages']['ro'] = "Messages";
$text['label-messages']['de-at'] = "Messages";
$text['label-messages']['ar-eg'] = "Messages";
$text['label-messages']['he'] = "Messages";
$text['label-micmute']['en-us'] = "MicMute";
$text['label-micmute']['es-cl'] = "MicMute";
$text['label-micmute']['pt-pt'] = "MicMute";
$text['label-micmute']['fr-fr'] = "MicMute";
$text['label-micmute']['pt-br'] = "MicMute";
$text['label-micmute']['pl'] = "MicMute";
$text['label-micmute']['uk'] = "MicMute";
$text['label-micmute']['sv-se'] = "MicMute";
$text['label-micmute']['ro'] = "MicMute";
$text['label-micmute']['de-at'] = "MicMute";
$text['label-micmute']['ar-eg'] = "MicMute";
$text['label-micmute']['he'] = "MicMute";
$text['label-redial']['en-us'] = "Redial";
$text['label-redial']['es-cl'] = "Redial";
$text['label-redial']['pt-pt'] = "Redial";
$text['label-redial']['fr-fr'] = "Redial";
$text['label-redial']['pt-br'] = "Redial";
$text['label-redial']['pl'] = "Redial";
$text['label-redial']['uk'] = "Redial";
$text['label-redial']['sv-se'] = "Redial";
$text['label-redial']['ro'] = "Redial";
$text['label-redial']['de-at'] = "Redial";
$text['label-redial']['ar-eg'] = "Redial";
$text['label-redial']['he'] = "Redial";
$text['label-null']['en-us'] = "Null";
$text['label-null']['es-cl'] = "Null";
$text['label-null']['pt-pt'] = "Null";
$text['label-null']['fr-fr'] = "Null";
$text['label-null']['pt-br'] = "Null";
$text['label-null']['pl'] = "Null";
$text['label-null']['uk'] = "Null";
$text['label-null']['sv-se'] = "Null";
$text['label-null']['ro'] = "Null";
$text['label-null']['de-at'] = "Null";
$text['label-null']['ar-eg'] = "Null";
$text['label-null']['he'] = "Null";
$text['label-speeddial']['en-us'] = "SpeedDial";
$text['label-speeddial']['es-cl'] = "SpeedDial";
$text['label-speeddial']['pt-pt'] = "SpeedDial";
$text['label-speeddial']['fr-fr'] = "SpeedDial";
$text['label-speeddial']['pt-br'] = "SpeedDial";
$text['label-speeddial']['pl'] = "SpeedDial";
$text['label-speeddial']['uk'] = "SpeedDial";
$text['label-speeddial']['sv-se'] = "SpeedDial";
$text['label-speeddial']['ro'] = "SpeedDial";
$text['label-speeddial']['de-at'] = "SpeedDial";
$text['label-speeddial']['ar-eg'] = "SpeedDial";
$text['label-speeddial']['he'] = "SpeedDial";
$text['label-speeddialmenu']['en-us'] = "SpeedDialMenu";
$text['label-speeddialmenu']['es-cl'] = "SpeedDialMenu";
$text['label-speeddialmenu']['pt-pt'] = "SpeedDialMenu";
$text['label-speeddialmenu']['fr-fr'] = "SpeedDialMenu";
$text['label-speeddialmenu']['pt-br'] = "SpeedDialMenu";
$text['label-speeddialmenu']['pl'] = "SpeedDialMenu";
$text['label-speeddialmenu']['uk'] = "SpeedDialMenu";
$text['label-speeddialmenu']['sv-se'] = "SpeedDialMenu";
$text['label-speeddialmenu']['ro'] = "SpeedDialMenu";
$text['label-speeddialmenu']['de-at'] = "SpeedDialMenu";
$text['label-speeddialmenu']['ar-eg'] = "SpeedDialMenu";
$text['label-speeddialmenu']['he'] = "SpeedDialMenu";
$text['label-url']['en-us'] = "URL";
$text['label-url']['es-cl'] = "URL";
$text['label-url']['pt-pt'] = "URL";
$text['label-url']['fr-fr'] = "URL";
$text['label-url']['pt-br'] = "URL";
$text['label-url']['pl'] = "URL";
$text['label-url']['uk'] = "URL";
$text['label-url']['sv-se'] = "URL";
$text['label-url']['ro'] = "URL";
$text['label-url']['de-at'] = "URL";
$text['label-url']['ar-eg'] = "URL";
$text['label-url']['he'] = "URL";
$text['label-auto_answer']['en-us'] = "Auto Answer";
$text['label-auto_answer']['es-cl'] = "Respuesta Automática";

View File

@ -128,10 +128,25 @@ require_once "resources/require.php";
//get http post variables and set them to php variables
if (count($_POST) > 0) {
//device mac address
if (permission_exists('device_mac_address')) {
$device_mac_address = check_str($_POST["device_mac_address"]);
$device_mac_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address));
$_POST["device_mac_address"] = $device_mac_address;
}
else {
$orm = new orm;
$orm->name('devices');
$orm->uuid($device_uuid);
$result = $orm->find()->get();
//$message = $orm->message;
foreach ($result as &$row) {
$device_mac_address = $row["device_mac_address"];
$_POST["device_mac_address"] = $device_mac_address;
}
unset ($prep_statement);
}
//devices
$device_mac_address = check_str($_POST["device_mac_address"]);
$device_mac_address = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $device_mac_address));
$_POST["device_mac_address"] = $device_mac_address;
$device_label = check_str($_POST["device_label"]);
$device_vendor = check_str($_POST["device_vendor"]);
$device_uuid_alternate = check_str($_POST["device_uuid_alternate"]);
@ -288,7 +303,7 @@ require_once "resources/require.php";
}
//write the provision files
if (strlen($_SESSION['switch']['provision']['dir']) > 0) {
if (strlen($_SESSION['provision']['path']['text']) > 0) {
require_once "app/provision/provision_write.php";
}
@ -514,7 +529,7 @@ require_once "resources/require.php";
echo "</td>\n";
echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'>\n";
if ($action != "add") {
if (permission_exists('device_add') && $action != "add") {
echo " <input type='button' class='btn' name='' alt='".$text['button-copy']."' onclick=\"var new_mac = prompt('".$text['message_device']."'); if (new_mac != null) { window.location='device_copy.php?id=".$device_uuid."&mac=' + new_mac; }\" value='".$text['button-copy']."'>\n";
}
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
@ -526,195 +541,211 @@ require_once "resources/require.php";
echo " ".$text['label-device_mac_address']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_mac_address' id='device_mac_address' maxlength='255' value=\"$device_mac_address\">\n";
if (permission_exists('device_mac_address')) {
echo " <input class='formfld' type='text' name='device_mac_address' id='device_mac_address' maxlength='255' value=\"$device_mac_address\">\n";
echo "<br />\n";
echo $text['description-device_mac_address']."\n";
}
else {
echo $device_mac_address;
}
echo " <div style='display: none;' id='duplicate_mac_response'></div>\n";
echo "<br />\n";
echo $text['description-device_mac_address']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_label']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_label' maxlength='255' value=\"$device_label\">\n";
echo "<br />\n";
echo $text['description-device_label']."\n";
if (permission_exists('device_label')) {
echo " <input class='formfld' type='text' name='device_label' maxlength='255' value=\"$device_label\">\n";
echo "<br />\n";
echo $text['description-device_label']."\n";
}
else {
echo $device_label;
}
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_template']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
$device = new device;
$template_dir = $device->get_template_dir();
if (permission_exists('device_template')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_template']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
$device = new device;
$template_dir = $device->get_template_dir();
echo "<select id='device_template' name='device_template' class='formfld'>\n";
echo "<option value=''></option>\n";
echo "<select id='device_template' name='device_template' class='formfld'>\n";
echo "<option value=''></option>\n";
if (is_dir($template_dir)) {
$templates = scandir($template_dir);
foreach($templates as $dir) {
if($file != "." && $dir != ".." && $dir[0] != '.') {
if(is_dir($template_dir . "/" . $dir)) {
echo "<optgroup label='$dir'>";
$dh_sub=$template_dir . "/" . $dir;
if(is_dir($dh_sub)) {
$templates_sub = scandir($dh_sub);
foreach($templates_sub as $dir_sub) {
if($file_sub != '.' && $dir_sub != '..' && $dir_sub[0] != '.') {
if(is_dir($template_dir . '/' . $dir .'/'. $dir_sub)) {
if ($device_template == $dir."/".$dir_sub) {
echo "<option value='".$dir."/".$dir_sub."' selected='selected'>".$dir."/".$dir_sub."</option>\n";
}
else {
echo "<option value='".$dir."/".$dir_sub."'>".$dir."/".$dir_sub."</option>\n";
if (is_dir($template_dir)) {
$templates = scandir($template_dir);
foreach($templates as $dir) {
if($file != "." && $dir != ".." && $dir[0] != '.') {
if(is_dir($template_dir . "/" . $dir)) {
echo "<optgroup label='$dir'>";
$dh_sub=$template_dir . "/" . $dir;
if(is_dir($dh_sub)) {
$templates_sub = scandir($dh_sub);
foreach($templates_sub as $dir_sub) {
if($file_sub != '.' && $dir_sub != '..' && $dir_sub[0] != '.') {
if(is_dir($template_dir . '/' . $dir .'/'. $dir_sub)) {
if ($device_template == $dir."/".$dir_sub) {
echo "<option value='".$dir."/".$dir_sub."' selected='selected'>".$dir."/".$dir_sub."</option>\n";
}
else {
echo "<option value='".$dir."/".$dir_sub."'>".$dir."/".$dir_sub."</option>\n";
}
}
}
}
closedir($dh_sub);
}
closedir($dh_sub);
echo "</optgroup>";
}
echo "</optgroup>";
}
}
closedir($dh);
}
closedir($dh);
}
echo "</select>\n";
echo "<br />\n";
echo $text['description-device_template']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-lines']."</td>";
echo " <td class='vtable' align='left'>";
echo " <table width='100%' border='0' cellpadding='0' cellspacing='3'>\n";
echo " <tr>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-line']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-server_address']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-outbound_proxy']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-display_name']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-user_id']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-auth_id']."</td>\n";
if (permission_exists('device_line_password')) {
echo " <td class='vtable' nowrap='nowrap'>".$text['label-password']."</td>\n";
echo "</select>\n";
echo "<br />\n";
echo $text['description-device_template']."\n";
echo "</td>\n";
echo "</tr>\n";
}
echo " <td class='vtable' nowrap='nowrap'>".$text['label-sip_port']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-sip_transport']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-register_expires']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-enabled']."</td>\n";
echo " <td>&nbsp;</td>\n";
echo " </tr>\n";
$x = 0;
foreach($device_lines as $row) {
//determine whether to hide the element
if (strlen($device_line_uuid) == 0) {
$element['hidden'] = false;
$element['visibility'] = "visibility:visible;";
}
else {
$element['hidden'] = true;
$element['visibility'] = "visibility:hidden;";
}
//add the primary key uuid
if (strlen($row['device_line_uuid']) > 0) {
echo " <input name='device_lines[".$x."][device_line_uuid]' type='hidden' value=\"".$row['device_line_uuid']."\">\n";
}
//show each row in the array
echo " <tr>\n";
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
$selected = "selected=\"selected\" ";
echo " <select class='formfld' style='width: 45px;' name='device_lines[".$x."][line_number]'>\n";
echo " <option value=''></option>\n";
echo " <option value='1' ".($row['line_number'] == "1" ? $selected:"").">1</option>\n";
echo " <option value='2' ".($row['line_number'] == "2" ? $selected:"").">2</option>\n";
echo " <option value='3' ".($row['line_number'] == "3" ? $selected:"").">3</option>\n";
echo " <option value='4' ".($row['line_number'] == "4" ? $selected:"").">4</option>\n";
echo " <option value='5' ".($row['line_number'] == "5" ? $selected:"").">5</option>\n";
echo " <option value='6' ".($row['line_number'] == "6" ? $selected:"").">6</option>\n";
echo " <option value='7' ".($row['line_number'] == "7" ? $selected:"").">7</option>\n";
echo " <option value='8' ".($row['line_number'] == "8" ? $selected:"").">8</option>\n";
echo " <option value='9' ".($row['line_number'] == "9" ? $selected:"").">9</option>\n";
echo " <option value='10' ".($row['line_number'] == "10" ? $selected:"").">10</option>\n";
echo " <option value='11' ".($row['line_number'] == "11" ? $selected:"").">11</option>\n";
echo " <option value='12' ".($row['line_number'] == "12" ? $selected:"").">12</option>\n";
echo " </select>\n";
echo " </td>\n";
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
echo " <input class='formfld' style='width: 125px;' type='text' name='device_lines[".$x."][server_address]' maxlength='255' value=\"".$row['server_address']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 125px;' type='text' name='device_lines[".$x."][outbound_proxy]' maxlength='255' value=\"".$row['outbound_proxy']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 95px;' type='text' name='device_lines[".$x."][display_name]' maxlength='255' value=\"".$row['display_name']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 75px;' type='text' name='device_lines[".$x."][user_id]' maxlength='255' value=\"".$row['user_id']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 75px;' type='text' name='device_lines[".$x."][auth_id]' maxlength='255' value=\"".$row['auth_id']."\">\n";
echo " </td>\n";
if (permission_exists('device_line_password')) {
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 90px;' type='password' name='device_lines[".$x."][password]' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" autocomplete=\"off\" maxlength='255' value=\"".$row['password']."\">\n";
echo " </td>\n";
}
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 75px;' type='text' name='device_lines[".$x."][sip_port]' maxlength='255' value=\"".$row['sip_port']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <select class='formfld' style='width: 60px;' name='device_lines[".$x."][sip_transport]'>\n";
echo " <option value='tcp' ".(($row['sip_transport'] == 'tcp') ? "selected" : null).">TCP</option>\n";
echo " <option value='udp' ".(($row['sip_transport'] == 'udp') ? "selected" : null).">UDP</option>\n";
echo " <option value='tls' ".(($row['sip_transport'] == 'tls') ? "selected" : null).">TLS</option>\n";
echo " <option value='dns srv' ".(($row['sip_transport'] == 'dns srv') ? "selected" : null).">DNS SRV</option>\n";
echo " </select>\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 75px;' type='text' name='device_lines[".$x."][register_expires]' maxlength='255' value=\"".$row['register_expires']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <select class='formfld' name='device_lines[".$x."][enabled]'>\n";
echo " <option value='true' ".(($row['enabled'] == "true") ? "selected='selected'" : null).">".$text['label-true']."</option>\n";
echo " <option value='false' ".(($row['enabled'] == "false") ? "selected='selected'" : null).">".$text['label-false']."</option>\n";
echo " </select>\n";
echo " </td>\n";
echo " <td>\n";
if (strlen($row['device_line_uuid']) > 0) {
if (permission_exists('device_delete')) {
echo " <a href='device_line_delete.php?device_uuid=".$row['device_uuid']."&id=".$row['device_line_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
}
if (permission_exists('device_line_view')) {
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-lines']."</td>";
echo " <td class='vtable' align='left'>";
echo " <table width='100%' border='0' cellpadding='0' cellspacing='3'>\n";
echo " <tr>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-line']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-server_address']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-outbound_proxy']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-display_name']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-user_id']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-auth_id']."</td>\n";
if (permission_exists('device_line_password')) {
echo " <td class='vtable' nowrap='nowrap'>".$text['label-password']."</td>\n";
}
echo " </td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-sip_port']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-sip_transport']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-register_expires']."</td>\n";
echo " <td class='vtable' nowrap='nowrap'>".$text['label-enabled']."</td>\n";
echo " <td>&nbsp;</td>\n";
echo " </tr>\n";
$x++;
}
echo " </table>\n";
if (strlen($text['description-lines']) > 0) {
echo " <br>".$text['description-lines']."\n";
}
echo " </td>";
echo " </tr>";
if (permission_exists('device_key_add') || permission_exists('device_key_edit')) {
$x = 0;
foreach($device_lines as $row) {
//determine whether to hide the element
if (strlen($device_line_uuid) == 0) {
$element['hidden'] = false;
$element['visibility'] = "visibility:visible;";
}
else {
$element['hidden'] = true;
$element['visibility'] = "visibility:hidden;";
}
//add the primary key uuid
if (strlen($row['device_line_uuid']) > 0) {
echo " <input name='device_lines[".$x."][device_line_uuid]' type='hidden' value=\"".$row['device_line_uuid']."\">\n";
}
//show each row in the array
echo " <tr>\n";
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
$selected = "selected=\"selected\" ";
echo " <select class='formfld' style='width: 45px;' name='device_lines[".$x."][line_number]'>\n";
echo " <option value=''></option>\n";
echo " <option value='1' ".($row['line_number'] == "1" ? $selected:"").">1</option>\n";
echo " <option value='2' ".($row['line_number'] == "2" ? $selected:"").">2</option>\n";
echo " <option value='3' ".($row['line_number'] == "3" ? $selected:"").">3</option>\n";
echo " <option value='4' ".($row['line_number'] == "4" ? $selected:"").">4</option>\n";
echo " <option value='5' ".($row['line_number'] == "5" ? $selected:"").">5</option>\n";
echo " <option value='6' ".($row['line_number'] == "6" ? $selected:"").">6</option>\n";
echo " <option value='7' ".($row['line_number'] == "7" ? $selected:"").">7</option>\n";
echo " <option value='8' ".($row['line_number'] == "8" ? $selected:"").">8</option>\n";
echo " <option value='9' ".($row['line_number'] == "9" ? $selected:"").">9</option>\n";
echo " <option value='10' ".($row['line_number'] == "10" ? $selected:"").">10</option>\n";
echo " <option value='11' ".($row['line_number'] == "11" ? $selected:"").">11</option>\n";
echo " <option value='12' ".($row['line_number'] == "12" ? $selected:"").">12</option>\n";
echo " </select>\n";
echo " </td>\n";
echo " <td valign='top' align='left' nowrap='nowrap'>\n";
echo " <input class='formfld' style='width: 125px;' type='text' name='device_lines[".$x."][server_address]' maxlength='255' value=\"".$row['server_address']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 125px;' type='text' name='device_lines[".$x."][outbound_proxy]' maxlength='255' value=\"".$row['outbound_proxy']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 95px;' type='text' name='device_lines[".$x."][display_name]' maxlength='255' value=\"".$row['display_name']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 75px;' type='text' name='device_lines[".$x."][user_id]' maxlength='255' value=\"".$row['user_id']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 75px;' type='text' name='device_lines[".$x."][auth_id]' maxlength='255' value=\"".$row['auth_id']."\">\n";
echo " </td>\n";
if (permission_exists('device_line_password')) {
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 90px;' type='password' name='device_lines[".$x."][password]' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" autocomplete=\"off\" maxlength='255' value=\"".$row['password']."\">\n";
echo " </td>\n";
}
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 75px;' type='text' name='device_lines[".$x."][sip_port]' maxlength='255' value=\"".$row['sip_port']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <select class='formfld' style='width: 60px;' name='device_lines[".$x."][sip_transport]'>\n";
echo " <option value='tcp' ".(($row['sip_transport'] == 'tcp') ? "selected" : null).">TCP</option>\n";
echo " <option value='udp' ".(($row['sip_transport'] == 'udp') ? "selected" : null).">UDP</option>\n";
echo " <option value='tls' ".(($row['sip_transport'] == 'tls') ? "selected" : null).">TLS</option>\n";
echo " <option value='dns srv' ".(($row['sip_transport'] == 'dns srv') ? "selected" : null).">DNS SRV</option>\n";
echo " </select>\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <input class='formfld' style='width: 75px;' type='text' name='device_lines[".$x."][register_expires]' maxlength='255' value=\"".$row['register_expires']."\">\n";
echo " </td>\n";
echo " <td align='left'>\n";
echo " <select class='formfld' name='device_lines[".$x."][enabled]'>\n";
echo " <option value='true' ".(($row['enabled'] == "true") ? "selected='selected'" : null).">".$text['label-true']."</option>\n";
echo " <option value='false' ".(($row['enabled'] == "false") ? "selected='selected'" : null).">".$text['label-false']."</option>\n";
echo " </select>\n";
echo " </td>\n";
echo " <td>\n";
if (strlen($row['device_line_uuid']) > 0) {
if (permission_exists('device_delete')) {
echo " <a href='device_line_delete.php?device_uuid=".$row['device_uuid']."&id=".$row['device_line_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
}
}
echo " </td>\n";
echo " </tr>\n";
$x++;
}
echo " </table>\n";
if (strlen($text['description-lines']) > 0) {
echo " <br>".$text['description-lines']."\n";
}
echo " </td>";
echo " </tr>";
}
if (permission_exists('device_profile_edit')) {
//device profile
$sql = "select * from v_device_profiles ";
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
@ -738,7 +769,9 @@ require_once "resources/require.php";
echo " </td>";
echo " </tr>";
}
}
if (permission_exists('device_key_edit')) {
$vendor_count = 0;
foreach($device_keys as $row) {
if ($previous_vendor != $row['device_key_vendor']) {
@ -931,6 +964,13 @@ require_once "resources/require.php";
<option value='line' <?php if ($row['device_key_type'] == "line") { echo $selected;$found=true; } ?>><?php echo $text['label-line'] ?></option>
<option value='automata' <?php if ($row['device_key_type'] == "automata") { echo $selected;$found=true; } ?>><?php echo $text['label-automata'] ?></option>
<option value='normal' <?php if ($row['device_key_type'] == "normal") { echo $selected;$found=true; } ?>><?php echo $text['label-normal'] ?></option>
<option value='Messages' <?php if ($row['device_key_type'] == "Messages") { echo $selected;$found=true; } ?>><?php echo $text['label-messages'] ?></option>
<option value='MicMute' <?php if ($row['device_key_type'] == "MicMute") { echo $selected;$found=true; } ?>><?php echo $text['label-micmute'] ?></option>
<option value='Redial' <?php if ($row['device_key_type'] == "Redial") { echo $selected;$found=true; } ?>><?php echo $text['label-redial'] ?></option>
<option value='Null' <?php if ($row['device_key_type'] == "Null") { echo $selected;$found=true; } ?>><?php echo $text['label-null'] ?></option>
<option value='SpeedDial' <?php if ($row['device_key_type'] == "SpeedDial") { echo $selected;$found=true; } ?>><?php echo $text['label-speeddial'] ?></option>
<option value='SpeedDialMenu' <?php if ($row['device_key_type'] == "SpeedDialMenu") { echo $selected;$found=true; } ?>><?php echo $text['label-speeddialmenu'] ?></option>
<option value='URL' <?php if ($row['device_key_type'] == "URL") { echo $selected;$found=true; } ?>><?php echo $text['label-url'] ?></option>
<?php
if (strlen($device_vendor) == 0) { echo "</optgroup>"; }
}
@ -1065,7 +1105,7 @@ require_once "resources/require.php";
}
//device settings
if (permission_exists('device_setting_add')) {
if (permission_exists('device_setting_edit')) {
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-settings']."</td>";
echo " <td class='vtable' align='left'>";
@ -1153,75 +1193,85 @@ require_once "resources/require.php";
echo " </tr>\n";
}
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_username' id='device_username' autocomplete=\"off\" maxlength='255' placeholder=\"".$text['label-device_username']."\" value=\"$device_username\">\n";
echo " <input class='formfld' type='text' name='device_password' id='device_password' autocomplete=\"off\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" maxlength='255' placeholder=\"".$text['label-device_password']."\" value=\"$device_password\">\n";
echo " <div style='display: none;' id='duplicate_username_response'></div>\n";
echo "<br />\n";
echo $text['description-device']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_uuid_alternate']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left' nowrap='nowrap'>\n";
if (strlen($device_uuid_alternate) == 0) {
echo " <input class='formfld' type='text' name='device_uuid_alternate' id='device_uuid_alternate' maxlength='255' value=\"$device_uuid_alternate\">";
if (permission_exists('device_username_password')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_username' id='device_username' autocomplete=\"off\" maxlength='255' placeholder=\"".$text['label-device_username']."\" value=\"$device_username\">\n";
echo " <input class='formfld' type='text' name='device_password' id='device_password' autocomplete=\"off\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" maxlength='255' placeholder=\"".$text['label-device_password']."\" value=\"$device_password\">\n";
echo " <div style='display: none;' id='duplicate_username_response'></div>\n";
echo "<br />\n";
echo $text['description-device']."\n";
echo "</td>\n";
echo "</tr>\n";
}
else {
$label = $device_alternate[0]['device_label'];
if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; }
if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; }
echo " <table>\n";
echo " <tr>\n";
echo " <td><a href='?id=$device_uuid_alternate' id='device_uuid_alternate_link'>$label</a><input class='formfld' type='hidden' name='device_uuid_alternate' id='device_uuid_alternate' maxlength='255' value=\"$device_uuid_alternate\">&nbsp;</td>";
echo " <td><a href='#' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.getElementById('device_uuid_alternate').value = ''; document.getElementById('device_uuid_alternate_link').hidden = 'true'; document.forms.frm.submit(); }\" alt='".$text['button-delete']."'>$v_link_label_delete</a></td>\n";
echo " </tr>\n";
echo " </table>\n";
unset($label);
if (permission_exists('device_alternate')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_uuid_alternate']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left' nowrap='nowrap'>\n";
if (strlen($device_uuid_alternate) == 0) {
echo " <input class='formfld' type='text' name='device_uuid_alternate' id='device_uuid_alternate' maxlength='255' value=\"$device_uuid_alternate\">";
}
else {
$label = $device_alternate[0]['device_label'];
if (strlen($label) == 0) { $label = $device_alternate[0]['device_description']; }
if (strlen($label) == 0) { $label = $device_alternate[0]['device_mac_address']; }
echo " <table>\n";
echo " <tr>\n";
echo " <td><a href='?id=$device_uuid_alternate' id='device_uuid_alternate_link'>$label</a><input class='formfld' type='hidden' name='device_uuid_alternate' id='device_uuid_alternate' maxlength='255' value=\"$device_uuid_alternate\">&nbsp;</td>";
echo " <td><a href='#' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.getElementById('device_uuid_alternate').value = ''; document.getElementById('device_uuid_alternate_link').hidden = 'true'; document.forms.frm.submit(); }\" alt='".$text['button-delete']."'>$v_link_label_delete</a></td>\n";
echo " </tr>\n";
echo " </table>\n";
unset($label);
}
echo $text['description-device_uuid_alternate']."\n";
echo "</td>\n";
echo "</tr>\n";
}
echo $text['description-device_uuid_alternate']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_vendor']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_vendor' maxlength='255' value=\"$device_vendor\">\n";
echo "<br />\n";
echo $text['description-device_vendor']."\n";
echo "</td>\n";
echo "</tr>\n";
if (permission_exists('device_vendor')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_vendor']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_vendor' maxlength='255' value=\"$device_vendor\">\n";
echo "<br />\n";
echo $text['description-device_vendor']."\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_model']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_model' maxlength='255' value=\"$device_model\">\n";
echo "<br />\n";
echo $text['description-device_model']."\n";
echo "</td>\n";
echo "</tr>\n";
if (permission_exists('device_model')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_model']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_model' maxlength='255' value=\"$device_model\">\n";
echo "<br />\n";
echo $text['description-device_model']."\n";
echo "</td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_firmware_version']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_firmware_version' maxlength='255' value=\"$device_firmware_version\">\n";
echo "<br />\n";
echo $text['description-device_firmware_version']."\n";
echo "</td>\n";
echo "</tr>\n";
if (permission_exists('device_firmware')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_firmware_version']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_firmware_version' maxlength='255' value=\"$device_firmware_version\">\n";
echo "<br />\n";
echo $text['description-device_firmware_version']."\n";
echo "</td>\n";
echo "</tr>\n";
}
if (permission_exists('device_domain')) {
echo "<tr>\n";
@ -1253,38 +1303,46 @@ require_once "resources/require.php";
echo " <input type='hidden' name='domain_uuid' id='domain_uuid' value=\"".$_SESSION['domain_uuid']."\">\n";
}
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_provision_enable']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='device_provision_enable'>\n";
if ($device_provision_enable == "true" || strlen($device_provision_enable) == 0) {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
if (permission_exists('device_enable')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_provision_enable']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='device_provision_enable'>\n";
if ($device_provision_enable == "true" || strlen($device_provision_enable) == 0) {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['label-true']."</option>\n";
}
if ($device_provision_enable == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-device_provision_enable']."\n";
echo "</td>\n";
echo "</tr>\n";
}
else {
echo " <option value='true'>".$text['label-true']."</option>\n";
}
if ($device_provision_enable == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-device_provision_enable']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_description' maxlength='255' value=\"$device_description\">\n";
echo "<br />\n";
echo $text['description-device_description']."\n";
if (permission_exists('device_description')) {
echo " <input class='formfld' type='text' name='device_description' maxlength='255' value=\"$device_description\">\n";
echo "<br />\n";
echo $text['description-device_description']."\n";
}
else {
echo $device_description."\n";
}
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";

View File

@ -138,7 +138,7 @@ require_once "resources/require.php";
}
//write the provision files
if (strlen($_SESSION['switch']['provision']['dir']) > 0) {
if (strlen($_SESSION['provision']['path']['text']) > 0) {
require_once "app/provision/provision_write.php";
}
@ -454,6 +454,13 @@ require_once "resources/require.php";
<option value='line' <?php if ($row['device_key_type'] == "line") { echo $selected;$found=true; } ?>><?php echo $text['label-line'] ?></option>
<option value='automata' <?php if ($row['device_key_type'] == "automata") { echo $selected;$found=true; } ?>><?php echo $text['label-automata'] ?></option>
<option value='normal' <?php if ($row['device_key_type'] == "normal") { echo $selected;$found=true; } ?>><?php echo $text['label-normal'] ?></option>
<option value='Messages' <?php if ($row['device_key_type'] == "Messages") { echo $selected;$found=true; } ?>><?php echo $text['label-messages'] ?></option>
<option value='MicMute' <?php if ($row['device_key_type'] == "MicMute") { echo $selected;$found=true; } ?>><?php echo $text['label-micmute'] ?></option>
<option value='Redial' <?php if ($row['device_key_type'] == "Redial") { echo $selected;$found=true; } ?>><?php echo $text['label-redial'] ?></option>
<option value='Null' <?php if ($row['device_key_type'] == "Null") { echo $selected;$found=true; } ?>><?php echo $text['label-null'] ?></option>
<option value='SpeedDial' <?php if ($row['device_key_type'] == "SpeedDial") { echo $selected;$found=true; } ?>><?php echo $text['label-speeddial'] ?></option>
<option value='SpeedDialMenu' <?php if ($row['device_key_type'] == "SpeedDialMenu") { echo $selected;$found=true; } ?>><?php echo $text['label-speeddialmenu'] ?></option>
<option value='URL' <?php if ($row['device_key_type'] == "URL") { echo $selected;$found=true; } ?>><?php echo $text['label-url'] ?></option>
<?php
if (strlen($device_vendor) == 0) { echo "</optgroup>"; }
}

View File

@ -29,6 +29,7 @@ include "root.php";
require_once "resources/require.php";
require_once "resources/functions/object_to_array.php";
require_once "resources/functions/parse_attachments.php";
require_once "resources/classes/text.php";
//get accounts to monitor
$sql = "select * from v_fax ";

View File

@ -98,21 +98,28 @@ if (!$included) {
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'.((count($_SESSION["domains"]) > 1) ? '/'.$_SESSION['domain_name'] : null);
}
function correct_path($p) {
global $IS_WINDOWS;
if ($IS_WINDOWS) {
return str_replace('/', '\\', $p);
}
return $p;
else {
require_once "resources/classes/EventSocket.php";
}
function gs_cmd($args) {
global $IS_WINDOWS;
if ($IS_WINDOWS) {
return 'gswin32c '.$args;
if(!function_exists('correct_path')) {
function correct_path($p) {
global $IS_WINDOWS;
if ($IS_WINDOWS) {
return str_replace('/', '\\', $p);
}
return $p;
}
}
if(!function_exists('gs_cmd')) {
function gs_cmd($args) {
global $IS_WINDOWS;
if ($IS_WINDOWS) {
return 'gswin32c '.$args;
}
return 'gs '.$args;
}
return 'gs '.$args;
}
//get the fax extension

View File

@ -103,6 +103,13 @@
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'provision';
$array[$x]['default_setting_subcategory'] = 'path';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = '';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = '';
$x++;
$array[$x]['default_setting_category'] = 'provision';
$array[$x]['default_setting_subcategory'] = 'voicemail_number';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = '*97';

View File

@ -822,8 +822,8 @@ include "root.php";
//$file_size = round(filesize($new_path)/1024, 2);
//echo $this->template_dir."/".$device_template."/".$file_name." $file_size\n";
//write the configuration to the directory
if (strlen($_SESSION['switch']['provision']['dir']) > 0) {
$dir_array = explode(";", $_SESSION['switch']['provision']['dir']);
if (strlen($provision["path"]) > 0) {
$dir_array = explode(";", $provision["path"]);
foreach($dir_array as $directory) {
if (file_exists($this->template_dir."/".$device_template."/".$file_name)) {

View File

@ -3,54 +3,68 @@
if ($domains_processed == 1) {
//define holiday presets
$preset[] = json_encode(array("new_years_day" => array("mday" => "1", "mon" => "1")));
$preset[] = json_encode(array("martin_luther_king_jr_day" => array("wday" => "2", "mon" => "1", "mweek" => "3")));
$preset[] = json_encode(array("presidents_day" => array("wday" => "2", "mon" => "2", "mweek" => "3")));
$preset[] = json_encode(array("memorial_day" => array("mday" => "25-31", "wday" => "2", "mon" => "5")));
$preset[] = json_encode(array("independence_day" => array("mday" => "4", "mon" => "7")));
$preset[] = json_encode(array("labor_day" => array("wday" => "2", "mon" => "9", "mweek" => "1")));
$preset[] = json_encode(array("columbus_day" => array("wday" => "2", "mon" => "10", "mweek" => "2")));
$preset[] = json_encode(array("veterans_day" => array("mday" => "11", "mon" => "11")));
$preset[] = json_encode(array("thanksgiving_day" => array("wday" => "5-6", "mon" => "11", "mweek" => "4")));
$preset[] = json_encode(array("christmas_day" => array("mday" => "25", "mon" => "12")));
$preset['usa'][] = json_encode(array("new_years_day" => array("mday" => "1", "mon" => "1")));
$preset['usa'][] = json_encode(array("martin_luther_king_jr_day" => array("wday" => "2", "mon" => "1", "mweek" => "3")));
$preset['usa'][] = json_encode(array("presidents_day" => array("wday" => "2", "mon" => "2", "mweek" => "3")));
$preset['usa'][] = json_encode(array("memorial_day" => array("mday" => "25-31", "wday" => "2", "mon" => "5")));
$preset['usa'][] = json_encode(array("independence_day" => array("mday" => "4", "mon" => "7")));
$preset['usa'][] = json_encode(array("labor_day" => array("wday" => "2", "mon" => "9", "mweek" => "1")));
$preset['usa'][] = json_encode(array("columbus_day" => array("wday" => "2", "mon" => "10", "mweek" => "2")));
$preset['usa'][] = json_encode(array("veterans_day" => array("mday" => "11", "mon" => "11")));
$preset['usa'][] = json_encode(array("thanksgiving_day" => array("wday" => "5-6", "mon" => "11", "mweek" => "4")));
$preset['usa'][] = json_encode(array("christmas_day" => array("mday" => "25", "mon" => "12")));
//define array of settings
$x = 0;
foreach ($preset as $json) {
$array[$x]['default_setting_category'] = 'time_conditions';
$array[$x]['default_setting_subcategory'] = 'preset';
$array[$x]['default_setting_name'] = 'array';
$array[$x]['default_setting_value'] = $json;
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = 'Holiday';
$x++;
}
$preset['england'][] = json_encode(array("new_years_day" => array("mday" => "1", "mon" => "1")));
$preset['england'][] = json_encode(array("christmas_day" => array("mday" => "25", "mon" => "12")));
$preset['england'][] = json_encode(array("boxing_day" => array("mday" => "26", "mon" => "12")));
$preset['england'][] = json_encode(array("may_day" => array("mon" => "5", "mweek" => "1", "wday" => "2")));
$preset['england'][] = json_encode(array("spring_bank_holiday" => array("mon" => "5", "mday" => "25-31", "wday" => "2")));
$preset['england'][] = json_encode(array("august_bank_holiday" => array("mon" => "8", "mday" => "25-31", "wday" => "2")));
//get an array of the default settings
$sql = "select * from v_default_settings ";
//iterate and migrate old presets first
$sql = "update v_default_settings ";
$sql .= "set default_setting_subcategory = 'preset_usa' ";
$sql .= ", default_setting_description = 'usa Holiday' ";
$sql .= "where default_setting_category = 'time_conditions' ";
$sql .= "and default_setting_subcategory = 'preset' ";
$sql .= "and default_setting_name = 'array' ";
$prep_statement = $db->prepare($sql);
$prep_statement->execute();
$default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql);
//find the missing default settings
$x = 0;
foreach ($array as $setting) {
$found = false;
$missing[$x] = $setting;
foreach ($default_settings as $row) {
if (trim($row['default_setting_value']) == trim($setting['default_setting_value'])) {
$found = true;
//remove items from the array that were found
unset($missing[$x]);
}
}
$x++;
if ($prep_statement) {
$prep_statement->execute();
unset ($prep_statement, $sql);
}
//iterate and add each, if necessary
$x = 0;
foreach ($preset as $region => $data) {
$sql = "select * from v_default_settings ";
$sql .= "where default_setting_category = 'time_conditions' ";
$sql .= "and default_setting_subcategory = 'preset_$region' ";
$sql .= "and default_setting_name = 'array' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql);
foreach ($data as $json) {
$found = false;
$missing[$x]['default_setting_category'] = 'time_conditions';
$missing[$x]['default_setting_subcategory'] = "preset_$region";
$missing[$x]['default_setting_name'] = 'array';
$missing[$x]['default_setting_value'] = $json;
$missing[$x]['default_setting_enabled'] = 'true';
$missing[$x]['default_setting_description'] = "$region Holiday";
foreach ($default_settings as $row) {
if (trim($row['default_setting_value']) == trim($json)) {
$found = true;
//remove items from the array that were found
unset($missing[$x]);
}
}
$x++;
}
}
}
//add the missing default settings
foreach ($missing as $row) {
//add the default settings
@ -63,6 +77,39 @@ if ($domains_processed == 1) {
}
unset($missing);
$array[$x]['default_setting_category'] = 'time_conditions';
$array[$x]['default_setting_subcategory'] = 'region';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = 'usa';
$array[$x]['default_setting_enabled'] = 'true';
$array[$x]['default_setting_description'] = 'What region to use by default when choosing Time Conditions';
$x++;
//iterate and add each, if necessary
foreach ($array as $index => $default_settings) {
//add the default setting
$sql = "select count(*) as num_rows from v_default_settings ";
$sql .= "where default_setting_category = '".$default_settings['default_setting_category']."' ";
$sql .= "and default_setting_subcategory = '".$default_settings['default_setting_subcategory']."' ";
$sql .= "and default_setting_name = '".$default_settings['default_setting_name']."' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
unset($prep_statement);
if ($row['num_rows'] == 0) {
$orm = new orm;
$orm->name('default_settings');
$orm->save($array[$index]);
$message = $orm->message;
//print_r($message);
}
unset($row);
}
}
//unset the array variable
unset($array);
}

View File

@ -44,10 +44,12 @@ require_once "resources/header.php";
$destination = new destinations;
//load available presets
foreach ($_SESSION['time_conditions']['preset'] as $json) {
$preset_region = "preset_".$_SESSION['time_conditions']['region']['text'];
foreach ($_SESSION['time_conditions'][$preset_region] as $json) {
$available_presets[] = json_decode($json, true);
}
unset($preset_region);
//set the action as an add or an update
if (isset($_REQUEST["id"])) {
$action = "update";

View File

@ -131,6 +131,9 @@ if ($domains_processed == 1) {
if (strlen($_SESSION['switch']['sounds']['dir']) > 0) {
$tmp .= correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n");
}
if (strlen($_SESSION['switch']['phrases']['dir']) > 0) {
$tmp .= correct_path(" phrases_dir = [[".$_SESSION['switch']['phrases']['dir']."]];\n");
}
if (strlen($_SESSION['switch']['db']['dir']) > 0) {
$tmp .= correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n");
}

View File

@ -41,6 +41,16 @@
--array count
require "resources.functions.count";
local IS_WINDOWS = (package.config:sub(1,1) == '\\')
local function quote(s)
local q = IS_WINDOWS and '"' or "'"
if s:find('%s') or s:find(q, nil, true) then
s = q .. s:gsub(q, q..q) .. q
end
return s
end
-- set channel variables to lua variables
domain_uuid = env:getHeader("domain_uuid");
domain_name = env:getHeader("domain_name");
@ -181,23 +191,17 @@
end
--fax to email
cmd = "'"..php_dir.."/"..php_bin.."' '"..document_root.."/secure/fax_to_email.php' ";
cmd = cmd .. "email='"..fax_email.."' ";
cmd = cmd .. "extension="..fax_extension.." ";
cmd = cmd .. "name='"..fax_file.."' ";
cmd = cmd .. "messages='result:"..fax_result_text.." sender:"..fax_remote_station_id.." pages:"..fax_document_total_pages.."' ";
cmd = cmd .. "domain="..domain_name.." ";
cmd = cmd .. "caller_id_name='";
if (caller_id_name ~= nil) then
cmd = cmd .. caller_id_name;
end
cmd = cmd .. "' ";
cmd = cmd .. "caller_id_number=";
if (caller_id_number ~= nil) then
cmd = cmd .. caller_id_number;
end
cmd = cmd .. " ";
if (string.len(fax_forward_number) > 0) then
-- cmd = "lua" .. " " .. quote(scripts_dir .. "/fax_to_email.lua") .. " ";
cmd = quote(php_dir.."/"..php_bin).." "..quote(document_root.."/secure/fax_to_email.php").." ";
cmd = cmd .. "email="..quote(fax_email).." ";
cmd = cmd .. "extension="..quote(fax_extension).." ";
cmd = cmd .. "name="..quote(fax_file).." ";
cmd = cmd .. "messages=" .. quote("result:"..fax_result_text.." sender:"..fax_remote_station_id.." pages:"..fax_document_total_pages).." ";
cmd = cmd .. "domain="..quote(domain_name).." ";
cmd = cmd .. "caller_id_name=" .. quote(caller_id_name or '') .. " ";
cmd = cmd .. "caller_id_number=" .. quote(caller_id_number or '') .. " ";
if #fax_forward_number > 0 then
cmd = cmd .. "fax_relay=true ";
end
freeswitch.consoleLog("notice", "[fax] command: " .. cmd .. "\n");

View File

@ -497,7 +497,7 @@ local log = require "resources.functions.log".ring_group
end
elseif (r.dialplan_detail_type == "bridge") then
if (bridge_match) then
dial_string = dial_string .. "|" .. square .."]"..dialplan_detail_data;
dial_string = dial_string .. delimiter .. square .."]"..dialplan_detail_data;
square = "[";
else
dial_string = square .."]"..dialplan_detail_data;

View File

@ -78,6 +78,10 @@
if (not vm_disk_quota) then
vm_disk_quota = session:getVariable("vm_disk_quota");
end
record_silence_threshold = session:getVariable("record-silence-threshold");
if (not record_silence_threshold) then
record_silence_threshold = 300;
end
voicemail_authorized = session:getVariable("voicemail_authorized");
if (not vm_message_ext) then vm_message_ext = 'wav'; end

View File

@ -63,11 +63,10 @@
--prepare to record the greeting
if (session:ready()) then
max_len_seconds = 30;
silence_threshold = 30;
silence_seconds = 5;
mkdir(voicemail_dir.."/"..voicemail_id);
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs)
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".tmp.wav", max_len_seconds, silence_threshold, silence_seconds);
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".tmp.wav", max_len_seconds, record_silence_threshold, silence_seconds);
--session:execute("record", voicemail_dir.."/"..uuid.." 180 200");
end
end

View File

@ -143,10 +143,9 @@
--save the recording
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs)
max_len_seconds = 300;
silence_threshold = 30;
silence_seconds = 5;
if (storage_path == "http_cache") then
result = session:recordFile(storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, max_len_seconds, silence_threshold, silence_seconds);
result = session:recordFile(storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, max_len_seconds, record_silence_threshold, silence_seconds);
else
mkdir(voicemail_dir.."/"..voicemail_id);
if (vm_message_ext == "mp3") then
@ -154,10 +153,10 @@
if (shout_exists == "true") then
freeswitch.consoleLog("notice", "using mod_shout for mp3 encoding\n");
--record in mp3 directly
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".mp3", max_len_seconds, silence_threshold, silence_seconds);
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".mp3", max_len_seconds, record_silence_threshold, silence_seconds);
else
--create initial wav recording
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav", max_len_seconds, silence_threshold, silence_seconds);
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav", max_len_seconds, record_silence_threshold, silence_seconds);
--use lame to encode, if available
if (file_exists("/usr/bin/lame")) then
freeswitch.consoleLog("notice", "using lame for mp3 encoding\n");
@ -176,7 +175,7 @@
end
end
else
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, max_len_seconds, silence_threshold, silence_seconds);
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, max_len_seconds, record_silence_threshold, silence_seconds);
end
end

View File

@ -142,18 +142,9 @@
table.insert(xml, [[ </macro>]]);;
end
require "resources.functions.settings";
settings = settings(domain_uuid);
lang_path = "/usr/local/freeswitch/conf/lang/";
if (settings['switch']['phrases'] ~= nil) then
if (settings['switch']['phrases']['dir'] ~= nil) then
lang_path = settings['switch']['phrases']['dir'];
end
end
--read root xml language file, parse included xml files
local xml_file_paths = {}
local file_handle = io.open(lang_path.."/"..language.."/"..language..".xml", "r");
local file_handle = io.open(phrases_dir.."/"..language.."/"..language..".xml", "r");
if (file_handle ~= nil) then
for file_line in file_handle:lines() do
if (string.find(file_line, 'cmd="include" data="', 0, true) ~= nil) then

View File

@ -28,250 +28,309 @@
max_tries = "3";
digit_timeout = "3000";
--debug
debug["sql"] = false;
--define the trim function
require "resources.functions.trim"
--define the explode function
require "resources.functions.explode"
--create the api object
api = freeswitch.API();
--include config.lua
require "resources.functions.config";
--include config.lua
require "resources.functions.settings";
require "resources.functions.channel_utils";
local log = require "resources.functions.log".call_forward
local cache = require "resources.functions.cache"
local Database = require "resources.functions.database"
local function opt(t, ...)
if select('#', ...) == 0 then
return t
end
if type(t) ~= 'table' then
return nil
end
return opt(t[...], select(2, ...))
end
local function empty(t)
return (not t) or (#t == 0)
end
--check if the session is ready
if (session:ready()) then
--answer the call
session:answer();
if not session:ready() then return end
--get the variables
enabled = session:getVariable("enabled");
pin_number = session:getVariable("pin_number");
sounds_dir = session:getVariable("sounds_dir");
domain_uuid = session:getVariable("domain_uuid");
domain_name = session:getVariable("domain_name");
extension_uuid = session:getVariable("extension_uuid");
context = session:getVariable("context");
if (not context ) then context = 'default'; end
request_id = session:getVariable("request_id");
--answer the call
session:answer();
--set the sounds path for the language, dialect and voice
default_language = session:getVariable("default_language");
default_dialect = session:getVariable("default_dialect");
default_voice = session:getVariable("default_voice");
if (not default_language) then default_language = 'en'; end
if (not default_dialect) then default_dialect = 'us'; end
if (not default_voice) then default_voice = 'callie'; end
--get the variables
local enabled = session:getVariable("enabled");
local pin_number = session:getVariable("pin_number");
local sounds_dir = session:getVariable("sounds_dir");
local domain_uuid = session:getVariable("domain_uuid");
local domain_name = session:getVariable("domain_name");
local extension_uuid = session:getVariable("extension_uuid");
local request_id = session:getVariable("request_id");
local extension, dial_string
--a moment to sleep
session:sleep(1000);
--set the sounds path for the language, dialect and voice
local default_language = session:getVariable("default_language") or 'en';
local default_dialect = session:getVariable("default_dialect") or 'us';
local default_voice = session:getVariable("default_voice") or 'callie';
--connect to the database
require "resources.functions.database_handle";
dbh = database_handle('system');
--a moment to sleep
session:sleep(1000);
--request id is true
if (request_id == "true") then
--unset extension uuid
extension_uuid = nil;
--connect to the database
dbh = Database.new('system');
--get the id
if (session:ready()) then
min_digits = 2;
max_digits = 20;
id = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_id:#", "", "\\d+");
end
--request id is true
if (request_id == "true") then
--unset extension uuid
extension_uuid = nil;
--get the pin number
if (session:ready()) then
min_digits = 3;
max_digits = 20;
caller_pin_number = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
end
--get the extension
if not session:ready() then return end
local min_digits = 2;
local max_digits = 20;
extension = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_id:#", "", "\\d+");
if empty(extension) then return end
--check to see if the pin number is correct
if (session:ready()) then
sql = "SELECT * FROM v_voicemails ";
sql = sql .. "WHERE domain_uuid = '" .. domain_uuid .."' ";
sql = sql .. "AND voicemail_id = '" .. id .."' ";
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[call_forward] "..sql .."\n");
end
dbh:query(sql, function(row)
voicemail_password = row.voicemail_password;
--freeswitch.consoleLog("notice", "[call_forward] "..voicemail_password .."\n");
end);
if (voicemail_password ~= caller_pin_number) then
--access denied
session:streamFile("phrase:voicemail_fail_auth:#");
session:hangup("NORMAL_CLEARING");
end
end
--get the pin number
if not session:ready() then return end
min_digits = 3;
max_digits = 20;
local caller_pin_number = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
if empty(caller_pin_number) then return end
--check to see if the pin number is correct
if not session:ready() then return end
local sql = "SELECT voicemail_password FROM v_voicemails ";
sql = sql .. "WHERE domain_uuid = '" .. domain_uuid .."' ";
sql = sql .. "AND voicemail_id = '" .. extension .."' ";
if (debug["sql"]) then
log.notice(sql);
end
local voicemail_password = dbh:first_value(sql)
if (voicemail_password ~= caller_pin_number) then
--access denied
session:streamFile("phrase:voicemail_fail_auth:#");
return session:hangup("NORMAL_CLEARING");
end
end
--determine whether to update the dial string
if not session:ready() then return end
local sql = "select * from v_extensions ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
if (extension_uuid ~= nil) then
sql = sql .. "and extension_uuid = '"..extension_uuid.."' ";
else
sql = sql .. "and (extension = '"..extension.."' or number_alias = '"..extension.."') ";
end
if (debug["sql"]) then
log.notice(sql);
end
local row = dbh:first_row(sql)
if not row then return end
extension_uuid = row.extension_uuid;
extension = row.extension;
local number_alias = row.number_alias or '';
local accountcode = row.accountcode;
local forward_all_enabled = row.forward_all_enabled;
local forward_all_destination = row.forward_all_destination;
local follow_me_uuid = row.follow_me_uuid;
local toll_allow = row.toll_allow or '';
local forward_caller_id_uuid = row.forward_caller_id_uuid;
--toggle enabled
if enabled == "toggle" then
enabled = (forward_all_enabled == "true") and "false" or "true";
end
if not session:ready() then return end
--get the forward destination
if enabled == "true" and empty(forward_all_destination) then
forward_all_destination = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-enter_destination_telephone_number.wav", "", "\\d+");
if empty(forward_all_destination) then return end
end
--set call forward
if enabled == "true" then
--set forward_all_enabled
forward_all_enabled = "true";
channel_display(session:get_uuid(), "Activated")
--say the destination number
session:say(forward_all_destination, default_language, "number", "iterated");
--notify the caller
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_set.wav");
end
--get the caller_id for outbound call
local forward_caller_id = ""
if enabled == "true" and not empty(forward_caller_id_uuid) then
local sql = "select destination_number, destination_description,"..
"destination_caller_id_number, destination_caller_id_name " ..
"from v_destinations where domain_uuid = '" .. domain_uuid .. "' and " ..
"destination_type = 'inbound' and destination_uuid = '" .. forward_caller_id_uuid .. "'";
local row = dbh:first_row(sql)
if row then
local caller_id_number = row.destination_caller_id_number
if empty(caller_id_number) then
caller_id_number = row.destination_number
end
--determine whether to update the dial string
if (session:ready()) then
sql = "select * from v_extensions ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
if (extension_uuid ~= nil) then
sql = sql .. "and extension_uuid = '"..extension_uuid.."' ";
else
sql = sql .. "and (extension = '"..id.."' or number_alias = '"..id.."') ";
end
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[call_forward] "..sql.."\n");
end
status = dbh:query(sql, function(row)
extension_uuid = row.extension_uuid;
extension = row.extension;
number_alias = row.number_alias or '';
accountcode = row.accountcode;
forward_all_enabled = row.forward_all_enabled;
forward_all_destination = row.forward_all_destination;
follow_me_uuid = row.follow_me_uuid;
toll_allow = row.toll_allow or '';
--freeswitch.consoleLog("NOTICE", "[call forward] extension "..row.extension.."\n");
--freeswitch.consoleLog("NOTICE", "[call forward] accountcode "..row.accountcode.."\n");
end);
local caller_id_name = row.destination_caller_id_name
if empty(caller_id_name) then
caller_id_name = row.destination_description
end
--toggle enabled
if (session:ready() and enabled == "toggle") then
if (forward_all_enabled == "true") then
enabled = "false";
else
enabled = "true";
end
if not empty(caller_id_number) then
forward_caller_id = forward_caller_id ..
",outbound_caller_id_number=" .. caller_id_number ..
",origination_caller_id_number=" .. caller_id_number
end
--get the forward destination
if (session:ready() and (enabled == "true" or enabled == "toggle") ) then
if (string.len(forward_all_destination) == 0) then
forward_all_destination = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-enter_destination_telephone_number.wav", "", "\\d+");
end
if not empty(caller_id_name) then
forward_caller_id = forward_caller_id ..
",outbound_caller_id_name=" .. caller_id_name ..
",origination_caller_id_name=" .. caller_id_name
end
end
end
--set the dial string
if (session:ready() and enabled == "true") then
--used for number_alias to get the correct user
sql = "select * from v_extensions ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and number_alias = '"..forward_all_destination.."' ";
status = dbh:query(sql, function(row)
destination_user = row.extension;
end);
--set the dial string
if enabled == "true" then
local destination_extension, destination_number_alias
--set the dial_string
dial_string = "{presence_id="..forward_all_destination.."@"..domain_name;
dial_string = dial_string .. ",instant_ringback=true";
dial_string = dial_string .. ",domain_uuid="..domain_uuid;
dial_string = dial_string .. ",sip_invite_domain="..domain_name;
dial_string = dial_string .. ",domain_name="..domain_name;
dial_string = dial_string .. ",domain="..domain_name;
dial_string = dial_string .. ",toll_allow='"..toll_allow.."'";
if (accountcode ~= nil) then
dial_string = dial_string .. ",accountcode="..accountcode;
end
dial_string = dial_string .. "}";
--used for number_alias to get the correct user
local sql = "select extension, number_alias from v_extensions ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and number_alias = '"..forward_all_destination.."' ";
dbh:query(sql, function(row)
destination_user = row.extension;
destination_extension = row.extension;
destination_number_alias = row.number_alias or '';
end);
if (destination_user ~= nil) then
cmd = "user_exists id ".. destination_user .." "..domain_name;
else
cmd = "user_exists id ".. forward_all_destination .." "..domain_name;
end
user_exists = trim(api:executeString(cmd));
if (user_exists == "true") then
if (destination_user ~= nil) then
dial_string = dial_string .. "user/"..destination_user.."@"..domain_name;
else
dial_string = dial_string .. "user/"..forward_all_destination.."@"..domain_name;
end
else
dial_string = dial_string .. "loopback/"..forward_all_destination;
end
end
--set call forward
if (session:ready() and enabled == "true") then
--set forward_all_enabled
forward_all_enabled = "true";
--say the destination number
session:say(forward_all_destination, default_language, "number", "iterated");
--notify the caller
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_set.wav");
end
--unset call forward
if (session:ready() and enabled == "false") then
--set forward_all_enabled
forward_all_enabled = "false";
--notify the caller
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_cancelled.wav");
end
--disable the follow me
if (session:ready() and enabled == "true" and follow_me_uuid ~= nil) then
if (string.len(follow_me_uuid) > 0) then
sql = "update v_follow_me set ";
sql = sql .. "follow_me_enabled = 'false' ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' ";
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[call_forward] "..sql.."\n");
end
dbh:query(sql);
end
end
--check the destination
if (forward_all_destination == nil) then
enabled = false;
forward_all_enabled = "false";
local presence_id
if destination_extension then
if (#destination_number_alias > 0) and (opt(settings(domain_uuid), 'provision', 'number_as_presence_id', 'boolean') == 'true') then
presence_id = destination_number_alias
else
if (string.len(forward_all_destination) == 0) then
enabled = false;
forward_all_enabled = "false";
end
presence_id = destination_extension
end
--update the extension
if (session:ready()) then
sql = "update v_extensions set ";
if (enabled == "true") then
sql = sql .. "forward_all_destination = '"..forward_all_destination.."', ";
sql = sql .. "dial_string = '"..dial_string:gsub("'", "''").."', ";
sql = sql .. "do_not_disturb = 'false', ";
else
sql = sql .. "forward_all_destination = null, ";
sql = sql .. "dial_string = null, ";
end
sql = sql .. "forward_all_enabled = '"..forward_all_enabled.."' ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and extension_uuid = '"..extension_uuid.."' ";
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[call_forward] "..sql.."\n");
end
dbh:query(sql);
--clear the cache
if (extension ~= nil) then
api:execute("memcache", "delete directory:"..extension.."@"..domain_name);
if #number_alias > 0 then
api:execute("memcache", "delete directory:"..number_alias.."@"..domain_name);
end
end
elseif extension then
-- setting here presence_id equal extension not dialed number allows work BLF and intercept.
-- $presence_id = extension_presence_id($this->extension, $this->number_alias);
if (#number_alias > 0) and (opt(settings(domain_uuid), 'provision', 'number_as_presence_id', 'boolean') == 'true') then
presence_id = number_alias
else
presence_id = extension
end
else
presence_id = forward_all_destination
end
-- hangup
if (session:ready()) then
--wait for the file to be written before proceeding
session:sleep(100);
--set the dial_string
dial_string = "{presence_id="..presence_id.."@"..domain_name;
dial_string = dial_string .. ",instant_ringback=true";
dial_string = dial_string .. ",domain_uuid="..domain_uuid;
dial_string = dial_string .. ",sip_invite_domain="..domain_name;
dial_string = dial_string .. ",domain_name="..domain_name;
dial_string = dial_string .. ",domain="..domain_name;
dial_string = dial_string .. ",toll_allow='"..toll_allow.."'";
if (accountcode ~= nil) then
dial_string = dial_string .. ",accountcode="..accountcode;
end
dial_string = dial_string .. forward_caller_id
dial_string = dial_string .. "}";
--end the call
session:hangup();
if (destination_user ~= nil) then
cmd = "user_exists id ".. destination_user .." "..domain_name;
else
cmd = "user_exists id ".. forward_all_destination .." "..domain_name;
end
user_exists = trim(api:executeString(cmd));
if (user_exists == "true") then
if (destination_user ~= nil) then
dial_string = dial_string .. "user/"..destination_user.."@"..domain_name;
else
dial_string = dial_string .. "user/"..forward_all_destination.."@"..domain_name;
end
end
else
dial_string = dial_string .. "loopback/"..forward_all_destination;
end
end
--unset call forward
if session:ready() and enabled == "false" then
--set forward_all_enabled
forward_all_enabled = "false";
channel_display(session:get_uuid(), "Cancelled")
--notify the caller
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_cancelled.wav");
end
--disable the follow me
if enabled == "true" and not empty(follow_me_uuid) then
local sql = "update v_follow_me set ";
sql = sql .. "follow_me_enabled = 'false' ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' ";
if (debug["sql"]) then
log.notice(sql);
end
dbh:query(sql);
end
--check the destination
if empty(forward_all_destination) then
enabled = "false";
forward_all_enabled = "false";
end
--update the extension
do
local sql = "update v_extensions set ";
if (enabled == "true") then
sql = sql .. "forward_all_destination = '"..forward_all_destination.."', ";
sql = sql .. "dial_string = '"..dial_string:gsub("'", "''").."', ";
sql = sql .. "do_not_disturb = 'false', ";
else
sql = sql .. "forward_all_destination = null, ";
sql = sql .. "dial_string = null, ";
end
sql = sql .. "forward_all_enabled = '"..forward_all_enabled.."' ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and extension_uuid = '"..extension_uuid.."' ";
if (debug["sql"]) then
log.notice(sql);
end
dbh:query(sql);
end
--disconnect from database
dbh:release()
--clear the cache
if extension and #extension > 0 and cache.support() then
cache.del("directory:"..extension.."@"..domain_name);
if #number_alias > 0 then
cache.del("directory:"..number_alias.."@"..domain_name);
end
end
--hangup
if (session:ready()) then
--wait for the file to be written before proceeding
session:sleep(100);
--end the call
session:hangup();
end

View File

@ -22,158 +22,140 @@
-- Contributor(s):
-- Mark J Crane <markjcrane@fusionpbx.com>
--set default variables
min_digits = "1";
max_digits = "11";
max_tries = "3";
digit_timeout = "3000";
--debug
debug["sql"] = true;
--define the trim function
require "resources.functions.trim";
--define the explode function
require "resources.functions.explode";
--include config.lua
require "resources.functions.config";
--create the api object
api = freeswitch.API();
--include config.lua
require "resources.functions.config";
require "resources.functions.channel_utils";
local log = require "resources.functions.log".follow_me
local cache = require "resources.functions.cache"
local Database = require "resources.functions.database"
--check if the session is ready
if ( session:ready() ) then
--answer the call
session:answer();
--get the variables
pin_number = session:getVariable("pin_number");
sounds_dir = session:getVariable("sounds_dir");
domain_uuid = session:getVariable("domain_uuid");
domain_name = session:getVariable("domain_name");
extension_uuid = session:getVariable("extension_uuid");
context = session:getVariable("context");
if (not context ) then context = 'default'; end
--set the sounds path for the language, dialect and voice
default_language = session:getVariable("default_language");
default_dialect = session:getVariable("default_dialect");
default_voice = session:getVariable("default_voice");
if (not default_language) then default_language = 'en'; end
if (not default_dialect) then default_dialect = 'us'; end
if (not default_voice) then default_voice = 'callie'; end
--a moment to sleep
session:sleep(1000);
--connect to the database
require "resources.functions.database_handle";
dbh = database_handle('system');
--determine whether to update the dial string
sql = "select * from v_extensions ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and extension_uuid = '"..extension_uuid.."' ";
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[follow_me] "..sql.."\n");
end
status = dbh:query(sql, function(row)
extension = row.extension;
number_alias = row.number_alias or '';
accountcode = row.accountcode;
follow_me_uuid = row.follow_me_uuid;
--freeswitch.consoleLog("NOTICE", "[call forward] extension "..row.extension.."\n");
--freeswitch.consoleLog("NOTICE", "[call forward] accountcode "..row.accountcode.."\n");
end);
if not session:ready() then return end
--determine whether to update the dial string
enabled = "false";
sql = "select * from v_follow_me ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' ";
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[follow_me] "..sql.."\n");
end
status = dbh:query(sql, function(row)
enabled = row.follow_me_enabled;
call_prompt = row.call_prompt;
cid_name_prefix = row.cid_name_prefix;
cid_number_prefix = row.cid_number_prefix;
dial_string = row.dial_string;
end);
--set follow me
if (enabled == "false") then
--answer and play a tone
session:answer();
api = freeswitch.API();
reply = api:executeString("uuid_display "..session:get_uuid().." Activated ");
--answer the call
session:answer();
session:execute("sleep", "2000");
session:execute("playback", "tone_stream://%(200,0,500,600,700)");
--notify the caller
--session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_set.wav");
end
--unset follow me
if (enabled == "true") then
--answer and play a tone
session:answer();
api = freeswitch.API();
reply = api:executeString("uuid_display "..session:get_uuid().." Cancelled ");
--get the variables
local domain_uuid = session:getVariable("domain_uuid");
local domain_name = session:getVariable("domain_name");
local extension_uuid = session:getVariable("extension_uuid");
session:execute("sleep", "2000");
session:execute("playback", "tone_stream://%(500,0,300,200,100,50,25)");
--notify the caller
--session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_cancelled.wav");
end
--set the sounds path for the language, dialect and voice
local sounds_dir = session:getVariable("sounds_dir");
local default_language = session:getVariable("default_language") or 'en';
local default_dialect = session:getVariable("default_dialect") or 'us';
local default_voice = session:getVariable("default_voice") or 'callie';
--enable or disable follow me
if (follow_me_uuid ~= nil) then
sql = "update v_follow_me set ";
if (enabled == "true") then
sql = sql .. "follow_me_enabled = 'false' ";
else
sql = sql .. "follow_me_enabled = 'true' ";
end
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' ";
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[follow_me] "..sql.."\n");
end
dbh:query(sql);
end
--update the extension
sql = "update v_extensions set ";
if (enabled == "true") then
sql = sql .. "dial_string = null, ";
else
sql = sql .. "dial_string = '"..dial_string.."', ";
end
sql = sql .. "do_not_disturb = 'false', ";
sql = sql .. "forward_all_enabled= 'false' ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and extension_uuid = '"..extension_uuid.."' ";
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[follow_me] "..sql.."\n");
end
dbh:query(sql);
--clear the cache
if (extension ~= nil) then
api:execute("memcache", "delete directory:"..extension.."@"..domain_name);
if #number_alias > 0 then
api:execute("memcache", "delete directory:"..number_alias.."@"..domain_name);
end
end
--wait for the file to be written before proceeding
session:sleep(1000);
--end the call
session:hangup();
--a moment to sleep
session:sleep(1000);
--check if the session is ready
if not session:ready() then return end
--connect to the database
local dbh = Database.new('system');
--determine whether to update the dial string
local sql = "select extension, number_alias, accountcode, follow_me_uuid ";
sql = sql .. "from v_extensions ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and extension_uuid = '"..extension_uuid.."' ";
if (debug["sql"]) then
log.notice(sql);
end
local row = dbh:first_row(sql)
if not row then return end
local extension = row.extension;
local number_alias = row.number_alias or '';
local accountcode = row.accountcode;
local follow_me_uuid = row.follow_me_uuid;
--determine whether to update the dial string
sql = "select follow_me_enabled, call_prompt, cid_name_prefix, cid_number_prefix, dial_string "
sql = sql .. "from v_follow_me ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' ";
if (debug["sql"]) then
log.notice(sql);
end
row = dbh:first_row(sql)
if not row then return end
local enabled = row.follow_me_enabled;
local call_prompt = row.call_prompt;
local cid_name_prefix = row.cid_name_prefix;
local cid_number_prefix = row.cid_number_prefix;
local dial_string = row.dial_string;
--set follow me
if (enabled == "false") then
--play a tone
channel_display(session:get_uuid(), "Activated")
session:execute("sleep", "2000");
session:execute("playback", "tone_stream://%(200,0,500,600,700)");
--notify the caller
--session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_set.wav");
end
--unset follow me
if (enabled == "true") then
--play a tone
channel_display(session:get_uuid(), "Cancelled")
session:execute("sleep", "2000");
session:execute("playback", "tone_stream://%(500,0,300,200,100,50,25)");
--notify the caller
--session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-call_forwarding_has_been_cancelled.wav");
end
--enable or disable follow me
sql = "update v_follow_me set ";
if (enabled == "true") then
sql = sql .. "follow_me_enabled = 'false' ";
else
sql = sql .. "follow_me_enabled = 'true' ";
end
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and follow_me_uuid = '"..follow_me_uuid.."' ";
if (debug["sql"]) then
log.notice(sql);
end
dbh:query(sql);
--update the extension
sql = "update v_extensions set ";
if (enabled == "true") then
sql = sql .. "dial_string = null, ";
else
sql = sql .. "dial_string = '"..dial_string:gsub("'", "''").."', ";
end
sql = sql .. "do_not_disturb = 'false', ";
sql = sql .. "forward_all_enabled= 'false' ";
sql = sql .. "where domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "and extension_uuid = '"..extension_uuid.."' ";
if (debug["sql"]) then
log.notice(sql);
end
dbh:query(sql);
--clear the cache
if (extension ~= nil) and cache.support() then
cache.del("directory:"..extension.."@"..domain_name);
if #number_alias > 0 then
cache.del("directory:"..number_alias.."@"..domain_name);
end
end
--wait for the file to be written before proceeding
session:sleep(1000);
--end the call
session:hangup();

View File

@ -24,9 +24,10 @@
-- Errol W Samuels <ewsamuels@gmail.com>
--user defined variables
max_tries = "3";
digit_timeout = "5000";
extension = argv[1];
local extension = argv[1];
-- we can use any number because other box should check sip_h_X_*** headers first
local pickup_number = '*8' -- extension and '**' or '*8'
--set the debug options
debug["sql"] = false;
@ -34,139 +35,298 @@
--include config.lua
require "resources.functions.config";
--connect to the database
if (file_exists(database_dir.."/core.db")) then
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
else
require "resources.functions.database_handle";
dbh = database_handle('switch');
end
--add the function
require "resources.functions.explode";
require "resources.functions.trim";
require "resources.functions.channel_utils";
--prepare the api object
api = freeswitch.API();
--add the function
require "resources.functions.trim";
require "resources.functions.channel_utils";
--Get intercept logger
local log = require "resources.functions.log".intercept
--exits the script if we didn't connect properly
assert(dbh:connected());
if ( session:ready() ) then
--answer the session
session:answer();
--get session variables
pin_number = session:getVariable("pin_number");
sounds_dir = session:getVariable("sounds_dir");
domain_uuid = session:getVariable("domain_uuid");
domain_name = session:getVariable("domain_name");
context = session:getVariable("context");
sofia_profile_name = session:getVariable("sofia_profile_name");
--set the sounds path for the language, dialect and voice
default_language = session:getVariable("default_language");
default_dialect = session:getVariable("default_dialect");
default_voice = session:getVariable("default_voice");
if (not default_language) then default_language = 'en'; end
if (not default_dialect) then default_dialect = 'us'; end
if (not default_voice) then default_voice = 'callie'; end
--set defaults
if (digit_min_length) then
--do nothing
else
digit_min_length = "2";
end
if (digit_max_length) then
--do nothing
else
digit_max_length = "11";
end
--if the pin number is provided then require it
if (pin_number) then
--sleep
session:sleep(500);
--get the user pin number
min_digits = 2;
max_digits = 20;
digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
--validate the user pin number
pin_number_table = explode(",",pin_number);
for index,pin_number in pairs(pin_number_table) do
if (digits == pin_number) then
--set the variable to true
auth = true;
--set the authorized pin number that was used
session:setVariable("pin_number", pin_number);
--end the loop
break;
end
end
--if not authorized play a message and then hangup
if (not auth) then
session:streamFile("phrase:voicemail_fail_auth:#");
session:hangup("NORMAL_CLEARING");
return;
end
end
--predefined variables
uuid = '';
call_hostname = '';
callee_num = '';
--check the database to get the uuid of a ringing call
sql = "select uuid, call_uuid, hostname, callee_num, ip_addr from channels ";
sql = sql .. "where callstate in ('RINGING', 'EARLY') ";
--sql = sql .. "AND direction = 'outbound' ";
if (extension) then
sql = sql .. "and presence_id = '"..extension.."@"..domain_name.."' ";
else
if (domain_count > 1) then
sql = sql .. "and context = '"..context.."' ";
end
end
if (debug["sql"]) then
freeswitch.consoleLog("NOTICE", "sql "..sql.."\n");
end
dbh:query(sql, function(result)
--for key, val in pairs(result) do
-- freeswitch.consoleLog("NOTICE", "result "..key.." "..val.."\n");
--end
if result.uuid == result.call_uuid then
uuid = channel_variable(result.uuid, 'ent_originate_aleg_uuid') or
channel_variable(result.uuid, 'cc_member_session_uuid') or
channel_variable(result.uuid, 'fifo_bridge_uuid') or
result.uuid
else
uuid = result.call_uuid;
end
call_hostname = result.hostname;
callee_num = result.callee_num;
end);
end
--include database class
local Database = require "resources.functions.database"
--get the hostname
hostname = trim(api:execute("hostname", ""));
freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n");
local hostname = trim(api:execute("switchname", ""));
-- redirect call to another box
local function make_proxy_call(destination, call_hostname)
destination = destination .. "@" .. domain_name
local profile, proxy = "internal", call_hostname;
local sip_auth_username = session:getVariable("sip_auth_username");
local sip_auth_password = api:execute("user_data", sip_auth_username .. "@" .. domain_name .." param password");
local auth = "sip_auth_username="..sip_auth_username..",sip_auth_password='"..sip_auth_password.."'"
dial_string = "{sip_invite_domain=" .. domain_name .. "," .. auth .. "}sofia/" .. profile .. "/" .. destination .. ";fs_path=sip:" .. proxy;
log.notice("Send call to other host....");
session:execute("bridge", dial_string);
end
-- check pin number if defined
local function pin(pin_number)
if not pin_number then
return true
end
--sleep
session:sleep(500);
--get the user pin number
local min_digits = 2;
local max_digits = 20;
local max_tries = "3";
local digit_timeout = "5000";
local digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
--validate the user pin number
local pin_number_table = explode(",",pin_number);
for index,pin_number in pairs(pin_number_table) do
if (digits == pin_number) then
--set the authorized pin number that was used
session:setVariable("pin_number", pin_number);
--done
return true;
end
end
--if not authorized play a message and then hangup
session:streamFile("phrase:voicemail_fail_auth:#");
session:hangup("NORMAL_CLEARING");
return;
end
-- do intercept if we get redirected request from another box
local function proxy_intercept()
-- Proceed calls from other boxes
-- Check if this call from other box with setted intercept_uuid
local intercept_uuid = session:getVariable("sip_h_X-intercept_uuid")
if intercept_uuid and #intercept_uuid > 0 then
log.notice("Get intercept_uuid from sip header. Do intercept....")
session:execute("intercept", intercept_uuid)
return true
end
-- Check if this call from other box and we need parent uuid for channel
local child_intercept_uuid = session:getVariable("sip_h_X-child_intercept_uuid")
if (not child_intercept_uuid) or (#child_intercept_uuid == 0) then
return
end
-- search parent uuid
log.notice("Get child_intercept_uuid from sip header.")
local parent_uuid =
channel_variable(child_intercept_uuid, 'ent_originate_aleg_uuid') or
channel_variable(child_intercept_uuid, 'cc_member_session_uuid') or
channel_variable(child_intercept_uuid, 'fifo_bridge_uuid') or
child_intercept_uuid
if parent_uuid == child_intercept_uuid then
log.notice("Can not found parent call. Try intercept child.")
session:execute("intercept", child_intercept_uuid)
return true
end
-- search parent hostname
call_hostname = hostname
--[[ parent and child have to be on same box so we do not search it
log.notice("Found parent channel try detect parent hostname")
local dbh = Database.new('switch')
local sql = "SELECT hostname FROM channels WHERE uuid='" .. parent_uuid .. "'"
local call_hostname = dbh:first_value(sql)
dbh:release()
if not call_hostname then
log.notice("Can not find host name. Channels is dead?")
return true
end
--]]
if hostname == call_hostname then
log.notice("Found parent call on local machine. Do intercept....")
session:execute("intercept", parent_uuid);
return true
end
log.noticef("Found parent call on remote machine `%s`.", call_hostname)
session:execute("export", "sip_h_X-intercept_uuid="..parent_uuid);
make_proxy_call(pickup_number, call_hostname)
return true
end
-- return array of extensions for group
local function select_group_extensions()
-- connect to Fusion database
local dbh = Database.new('system');
--get the call groups the extension is a member of
local sql = "SELECT call_group FROM v_extensions ";
sql = sql .. "WHERE domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "AND (extension = '"..caller_id_number.."'";
sql = sql .. "OR number_alias = '"..caller_id_number.."')";
sql = sql .. "limit 1";
local call_group = dbh:first_value(sql) or ''
log.noticef("call_group: `%s`", call_group);
call_groups = explode(",", call_group);
--get the extensions in the call groups
sql = "SELECT extension, number_alias FROM v_extensions ";
sql = sql .. "WHERE domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "AND (";
for key,call_group in ipairs(call_groups) do
if (key > 1) then
sql = sql .. "OR ";
end
if (#call_group > 0) then
sql = sql .. "call_group like '%"..call_group.."%' ";
else
sql = sql .. "call_group = '' ";
end
end
sql = sql .. ") ";
if (debug["sql"]) then
log.notice("sql "..sql);
end
local extensions = {}
dbh:query(sql, function(row)
local member = row.extension
if row.number_alias and #row.number_alias > 0 then
member = row.number_alias
end
extensions[#extensions+1] = member
log.noticef("member `%s`", member)
end);
-- release Fusion database
dbh:release()
-- return result
return extensions
end
--check if the session is ready
if ( session:ready() ) then
--answer the session
session:answer();
--get session variables
domain_uuid = session:getVariable("domain_uuid");
domain_name = session:getVariable("domain_name");
pin_number = session:getVariable("pin_number");
context = session:getVariable("context");
caller_id_number = session:getVariable("caller_id_number");
end
--check if the session is ready
if ( session:ready() ) then
if proxy_intercept() then
return
end
end
--check if the session is ready
if ( session:ready() ) then
--if the pin number is provided then require it
if not pin(pin_number) then
return
end
end
if ( session:ready() ) then
-- select intercept mode
if not extension then
log.notice("GROUP INTERCEPT")
extensions = select_group_extensions()
else
log.noticef("INTERCEPT %s", extension)
extensions = {extension}
end
--connect to FS database
local dbh = Database.new('switch')
--check the database to get the uuid of a ringing call
call_hostname = "";
sql = "SELECT uuid, call_uuid, hostname FROM channels ";
sql = sql .. "WHERE callstate in ('RINGING', 'EARLY') ";
-- next check should prevent pickup call from extension
-- e.g. if extension 100 dial some cell phone and some one else dial *8
-- he can pickup this call.
if not extension then
sql = sql .. "AND direction = 'outbound' ";
end
sql = sql .. "AND (1<>1 ";
for key,extension in pairs(extensions) do
sql = sql .. "OR presence_id = '"..extension.."@"..domain_name.."' ";
end
sql = sql .. ") ";
sql = sql .. "and call_uuid is not null ";
sql = sql .. "limit 1 ";
if (debug["sql"]) then
log.notice("sql "..sql);
end
local is_child
dbh:query(sql, function(row)
-- for key, val in pairs(row) do
-- log.notice("row "..key.." "..val);
-- end
-- log.notice("-----------------------");
is_child = (row.uuid == row.call_uuid)
uuid = row.call_uuid;
call_hostname = row.hostname;
end);
if is_child then
-- we need intercept `parent` call e.g. call in FIFO/CallCenter Queue
if (call_hostname == hostname) then
log.notice("Found child call on local machine. Try find parent channel.")
local parent_uuid =
channel_variable(uuid, 'ent_originate_aleg_uuid') or
channel_variable(uuid, 'cc_member_session_uuid') or
channel_variable(uuid, 'fifo_bridge_uuid') or
uuid
--[[ parent and child have to be on same box so we do not search it
if parent_uuid ~= uuid then
local sql = "SELECT hostname FROM channels WHERE uuid='" .. uuid .. "'"
call_hostname = dbh:first_value(sql)
end
--]]
if call_hostname then
uuid = parent_uuid
if call_hostname ~= hostname then
log.noticef("Found parent call on remote machine `%s`.", call_hostname)
else
log.notice("Found parent call on local machine.")
end
end
else
log.noticef("Found child call on remote machine `%s`.", call_hostname)
-- we can not find parent on this box because channel on other box so we have to
-- forward call to this box
session:execute("export", "sip_h_X-child_intercept_uuid="..uuid);
return make_proxy_call(pickup_number, call_hostname)
end
end
--release FS database
dbh:release()
end
log.noticef( "Hostname: %s Call Hostname: %s", hostname, call_hostname);
--intercept a call that is ringing
if (uuid) then
if (uuid ~= nil) then
if (session:getVariable("billmsec") == nil) then
if (hostname == call_hostname) then
session:execute("intercept", uuid);
else
session:execute("export", "sip_h_X-intercept_uuid="..uuid);
session:execute("export", "sip_h_X-domain_uuid="..domain_uuid);
session:execute("export", "sip_h_X-domain_name="..domain_name);
session:execute("export", "sip_h_X-callee_num="..callee_num);
port = freeswitch.getGlobalVariable(sofia_profile_name.."_sip_port");
session:execute("bridge", "sofia/"..sofia_profile_name.."/**@"..call_hostname..":"..port);
freeswitch.consoleLog("NOTICE", "Send call to other host.... \n");
make_proxy_call(pickup_number, call_hostname)
end
end
end

View File

@ -14,223 +14,5 @@
--
-- The Original Code is FusionPBX
--
-- The Initial Developer of the Original Code is
-- Mark J Crane <markjcrane@fusionpbx.com>
-- Copyright (C) 2010 - 2014
-- the Initial Developer. All Rights Reserved.
--
-- Contributor(s):
-- Mark J Crane <markjcrane@fusionpbx.com>
--user defined variables
max_tries = "3";
digit_timeout = "5000";
extension = argv[1];
--set the debug options
debug["sql"] = false;
--include config.lua
require "resources.functions.config";
--add the function
require "resources.functions.explode";
require "resources.functions.trim";
require "resources.functions.channel_utils";
--prepare the api object
api = freeswitch.API();
--connect to the database
require "resources.functions.database_handle";
dbh = database_handle('system');
--get the hostname
hostname = trim(api:execute("switchname", ""));
--check if the session is ready
if ( session:ready() ) then
--answer the session
session:answer();
--get session variables
domain_uuid = session:getVariable("domain_uuid");
domain_name = session:getVariable("domain_name");
pin_number = session:getVariable("pin_number");
sounds_dir = session:getVariable("sounds_dir");
context = session:getVariable("context");
caller_id_number = session:getVariable("caller_id_number");
sofia_profile_name = session:getVariable("sofia_profile_name");
--set the sounds path for the language, dialect and voice
default_language = session:getVariable("default_language");
default_dialect = session:getVariable("default_dialect");
default_voice = session:getVariable("default_voice");
if (not default_language) then default_language = 'en'; end
if (not default_dialect) then default_dialect = 'us'; end
if (not default_voice) then default_voice = 'callie'; end
--set defaults
if (digit_min_length) then
--do nothing
else
digit_min_length = "2";
end
if (digit_max_length) then
--do nothing
else
digit_max_length = "11";
end
--if the pin number is provided then require it
if (pin_number) then
--sleep
session:sleep(500);
--get the user pin number
min_digits = 2;
max_digits = 20;
digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
--validate the user pin number
pin_number_table = explode(",",pin_number);
for index,pin_number in pairs(pin_number_table) do
if (digits == pin_number) then
--set the variable to true
auth = true;
--set the authorized pin number that was used
session:setVariable("pin_number", pin_number);
--end the loop
break;
end
end
--if not authorized play a message and then hangup
if (not auth) then
session:streamFile("phrase:voicemail_fail_auth:#");
session:hangup("NORMAL_CLEARING");
return;
end
end
--get the call groups the extension is a member of
sql = "SELECT call_group FROM v_extensions ";
sql = sql .. "WHERE domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "AND (extension = '"..caller_id_number.."'";
sql = sql .. "OR number_alias = '"..caller_id_number.."')";
status = dbh:query(sql, function(row)
call_group = row.call_group;
freeswitch.consoleLog("NOTICE", "[intercept_group] call_group: "..call_group.."\n");
end);
call_groups = explode(",", call_group);
--get the extensions in the call groups
sql = "SELECT extension, number_alias FROM v_extensions ";
sql = sql .. "WHERE domain_uuid = '"..domain_uuid.."' ";
sql = sql .. "AND (";
x = 0;
for key,call_group in pairs(call_groups) do
if (x == 0) then
if (string.len(call_group) > 0) then
sql = sql .. "call_group like '%"..call_group.."%' ";
else
sql = sql .. "call_group = '' ";
end
else
if (string.len(call_group) > 0) then
sql = sql .. "OR call_group like '%"..call_group.."%' ";
end
end
x = x + 1;
end
x = 0;
sql = sql .. ") ";
if (debug["sql"]) then
freeswitch.consoleLog("NOTICE", "[intercept_group] sql "..sql.."\n");
end
extensions = {}
status = dbh:query(sql, function(row)
local member = row.extension
if row.number_alias and #row.number_alias > 0 then
member = row.number_alias
end
extensions[x] = member
freeswitch.consoleLog("NOTICE", "[intercept_group] member "..extensions[x].."\n");
x = x + 1;
end);
--connect to the database
if (file_exists(database_dir.."/core.db")) then
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
dbh = freeswitch.Dbh("sqlite://"..database_dir.."/core.db");
else
require "resources.functions.database_handle";
dbh = database_handle('switch');
end
--exits the script if we didn't connect properly
assert(dbh:connected());
--check the database to get the uuid of a ringing call
call_hostname = "";
sql = "SELECT uuid, call_uuid, hostname, ip_addr FROM channels ";
sql = sql .. "WHERE callstate in ('RINGING', 'EARLY') ";
--sql = sql .. "AND direction = 'outbound' ";
sql = sql .. "AND (";
x = 0;
for key,extension in pairs(extensions) do
if (x == 0) then
sql = sql .. " presence_id = '"..extension.."@"..domain_name.."' ";
else
sql = sql .. "OR presence_id = '"..extension.."@"..domain_name.."' ";
end
x = x + 1;
end
sql = sql .. ") ";
sql = sql .. "and call_uuid is not null ";
sql = sql .. "and direction = 'outbound' ";
--if (domain_count > 1) then
-- sql = sql .. "and context = '"..context.."' ";
--end
sql = sql .. "limit 1 ";
if (debug["sql"]) then
freeswitch.consoleLog("NOTICE", "[intercept_group] sql "..sql.."\n");
end
dbh:query(sql, function(row)
--for key, val in pairs(row) do
-- freeswitch.consoleLog("NOTICE", "row "..key.." "..val.."\n");
--end
if row.uuid == row.call_uuid then
uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or
channel_variable(row.uuid, 'cc_member_session_uuid') or
channel_variable(row.uuid, 'fifo_bridge_uuid') or
row.uuid
else
uuid = row.call_uuid;
end
call_hostname = row.hostname;
ip_addr = row.ip_addr;
end);
end
freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n");
--intercept a call that is ringing
if (uuid ~= nil) then
if (session:getVariable("billmsec") == nil) then
if (hostname == call_hostname) then
session:execute("intercept", uuid);
else
session:execute("export", "sip_h_X-intercept_uuid="..uuid);
session:execute("export", "sip_h_X-domain_uuid="..domain_uuid);
session:execute("export", "sip_h_X-domain_name="..domain_name);
port = freeswitch.getGlobalVariable(sofia_profile_name.."_sip_port");
session:execute("bridge", "sofia/"..sofia_profile_name.."/*8@"..call_hostname..":"..port);
freeswitch.consoleLog("NOTICE", "Send call to other host.... \n");
end
end
end
--notes
--originate a call
--cmd = "originate user/1007@voip.example.com &intercept("..uuid..")";
--api = freeswitch.API();
--result = api:executeString(cmd);
require "intercept"

View File

@ -407,8 +407,12 @@
if (row.ivr_menu_option_action == "menu-exec-app") then
--get the action and data
pos = string.find(row.ivr_menu_option_param, " ", 0, true);
action = string.sub(row.ivr_menu_option_param, 0, pos-1);
data = string.sub(row.ivr_menu_option_param, pos+1);
if pos then
action = string.sub(row.ivr_menu_option_param, 0, pos-1);
data = string.sub(row.ivr_menu_option_param, pos+1);
else
action, data = row.ivr_menu_option_param, ""
end
--check if the option uses a regex
regex = string.find(row.ivr_menu_option_digits, "(", 0, true);
@ -431,7 +435,11 @@
end
if (action == "lua") then
pos = string.find(data, " ", 0, true);
script = string.sub(data, 0, pos-1);
if pos then
script = string.sub(data, 0, pos-1);
else
script = data
end
end
end --if regex match

View File

@ -1,4 +1,4 @@
require 'resources.config'
require 'resources.functions.config'
require 'resources.functions.trim'
local Database = require 'resources.functions.database'
@ -23,6 +23,14 @@ function channel_evalute(uuid, cmd)
return result
end
function channel_display(uuid, text)
local cmd = ("uuid_display %s '%s'"):format(uuid, text)
local result = trim(api:executeString(cmd))
if result:sub(1, 4) == '-ERR' then return nil, result end
if result == '_undef_' then return false end
return result
end
local _switchname
local function switchname()
if _switchname then return _switchname end

View File

@ -1,4 +1,4 @@
require 'resources.config'
require 'resources.functions.config'
require 'resources.functions.file_exists'
require 'resources.functions.database_handle'
@ -27,7 +27,11 @@ function Database.new(name)
end
function Database:query(sql, fn)
return self._dbh:query(sql, fn)
if (fn == nil) then
return self._dbh:query(sql)
else
return self._dbh:query(sql, fn)
end
end
function Database:first_row(sql)
@ -81,9 +85,9 @@ function Database.__self_test__(name)
local db = Database.new(name or 'system')
assert(db:connected())
assert("1" == db:first_value("select 1 as v"))
assert("1" == db:first_value("select 1 as v union all select 2 as v"))
local t = assert(db:first_row("select 1 as v"))
local t = assert(db:first_row("select 1 as v union all select 2 as v"))
assert(t.v == "1")
t = assert(db:fetch_all("select 1 as v union all select 2 as v"))
@ -99,10 +103,13 @@ function Database.__self_test__(name)
db:release()
assert(not db:connected())
print(" * databse - OK!")
end
end
-- Database.__self_test__()
-- if debug.self_test then
-- Database.__self_test__()
-- end
return Database

View File

@ -13,7 +13,7 @@
These entries will be pre-pended to the LUA_PATH environment variable
-->
<!-- <param name="script-directory" value="/usr/local/lua/?.lua"/> -->
<param name="script-directory" value="$${base_dir}/scripts/?.lua"/>
<param name="script-directory" value="$${script_dir}/?.lua"/>
<param name="xml-handler-script" value="app.lua xml_handler"/>
<param name="xml-handler-bindings" value="configuration,dialplan,directory"/>

View File

@ -5,49 +5,34 @@
<!-- To schedule a wakeup call enter a 4 digit number -->
<!-- For 6:30 am press 0630. Enter the digits now. -->
<action function="execute" data="sleep(750)"/>
<action function="play-file" data="custom/to.wav"/>
<action function="play-file" data="custom/schedule.wav"/>
<action function="play-file" data="custom/a.wav"/>
<action function="play-file" data="custom/wakeup.wav"/>
<action function="play-file" data="custom/call.wav"/>
<action function="play-file" data="custom/enter.wav"/>
<action function="play-file" data="custom/a.wav"/>
<action function="play-file" data="custom/4.wav"/>
<action function="play-file" data="custom/digit.wav"/>
<action function="play-file" data="custom/number.wav"/>
<action function="execute" data="sleep(750)"/>
<action function="play-file" data="custom/for.wav"/>
<action function="play-file" data="digits/6.wav"/>
<action function="play-file" data="digits/30.wav"/>
<action function="play-file" data="custom/a.wav"/>
<action function="play-file" data="custom/m.wav"/>
<action function="execute" data="sleep(750)"/>
<action function="play-file" data="custom/press.wav"/>
<action function="play-file" data="ivr/ivr-request_wakeup_call.wav"/>
<action function="play-file" data="voicemail/vm-press.wav"/>
<action function="play-file" data="digits/0.wav"/>
<action function="play-file" data="digits/6.wav"/>
<action function="play-file" data="digits/3.wav"/>
<action function="play-file" data="digits/0.wav"/>
<action function="execute" data="sleep(750)"/>
<action function="play-file" data="custom/enter.wav"/>
<action function="play-file" data="custom/the.wav"/>
<action function="play-file" data="custom/digits.wav"/>
<action function="play-file" data="custom/now.wav"/>
<action function="play-file" data="ivr-for.wav"/>
<action function="play-file" data="digits/6.wav"/>
<action function="play-file" data="digits/30.wav"/>
<action function="play-file" data="time/a-m.wav"/>
<action function="execute" data="sleep(750)"/>
<action function="play-file" data="ivr/ivr-please_enter_the.wav"/>
<action function="play-file" data="ivr/ivr-number.wav"/>
<action function="play-file" data="misc/followed.wav"/>
</match>
</input>
</macro>
<macro name="wakeup-get-extension">
<input pattern="(.*)">
<match>
<!-- Tnter the extension number now -->
<!-- Enter the extension number now -->
<action function="execute" data="sleep(750)"/>
<action function="play-file" data="custom/enter.wav"/>
<action function="play-file" data="custom/the.wav"/>
<action function="play-file" data="custom/extension.wav"/>
<action function="play-file" data="custom/number.wav"/>
<action function="play-file" data="custom/now.wav"/>
<action function="play-file" data="ivr/ivr-please_enter_the.wav"/>
<action function="play-file" data="ivr/ivr-number.wav"/>
<action function="play-file" data="misc/followed.wav"/>
<action function="execute" data="sleep(100)"/>
</match>
</input>
@ -57,13 +42,7 @@
<match>
<!-- Your wakeup call has been scheduled for 0715 -->
<action function="execute" data="sleep(750)"/>
<action function="play-file" data="custom/your.wav"/>
<action function="play-file" data="custom/wakeup.wav"/>
<action function="play-file" data="custom/call.wav"/>
<action function="play-file" data="custom/has.wav"/>
<action function="play-file" data="custom/been.wav"/>
<action function="play-file" data="custom/scheduled.wav"/>
<action function="play-file" data="custom/for.wav"/>
<action function="play-file" data="ivr/ivr-requested_wakeup_call_for.wav"/>
<action function="execute" data="sleep(100)"/>
</match>
</input>
@ -73,13 +52,10 @@
<match>
<!-- To accept press 1 to cancel press 2 -->
<action function="execute" data="sleep(750)"/>
<action function="play-file" data="custom/to.wav"/>
<action function="play-file" data="custom/accept.wav"/>
<action function="play-file" data="custom/press.wav"/>
<action function="play-file" data="ivr/ivr-to_accept_press"/>
<action function="play-file" data="digits/1.wav"/>
<action function="play-file" data="custom/to.wav"/>
<action function="play-file" data="custom/cancel.wav"/>
<action function="play-file" data="custom/press.wav"/>
<action function="play-file" data="ivr/ivr-to_reject.wav"/>
<action function="play-file" data="voicemail/vm-press.wav"/>
<action function="play-file" data="digits/2.wav"/>
<action function="execute" data="sleep(100)"/>
</match>
@ -90,12 +66,8 @@
<match>
<!-- To cancel the wakeup call press * -->
<action function="execute" data="sleep(750)"/>
<action function="play-file" data="custom/to.wav"/>
<action function="play-file" data="custom/cancel.wav"/>
<action function="play-file" data="custom/the.wav"/>
<action function="play-file" data="custom/wakeup.wav"/>
<action function="play-file" data="custom/call.wav"/>
<action function="play-file" data="custom/press.wav"/>
<action function="play-file" data="ivr/ivr-cancel_wakeup_call.wav"/>
<action function="play-file" data="voicemail/vm-press.wav"/>
<action function="play-file" data="digits/*.wav"/>
<action function="execute" data="sleep(100)"/>
</match>
@ -104,26 +76,45 @@
<macro name="wakeup-call">
<input pattern="(.*)">
<match>
<!-- This is your wakeup call to exit press 1 to snooze for 10 minutes press 2 -->
<!-- Say the current date and time -->
<action function="execute" data="sleep(1000)"/>
<action function="play-file" data="custom/this.wav"/>
<action function="play-file" data="custom/is.wav"/>
<action function="play-file" data="custom/your.wav"/>
<action function="play-file" data="custom/wakeup.wav"/>
<action function="play-file" data="custom/call.wav"/>
<action function="play-file" data="custom/to.wav"/>
<action function="play-file" data="custom/exit.wav"/>
<action function="play-file" data="custom/press.wav"/>
<action function="say" data="current_date_time"/>
<action function="play-file" data="voicemail/vm-to_exit.wav"/>
<action function="play-file" data="voicemail/vm-press.wav"/>
<action function="play-file" data="digits/*.wav"/>
<action function="execute" data="sleep(100)"/>
</match>
</input>
</macro>
<macro name="wakeup-call-exit" enabled="false">
<input pattern="(.*)">
<match>
<!-- This is your wakeup call to exit press 1 for 9 minutes press 2 -->
<action function="execute" data="sleep(1000)"/>
<action function="play-file" data="ivr/ivr-this_is_your_wakeup_call.wav"/>
<action function="play-file" data="voicemail/vm-to_exit.wav"/>
<action function="play-file" data="voicemail/vm-press.wav"/>
<action function="play-file" data="digits/*.wav"/>
<action function="execute" data="sleep(100)"/>
</match>
</input>
</macro>
<macro name="wakeup-call-snooze" enabled="false">
<input pattern="(.*)">
<match>
<!-- This is your wakeup call to exit press 1 for 10 minutes press 2 -->
<action function="execute" data="sleep(1000)"/>
<action function="play-file" data="ivr/ivr-this_is_your_wakeup_call.wav"/>
<action function="play-file" data="voicemail/vm-to_exit.wav"/>
<action function="play-file" data="voicemail/vm-press.wav"/>
<action function="play-file" data="digits/1.wav"/>
<action function="play-file" data="custom/to.wav"/>
<action function="play-file" data="custom/snooze.wav"/>
<action function="play-file" data="custom/for.wav"/>
<action function="play-file" data="ivr-for.wav"/>
<action function="play-file" data="digits/10.wav"/>
<action function="play-file" data="custom/minutes.wav"/>
<action function="play-file" data="custom/press.wav"/>
<action function="play-file" data="time/minutes.wav"/>
<action function="play-file" data="voicemail/vm-press.wav"/>
<action function="play-file" data="digits/2.wav"/>
<action function="execute" data="sleep(100)"/>
</match>
</input>
</macro>
</include>
</include>

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PHONE>
<REGISTRATION
{foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.user_id}"
{foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.display_name}"
reg.{$row.line_number}.address="{$row.user_id}"
reg.{$row.line_number}.label="{$row.user_id}"
reg.{$row.line_number}.label="{$row.display_name}"
reg.{$row.line_number}.type="private"
reg.{$row.line_number}.auth.userId="{$row.user_id}"
reg.{$row.line_number}.auth.password="{$row.password}"
reg.{$row.line_number}.lineKeys="{$line_key_value_{$row.line_number}}"
{if isset($row.outbound_proxy)}reg.{$row.line_number}.outboundProxy.address = "{$row.outbound_proxy}"{/if}
{if isset($row.sip_port)}reg.{$row.line_number}.outboundProxy.port="{$row.sip_port}"{else}reg.{$row.line_number}.server.1.port="5060"{/if}
@ -55,12 +57,26 @@
attendant.behaviors.display.remoteCallerID.normal="1"
attendant.behaviors.display.spontaneousCallAppearances.automata="1"
attendant.behaviors.display.spontaneousCallAppearances.normal="0"
{foreach $keys as $row}{if $row.device_key_category == "line"}{if $row.device_key_type != "line"}attendant.resourceList.{$row.device_key_id}.address="{$row.device_key_value}"
attendant.resourceList.{$row.device_key_id}.callAddress=""
attendant.resourceList.{$row.device_key_id}.label="{$row.device_key_label}"
attendant.resourceList.{$row.device_key_id}.proceedingIsRecipient="0"
attendant.resourceList.{$row.device_key_id}.type="{$row.device_key_type}"
{/if}{/if}
feature.enhancedFeatureKeys.enabled="1"
{foreach $keys as $row}
{if $row.device_key_category == "line"}
{if $row.device_key_type == "automata" || $row.device_key_type == "normal"}
attendant.resourceList.{$row.device_key_id}.address="{$row.device_key_value}"
attendant.resourceList.{$row.device_key_id}.callAddress=""
attendant.resourceList.{$row.device_key_id}.label="{$row.device_key_label}"
attendant.resourceList.{$row.device_key_id}.proceedingIsRecipient="0"
attendant.resourceList.{$row.device_key_id}.type="{$row.device_key_type}"
{else}
{if $row.device_key_type != "line"}
{if $row.device_key_type == "URL"}
key.{$row.device_key_id}.function.prim="{$row.device_key_value}"
{else}
key.{$row.device_key_id}.function.prim="{$row.device_key_type}"
key.{$row.device_key_id}.subPoint.prim="{$row.device_key_value}"
{/if}
{/if}
{/if}
{/if}
{/foreach}
/>
<MULTICAST_PAGING
@ -77,5 +93,6 @@
voice.volume.persist.handset="1"
{if $headset_mode != ''}up.handsfreeMode="1"
up.headsetMode="{$headset_mode}"{/if}
{if $analog_headset_option != ''}up.analogHeadsetOption="{$analog_headset_option}"{/if}
/>
</PHONE>

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PHONE>
<REGISTRATION
{foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.user_id}"
{foreach $lines as $row}reg.{$row.line_number}.displayName="{$row.display_name}"
reg.{$row.line_number}.address="{$row.user_id}"
reg.{$row.line_number}.label="{$row.user_id}"
reg.{$row.line_number}.label="{$row.display_name}"
reg.{$row.line_number}.type="private"
reg.{$row.line_number}.auth.userId="{$row.user_id}"
reg.{$row.line_number}.auth.password="{$row.password}"
reg.{$row.line_number}.lineKeys="{$line_key_value_{$row.line_number}}"
{if isset($row.outbound_proxy)}reg.{$row.line_number}.outboundProxy.address = "{$row.outbound_proxy}"{/if}
{if isset($row.sip_port)}reg.{$row.line_number}.outboundProxy.port="{$row.sip_port}"{else}reg.{$row.line_number}.server.1.port="5060"{/if}
@ -55,12 +57,26 @@
attendant.behaviors.display.remoteCallerID.normal="1"
attendant.behaviors.display.spontaneousCallAppearances.automata="1"
attendant.behaviors.display.spontaneousCallAppearances.normal="0"
{foreach $keys as $row}{if $row.device_key_category == "line"}{if $row.device_key_type != "line"}attendant.resourceList.{$row.device_key_id}.address="{$row.device_key_value}"
attendant.resourceList.{$row.device_key_id}.callAddress=""
attendant.resourceList.{$row.device_key_id}.label="{$row.device_key_label}"
attendant.resourceList.{$row.device_key_id}.proceedingIsRecipient="0"
attendant.resourceList.{$row.device_key_id}.type="{$row.device_key_type}"
{/if}{/if}
feature.enhancedFeatureKeys.enabled="1"
{foreach $keys as $row}
{if $row.device_key_category == "line"}
{if $row.device_key_type == "automata" || $row.device_key_type == "normal"}
attendant.resourceList.{$row.device_key_id}.address="{$row.device_key_value}"
attendant.resourceList.{$row.device_key_id}.callAddress=""
attendant.resourceList.{$row.device_key_id}.label="{$row.device_key_label}"
attendant.resourceList.{$row.device_key_id}.proceedingIsRecipient="0"
attendant.resourceList.{$row.device_key_id}.type="{$row.device_key_type}"
{else}
{if $row.device_key_type != "line"}
{if $row.device_key_type == "URL"}
key.{$row.device_key_id}.function.prim="{$row.device_key_value}"
{else}
key.{$row.device_key_id}.function.prim="{$row.device_key_type}"
key.{$row.device_key_id}.subPoint.prim="{$row.device_key_value}"
{/if}
{/if}
{/if}
{/if}
{/foreach}
/>
<MULTICAST_PAGING
@ -77,5 +93,6 @@
voice.volume.persist.handset="1"
{if $headset_mode != ''}up.handsfreeMode="1"
up.headsetMode="{$headset_mode}"{/if}
{if $analog_headset_option != ''}up.analogHeadsetOption="{$analog_headset_option}"{/if}
/>
</PHONE>

View File

@ -223,8 +223,8 @@ account.1.nat.stun_server =
#Configure the STUN server port, the default value is 3478.
account.1.nat.stun_port =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default);
account.1.nat.udp_update_enable =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time =

View File

@ -126,7 +126,7 @@ account.1.nat.stun_server =
account.1.nat.stun_port = 3478
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 1
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time = 30

View File

@ -126,7 +126,7 @@ account.1.nat.stun_server =
account.1.nat.stun_port = 3478
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 1
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time = 30

View File

@ -223,8 +223,8 @@ account.1.nat.stun_server =
#Configure the STUN server port, the default value is 3478.
account.1.nat.stun_port =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default);
account.1.nat.udp_update_enable =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time =

View File

@ -126,7 +126,7 @@ account.1.nat.stun_server =
account.1.nat.stun_port = 3478
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 1
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time = 30

View File

@ -223,8 +223,8 @@ account.1.nat.stun_server =
#Configure the STUN server port, the default value is 3478.
account.1.nat.stun_port =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default);
account.1.nat.udp_update_enable =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time =

View File

@ -126,7 +126,7 @@ account.1.nat.stun_server =
account.1.nat.stun_port = 3478
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 1
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time = 30

View File

@ -223,8 +223,8 @@ account.1.nat.stun_server =
#Configure the STUN server port, the default value is 3478.
account.1.nat.stun_port =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default);
account.1.nat.udp_update_enable =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time =

View File

@ -223,8 +223,8 @@ account.1.nat.stun_server =
#Configure the STUN server port, the default value is 3478.
account.1.nat.stun_port =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default);
account.1.nat.udp_update_enable =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time =

View File

@ -126,7 +126,7 @@ account.1.nat.stun_server =
account.1.nat.stun_port = 3478
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 1
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time = 30

View File

@ -126,7 +126,7 @@ account.1.nat.stun_server =
account.1.nat.stun_port = 3478
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 1
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time = 30

View File

@ -253,8 +253,8 @@ account.1.nat.stun_server =
#Configure the STUN server port, the default value is 3478.
account.1.nat.stun_port =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default);
account.1.nat.udp_update_enable =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time =

View File

@ -147,8 +147,8 @@ account.1.nat.stun_server =
#Configure the STUN server port, the default value is 3478.
account.1.nat.stun_port =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Enabled (default);
account.1.nat.udp_update_enable =
#Enable or disable the NAT keep-alive; 0-Disabled, 1-Default (default), 2-Option, 3-Notify;
account.1.nat.udp_update_enable = 3
#Specify the keep-alive interval (in seconds), the default value is 30.
account.1.nat.udp_update_time =

View File

@ -251,7 +251,7 @@ form {
margin: 0;
}
input.btn, input.button {
input.btn, input.button, button {
font-family: Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif;
padding: 2px 6px 3px 6px;
color: #fff;
@ -273,7 +273,7 @@ input.btn, input.button {
-moz-opacity: 0.9;
}
input.btn:hover, input.button:hover, img.list_control_icon:hover {
input.btn:hover, input.button:hover, img.list_control_icon:hover, button:hover {
box-shadow: 0 0 5px #cddaf0;
-webkit-box-shadow: 0 0 5px #cddaf0;
-moz-box-shadow: 0 0 5px #cddaf0;