format class for comments to be at the same tab stop (#7018)
Co-authored-by: Tim Fry <tim@fusionpbx.com>
This commit is contained in:
parent
3215f50826
commit
820a7231dc
|
|
@ -6,6 +6,7 @@
|
||||||
* @method null download
|
* @method null download
|
||||||
*/
|
*/
|
||||||
if (!class_exists('access_controls')) {
|
if (!class_exists('access_controls')) {
|
||||||
|
|
||||||
class access_controls {
|
class access_controls {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -24,10 +25,9 @@ if (!class_exists('access_controls')) {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
|
||||||
//assign private variables
|
//assign private variables
|
||||||
$this->app_name = 'access_controls';
|
$this->app_name = 'access_controls';
|
||||||
$this->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
|
$this->app_uuid = '1416a250-f6e1-4edc-91a6-5c9b883638fd';
|
||||||
$this->list_page = 'access_controls.php';
|
$this->list_page = 'access_controls.php';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -36,120 +36,120 @@ if (!class_exists('access_controls')) {
|
||||||
public function delete($records) {
|
public function delete($records) {
|
||||||
|
|
||||||
//assign private variables
|
//assign private variables
|
||||||
$this->permission_prefix = 'access_control_';
|
$this->permission_prefix = 'access_control_';
|
||||||
$this->table = 'access_controls';
|
$this->table = 'access_controls';
|
||||||
$this->uuid_prefix = 'access_control_';
|
$this->uuid_prefix = 'access_control_';
|
||||||
|
|
||||||
if (permission_exists($this->permission_prefix.'delete')) {
|
if (permission_exists($this->permission_prefix . 'delete')) {
|
||||||
|
|
||||||
//add multi-lingual support
|
//add multi-lingual support
|
||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get();
|
$text = $language->get();
|
||||||
|
|
||||||
//validate the token
|
//validate the token
|
||||||
$token = new token;
|
$token = new token;
|
||||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||||
message::add($text['message-invalid_token'],'negative');
|
message::add($text['message-invalid_token'], 'negative');
|
||||||
header('Location: '.$this->list_page);
|
header('Location: ' . $this->list_page);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete multiple records
|
//delete multiple records
|
||||||
if (is_array($records) && @sizeof($records) != 0) {
|
if (is_array($records) && @sizeof($records) != 0) {
|
||||||
|
|
||||||
//build the delete array
|
//build the delete array
|
||||||
foreach($records as $x => $record) {
|
foreach ($records as $x => $record) {
|
||||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
$array[$this->table][$x][$this->uuid_prefix . 'uuid'] = $record['uuid'];
|
||||||
$array['access_control_nodes'][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
$array['access_control_nodes'][$x][$this->uuid_prefix . 'uuid'] = $record['uuid'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//delete the checked rows
|
|
||||||
if (is_array($array) && @sizeof($array) != 0) {
|
|
||||||
|
|
||||||
//grant temporary permissions
|
|
||||||
$p = new permissions;
|
|
||||||
$p->add('access_control_node_delete', 'temp');
|
|
||||||
|
|
||||||
//execute delete
|
|
||||||
$database = new database;
|
|
||||||
$database->app_name = $this->app_name;
|
|
||||||
$database->app_uuid = $this->app_uuid;
|
|
||||||
$database->delete($array);
|
|
||||||
unset($array);
|
|
||||||
|
|
||||||
//revoke temporary permissions
|
|
||||||
$p->delete('access_control_node_delete', 'temp');
|
|
||||||
|
|
||||||
//clear the cache
|
|
||||||
$cache = new cache;
|
|
||||||
$cache->delete("configuration:acl.conf");
|
|
||||||
|
|
||||||
//create the event socket connection
|
|
||||||
event_socket::async("reloadacl");
|
|
||||||
|
|
||||||
//set message
|
|
||||||
message::add($text['message-delete']);
|
|
||||||
}
|
|
||||||
unset($records);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//delete the checked rows
|
||||||
|
if (is_array($array) && @sizeof($array) != 0) {
|
||||||
|
|
||||||
|
//grant temporary permissions
|
||||||
|
$p = new permissions;
|
||||||
|
$p->add('access_control_node_delete', 'temp');
|
||||||
|
|
||||||
|
//execute delete
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = $this->app_name;
|
||||||
|
$database->app_uuid = $this->app_uuid;
|
||||||
|
$database->delete($array);
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//revoke temporary permissions
|
||||||
|
$p->delete('access_control_node_delete', 'temp');
|
||||||
|
|
||||||
|
//clear the cache
|
||||||
|
$cache = new cache;
|
||||||
|
$cache->delete("configuration:acl.conf");
|
||||||
|
|
||||||
|
//create the event socket connection
|
||||||
|
event_socket::async("reloadacl");
|
||||||
|
|
||||||
|
//set message
|
||||||
|
message::add($text['message-delete']);
|
||||||
|
}
|
||||||
|
unset($records);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete_nodes($records) {
|
public function delete_nodes($records) {
|
||||||
|
|
||||||
//assign private variables
|
//assign private variables
|
||||||
$this->permission_prefix = 'access_control_node_';
|
$this->permission_prefix = 'access_control_node_';
|
||||||
$this->table = 'access_control_nodes';
|
$this->table = 'access_control_nodes';
|
||||||
$this->uuid_prefix = 'access_control_node_';
|
$this->uuid_prefix = 'access_control_node_';
|
||||||
|
|
||||||
if (permission_exists($this->permission_prefix.'delete')) {
|
if (permission_exists($this->permission_prefix . 'delete')) {
|
||||||
|
|
||||||
//add multi-lingual support
|
//add multi-lingual support
|
||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get();
|
$text = $language->get();
|
||||||
|
|
||||||
//validate the token
|
//validate the token
|
||||||
$token = new token;
|
$token = new token;
|
||||||
if (!$token->validate('/app/access_controls/access_control_nodes.php')) {
|
if (!$token->validate('/app/access_controls/access_control_nodes.php')) {
|
||||||
message::add($text['message-invalid_token'],'negative');
|
message::add($text['message-invalid_token'], 'negative');
|
||||||
header('Location: '.$this->list_page);
|
header('Location: ' . $this->list_page);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete multiple records
|
//delete multiple records
|
||||||
if (is_array($records) && @sizeof($records) != 0) {
|
if (is_array($records) && @sizeof($records) != 0) {
|
||||||
|
|
||||||
//build the delete array
|
//build the delete array
|
||||||
foreach($records as $x => $record) {
|
foreach ($records as $x => $record) {
|
||||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
$array[$this->table][$x][$this->uuid_prefix . 'uuid'] = $record['uuid'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//delete the checked rows
|
|
||||||
if (is_array($array) && @sizeof($array) != 0) {
|
|
||||||
|
|
||||||
//execute delete
|
|
||||||
$database = new database;
|
|
||||||
$database->app_name = $this->app_name;
|
|
||||||
$database->app_uuid = $this->app_uuid;
|
|
||||||
$database->delete($array);
|
|
||||||
unset($array);
|
|
||||||
|
|
||||||
//clear the cache
|
|
||||||
$cache = new cache;
|
|
||||||
$cache->delete("configuration:acl.conf");
|
|
||||||
|
|
||||||
//create the event socket connection
|
|
||||||
event_socket::async("reloadacl");
|
|
||||||
|
|
||||||
//set message
|
|
||||||
message::add($text['message-delete']);
|
|
||||||
}
|
|
||||||
unset($records);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//delete the checked rows
|
||||||
|
if (is_array($array) && @sizeof($array) != 0) {
|
||||||
|
|
||||||
|
//execute delete
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = $this->app_name;
|
||||||
|
$database->app_uuid = $this->app_uuid;
|
||||||
|
$database->delete($array);
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//clear the cache
|
||||||
|
$cache = new cache;
|
||||||
|
$cache->delete("configuration:acl.conf");
|
||||||
|
|
||||||
|
//create the event socket connection
|
||||||
|
event_socket::async("reloadacl");
|
||||||
|
|
||||||
|
//set message
|
||||||
|
message::add($text['message-delete']);
|
||||||
|
}
|
||||||
|
unset($records);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,115 +159,111 @@ if (!class_exists('access_controls')) {
|
||||||
public function copy($records) {
|
public function copy($records) {
|
||||||
|
|
||||||
//assign private variables
|
//assign private variables
|
||||||
$this->permission_prefix = 'access_control_';
|
$this->permission_prefix = 'access_control_';
|
||||||
$this->table = 'access_controls';
|
$this->table = 'access_controls';
|
||||||
$this->uuid_prefix = 'access_control_';
|
$this->uuid_prefix = 'access_control_';
|
||||||
|
|
||||||
if (permission_exists($this->permission_prefix.'add')) {
|
if (permission_exists($this->permission_prefix . 'add')) {
|
||||||
|
|
||||||
//add multi-lingual support
|
//add multi-lingual support
|
||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get();
|
$text = $language->get();
|
||||||
|
|
||||||
//validate the token
|
//validate the token
|
||||||
$token = new token;
|
$token = new token;
|
||||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||||
message::add($text['message-invalid_token'],'negative');
|
message::add($text['message-invalid_token'], 'negative');
|
||||||
header('Location: '.$this->list_page);
|
header('Location: ' . $this->list_page);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//copy the checked records
|
//copy the checked records
|
||||||
if (is_array($records) && @sizeof($records) != 0) {
|
if (is_array($records) && @sizeof($records) != 0) {
|
||||||
|
|
||||||
//get checked records
|
//get checked records
|
||||||
foreach($records as $x => $record) {
|
foreach ($records as $x => $record) {
|
||||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||||
$uuids[] = "'".$record['uuid']."'";
|
$uuids[] = "'" . $record['uuid'] . "'";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//create insert array from existing data
|
|
||||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
|
||||||
|
|
||||||
//primary table
|
|
||||||
$sql = "select * from v_".$this->table." ";
|
|
||||||
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
|
||||||
$database = new database;
|
|
||||||
$rows = $database->select($sql, $parameters, 'all');
|
|
||||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
|
||||||
$y = 0;
|
|
||||||
foreach ($rows as $x => $row) {
|
|
||||||
$primary_uuid = uuid();
|
|
||||||
|
|
||||||
//copy data
|
|
||||||
$array[$this->table][$x] = $row;
|
|
||||||
|
|
||||||
//overwrite
|
|
||||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $primary_uuid;
|
|
||||||
$array[$this->table][$x]['access_control_description'] = trim($row['access_control_description'].' ('.$text['label-copy'].')');
|
|
||||||
|
|
||||||
//nodes sub table
|
|
||||||
$sql_2 = "select * from v_access_control_nodes where access_control_uuid = :access_control_uuid";
|
|
||||||
$parameters_2['access_control_uuid'] = $row['access_control_uuid'];
|
|
||||||
$database = new database;
|
|
||||||
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
|
|
||||||
if (is_array($rows_2) && @sizeof($rows_2) != 0) {
|
|
||||||
foreach ($rows_2 as $row_2) {
|
|
||||||
|
|
||||||
//copy data
|
|
||||||
$array['access_control_nodes'][$y] = $row_2;
|
|
||||||
|
|
||||||
//overwrite
|
|
||||||
$array['access_control_nodes'][$y]['access_control_node_uuid'] = uuid();
|
|
||||||
$array['access_control_nodes'][$y]['access_control_uuid'] = $primary_uuid;
|
|
||||||
|
|
||||||
//increment
|
|
||||||
$y++;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($sql_2, $parameters_2, $rows_2, $row_2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($sql, $parameters, $rows, $row);
|
|
||||||
}
|
|
||||||
|
|
||||||
//save the changes and set the message
|
|
||||||
if (is_array($array) && @sizeof($array) != 0) {
|
|
||||||
|
|
||||||
//grant temporary permissions
|
|
||||||
$p = new permissions;
|
|
||||||
$p->add('access_control_node_add', 'temp');
|
|
||||||
|
|
||||||
//save the array
|
|
||||||
$database = new database;
|
|
||||||
$database->app_name = $this->app_name;
|
|
||||||
$database->app_uuid = $this->app_uuid;
|
|
||||||
$database->save($array);
|
|
||||||
unset($array);
|
|
||||||
|
|
||||||
//revoke temporary permissions
|
|
||||||
$p->delete('access_control_node_add', 'temp');
|
|
||||||
|
|
||||||
//clear the cache
|
|
||||||
$cache = new cache;
|
|
||||||
$cache->delete("configuration:acl.conf");
|
|
||||||
|
|
||||||
//create the event socket connection
|
|
||||||
event_socket::async("reloadacl");
|
|
||||||
|
|
||||||
//set message
|
|
||||||
message::add($text['message-copy']);
|
|
||||||
|
|
||||||
}
|
|
||||||
unset($records);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//create insert array from existing data
|
||||||
|
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||||
|
|
||||||
|
//primary table
|
||||||
|
$sql = "select * from v_" . $this->table . " ";
|
||||||
|
$sql .= "where " . $this->uuid_prefix . "uuid in (" . implode(', ', $uuids) . ") ";
|
||||||
|
$database = new database;
|
||||||
|
$rows = $database->select($sql, $parameters, 'all');
|
||||||
|
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||||
|
$y = 0;
|
||||||
|
foreach ($rows as $x => $row) {
|
||||||
|
$primary_uuid = uuid();
|
||||||
|
|
||||||
|
//copy data
|
||||||
|
$array[$this->table][$x] = $row;
|
||||||
|
|
||||||
|
//overwrite
|
||||||
|
$array[$this->table][$x][$this->uuid_prefix . 'uuid'] = $primary_uuid;
|
||||||
|
$array[$this->table][$x]['access_control_description'] = trim($row['access_control_description'] . ' (' . $text['label-copy'] . ')');
|
||||||
|
|
||||||
|
//nodes sub table
|
||||||
|
$sql_2 = "select * from v_access_control_nodes where access_control_uuid = :access_control_uuid";
|
||||||
|
$parameters_2['access_control_uuid'] = $row['access_control_uuid'];
|
||||||
|
$database = new database;
|
||||||
|
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
|
||||||
|
if (is_array($rows_2) && @sizeof($rows_2) != 0) {
|
||||||
|
foreach ($rows_2 as $row_2) {
|
||||||
|
|
||||||
|
//copy data
|
||||||
|
$array['access_control_nodes'][$y] = $row_2;
|
||||||
|
|
||||||
|
//overwrite
|
||||||
|
$array['access_control_nodes'][$y]['access_control_node_uuid'] = uuid();
|
||||||
|
$array['access_control_nodes'][$y]['access_control_uuid'] = $primary_uuid;
|
||||||
|
|
||||||
|
//increment
|
||||||
|
$y++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($sql_2, $parameters_2, $rows_2, $row_2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($sql, $parameters, $rows, $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
//save the changes and set the message
|
||||||
|
if (is_array($array) && @sizeof($array) != 0) {
|
||||||
|
|
||||||
|
//grant temporary permissions
|
||||||
|
$p = new permissions;
|
||||||
|
$p->add('access_control_node_add', 'temp');
|
||||||
|
|
||||||
|
//save the array
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = $this->app_name;
|
||||||
|
$database->app_uuid = $this->app_uuid;
|
||||||
|
$database->save($array);
|
||||||
|
unset($array);
|
||||||
|
|
||||||
|
//revoke temporary permissions
|
||||||
|
$p->delete('access_control_node_add', 'temp');
|
||||||
|
|
||||||
|
//clear the cache
|
||||||
|
$cache = new cache;
|
||||||
|
$cache->delete("configuration:acl.conf");
|
||||||
|
|
||||||
|
//create the event socket connection
|
||||||
|
event_socket::async("reloadacl");
|
||||||
|
|
||||||
|
//set message
|
||||||
|
message::add($text['message-copy']);
|
||||||
|
}
|
||||||
|
unset($records);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
}
|
||||||
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue