Updates to Access Controls, Bridges, and Call Block.
This commit is contained in:
@@ -9,14 +9,34 @@ if (!class_exists('call_block')) {
|
||||
class call_block {
|
||||
|
||||
/**
|
||||
* Called when the object is created
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $table;
|
||||
private $uuid_prefix;
|
||||
private $enabled_prefix;
|
||||
|
||||
/**
|
||||
* called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = 'call_block';
|
||||
$this->app_uuid = '9ed63276-e085-4897-839c-4f2e36d92d6c';
|
||||
$this->permission_prefix = 'call_block';
|
||||
$this->list_page = 'call_block.php';
|
||||
$this->table = 'call_block';
|
||||
$this->uuid_prefix = 'call_block_';
|
||||
$this->enabled_prefix = 'call_block_';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when there are no references to a particular object
|
||||
* called when there are no references to a particular object
|
||||
* unset the variables used in the class
|
||||
*/
|
||||
public function __destruct() {
|
||||
@@ -26,10 +46,10 @@ if (!class_exists('call_block')) {
|
||||
}
|
||||
|
||||
/**
|
||||
* delete call block
|
||||
* delete records
|
||||
*/
|
||||
public function delete($call_blocks) {
|
||||
if (permission_exists('call_block_delete')) {
|
||||
public function delete($records) {
|
||||
if (permission_exists($this->permission_prefix.'_delete')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
@@ -39,40 +59,44 @@ if (!class_exists('call_block')) {
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: call_block.php');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple call blocks
|
||||
if (is_array($call_blocks) && @sizeof($call_blocks) != 0) {
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//build the delete array
|
||||
foreach($call_blocks as $x => $row) {
|
||||
if ($row['checked'] == 'true' && is_uuid($row['call_block_uuid'])) {
|
||||
$array['call_block'][$x]['call_block_uuid'] = $row['call_block_uuid'];
|
||||
$array['call_block'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'call_block';
|
||||
$database->app_uuid = '9ed63276-e085-4897-839c-4f2e36d92d6c';
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
}
|
||||
unset($call_blocks);
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toggle call block
|
||||
* toggle records
|
||||
*/
|
||||
public function toggle($call_blocks) {
|
||||
if (permission_exists('call_block_edit')) {
|
||||
public function toggle($records) {
|
||||
if (permission_exists($this->permission_prefix.'_edit')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
@@ -82,28 +106,29 @@ if (!class_exists('call_block')) {
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: call_block.php');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//toggle the checked call blocks
|
||||
if (is_array($call_blocks) && @sizeof($call_blocks) != 0) {
|
||||
//get current enabled state of checked call block
|
||||
foreach($call_blocks as $x => $row) {
|
||||
if ($row['checked'] == 'true' && is_uuid($row['call_block_uuid'])) {
|
||||
$call_block_uuids[] = "call_block_uuid = '".$row['call_block_uuid']."'";
|
||||
//toggle the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//get current enabled state
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
if (is_array($call_block_uuids) && @sizeof($call_block_uuids) != 0) {
|
||||
$sql = "select call_block_uuid, call_block_enabled from v_call_block ";
|
||||
if (is_array($record_uuids) && @sizeof($record_uuids) != 0) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->enabled_prefix."enabled as enabled from v_".$this->table." ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and ( ".implode(' or ', $call_block_uuids)." ) ";
|
||||
$sql .= "and ( ".implode(' or ', $record_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) {
|
||||
$call_block_states[$row['call_block_uuid']] = $row['call_block_enabled'];
|
||||
$states[$row['uuid']] = $row['enabled'];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
@@ -111,34 +136,36 @@ if (!class_exists('call_block')) {
|
||||
|
||||
//build update array
|
||||
$x = 0;
|
||||
foreach($call_block_states as $call_block_uuid => $call_block_state) {
|
||||
$array['call_block'][$x]['call_block_uuid'] = $call_block_uuid;
|
||||
$array['call_block'][$x]['call_block_enabled'] = $call_block_state == 'true' ? 'false' : 'true';
|
||||
foreach($states as $uuid => $state) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
|
||||
$array[$this->table][$x][$this->enabled_prefix.'enabled'] = $state == 'true' ? 'false' : 'true';
|
||||
$x++;
|
||||
}
|
||||
|
||||
//save the changes
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = 'call_block';
|
||||
$database->app_uuid = '9ed63276-e085-4897-839c-4f2e36d92d6c';
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//set message
|
||||
message::add($text['message-toggle']);
|
||||
}
|
||||
unset($call_blocks, $call_block_states);
|
||||
unset($records, $states);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* copy call blocks
|
||||
* copy records
|
||||
*/
|
||||
public function copy($call_blocks) {
|
||||
if (permission_exists('call_block_add')) {
|
||||
public function copy($records) {
|
||||
if (permission_exists($this->permission_prefix.'_add')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
@@ -148,55 +175,60 @@ if (!class_exists('call_block')) {
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: call_block.php');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//copy the checked call blocks
|
||||
if (is_array($call_blocks) && @sizeof($call_blocks) != 0) {
|
||||
//copy the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//get checked call blocks
|
||||
foreach($call_blocks as $x => $row) {
|
||||
if ($row['checked'] == 'true' && is_uuid($row['call_block_uuid'])) {
|
||||
$call_block_uuids[] = "call_block_uuid = '".$row['call_block_uuid']."'";
|
||||
//get checked records
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
|
||||
//create insert array from existing data
|
||||
if (is_array($call_block_uuids) && @sizeof($call_block_uuids) != 0) {
|
||||
$sql = "select * from v_call_block ";
|
||||
if (is_array($record_uuids) && @sizeof($record_uuids) != 0) {
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and ( ".implode(' or ', $call_block_uuids)." ) ";
|
||||
$sql .= "and ( ".implode(' or ', $record_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['call_block'][$x]['call_block_uuid'] = uuid();
|
||||
$array['call_block'][$x]['domain_uuid'] = $row['domain_uuid'];
|
||||
$array['call_block'][$x]['call_block_name'] = $row['call_block_name'];
|
||||
$array['call_block'][$x]['call_block_number'] = $row['call_block_number'];
|
||||
$array['call_block'][$x]['call_block_count'] = 0;
|
||||
$array['call_block'][$x]['call_block_action'] = $row['call_block_action'];
|
||||
$array['call_block'][$x]['date_added'] = $row['date_added'];
|
||||
$array['call_block'][$x]['call_block_enabled'] = $row['call_block_enabled'];
|
||||
$array['call_block'][$x]['call_block_description'] = trim($row['call_block_description'].' ('.$text['label-copy'].')');
|
||||
$new_uuid = uuid();
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $new_uuid;
|
||||
$array[$this->table][$x]['domain_uuid'] = $row['domain_uuid'];
|
||||
$array[$this->table][$x]['call_block_name'] = $row['call_block_name'];
|
||||
$array[$this->table][$x]['call_block_number'] = $row['call_block_number'];
|
||||
$array[$this->table][$x]['call_block_count'] = 0;
|
||||
$array[$this->table][$x]['call_block_action'] = $row['call_block_action'];
|
||||
$array[$this->table][$x]['date_added'] = $row['date_added'];
|
||||
$array[$this->table][$x]['call_block_enabled'] = $row['call_block_enabled'];
|
||||
$array[$this->table][$x]['call_block_description'] = trim($row['call_block_description'].' ('.$text['label-copy'].')');
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//save the changes and set the message
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = 'call_block';
|
||||
$database->app_uuid = '9ed63276-e085-4897-839c-4f2e36d92d6c';
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//set message
|
||||
message::add($text['message-copy']);
|
||||
|
||||
}
|
||||
unset($call_blocks);
|
||||
unset($records);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -205,9 +237,4 @@ if (!class_exists('call_block')) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$obj = new call_block;
|
||||
$obj->delete();
|
||||
*/
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user