header("Location: time_condition_edit.php?id=" . $dialplan_uuid . ($app_uuid != '' ? "&app_uuid=" . $app_uuid : null));
    return;
}
//end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//get existing data to pre-populate form
if ($dialplan_uuid != '' && $_POST["persistformvar"] != "true") {
    //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');
    //get main dialplan entry
    $orm = new orm();
    $orm->name('dialplans');
    $orm->uuid($dialplan_uuid);
    $result = $orm->find()->get();
    //$message = $orm->message;
    foreach ($result as &$row) {
        $domain_uuid = $row["domain_uuid"];
        //$app_uuid = $row["app_uuid"];
        $dialplan_name = $row["dialplan_name"];
        $dialplan_number = $row["dialplan_number"];
        $dialplan_order = $row["dialplan_order"];
        $dialplan_continue = $row["dialplan_continue"];
        $dialplan_context = $row["dialplan_context"];
        $dialplan_enabled = $row["dialplan_enabled"];
        $dialplan_description = $row["dialplan_description"];
    }
    unset($prep_statement);
    //remove the temporary permission
Exemple #2
0
         //unset the empty row
         if (strlen($_POST["ring_group_destinations"][$x]["destination_number"]) == 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
            $_SESSION["message"] = $text['message-update'];
        }
        header("Location: destination_edit.php?id=" . $destination_uuid);
        return;
    }
    //if ($_POST["persistformvar"] != "true")
}
//(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0)
//initialize the destinations object
$destination = new destinations();
//pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
    $destination_uuid = $_GET["id"];
    $orm = new orm();
    $orm->name('destinations');
    $orm->uuid($destination_uuid);
    $result = $orm->find()->get();
    foreach ($result as &$row) {
        $domain_uuid = $row["domain_uuid"];
        $dialplan_uuid = $row["dialplan_uuid"];
        $destination_type = $row["destination_type"];
        $destination_number = $row["destination_number"];
        $destination_caller_id_name = $row["destination_caller_id_name"];
        $destination_caller_id_number = $row["destination_caller_id_number"];
        $destination_cid_name_prefix = $row["destination_cid_name_prefix"];
        $destination_context = $row["destination_context"];
        $fax_uuid = $row["fax_uuid"];
        $destination_enabled = $row["destination_enabled"];
        $destination_description = $row["destination_description"];
        $currency = $row["currency"];
        $destination_sell = $row["destination_sell"];
            $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);
    }
}
Exemple #5
0
                    $_SESSION['message'] = $text['message-update'];
                }
                //redirect the browser
                header("Location: device_edit.php?id={$device_uuid}");
                exit;
            }
        }
    }
    //if ($_POST["persistformvar"] != "true")
}
//(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
    $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"];
        $domain_uuid = $row["domain_uuid"];
        $device_label = $row["device_label"];
        //$device_mac_address = substr($device_mac_address, 0,2).'-'.substr($device_mac_address, 2,2).'-'.substr($device_mac_address, 4,2).'-'.substr($device_mac_address, 6,2).'-'.substr($device_mac_address, 8,2).'-'.substr($device_mac_address, 10,2);
        $device_label = $row["device_label"];
        $device_username = $row["device_username"];
        $device_password = $row["device_password"];
        $device_vendor = $row["device_vendor"];
        $device_uuid_alternate = $row["device_uuid_alternate"];
        $device_model = $row["device_model"];
        $device_firmware_version = $row["device_firmware_version"];
        $device_enabled = $row["device_enabled"];
                    $_SESSION['message'] = $text['message-update'];
                }
                //redirect the browser
                header("Location: device_profile_edit.php?id=" . $device_profile_uuid);
                exit;
            }
        }
    }
    //if ($_POST["persistformvar"] != "true")
}
//(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
    $orm = new orm();
    $orm->name('device_profiles');
    $orm->uuid($device_profile_uuid);
    $result = $orm->find()->get();
    //$message = $orm->message;
    foreach ($result as &$row) {
        $device_profile_name = $row["device_profile_name"];
        $device_profile_domain_uuid = $row["domain_uuid"];
        $device_profile_enabled = $row["device_profile_enabled"];
        $device_profile_description = $row["device_profile_description"];
    }
    unset($prep_statement);
}
//set the sub array index
$x = "999";
//get device keys
$sql = "SELECT * FROM v_device_keys ";
$sql .= "WHERE device_profile_uuid = '" . $device_profile_uuid . "' ";
if (count($_GET) > 0) {
    $id = check_str($_GET["id"]);
}
//if the ID is not set then exit
if (!isset($id)) {
    echo "ID is required.";
    exit;
}
//add the dialplan permission
$permission = "dialplan_delete";
$p = new permissions();
$p->add($permission, 'temp');
//get the dialplan_uuid
$orm = new orm();
$orm->name('destinations');
$orm->uuid($id);
$result = $orm->find()->get();
foreach ($result as &$row) {
    if (permission_exists('destination_domain')) {
        $domain_uuid = $row["domain_uuid"];
    }
    $dialplan_uuid = $row["dialplan_uuid"];
    $destination_context = $row["destination_context"];
}
unset($prep_statement);
//remove the temporary permission
$p->delete($permission, 'temp');
//start the atomic transaction
$db->beginTransaction();
//delete the dialplan
if (isset($dialplan_uuid)) {
Exemple #8
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()
 {
     //check to see if the dialplan exists
     if (strlen($this->dialplan_uuid) > 0) {
         $sql = "select dialplan_uuid, dialplan_name, dialplan_description from v_dialplans ";
         $sql .= "where dialplan_uuid = '" . $this->dialplan_uuid . "' ";
         $sql .= "and domain_uuid = '" . $this->domain_uuid . "' ";
         $prep_statement = $this->db->prepare($sql);
         if ($prep_statement) {
             $prep_statement->execute();
             $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
             if (is_array($row)) {
                 //results found
                 $dialplan_name = $row['dialplan_name'];
                 $dialplan_description = $row['dialplan_description'];
             } else {
                 //no results
                 unset($this->dialplan_uuid);
                 $sql = "update v_call_center_queues ";
                 $sql .= "set dialplan_uuid = null ";
                 $sql .= "where call_center_queue_uuid = '" . $this->call_center_queue_uuid . "' ";
                 $sql .= "and domain_uuid = '" . $this->domain_uuid . "' ";
                 //echo $sql."<br />\n";
                 //exit;
                 $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;
     //delete the previous dialplan
     if (strlen($this->dialplan_uuid) > 0) {
         $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);
     }
     //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');
     if (strlen($this->dialplan_uuid) > 0) {
         $orm->uuid($this->dialplan_uuid);
     }
     $orm->save($dialplan);
     $dialplan_response = $orm->message;
     //if new dialplan uuid then update the call center queue
     if (strlen($this->dialplan_uuid) == 0) {
         $this->dialplan_uuid = $dialplan_response['uuid'];
         $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;
 }
Exemple #9
0
 public function save($array)
 {
     //action add or update
     if (strlen($this->ivr_menu_uuid) == 0) {
         $action = "add";
     } else {
         $action = "update";
     }
     //add or update the dialplan
     $this->dialplan($array);
     $array['dialplan_uuid'] = $this->dialplan_uuid;
     //save the ivr_menus
     $orm = new orm();
     $orm->name('ivr_menus');
     if (strlen($this->ivr_menu_uuid) > 0) {
         $orm->uuid($this->ivr_menu_uuid);
     }
     $orm->save($array);
     $this->ivr_menu_uuid = $orm->message['uuid'];
     //update dialplan with the ivr_menu_uuid
     if ($action == "add") {
         $array['ivr_menu_uuid'] = $this->ivr_menu_uuid;
         $this->dialplan($array);
     }
     //set the add message
     if ($action == "add" && permission_exists('ivr_menu_add')) {
         $_SESSION['message'] = $text['message-add'];
     }
     //set the update message
     if ($action == "update" && permission_exists('ivr_menu_edit')) {
         $_SESSION['message'] = $text['message-update'];
     }
     //return the result
     return $orm->message;
 }