mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Misc Classes: Database class integration.
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
//define the directory class
|
||||
if (!class_exists('extension')) {
|
||||
class extension {
|
||||
public $db;
|
||||
public $domain_uuid;
|
||||
public $domain_name;
|
||||
private $app_uuid;
|
||||
@@ -72,14 +71,6 @@ if (!class_exists('extension')) {
|
||||
public $description;
|
||||
|
||||
public function __construct() {
|
||||
//connect to the database if not connected
|
||||
if (!$this->db) {
|
||||
require_once "resources/classes/database.php";
|
||||
$database = new database;
|
||||
$database->connect();
|
||||
$this->db = $database->db;
|
||||
}
|
||||
|
||||
//set the application id
|
||||
$this->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
|
||||
}
|
||||
@@ -91,21 +82,18 @@ if (!class_exists('extension')) {
|
||||
}
|
||||
|
||||
public function exists($domain_uuid, $extension) {
|
||||
$sql = "select extension_uuid from v_extensions ";
|
||||
$sql = "select count(*) from v_extensions ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and (extension = :extension or number_alias = :extension) ";
|
||||
$sql .= "and ( ";
|
||||
$sql .= "extension = :extension ";
|
||||
$sql .= "or number_alias = :extension ";
|
||||
$sql .= ") ";
|
||||
$sql .= "and enabled = 'true' ";
|
||||
$prep_statement = $this->db->prepare($sql);
|
||||
$prep_statement->bindParam(':domain_uuid', $domain_uuid);
|
||||
$prep_statement->bindParam(':extension', $extension);
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if ($result && count($result) > 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$parameters['extension'] = $extension;
|
||||
$database = new database;
|
||||
return $database->select($sql, $parameters, 'column') != 0 ? true : false;
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
||||
public function get_domain_uuid() {
|
||||
@@ -117,7 +105,6 @@ if (!class_exists('extension')) {
|
||||
}
|
||||
|
||||
public function voicemail() {
|
||||
|
||||
//determine the voicemail_id
|
||||
if (is_numeric($this->number_alias)) {
|
||||
$this->voicemail_id = $this->number_alias;
|
||||
@@ -126,66 +113,58 @@ if (!class_exists('extension')) {
|
||||
$this->voicemail_id = $this->extension;
|
||||
}
|
||||
|
||||
//update the voicemail settings
|
||||
$sql = "select * from v_voicemails ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and voicemail_id = '".$this->voicemail_id."' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
if (count($result) == 0) {
|
||||
//add the voicemail box
|
||||
$sql = "insert into v_voicemails ";
|
||||
$sql .= "(";
|
||||
$sql .= "domain_uuid, ";
|
||||
$sql .= "voicemail_uuid, ";
|
||||
$sql .= "voicemail_id, ";
|
||||
$sql .= "voicemail_password, ";
|
||||
if (strlen($this->greeting_id) > 0) {
|
||||
$sql .= "greeting_id, ";
|
||||
}
|
||||
$sql .= "voicemail_mail_to, ";
|
||||
$sql .= "voicemail_file, ";
|
||||
$sql .= "voicemail_local_after_email, ";
|
||||
$sql .= "voicemail_enabled, ";
|
||||
$sql .= "voicemail_description ";
|
||||
$sql .= ") ";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".$this->domain_uuid."', ";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'".$this->voicemail_id."', ";
|
||||
$sql .= "'".$this->voicemail_password."', ";
|
||||
$sql .= "'".$this->voicemail_mail_to."', ";
|
||||
$sql .= "'".$this->voicemail_file."', ";
|
||||
$sql .= "'".$this->voicemail_local_after_email."', ";
|
||||
$sql .= "'".$this->voicemail_enabled."', ";
|
||||
$sql .= "'".$this->description."' ";
|
||||
$sql .= ")";
|
||||
$this->db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
//insert or update the voicemail settings
|
||||
$sql = "select voicemail_uuid from v_voicemails ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and voicemail_id = :voicemail_id ";
|
||||
$parameters['domain_uuid'] = $this->domain_uuid;
|
||||
$parameters['voicemail_id'] = $this->voicemail_id;
|
||||
$database = new database;
|
||||
$voicemail_uuid = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
if (is_uuid($voicemail_uuid)) {
|
||||
//build update array
|
||||
$array['voicemails'][0]['voicemail_uuid'] = $voicemail_uuid;
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('voicemail_edit', 'temp');
|
||||
}
|
||||
else {
|
||||
//update the voicemail box
|
||||
$sql = "update v_voicemails set ";
|
||||
$sql .= "voicemail_password = '".$this->voicemail_password."', ";
|
||||
$sql .= "voicemail_mail_to = '".$this->voicemail_mail_to."', ";
|
||||
$sql .= "voicemail_file = '".$this->voicemail_file."', ";
|
||||
$sql .= "voicemail_local_after_email = '".$this->voicemail_local_after_email."', ";
|
||||
$sql .= "voicemail_enabled = '".$this->voicemail_enabled."', ";
|
||||
$sql .= "voicemail_description = '".$this->description."' ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and voicemail_id = '".$this->voicemail_id."' ";
|
||||
$this->db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
//build insert array
|
||||
$array['voicemails'][0]['voicemail_uuid'] = uuid();
|
||||
$array['voicemails'][0]['domain_uuid'] = $this->domain_uuid;
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('voicemail_add', 'temp');
|
||||
}
|
||||
unset ($prep_statement);
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//include common array fields
|
||||
$array['voicemails'][0]['voicemail_id'] = $this->voicemail_id;
|
||||
$array['voicemails'][0]['voicemail_password'] = $this->voicemail_password;
|
||||
$array['voicemails'][0]['voicemail_mail_to'] = $this->voicemail_mail_to;
|
||||
$array['voicemails'][0]['voicemail_file'] = $this->voicemail_file;
|
||||
$array['voicemails'][0]['voicemail_local_after_email'] = $this->voicemail_local_after_email;
|
||||
$array['voicemails'][0]['voicemail_enabled'] = $this->voicemail_enabled;
|
||||
$array['voicemails'][0]['voicemail_description'] = $this->description;
|
||||
//execute insert/update
|
||||
$database = new database;
|
||||
$database->app_name = 'extensions';
|
||||
$database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
//revoke temporary permissions
|
||||
$p->delete('voicemail_edit', 'temp');
|
||||
$p->delete('voicemail_add', 'temp');
|
||||
}
|
||||
|
||||
unset($voicemail_uuid);
|
||||
}
|
||||
|
||||
public function xml() {
|
||||
if (isset($_SESSION['switch']['extensions']['dir'])) {
|
||||
//declare global variables
|
||||
global $config, $db, $domain_uuid;
|
||||
global $config, $domain_uuid;
|
||||
|
||||
//get the domain_name
|
||||
$domain_name = $_SESSION['domains'][$domain_uuid]['domain_name'];
|
||||
@@ -198,243 +177,246 @@ if (!class_exists('extension')) {
|
||||
}
|
||||
|
||||
//write the xml files
|
||||
$sql = "SELECT * FROM v_extensions AS e, v_voicemails AS v ";
|
||||
$sql .= "WHERE e.domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "AND COALESCE(NULLIF(e.number_alias,''),e.extension) = CAST(v.voicemail_id as VARCHAR) ";
|
||||
$sql .= "ORDER BY e.call_group ASC ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$i = 0;
|
||||
$sql = "select * from v_extensions as e, v_voicemails as v ";
|
||||
$sql .= "where e.domain_uuid = :domain_uuid ";
|
||||
$sql .= "and coalesce(nullif(e.number_alias,''),e.extension) = cast(v.voicemail_id as varchar) ";
|
||||
$sql .= "order by e.call_group asc ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
$extension_xml_condensed = false;
|
||||
while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
|
||||
$call_group = $row['call_group'];
|
||||
$call_group = str_replace(";", ",", $call_group);
|
||||
$tmp_array = explode(",", $call_group);
|
||||
foreach ($tmp_array as &$tmp_call_group) {
|
||||
$tmp_call_group = trim($tmp_call_group);
|
||||
if (strlen($tmp_call_group) > 0) {
|
||||
if (strlen($call_group_array[$tmp_call_group]) == 0) {
|
||||
$call_group_array[$tmp_call_group] = $row['extension'];
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$call_group = $row['call_group'];
|
||||
$call_group = str_replace(";", ",", $call_group);
|
||||
$tmp_array = explode(",", $call_group);
|
||||
foreach ($tmp_array as &$tmp_call_group) {
|
||||
$tmp_call_group = trim($tmp_call_group);
|
||||
if (strlen($tmp_call_group) > 0) {
|
||||
if (strlen($call_group_array[$tmp_call_group]) == 0) {
|
||||
$call_group_array[$tmp_call_group] = $row['extension'];
|
||||
}
|
||||
else {
|
||||
$call_group_array[$tmp_call_group] = $call_group_array[$tmp_call_group].','.$row['extension'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$call_timeout = $row['call_timeout'];
|
||||
$user_context = $row['user_context'];
|
||||
$password = $row['password'];
|
||||
$voicemail_password = $row['voicemail_password'];
|
||||
//$voicemail_password = str_replace("#", "", $voicemail_password); //preserves leading zeros
|
||||
|
||||
//echo "enabled: ".$row['enabled'];
|
||||
if ($row['enabled'] != "false") {
|
||||
$extension_uuid = $row['extension_uuid'];
|
||||
//remove invalid characters from the file names
|
||||
$extension = $row['extension'];
|
||||
$extension = str_replace(" ", "_", $extension);
|
||||
$extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension);
|
||||
$dial_string = $row['dial_string'];
|
||||
if (strlen($dial_string) == 0) {
|
||||
if (strlen($_SESSION['domain']['dial_string']['text']) > 0) {
|
||||
$dial_string = $_SESSION['domain']['dial_string']['text'];
|
||||
}
|
||||
else {
|
||||
$dial_string = "{sip_invite_domain=\${domain_name},leg_timeout=".$call_timeout.",presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}";
|
||||
}
|
||||
}
|
||||
|
||||
//set the password hashes
|
||||
$a1_hash = md5($extension.":".$domain_name.":".$password);
|
||||
$vm_a1_hash = md5($extension.":".$domain_name.":".$voicemail_password);
|
||||
|
||||
$xml .= "<include>\n";
|
||||
$cidr = '';
|
||||
if (strlen($row['cidr']) > 0) {
|
||||
$cidr = " cidr=\"" . $row['cidr'] . "\"";
|
||||
}
|
||||
$number_alias = '';
|
||||
if (strlen($row['number_alias']) > 0) {
|
||||
$number_alias = " number-alias=\"".$row['number_alias']."\"";
|
||||
}
|
||||
$xml .= " <user id=\"".$row['extension']."\"".$cidr."".$number_alias.">\n";
|
||||
$xml .= " <params>\n";
|
||||
//$xml .= " <param name=\"a1-hash\" value=\"" . $a1_hash . "\"/>\n";
|
||||
$xml .= " <param name=\"password\" value=\"" . $row['password'] . "\"/>\n";
|
||||
$xml .= " <param name=\"reverse-auth-user\" value=\"" . $row['extension'] . "\"/>\n";
|
||||
$xml .= " <param name=\"reverse-auth-pass\" value=\"" . $row['password'] . "\"/>\n";
|
||||
|
||||
//voicemail settings
|
||||
//$xml .= " <param name=\"vm-a1-hash\" value=\"" . $vm_a1_hash. "\"/>\n";
|
||||
$xml .= " <param name=\"vm-password\" value=\"" . $voicemail_password . "\"/>\n";
|
||||
switch ($row['voicemail_enabled']) {
|
||||
case "true":
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"true\"/>\n";
|
||||
}
|
||||
if (strlen($row['voicemail_mail_to']) > 0) {
|
||||
$xml .= " <param name=\"vm-email-all-messages\" value=\"true\"/>\n";
|
||||
switch ($row['voicemail_file']) {
|
||||
case "attach":
|
||||
$xml .= " <param name=\"vm-attach-file\" value=\"true\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$xml .= " <param name=\"vm-attach-file\" value=\"false\"/>\n";
|
||||
}
|
||||
switch ($row['voicemail_local_after_email']) {
|
||||
case "true":
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"true\"/>\n";
|
||||
}
|
||||
$xml .= " <param name=\"vm-mailto\" value=\"" . $row['voicemail_mail_to'] . "\"/>\n";
|
||||
}
|
||||
|
||||
if (strlen($row['mwi_account']) > 0) {
|
||||
$xml .= " <param name=\"MWI-Account\" value=\"" . $row['mwi_account'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['auth_acl']) > 0) {
|
||||
$xml .= " <param name=\"auth-acl\" value=\"" . $row['auth_acl'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_exten_visible']) > 0) {
|
||||
$xml .= " <param name=\"directory-exten-visible\" value=\"" . $row['directory_exten_visible'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " <param name=\"dial-string\" value=\"" . $dial_string . "\"/>\n";
|
||||
$xml .= " </params>\n";
|
||||
$xml .= " <variables>\n";
|
||||
$xml .= " <variable name=\"domain_name\" value=\"" . $_SESSION['domain_name'] . "\"/>\n";
|
||||
$xml .= " <variable name=\"domain_uuid\" value=\"" . $_SESSION['domain_uuid'] . "\"/>\n";
|
||||
$xml .= " <variable name=\"extension_uuid\" value=\"" . $extension_uuid . "\"/>\n";
|
||||
if (strlen($row['call_group']) > 0) {
|
||||
$xml .= " <variable name=\"call_group\" value=\"" . $row['call_group'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['user_record']) > 0) {
|
||||
$xml .= " <variable name=\"user_record\" value=\"" . $row['user_record'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['hold_music']) > 0) {
|
||||
$xml .= " <variable name=\"hold_music\" value=\"" . $row['hold_music'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " <variable name=\"toll_allow\" value=\"" . $row['toll_allow'] . "\"/>\n";
|
||||
if (strlen($row['call_timeout']) > 0) {
|
||||
$xml .= " <variable name=\"call_timeout\" value=\"" . $row['call_timeout'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($switch_account_code) > 0) {
|
||||
$xml .= " <variable name=\"accountcode\" value=\"" . $switch_account_code . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$call_group_array[$tmp_call_group] = $call_group_array[$tmp_call_group].','.$row['extension'];
|
||||
$xml .= " <variable name=\"accountcode\" value=\"" . $row['accountcode'] . "\"/>\n";
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$call_timeout = $row['call_timeout'];
|
||||
$user_context = $row['user_context'];
|
||||
$password = $row['password'];
|
||||
$voicemail_password = $row['voicemail_password'];
|
||||
//$voicemail_password = str_replace("#", "", $voicemail_password); //preserves leading zeros
|
||||
|
||||
//echo "enabled: ".$row['enabled'];
|
||||
if ($row['enabled'] != "false") {
|
||||
$extension_uuid = $row['extension_uuid'];
|
||||
//remove invalid characters from the file names
|
||||
$extension = $row['extension'];
|
||||
$extension = str_replace(" ", "_", $extension);
|
||||
$extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension);
|
||||
$dial_string = $row['dial_string'];
|
||||
if (strlen($dial_string) == 0) {
|
||||
if (strlen($_SESSION['domain']['dial_string']['text']) > 0) {
|
||||
$dial_string = $_SESSION['domain']['dial_string']['text'];
|
||||
$xml .= " <variable name=\"user_context\" value=\"" . $row['user_context'] . "\"/>\n";
|
||||
if (strlen($row['effective_caller_id_name']) > 0) {
|
||||
$xml .= " <variable name=\"effective_caller_id_name\" value=\"" . $row['effective_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['effective_caller_id_number']) > 0) {
|
||||
$xml .= " <variable name=\"effective_caller_id_number\" value=\"" . $row['effective_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['outbound_caller_id_name']) > 0) {
|
||||
$xml .= " <variable name=\"outbound_caller_id_name\" value=\"" . $row['outbound_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['outbound_caller_id_number']) > 0) {
|
||||
$xml .= " <variable name=\"outbound_caller_id_number\" value=\"" . $row['outbound_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['emergency_caller_id_name']) > 0) {
|
||||
$xml .= " <variable name=\"emergency_caller_id_name\" value=\"" . $row['emergency_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['emergency_caller_id_number']) > 0) {
|
||||
$xml .= " <variable name=\"emergency_caller_id_number\" value=\"" . $row['emergency_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_full_name']) > 0) {
|
||||
$xml .= " <variable name=\"directory_full_name\" value=\"" . $row['directory_full_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_visible']) > 0) {
|
||||
$xml .= " <variable name=\"directory-visible\" value=\"" . $row['directory_visible'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['limit_max']) > 0) {
|
||||
$xml .= " <variable name=\"limit_max\" value=\"" . $row['limit_max'] . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$dial_string = "{sip_invite_domain=\${domain_name},leg_timeout=".$call_timeout.",presence_id=\${dialed_user}@\${dialed_domain}}\${sofia_contact(\${dialed_user}@\${dialed_domain})}";
|
||||
$xml .= " <variable name=\"limit_max\" value=\"5\"/>\n";
|
||||
}
|
||||
}
|
||||
|
||||
//set the password hashes
|
||||
$a1_hash = md5($extension.":".$domain_name.":".$password);
|
||||
$vm_a1_hash = md5($extension.":".$domain_name.":".$voicemail_password);
|
||||
|
||||
$xml .= "<include>\n";
|
||||
$cidr = '';
|
||||
if (strlen($row['cidr']) > 0) {
|
||||
$cidr = " cidr=\"" . $row['cidr'] . "\"";
|
||||
}
|
||||
$number_alias = '';
|
||||
if (strlen($row['number_alias']) > 0) {
|
||||
$number_alias = " number-alias=\"".$row['number_alias']."\"";
|
||||
}
|
||||
$xml .= " <user id=\"".$row['extension']."\"".$cidr."".$number_alias.">\n";
|
||||
$xml .= " <params>\n";
|
||||
//$xml .= " <param name=\"a1-hash\" value=\"" . $a1_hash . "\"/>\n";
|
||||
$xml .= " <param name=\"password\" value=\"" . $row['password'] . "\"/>\n";
|
||||
$xml .= " <param name=\"reverse-auth-user\" value=\"" . $row['extension'] . "\"/>\n";
|
||||
$xml .= " <param name=\"reverse-auth-pass\" value=\"" . $row['password'] . "\"/>\n";
|
||||
|
||||
//voicemail settings
|
||||
//$xml .= " <param name=\"vm-a1-hash\" value=\"" . $vm_a1_hash. "\"/>\n";
|
||||
$xml .= " <param name=\"vm-password\" value=\"" . $voicemail_password . "\"/>\n";
|
||||
switch ($row['voicemail_enabled']) {
|
||||
case "true":
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$xml .= " <param name=\"vm-enabled\" value=\"true\"/>\n";
|
||||
}
|
||||
if (strlen($row['voicemail_mail_to']) > 0) {
|
||||
$xml .= " <param name=\"vm-email-all-messages\" value=\"true\"/>\n";
|
||||
switch ($row['voicemail_file']) {
|
||||
case "attach":
|
||||
$xml .= " <param name=\"vm-attach-file\" value=\"true\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$xml .= " <param name=\"vm-attach-file\" value=\"false\"/>\n";
|
||||
if (strlen($row['limit_destination']) > 0) {
|
||||
$xml .= " <variable name=\"limit_destination\" value=\"" . $row['limit_destination'] . "\"/>\n";
|
||||
}
|
||||
switch ($row['voicemail_local_after_email']) {
|
||||
case "true":
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "false":
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"false\"/>\n";
|
||||
break;
|
||||
default:
|
||||
$xml .= " <param name=\"vm-keep-local-after-email\" value=\"true\"/>\n";
|
||||
if (strlen($row['sip_force_contact']) > 0) {
|
||||
$xml .= " <variable name=\"sip-force-contact\" value=\"" . $row['sip_force_contact'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['sip_force_expires']) > 0) {
|
||||
$xml .= " <variable name=\"sip-force-expires\" value=\"" . $row['sip_force_expires'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['nibble_account']) > 0) {
|
||||
$xml .= " <variable name=\"nibble_account\" value=\"" . $row['nibble_account'] . "\"/>\n";
|
||||
}
|
||||
switch ($row['sip_bypass_media']) {
|
||||
case "bypass-media":
|
||||
$xml .= " <variable name=\"bypass_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "bypass-media-after-bridge":
|
||||
$xml .= " <variable name=\"bypass_media_after_bridge\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "proxy-media":
|
||||
$xml .= " <variable name=\"proxy_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
}
|
||||
if (strlen($row['absolute_codec_string']) > 0) {
|
||||
$xml .= " <variable name=\"absolute_codec_string\" value=\"" . $row['absolute_codec_string'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_all_enabled']) > 0) {
|
||||
$xml .= " <variable name=\"forward_all_enabled\" value=\"" . $row['forward_all_enabled'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_all_destination']) > 0) {
|
||||
$xml .= " <variable name=\"forward_all_destination\" value=\"" . $row['forward_all_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_busy_enabled']) > 0) {
|
||||
$xml .= " <variable name=\"forward_busy_enabled\" value=\"" . $row['forward_busy_enabled'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_busy_destination']) > 0) {
|
||||
$xml .= " <variable name=\"forward_busy_destination\" value=\"" . $row['forward_busy_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_no_answer_enabled']) > 0) {
|
||||
$xml .= " <variable name=\"forward_no_answer_enabled\" value=\"" . $row['forward_no_answer_enabled'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_no_answer_destination']) > 0) {
|
||||
$xml .= " <variable name=\"forward_no_answer_destination\" value=\"" . $row['forward_no_answer_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_user_not_registered_enabled']) > 0) {
|
||||
$xml .= " <variable name=\"forward_user_not_registered_enabled\" value=\"" . $row['forward_user_not_registered_enabled'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_user_not_registered_destination']) > 0) {
|
||||
$xml .= " <variable name=\"forward_user_not_registered_destination\" value=\"" . $row['forward_user_not_registered_destination'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " <param name=\"vm-mailto\" value=\"" . $row['voicemail_mail_to'] . "\"/>\n";
|
||||
}
|
||||
|
||||
if (strlen($row['mwi_account']) > 0) {
|
||||
$xml .= " <param name=\"MWI-Account\" value=\"" . $row['mwi_account'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['auth_acl']) > 0) {
|
||||
$xml .= " <param name=\"auth-acl\" value=\"" . $row['auth_acl'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_exten_visible']) > 0) {
|
||||
$xml .= " <param name=\"directory-exten-visible\" value=\"" . $row['directory_exten_visible'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " <param name=\"dial-string\" value=\"" . $dial_string . "\"/>\n";
|
||||
$xml .= " </params>\n";
|
||||
$xml .= " <variables>\n";
|
||||
$xml .= " <variable name=\"domain_name\" value=\"" . $_SESSION['domain_name'] . "\"/>\n";
|
||||
$xml .= " <variable name=\"domain_uuid\" value=\"" . $_SESSION['domain_uuid'] . "\"/>\n";
|
||||
$xml .= " <variable name=\"extension_uuid\" value=\"" . $extension_uuid . "\"/>\n";
|
||||
if (strlen($row['call_group']) > 0) {
|
||||
$xml .= " <variable name=\"call_group\" value=\"" . $row['call_group'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['user_record']) > 0) {
|
||||
$xml .= " <variable name=\"user_record\" value=\"" . $row['user_record'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['hold_music']) > 0) {
|
||||
$xml .= " <variable name=\"hold_music\" value=\"" . $row['hold_music'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " <variable name=\"toll_allow\" value=\"" . $row['toll_allow'] . "\"/>\n";
|
||||
if (strlen($row['call_timeout']) > 0) {
|
||||
$xml .= " <variable name=\"call_timeout\" value=\"" . $row['call_timeout'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($switch_account_code) > 0) {
|
||||
$xml .= " <variable name=\"accountcode\" value=\"" . $switch_account_code . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$xml .= " <variable name=\"accountcode\" value=\"" . $row['accountcode'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " <variable name=\"user_context\" value=\"" . $row['user_context'] . "\"/>\n";
|
||||
if (strlen($row['effective_caller_id_name']) > 0) {
|
||||
$xml .= " <variable name=\"effective_caller_id_name\" value=\"" . $row['effective_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['effective_caller_id_number']) > 0) {
|
||||
$xml .= " <variable name=\"effective_caller_id_number\" value=\"" . $row['effective_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['outbound_caller_id_name']) > 0) {
|
||||
$xml .= " <variable name=\"outbound_caller_id_name\" value=\"" . $row['outbound_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['outbound_caller_id_number']) > 0) {
|
||||
$xml .= " <variable name=\"outbound_caller_id_number\" value=\"" . $row['outbound_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['emergency_caller_id_name']) > 0) {
|
||||
$xml .= " <variable name=\"emergency_caller_id_name\" value=\"" . $row['emergency_caller_id_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['emergency_caller_id_number']) > 0) {
|
||||
$xml .= " <variable name=\"emergency_caller_id_number\" value=\"" . $row['emergency_caller_id_number'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_full_name']) > 0) {
|
||||
$xml .= " <variable name=\"directory_full_name\" value=\"" . $row['directory_full_name'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['directory_visible']) > 0) {
|
||||
$xml .= " <variable name=\"directory-visible\" value=\"" . $row['directory_visible'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['limit_max']) > 0) {
|
||||
$xml .= " <variable name=\"limit_max\" value=\"" . $row['limit_max'] . "\"/>\n";
|
||||
}
|
||||
else {
|
||||
$xml .= " <variable name=\"limit_max\" value=\"5\"/>\n";
|
||||
}
|
||||
if (strlen($row['limit_destination']) > 0) {
|
||||
$xml .= " <variable name=\"limit_destination\" value=\"" . $row['limit_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['sip_force_contact']) > 0) {
|
||||
$xml .= " <variable name=\"sip-force-contact\" value=\"" . $row['sip_force_contact'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['sip_force_expires']) > 0) {
|
||||
$xml .= " <variable name=\"sip-force-expires\" value=\"" . $row['sip_force_expires'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['nibble_account']) > 0) {
|
||||
$xml .= " <variable name=\"nibble_account\" value=\"" . $row['nibble_account'] . "\"/>\n";
|
||||
}
|
||||
switch ($row['sip_bypass_media']) {
|
||||
case "bypass-media":
|
||||
$xml .= " <variable name=\"bypass_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "bypass-media-after-bridge":
|
||||
$xml .= " <variable name=\"bypass_media_after_bridge\" value=\"true\"/>\n";
|
||||
break;
|
||||
case "proxy-media":
|
||||
$xml .= " <variable name=\"proxy_media\" value=\"true\"/>\n";
|
||||
break;
|
||||
}
|
||||
if (strlen($row['absolute_codec_string']) > 0) {
|
||||
$xml .= " <variable name=\"absolute_codec_string\" value=\"" . $row['absolute_codec_string'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_all_enabled']) > 0) {
|
||||
$xml .= " <variable name=\"forward_all_enabled\" value=\"" . $row['forward_all_enabled'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_all_destination']) > 0) {
|
||||
$xml .= " <variable name=\"forward_all_destination\" value=\"" . $row['forward_all_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_busy_enabled']) > 0) {
|
||||
$xml .= " <variable name=\"forward_busy_enabled\" value=\"" . $row['forward_busy_enabled'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_busy_destination']) > 0) {
|
||||
$xml .= " <variable name=\"forward_busy_destination\" value=\"" . $row['forward_busy_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_no_answer_enabled']) > 0) {
|
||||
$xml .= " <variable name=\"forward_no_answer_enabled\" value=\"" . $row['forward_no_answer_enabled'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_no_answer_destination']) > 0) {
|
||||
$xml .= " <variable name=\"forward_no_answer_destination\" value=\"" . $row['forward_no_answer_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_user_not_registered_enabled']) > 0) {
|
||||
$xml .= " <variable name=\"forward_user_not_registered_enabled\" value=\"" . $row['forward_user_not_registered_enabled'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['forward_user_not_registered_destination']) > 0) {
|
||||
$xml .= " <variable name=\"forward_user_not_registered_destination\" value=\"" . $row['forward_user_not_registered_destination'] . "\"/>\n";
|
||||
}
|
||||
if (strlen($row['do_not_disturb']) > 0) {
|
||||
$xml .= " <variable name=\"do_not_disturb\" value=\"" . $row['do_not_disturb'] . "\"/>\n";
|
||||
}
|
||||
$xml .= " </variables>\n";
|
||||
$xml .= " </user>\n";
|
||||
|
||||
if (strlen($row['do_not_disturb']) > 0) {
|
||||
$xml .= " <variable name=\"do_not_disturb\" value=\"" . $row['do_not_disturb'] . "\"/>\n";
|
||||
if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) {
|
||||
event_socket_mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context']);
|
||||
}
|
||||
if (strlen($extension) > 0) {
|
||||
$fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w");
|
||||
}
|
||||
$xml .= "</include>\n";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
}
|
||||
$xml .= " </variables>\n";
|
||||
$xml .= " </user>\n";
|
||||
|
||||
if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) {
|
||||
event_socket_mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context']);
|
||||
}
|
||||
if (strlen($extension) > 0) {
|
||||
$fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w");
|
||||
}
|
||||
$xml .= "</include>\n";
|
||||
fwrite($fout, $xml);
|
||||
unset($xml);
|
||||
fclose($fout);
|
||||
}
|
||||
}
|
||||
unset ($prep_statement);
|
||||
unset($rows, $row);
|
||||
|
||||
//prepare extension
|
||||
$extension_dir = realpath($_SESSION['switch']['extensions']['dir']);
|
||||
@@ -533,4 +515,4 @@ if (!class_exists('extension')) {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user