Update conference_edit.php
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//get http post variables and set them to php variables
|
//get http post variables and set them to php variables
|
||||||
if (count($_POST)>0) {
|
if (count($_POST) > 0) {
|
||||||
$dialplan_uuid = $_POST["dialplan_uuid"];
|
$dialplan_uuid = $_POST["dialplan_uuid"];
|
||||||
$conference_name = $_POST["conference_name"];
|
$conference_name = $_POST["conference_name"];
|
||||||
$conference_extension = $_POST["conference_extension"];
|
$conference_extension = $_POST["conference_extension"];
|
||||||
@@ -65,7 +65,6 @@
|
|||||||
|
|
||||||
//sanitize the conference name
|
//sanitize the conference name
|
||||||
$conference_name = preg_replace("/[^A-Za-z0-9\- ]/", "", $conference_name);
|
$conference_name = preg_replace("/[^A-Za-z0-9\- ]/", "", $conference_name);
|
||||||
$conference_name = str_replace(" ", "-", $conference_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete the user from the v_conference_users
|
//delete the user from the v_conference_users
|
||||||
@@ -120,16 +119,17 @@
|
|||||||
|
|
||||||
//send a message
|
//send a message
|
||||||
message::add($text['confirm-add']);
|
message::add($text['confirm-add']);
|
||||||
header("Location: conference_edit.php?id=".$conference_uuid);
|
header("Location: conference_edit.php?id=".urlencode($conference_uuid));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//process http post variables
|
//process http post variables
|
||||||
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||||
|
|
||||||
if ($action == "update") {
|
//get the conference id
|
||||||
$conference_uuid = $_POST["conference_uuid"];
|
if ($action == "update") {
|
||||||
}
|
$conference_uuid = $_POST["conference_uuid"];
|
||||||
|
}
|
||||||
|
|
||||||
//check for all required data
|
//check for all required data
|
||||||
$msg = '';
|
$msg = '';
|
||||||
@@ -157,157 +157,65 @@
|
|||||||
|
|
||||||
//add or update the database
|
//add or update the database
|
||||||
if ($_POST["persistformvar"] != "true") {
|
if ($_POST["persistformvar"] != "true") {
|
||||||
if ($action == "add") {
|
|
||||||
//prepare the uuids
|
|
||||||
$conference_uuid = uuid();
|
|
||||||
$dialplan_uuid = uuid();
|
|
||||||
//add the conference
|
|
||||||
$array['conferences'][0]['domain_uuid'] = $domain_uuid;
|
|
||||||
$array['conferences'][0]['conference_uuid'] = $conference_uuid;
|
|
||||||
$array['conferences'][0]['dialplan_uuid'] = $dialplan_uuid;
|
|
||||||
$array['conferences'][0]['conference_name'] = $conference_name;
|
|
||||||
$array['conferences'][0]['conference_extension'] = $conference_extension;
|
|
||||||
$array['conferences'][0]['conference_pin_number'] = $conference_pin_number;
|
|
||||||
$array['conferences'][0]['conference_profile'] = $conference_profile;
|
|
||||||
$array['conferences'][0]['conference_flags'] = $conference_flags;
|
|
||||||
$array['conferences'][0]['conference_order'] = $conference_order;
|
|
||||||
$array['conferences'][0]['conference_description'] = $conference_description;
|
|
||||||
$array['conferences'][0]['conference_enabled'] = $conference_enabled;
|
|
||||||
|
|
||||||
$database = new database;
|
//update the conference extension
|
||||||
$database->app_name = 'conferences';
|
$array['conferences'][0]['domain_uuid'] = $domain_uuid;
|
||||||
$database->app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9';
|
$array['conferences'][0]['conference_uuid'] = $conference_uuid;
|
||||||
$database->save($array);
|
$array['conferences'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||||
$response = $database->message;
|
$array['conferences'][0]['conference_name'] = $conference_name;
|
||||||
unset($array);
|
$array['conferences'][0]['conference_extension'] = $conference_extension;
|
||||||
|
$array['conferences'][0]['conference_pin_number'] = $conference_pin_number;
|
||||||
|
$array['conferences'][0]['conference_profile'] = $conference_profile;
|
||||||
|
$array['conferences'][0]['conference_flags'] = $conference_flags;
|
||||||
|
$array['conferences'][0]['conference_order'] = $conference_order;
|
||||||
|
$array['conferences'][0]['conference_description'] = $conference_description;
|
||||||
|
$array['conferences'][0]['conference_enabled'] = $conference_enabled;
|
||||||
|
|
||||||
//create the dialplan entry
|
//build the xml
|
||||||
$dialplan_name = $conference_name;
|
$dialplan_xml = "<extension name=\"".$conference_name."\" continue=\"\" uuid=\"".$dialplan_uuid."\">\n";
|
||||||
$dialplan_order ='333';
|
$dialplan_xml .= " <condition field=\"destination_number\" expression=\"^".$conference_extension."\">\n";
|
||||||
$dialplan_context = $_SESSION['context'];
|
$dialplan_xml .= " <action application=\"answer\" data=\"\"/>\n";
|
||||||
$dialplan_enabled = 'true';
|
$dialplan_xml .= " <action application=\"conference\" data=\"".$conference_uuid."@".$_SESSION['domain_name']."@default+flags{'".$conference_flags."}\"/>\n";
|
||||||
$dialplan_description = $conference_description;
|
$dialplan_xml .= " </condition>\n";
|
||||||
$app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9';
|
$dialplan_xml .= "</extension>\n";
|
||||||
dialplan_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid);
|
|
||||||
|
|
||||||
//<condition destination_number="500" />
|
//update the conference dialplan
|
||||||
$dialplan_detail_tag = 'condition'; //condition, action, antiaction
|
$array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||||
$dialplan_detail_type = 'destination_number';
|
$array['dialplans'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
$dialplan_detail_data = '^(conf\+)?'.$conference_extension.'$';
|
$array['dialplans'][0]['dialplan_name'] = $conference_name;
|
||||||
$dialplan_detail_order = '000';
|
$array['dialplans'][0]['dialplan_number'] = $conference_extension;
|
||||||
$dialplan_detail_group = '2';
|
$array['dialplans'][0]['dialplan_xml'] = $dialplan_xml;
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
if (strlen($dialplan_order) > 0) {
|
||||||
|
$array['dialplans'][0]['dialplan_order'] = '333';
|
||||||
|
}
|
||||||
|
$array['dialplans'][0]['dialplan_context'] = $_SESSION['context'];
|
||||||
|
$array['dialplans'][0]['dialplan_enabled'] = 'true';
|
||||||
|
$array['dialplans'][0]['dialplan_description'] = $conference_description;
|
||||||
|
|
||||||
//<action application="answer" />
|
$p = new permissions;
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$p->add('dialplan_edit', 'temp');
|
||||||
$dialplan_detail_type = 'answer';
|
|
||||||
$dialplan_detail_data = '';
|
|
||||||
$dialplan_detail_order = '010';
|
|
||||||
$dialplan_detail_group = '2';
|
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
|
||||||
|
|
||||||
//<action application="answer" />
|
$database = new database;
|
||||||
$dialplan_detail_tag = 'action'; //condition, action, antiaction
|
$database->app_name = 'conferences';
|
||||||
$dialplan_detail_type = 'conference';
|
$database->app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9';
|
||||||
$pin_number = ''; if (strlen($conference_pin_number) > 0) { $pin_number = "+".$conference_pin_number; }
|
$database->save($array);
|
||||||
$flags = ''; if (strlen($conference_flags) > 0) { $flags = "+flags{".$conference_flags."}"; }
|
$response = $database->message;
|
||||||
$dialplan_detail_data = $conference_name.'@'.$_SESSION['domain_name']."@".$conference_profile.$pin_number.$flags;
|
unset($array);
|
||||||
$dialplan_detail_order = '020';
|
|
||||||
$dialplan_detail_group = '2';
|
|
||||||
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
|
|
||||||
|
|
||||||
//add the message
|
$p->delete('dialplan_edit', 'temp');
|
||||||
message::add($text['confirm-add']);
|
|
||||||
} //if ($action == "add")
|
|
||||||
|
|
||||||
if ($action == "update") {
|
//delete the dialplan details
|
||||||
//update the conference extension
|
$sql = "delete from v_dialplan_details ";
|
||||||
$array['conferences'][0]['domain_uuid'] = $domain_uuid;
|
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||||
$array['conferences'][0]['conference_uuid'] = $conference_uuid;
|
//$sql .= "and domain_uuid = :domain_uuid ";
|
||||||
$array['conferences'][0]['dialplan_uuid'] = $dialplan_uuid;
|
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
$array['conferences'][0]['conference_name'] = $conference_name;
|
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||||
$array['conferences'][0]['conference_extension'] = $conference_extension;
|
$database = new database;
|
||||||
$array['conferences'][0]['conference_pin_number'] = $conference_pin_number;
|
$database->execute($sql, $parameters);
|
||||||
$array['conferences'][0]['conference_profile'] = $conference_profile;
|
unset($sql, $parameters);
|
||||||
$array['conferences'][0]['conference_flags'] = $conference_flags;
|
|
||||||
$array['conferences'][0]['conference_order'] = $conference_order;
|
|
||||||
$array['conferences'][0]['conference_description'] = $conference_description;
|
|
||||||
$array['conferences'][0]['conference_enabled'] = $conference_enabled;
|
|
||||||
|
|
||||||
$database = new database;
|
//add the message
|
||||||
$database->app_name = 'conferences';
|
message::add($text['confirm-update']);
|
||||||
$database->app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9';
|
|
||||||
$database->save($array);
|
|
||||||
$response = $database->message;
|
|
||||||
unset($array);
|
|
||||||
|
|
||||||
//update the conference dialplan
|
|
||||||
$array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
|
|
||||||
$array['dialplans'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
||||||
$array['dialplans'][0]['dialplan_name'] = $conference_name;
|
|
||||||
if (strlen($dialplan_order) > 0) {
|
|
||||||
$array['dialplans'][0]['dialplan_order'] = '333';
|
|
||||||
}
|
|
||||||
$array['dialplans'][0]['dialplan_context'] = $_SESSION['context'];
|
|
||||||
$array['dialplans'][0]['dialplan_enabled'] = 'true';
|
|
||||||
$array['dialplans'][0]['dialplan_description'] = $conference_description;
|
|
||||||
|
|
||||||
$p = new permissions;
|
|
||||||
$p->add('dialplan_edit', 'temp');
|
|
||||||
|
|
||||||
$database = new database;
|
|
||||||
$database->app_name = 'conferences';
|
|
||||||
$database->app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9';
|
|
||||||
$database->save($array);
|
|
||||||
$response = $database->message;
|
|
||||||
unset($array);
|
|
||||||
|
|
||||||
$p->delete('dialplan_edit', 'temp');
|
|
||||||
|
|
||||||
//update dialplan detail condition
|
|
||||||
$sql = "update v_dialplan_details set ";
|
|
||||||
$sql .= "dialplan_detail_data = :dialplan_detail_data ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$sql .= "and dialplan_detail_tag = 'condition' ";
|
|
||||||
$sql .= "and dialplan_detail_type = 'destination_number' ";
|
|
||||||
$sql .= "and dialplan_uuid = :dialplan_uuid ";
|
|
||||||
$parameters['dialplan_detail_data'] = '^'.$conference_extension.'$';
|
|
||||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
||||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
|
|
||||||
//update dialplan detail action
|
|
||||||
$pin_number = strlen($conference_pin_number) > 0 ? '+'.$conference_pin_number : null;
|
|
||||||
$flags = strlen($conference_flags) > 0 ? '+flags{'.$conference_flags.'}' : null;
|
|
||||||
$dialplan_detail_data = $conference_uuid.'@'.$_SESSION['domain_name']."@".$conference_profile.$pin_number.$flags;
|
|
||||||
$sql = "update v_dialplan_details set ";
|
|
||||||
$sql .= "dialplan_detail_data = :dialplan_detail_data ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$sql .= "and dialplan_detail_tag = 'action' ";
|
|
||||||
$sql .= "and dialplan_detail_type = 'conference' ";
|
|
||||||
$sql .= "and dialplan_uuid = :dialplan_uuid ";
|
|
||||||
$parameters['dialplan_detail_data'] = $dialplan_detail_data;
|
|
||||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
||||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
|
|
||||||
//add the message
|
|
||||||
message::add($text['confirm-update']);
|
|
||||||
} //if ($action == "update")
|
|
||||||
|
|
||||||
//update the dialplan xml
|
|
||||||
$dialplans = new dialplan;
|
|
||||||
$dialplans->source = "details";
|
|
||||||
$dialplans->destination = "database";
|
|
||||||
$dialplans->uuid = $dialplan_uuid;
|
|
||||||
$dialplans->xml();
|
|
||||||
|
|
||||||
//save the xml
|
|
||||||
save_dialplan_xml();
|
|
||||||
|
|
||||||
//apply settings reminder
|
//apply settings reminder
|
||||||
$_SESSION["reload_xml"] = true;
|
$_SESSION["reload_xml"] = true;
|
||||||
@@ -318,7 +226,7 @@
|
|||||||
|
|
||||||
//redirect the browser
|
//redirect the browser
|
||||||
header("Location: conferences.php");
|
header("Location: conferences.php");
|
||||||
return;
|
exit;
|
||||||
|
|
||||||
} //if ($_POST["persistformvar"] != "true")
|
} //if ($_POST["persistformvar"] != "true")
|
||||||
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user