mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Bridges: Integrate Action Bar, delete on edit.
This commit is contained in:
@@ -44,36 +44,158 @@ if (!class_exists('bridges')) {
|
||||
}
|
||||
|
||||
//delete multiple bridges
|
||||
if (is_array($bridges)) {
|
||||
//get the action
|
||||
foreach($bridges as $row) {
|
||||
if ($row['action'] == 'delete') {
|
||||
$action = 'delete';
|
||||
break;
|
||||
if (is_array($bridges) && @sizeof($bridges) != 0) {
|
||||
//delete the checked rows
|
||||
foreach($bridges as $x => $row) {
|
||||
if ($row['checked'] == 'true' && is_uuid($row['bridge_uuid'])) {
|
||||
$array['bridges'][$x]['bridge_uuid'] = $row['bridge_uuid'];
|
||||
$array['bridges'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
}
|
||||
//delete the checked rows
|
||||
if ($action == 'delete') {
|
||||
$database = new database;
|
||||
foreach($bridges as $x => $row) {
|
||||
if ($row['action'] == 'delete' or $row['checked'] == 'true') {
|
||||
$array['bridges'][$x]['bridge_uuid'] = $row['bridge_uuid'];
|
||||
$array['bridges'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
}
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'bridges';
|
||||
$database->app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
}
|
||||
unset($bridges);
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
}
|
||||
unset($bridges);
|
||||
}
|
||||
}
|
||||
} //end the delete function
|
||||
}
|
||||
|
||||
} //end the class
|
||||
/**
|
||||
* toggle bridges
|
||||
*/
|
||||
public function toggle($bridges) {
|
||||
if (permission_exists('bridge_edit')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: bridges.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
//toggle the checked bridges
|
||||
if (is_array($bridges) && @sizeof($bridges) != 0) {
|
||||
//get current enabled state of checked bridges
|
||||
foreach($bridges as $x => $row) {
|
||||
if ($row['checked'] == 'true' && is_uuid($row['bridge_uuid'])) {
|
||||
$bridge_uuids[] = "bridge_uuid = '".$row['bridge_uuid']."'";
|
||||
}
|
||||
}
|
||||
if (is_array($bridge_uuids) && @sizeof($bridge_uuids) != 0) {
|
||||
$sql = "select bridge_uuid, bridge_enabled from v_bridges ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and ( ".implode(' or ', $bridge_uuids)." ) ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$bridge_states[$row['bridge_uuid']] = $row['bridge_enabled'];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//build update array
|
||||
$x = 0;
|
||||
foreach($bridge_states as $bridge_uuid => $bridge_state) {
|
||||
$array['bridges'][$x]['bridge_uuid'] = $bridge_uuid;
|
||||
$array['bridges'][$x]['bridge_enabled'] = $bridge_state == 'true' ? 'false' : 'true';
|
||||
$x++;
|
||||
}
|
||||
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//execute update
|
||||
$database = new database;
|
||||
$database->app_name = 'bridges';
|
||||
$database->app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
//set message
|
||||
message::add($text['message-update']);
|
||||
}
|
||||
unset($bridges, $bridge_states);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* copy bridges
|
||||
*/
|
||||
public function copy($bridges) {
|
||||
if (permission_exists('bridge_add')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: bridges.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
//copy the checked bridges
|
||||
if (is_array($bridges) && @sizeof($bridges) != 0) {
|
||||
|
||||
//get checked bridges
|
||||
foreach($bridges as $x => $row) {
|
||||
if ($row['checked'] == 'true' && is_uuid($row['bridge_uuid'])) {
|
||||
$bridge_uuids[] = "bridge_uuid = '".$row['bridge_uuid']."'";
|
||||
}
|
||||
}
|
||||
//create insert array from existing data
|
||||
if (is_array($bridge_uuids) && @sizeof($bridge_uuids) != 0) {
|
||||
$sql = "select * from v_bridges ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and ( ".implode(' or ', $bridge_uuids)." ) ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $x => $row) {
|
||||
$array['bridges'][$x]['bridge_uuid'] = uuid();
|
||||
$array['bridges'][$x]['domain_uuid'] = $row['domain_uuid'];
|
||||
$array['bridges'][$x]['bridge_name'] = $row['bridge_name'];
|
||||
$array['bridges'][$x]['bridge_destination'] = $row['bridge_destination'];
|
||||
$array['bridges'][$x]['bridge_enabled'] = $row['bridge_enabled'];
|
||||
$array['bridges'][$x]['bridge_description'] = trim($row['bridge_description'].' ('.$text['label-copy'].')');
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
//execute insert
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
$database = new database;
|
||||
$database->app_name = 'bridges';
|
||||
$database->app_uuid = 'a6a7c4c5-340a-43ce-bcbc-2ed9bab8659d';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
//set message
|
||||
message::add($text['message-copy']);
|
||||
}
|
||||
unset($bridges);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -81,4 +203,4 @@ $obj = new bridges;
|
||||
$obj->delete();
|
||||
*/
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user