예제 #1
0
파일: fax.php 프로젝트: bitplus/fusionpbx
 /**
  * Add a dialplan for call center
  * @var string $domain_uuid		the multi-tenant id
  * @var string $value	string to be cached
  */
 public function dialplan()
 {
     //normalize the fax forward number
     if (strlen($this->fax_forward_number) > 3) {
         //$fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number);
         $this->fax_forward_number = str_replace(" ", "", $this->fax_forward_number);
         $this->fax_forward_number = str_replace("-", "", $this->fax_forward_number);
     }
     //set the forward prefix
     if (strripos($this->fax_forward_number, '$1') === false) {
         $this->forward_prefix = '';
         //not found
     } else {
         $this->forward_prefix = $this->forward_prefix . $this->fax_forward_number . '#';
         //found
     }
     //delete previous dialplan
     if (strlen($this->dialplan_uuid) > 0) {
         //delete the previous dialplan
         $sql = "delete from v_dialplans ";
         $sql .= "where dialplan_uuid = '" . $this->dialplan_uuid . "' ";
         $sql .= "and domain_uuid = '" . $this->domain_uuid . "' ";
         $this->db->exec($sql);
         $sql = "delete from v_dialplan_details ";
         $sql .= "where dialplan_uuid = '" . $this->dialplan_uuid . "' ";
         $sql .= "and domain_uuid = '" . $this->domain_uuid . "' ";
         $this->db->exec($sql);
         unset($sql);
     }
     unset($prep_statement);
     //build the dialplan array
     $dialplan["app_uuid"] = "24108154-4ac3-1db6-1551-4731703a4440";
     $dialplan["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_name"] = $this->fax_name != '' ? $this->fax_name : format_phone($this->destination_number);
     $dialplan["dialplan_number"] = $this->fax_extension;
     $dialplan["dialplan_context"] = $_SESSION['context'];
     $dialplan["dialplan_continue"] = "false";
     $dialplan["dialplan_order"] = "310";
     $dialplan["dialplan_enabled"] = "true";
     $dialplan["dialplan_description"] = $this->fax_description;
     $dialplan_detail_order = 10;
     //add the public condition
     $y = 1;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "^" . $this->destination_number . "\$";
     $dialplan["dialplan_details"][$y]["dialplan_detail_break"] = "";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "answer";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "fax_uuid=" . $this->fax_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "api_hangup_hook=lua app/fax/resources/scripts/hangup_rx.lua";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     foreach ($_SESSION['fax']['variable'] as $data) {
         $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
         $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
         $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
         if (substr($data, 0, 8) == "inbound:") {
             $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = substr($data, 8, strlen($data));
         } elseif (substr($data, 0, 9) == "outbound:") {
         } else {
             $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $data;
         }
         $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
         $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
         $y++;
     }
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
     if (strlen($_SESSION['fax']['last_fax']['text']) > 0) {
         $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "last_fax=" . $_SESSION['fax']['last_fax']['text'];
     } else {
         $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "last_fax=\${caller_id_number}-\${strftime(%Y-%m-%d-%H-%M-%S)}";
     }
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "playback";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "silence_stream://2000";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "rxfax";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $_SESSION['switch']['storage']['dir'] . '/fax/' . $_SESSION['domain_name'] . '/' . $this->fax_extension . '/inbox/' . $this->forward_prefix . '${last_fax}.tif';
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "hangup";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     //add the dialplan permission
     $p = new permissions();
     $p->add("dialplan_add", 'temp');
     $p->add("dialplan_detail_add", 'temp');
     $p->add("dialplan_edit", 'temp');
     $p->add("dialplan_detail_edit", 'temp');
     //save the dialplan
     $orm = new orm();
     $orm->name('dialplans');
     $orm->save($dialplan);
     $dialplan_response = $orm->message;
     $this->dialplan_uuid = $dialplan_response['uuid'];
     //if new dialplan uuid then update the call center queue
     $sql = "update v_fax ";
     $sql .= "set dialplan_uuid = '" . $this->dialplan_uuid . "' ";
     $sql .= "where fax_uuid = '" . $this->fax_uuid . "' ";
     $sql .= "and domain_uuid = '" . $this->domain_uuid . "' ";
     $this->db->exec($sql);
     unset($sql);
     //remove the temporary permission
     $p->delete("dialplan_add", 'temp');
     $p->delete("dialplan_detail_add", 'temp');
     $p->delete("dialplan_edit", 'temp');
     $p->delete("dialplan_detail_edit", 'temp');
     //synchronize the xml config
     save_dialplan_xml();
     //clear the cache
     $cache = new cache();
     $cache->delete("dialplan:" . $_SESSION['context']);
     //return the dialplan_uuid
     return $dialplan_response;
 }
예제 #2
0
    $array[$x]['default_setting_description'] = '';
    $x++;
    $array[$x]['default_setting_category'] = 'backup';
    $array[$x]['default_setting_subcategory'] = 'path';
    $array[$x]['default_setting_name'] = 'array';
    $array[$x]['default_setting_value'] = $_SESSION['switch']['db']['dir'];
    $array[$x]['default_setting_enabled'] = 'true';
    $array[$x]['default_setting_description'] = '';
    $sql = "select * from v_default_settings ";
    $sql .= "where default_setting_category = 'backup' ";
    $prep_statement = $db->prepare(check_sql($sql));
    $prep_statement->execute();
    $default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
    $x = 0;
    foreach ($array as $row) {
        $found = false;
        foreach ($default_settings as $field) {
            if ($row['default_setting_subcategory'] == $field['default_setting_subcategory']) {
                $found = true;
                $break;
            }
        }
        if (!$found) {
            $orm = new orm();
            $orm->name('default_settings');
            $orm->save($array[$x]);
            $message = $orm->message;
        }
        $x++;
    }
}
예제 #3
0
 //iterate and add each, if necessary
 foreach ($array as $index => $default_settings) {
     //add default settings
     $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);
     }
 }
 //create phrases folder and add include line in xml for each language found
 if (strlen($_SESSION['switch']['phrases']['dir']) > 0) {
     if (is_readable($_SESSION['switch']['phrases']['dir'])) {
         $conf_lang_folders = glob($_SESSION['switch']['phrases']['dir'] . "/*");
         foreach ($conf_lang_folders as $conf_lang_folder) {
             //create phrases folder, if necessary
             if (!file_exists($conf_lang_folder . "/phrases/")) {
                 mkdir($conf_lang_folder . "/phrases/", 0777);
             }
예제 #4
0
$device_profiles[0]["device_profile_name"] = $device_profiles[0]["device_profile_name"] . "-" . strtolower($text['button-copy']);
$device_profiles[0]["device_profile_description"] = $text['button-copy'] . " " . $device_profiles[0]["device_profile_description"];
//prepare the device_keys array
$x = 0;
foreach ($device_keys as $row) {
    unset($device_keys[$x]["device_profile_uuid"]);
    unset($device_keys[$x]["device_key_uuid"]);
    $x++;
}
//prepare the device_settings array
//$x = 0;
//foreach ($device_settings as $row) {
//	unset($device_settings[$x]["device_uuid"]);
//	unset($device_settings[$x]["device_setting_uuid"]);
//	$x++;
//}
//create the device array
$device_profile = $device_profiles[0];
$device_profile["device_keys"] = $device_keys;
//$device["device_settings"] = $device_settings;
//copy the device
if ($save) {
    $orm = new orm();
    $orm->name('device_profiles');
    $orm->save($device_profile);
    $response = $orm->message;
    $_SESSION["message"] = $text['message-copy'];
}
//redirect
header("Location: device_profiles.php");
return;
예제 #5
0
             unset($_POST["ring_group_destinations"][$x]);
         }
         //unset ring_group_destination_uuid if the field has no value
         if (strlen($row["ring_group_destination_uuid"]) == 0) {
             unset($_POST["ring_group_destinations"][$x]["ring_group_destination_uuid"]);
         }
         //increment the row
         $x++;
     }
     //save to the data
     $orm = new orm();
     $orm->name('ring_groups');
     if (strlen($ring_group_uuid) > 0) {
         $orm->uuid($ring_group_uuid);
     }
     $orm->save($_POST);
     $message = $orm->message;
     if (strlen($ring_group_uuid) == 0) {
         $ring_group_uuid = $message['uuid'];
         $_GET["id"] = $ring_group_uuid;
     }
 }
 //delete the dialplan details
 $sql = "delete from v_dialplan_details ";
 $sql .= "where domain_uuid = '" . $_SESSION['domain_uuid'] . "' ";
 $sql .= "and dialplan_uuid = '" . $dialplan_uuid . "' ";
 $db->exec(check_sql($sql));
 unset($sql);
 //delete from the dialplan
 $sql = "delete from v_dialplans ";
 $sql .= "where domain_uuid = '" . $_SESSION['domain_uuid'] . "' ";
//prepare the device_keys array
$x = 0;
foreach ($device_keys as $row) {
    unset($device_keys[$x]["device_uuid"]);
    unset($device_keys[$x]["device_key_uuid"]);
    $x++;
}
//prepare the device_settings array
$x = 0;
foreach ($device_settings as $row) {
    unset($device_settings[$x]["device_uuid"]);
    unset($device_settings[$x]["device_setting_uuid"]);
    $x++;
}
//create the device array
$device = $devices[0];
$device["device_mac_address"] = $mac_address_new;
$device["device_lines"] = $device_lines;
$device["device_keys"] = $device_keys;
$device["device_settings"] = $device_settings;
//copy the device
if ($save) {
    $orm = new orm();
    $orm->name('devices');
    $orm->save($device);
    $response = $orm->message;
    $_SESSION["message"] = $text['message-copy'];
}
//redirect
header("Location: devices.php");
return;
예제 #7
0
            $sql .= "('" . uuid() . "', 'Thai', 'th'), ";
            $sql .= "('" . uuid() . "', 'Tibetan', 'bo'), ";
            $sql .= "('" . uuid() . "', 'Tsonga', 'ts'), ";
            $sql .= "('" . uuid() . "', 'Turkish', 'tr'), ";
            $sql .= "('" . uuid() . "', 'Turkmen', 'tk'), ";
            $sql .= "('" . uuid() . "', 'Ukrainian', 'uk'), ";
            $sql .= "('" . uuid() . "', 'Urdu', 'ur'), ";
            $sql .= "('" . uuid() . "', 'Uzbek - Cyrillic, Latin', 'uz-uz'), ";
            $sql .= "('" . uuid() . "', 'Vietnamese', 'vi'), ";
            $sql .= "('" . uuid() . "', 'Welsh', 'cy'), ";
            $sql .= "('" . uuid() . "', 'Xhosa', 'xh'), ";
            $sql .= "('" . uuid() . "', 'Yiddish', 'yi') ";
            $db->exec(check_sql($sql));
            unset($sql);
        }
        unset($prep_statement, $row);
    }
    //set the sip_profiles directory for older installs
    if (isset($_SESSION['switch']['gateways']['dir'])) {
        $orm = new orm();
        $orm->name('default_settings');
        $orm->uuid($_SESSION['switch']['gateways']['uuid']);
        $array['default_setting_category'] = 'switch';
        $array['default_setting_subcategory'] = 'sip_profiles';
        $array['default_setting_name'] = 'dir';
        //$array['default_setting_value'] = '';
        //$array['default_setting_enabled'] = 'true';
        $orm->save($array);
        unset($array);
    }
}
예제 #8
0
                break;
            }
        }
    }
    //get default settings
    $sql = "select * from v_default_settings ";
    $sql .= "where default_setting_category = 'theme' ";
    $sql .= "and default_setting_subcategory = 'background_image' ";
    $prep_statement = $db->prepare(check_sql($sql));
    $prep_statement->execute();
    $default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
    unset($prep_statement);
    //add theme default settings
    foreach ($array as $row) {
        $found = false;
        foreach ($default_settings as $field) {
            if ($field["default_setting_value"] == $row["default_setting_value"]) {
                $found = true;
            }
        }
        if (!$found) {
            $orm = new orm();
            $orm->name('default_settings');
            $orm->save($row);
            $message = $orm->message;
            //print_r($message);
        }
    }
    //unset the array variable
    unset($array);
}
예제 #9
0
 /**
  * Add a dialplan for call center
  * @var string $domain_uuid		the multi-tenant id
  * @var string $value	string to be cached
  */
 public function dialplan()
 {
     //delete previous dialplan
     if (strlen($this->dialplan_uuid) > 0) {
         //delete the previous dialplan
         $sql = "delete from v_dialplans ";
         $sql .= "where dialplan_uuid = '" . $this->dialplan_uuid . "' ";
         $sql .= "and domain_uuid = '" . $this->domain_uuid . "' ";
         $this->db->exec($sql);
         $sql = "delete from v_dialplan_details ";
         $sql .= "where dialplan_uuid = '" . $this->dialplan_uuid . "' ";
         $sql .= "and domain_uuid = '" . $this->domain_uuid . "' ";
         $this->db->exec($sql);
         unset($sql);
     }
     unset($prep_statement);
     //build the dialplan array
     $dialplan["app_uuid"] = "95788e50-9500-079e-2807-fd530b0ea370";
     $dialplan["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_name"] = $this->queue_name != '' ? $this->queue_name : format_phone($this->destination_number);
     $dialplan["dialplan_number"] = $this->destination_number;
     $dialplan["dialplan_context"] = $_SESSION['context'];
     $dialplan["dialplan_continue"] = "false";
     $dialplan["dialplan_order"] = "210";
     $dialplan["dialplan_enabled"] = "true";
     $dialplan["dialplan_description"] = $this->queue_description;
     $dialplan_detail_order = 10;
     //add the public condition
     $y = 1;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "\${caller_id_name}";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "^([^#]+#)(.*)\$";
     $dialplan["dialplan_details"][$y]["dialplan_detail_break"] = "never";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "caller_id_name=\$2";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "1";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "condition";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "destination_number";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "^" . $this->destination_number . "\$";
     $dialplan["dialplan_details"][$y]["dialplan_detail_break"] = "";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "answer";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "hangup_after_bridge=true";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     if (strlen($this->queue_cid_prefix) > 0) {
         $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
         $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
         $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "set";
         $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "effective_caller_id_name=" . $this->queue_cid_prefix . "#\${caller_id_name}";
         $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2";
         $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
         $y++;
     }
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "callcenter";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = $this->queue_name . '@' . $_SESSION["domain_name"];
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     $y++;
     if (strlen($this->queue_timeout_action) > 0) {
         $action_array = explode(":", $this->queue_timeout_action);
         $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
         $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
         $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = $action_array[0];
         $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = substr($this->queue_timeout_action, strlen($action_array[0]) + 1, strlen($this->queue_timeout_action));
         $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2";
         $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
         $y++;
     }
     $dialplan["dialplan_details"][$y]["domain_uuid"] = $this->domain_uuid;
     $dialplan["dialplan_details"][$y]["dialplan_detail_tag"] = "action";
     $dialplan["dialplan_details"][$y]["dialplan_detail_type"] = "hangup";
     $dialplan["dialplan_details"][$y]["dialplan_detail_data"] = "";
     $dialplan["dialplan_details"][$y]["dialplan_detail_group"] = "2";
     $dialplan["dialplan_details"][$y]["dialplan_detail_order"] = $y * 10;
     //add the dialplan permission
     $p = new permissions();
     $p->add("dialplan_add", 'temp');
     $p->add("dialplan_detail_add", 'temp');
     $p->add("dialplan_edit", 'temp');
     $p->add("dialplan_detail_edit", 'temp');
     //save the dialplan
     $orm = new orm();
     $orm->name('dialplans');
     $orm->save($dialplan);
     $dialplan_response = $orm->message;
     $this->dialplan_uuid = $dialplan_response['uuid'];
     //if new dialplan uuid then update the call center queue
     $sql = "update v_call_center_queues ";
     $sql .= "set dialplan_uuid = '" . $this->dialplan_uuid . "' ";
     $sql .= "where call_center_queue_uuid = '" . $this->call_center_queue_uuid . "' ";
     $sql .= "and domain_uuid = '" . $this->domain_uuid . "' ";
     $this->db->exec($sql);
     unset($sql);
     //remove the temporary permission
     $p->delete("dialplan_add", 'temp');
     $p->delete("dialplan_detail_add", 'temp');
     $p->delete("dialplan_edit", 'temp');
     $p->delete("dialplan_detail_edit", 'temp');
     //synchronize the xml config
     save_dialplan_xml();
     //clear the cache
     $cache = new cache();
     $cache->delete("dialplan:" . $_SESSION['context']);
     //return the dialplan_uuid
     return $dialplan_response;
 }
예제 #10
0
 public function dialplan($field)
 {
     //set global variables
     global $db;
     //action add or update
     if (strlen($field['dialplan_uuid']) == 0) {
         $field['dialplan_uuid'] = uuid();
         $action = "add";
     } else {
         $action = "update";
     }
     //delete child data
     if ($action == "update") {
         $sql = "delete from v_dialplan_details ";
         $sql .= "where dialplan_uuid = '" . $field["dialplan_uuid"] . "'; ";
         $db->query($sql);
         unset($sql);
     }
     //get dialplan details from the database
     if ($action == "update") {
         $sql = "select * from v_dialplan_details ";
         $sql .= "where dialplan_uuid = '" . $field["dialplan_uuid"] . "' ";
         $prep_statement = $db->prepare($sql);
         if ($prep_statement) {
             $prep_statement->execute();
             $dialplan_details = $prep_statement->fetchAll(PDO::FETCH_NAMED);
         }
         unset($sql, $prep_statement, $row);
     }
     //get the array from the database
     /*
     $database = new database;
     if ($this->db) { $database->db = $this->db; }
     $database->table = "v_ivr_menu_details";
     $database->where[0]['name'] = 'ivr_menu_uuid';
     $database->where[0]['value'] = $field["ivr_menu_uuid"];
     $database->where[0]['operator'] = '=';
     $ivr_menu_details = $database->find();
     */
     //add the details array
     $x = 0;
     $details[$x]['dialplan_detail_tag'] = 'condition';
     //condition, action, antiaction
     $details[$x]['dialplan_detail_type'] = 'destination_number';
     $details[$x]['dialplan_detail_data'] = '^' . $field['ivr_menu_extension'] . '$';
     $details[$x]['dialplan_detail_order'] = '005';
     $x++;
     $details[$x]['dialplan_detail_tag'] = 'action';
     //condition, action, antiaction
     $details[$x]['dialplan_detail_type'] = 'answer';
     $details[$x]['dialplan_detail_data'] = '';
     $details[$x]['dialplan_detail_order'] = '010';
     $x++;
     $details[$x]['dialplan_detail_tag'] = 'action';
     //condition, action, antiaction
     $details[$x]['dialplan_detail_type'] = 'sleep';
     $details[$x]['dialplan_detail_data'] = '1000';
     $details[$x]['dialplan_detail_order'] = '015';
     $x++;
     $details[$x]['dialplan_detail_tag'] = 'action';
     //condition, action, antiaction
     $details[$x]['dialplan_detail_type'] = 'set';
     $details[$x]['dialplan_detail_data'] = 'hangup_after_bridge=true';
     $details[$x]['dialplan_detail_order'] = '020';
     $x++;
     $details[$x]['dialplan_detail_tag'] = 'action';
     //condition, action, antiaction
     $details[$x]['dialplan_detail_type'] = 'set';
     if ($field['ivr_menu_ringback'] == "music" || $field['ivr_menu_ringback'] == "") {
         $details[$x]['dialplan_detail_data'] = 'ringback=${hold_music}';
     } else {
         $details[$x]['dialplan_detail_data'] = 'ringback=' . $field['ivr_menu_ringback'];
     }
     $details[$x]['dialplan_detail_order'] = '025';
     $x++;
     $details[$x]['dialplan_detail_tag'] = 'action';
     //condition, action, antiaction
     $details[$x]['dialplan_detail_type'] = 'set';
     if ($field['ivr_menu_ringback'] == "music" || $field['ivr_menu_ringback'] == "") {
         $details[$x]['dialplan_detail_data'] = 'transfer_ringback=${hold_music}';
     } else {
         $details[$x]['dialplan_detail_data'] = 'transfer_ringback=' . $field['ivr_menu_ringback'];
     }
     $details[$x]['dialplan_detail_order'] = '030';
     $x++;
     $details[$x]['dialplan_detail_tag'] = 'action';
     //condition, action, antiaction
     $details[$x]['dialplan_detail_type'] = 'set';
     $details[$x]['dialplan_detail_data'] = 'ivr_menu_uuid=' . $this->ivr_menu_uuid;
     $details[$x]['dialplan_detail_order'] = '035';
     $x++;
     $details[$x]['dialplan_detail_tag'] = 'action';
     //condition, action, antiaction
     if ($_SESSION['ivr menu']['application']['text'] == "lua") {
         $details[$x]['dialplan_detail_type'] = 'lua';
         $details[$x]['dialplan_detail_data'] = 'ivr_menu.lua';
     } else {
         $details[$x]['dialplan_detail_type'] = 'ivr';
         $details[$x]['dialplan_detail_data'] = $this->ivr_menu_uuid;
     }
     $details[$x]['dialplan_detail_order'] = '040';
     if (strlen($field['ivr_menu_exit_app']) > 0) {
         $x++;
         $details[$x]['dialplan_detail_tag'] = 'action';
         //condition, action, antiaction
         $details[$x]['dialplan_detail_type'] = $field['ivr_menu_exit_app'];
         $details[$x]['dialplan_detail_data'] = $field['ivr_menu_exit_data'];
         $details[$x]['dialplan_detail_order'] = '045';
         $x++;
     }
     //build the array
     $array['domain_uuid'] = $field['domain_uuid'];
     $array['dialplan_uuid'] = $field['dialplan_uuid'];
     $array['dialplan_name'] = $field['ivr_menu_name'];
     $array['dialplan_order'] = '333';
     $array['dialplan_context'] = $_SESSION['context'];
     $array['dialplan_enabled'] = $field['ivr_menu_enabled'];
     $array['dialplan_description'] = $field['ivr_menu_description'];
     $array['app_uuid'] = $this->app_uuid;
     $x = 0;
     foreach ($details as $row) {
         //find the matching uuid
         /*
         foreach ($dialplan_details as $database) {
         	if ($database['dialplan_detail_tag'] == $row['dialplan_detail_tag']
         		&& $database['dialplan_detail_type'] == $row['dialplan_detail_type']
         		&& $database['dialplan_detail_data'] == $row['dialplan_detail_data']) {
         			$array['dialplan_details'][$x]['dialplan_detail_uuid'] = $database['dialplan_detail_uuid'];
         	}
         }
         */
         //add to the array
         $array['dialplan_details'][$x]['domain_uuid'] = $field['domain_uuid'];
         $array['dialplan_details'][$x]['dialplan_uuid'] = $field['dialplan_uuid'];
         $array['dialplan_details'][$x]['dialplan_detail_tag'] = $row['dialplan_detail_tag'];
         $array['dialplan_details'][$x]['dialplan_detail_type'] = $row['dialplan_detail_type'];
         $array['dialplan_details'][$x]['dialplan_detail_data'] = $row['dialplan_detail_data'];
         $array['dialplan_details'][$x]['dialplan_detail_order'] = $row['dialplan_detail_order'];
         //increment the row
         $x++;
     }
     //debug
     //echo "<pre>\n";
     //print_r($dialplan_details);
     //print_r($array);
     //echo "</pre>\n";
     //exit;
     //save the dialplan
     $orm = new orm();
     $orm->name('dialplans');
     $orm->save($array);
     $response = $orm->message;
     if (strlen($response['uuid']) > 0) {
         $this->dialplan_uuid = $response['uuid'];
     }
     //debug
     //echo "<pre>\n";
     //print_r($response);
     //echo "</pre>\n";
     //exit;
     //synchronize the xml config
     save_dialplan_xml();
     //delete the dialplan context from memcache
     //$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
     //if ($fp) {
     //	$switch_cmd .= "memcache delete dialplan:".$_SESSION["context"]."@".$_SESSION['domain_name'];
     //	$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
     //}
 }
예제 #11
0
 /**
  * settings Set switch directories in default settings
  */
 public function settings()
 {
     //define the variables
     if (!isset($this->event_socket_ip_address)) {
         $this->event_socket_ip_address = $_SESSION['event_socket_ip_address'];
     }
     if (!isset($this->event_socket_port)) {
         $this->event_socket_port = $_SESSION['event_socket_port'];
     }
     if (!isset($this->event_socket_password)) {
         $this->event_socket_password = $_SESSION['event_socket_password'];
     }
     //connect to event socket
     $esl = new event_socket();
     $esl->connect($this->event_socket_ip_address, $this->event_socket_port, $this->event_socket_password);
     //run the api command
     $result = $esl->request('api global_getvar');
     //close event socket
     fclose($fp);
     //set the result as a named array
     $vars = array();
     foreach (explode("\n", $result) as $row) {
         $a = explode("=", $row);
         if (substr($a[0], -4) == "_dir") {
             $vars[$a[0]] = $a[1];
         }
     }
     //set the bin directory
     if ($vars['base_dir'] == "/usr/local/freeswitch") {
         $bin = "/usr/local/freeswitch/bin";
     } else {
         $bin = "";
     }
     //create the default settings array
     $x = 0;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'bin';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $bin;
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'base';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['base_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'call_center';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['conf_dir'] . '/autoload_configs';
     $array[$x]['default_setting_enabled'] = 'false';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'conf';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['conf_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'db';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['db_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'dialplan';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['conf_dir'] . '/dialplan';
     $array[$x]['default_setting_enabled'] = 'false';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'extensions';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['conf_dir'] . '/directory';
     $array[$x]['default_setting_enabled'] = 'false';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'grammar';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['grammar_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'log';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['log_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'mod';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['mod_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'phrases';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['conf_dir'] . '/lang';
     $array[$x]['default_setting_enabled'] = 'false';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'recordings';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['recordings_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'scripts';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['script_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'sip_profiles';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['conf_dir'] . '/sip_profiles';
     $array[$x]['default_setting_enabled'] = 'false';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'sounds';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['sounds_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'storage';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['storage_dir'];
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     $array[$x]['default_setting_category'] = 'switch';
     $array[$x]['default_setting_subcategory'] = 'voicemail';
     $array[$x]['default_setting_name'] = 'dir';
     $array[$x]['default_setting_value'] = $vars['storage_dir'] . '/voicemail';
     $array[$x]['default_setting_enabled'] = 'true';
     $array[$x]['default_setting_description'] = '';
     $x++;
     //get an array of the default settings
     $sql = "select * from v_default_settings ";
     $sql .= "where default_setting_category = 'switch' ";
     $prep_statement = $this->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_subcategory']) == trim($setting['default_setting_subcategory'])) {
                 $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
         $orm = new orm();
         $orm->name('default_settings');
         $orm->save($row);
         $message = $orm->message;
         unset($orm);
         //print_r($message);
     }
     unset($missing);
     //set the default settings
     foreach ($array as $row) {
         if (!isset($_SESSION['switch'][$row['default_setting_subcategory']])) {
             if ($row['default_setting_enabled'] != "false") {
                 $_SESSION['switch'][$row['default_setting_subcategory']] = $row['default_setting_value'];
             }
         }
     }
     //unset the array variable
     unset($array);
 }