mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Fixed forms VC
This commit is contained in:
parent
49ab5e95aa
commit
9b4f12a875
@ -3639,6 +3639,74 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||||||
$output .= html_print_input_multicheck($data);
|
$output .= html_print_input_multicheck($data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'autocomplete_agent':
|
||||||
|
/*
|
||||||
|
if (is_metaconsole() === true) {
|
||||||
|
$connection = metaconsole_get_connection($server_name);
|
||||||
|
$agent_name = '';
|
||||||
|
|
||||||
|
if (metaconsole_load_external_db($connection) == NOERR) {
|
||||||
|
$agent_name = db_get_value_filter(
|
||||||
|
'alias',
|
||||||
|
'tagente',
|
||||||
|
['id_agente' => $idAgent]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append server name.
|
||||||
|
if (!empty($agent_name)) {
|
||||||
|
$agent_name .= ' ('.$server_name.')';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore db connection.
|
||||||
|
metaconsole_restore_db();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$agent_name = '';
|
||||||
|
if (isset($data['id_agent_hidden']) === true
|
||||||
|
&& empty($data['id_agent_hidden']) === false
|
||||||
|
) {
|
||||||
|
$agent_name = agents_get_alias($data['id_agent_hidden']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = [];
|
||||||
|
$params['return'] = $data['return'];
|
||||||
|
$params['show_helptip'] = false;
|
||||||
|
$params['input_name'] = $data['name'];
|
||||||
|
$params['value'] = $agent_name;
|
||||||
|
$params['javascript_is_function_select'] = true;
|
||||||
|
// $params['selectbox_id'] = 'id_agent_module';
|
||||||
|
// $params['add_none_module'] = true;
|
||||||
|
$params['use_hidden_input_idagent'] = true;
|
||||||
|
$params['hidden_input_idagent_id'] = 'hidden-'.$data['name_agent_hidden'];
|
||||||
|
/*
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
$params['use_input_id_server'] = true;
|
||||||
|
$params['input_id_server_id'] = 'hidden-server_id';
|
||||||
|
$params['metaconsole_enabled'] = true;
|
||||||
|
$params['input_id'] = 'agent_autocomplete_events';
|
||||||
|
$params['javascript_page'] = 'include/ajax/agent';
|
||||||
|
$params['input_name'] = 'agent_text';
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
$output .= html_print_input_hidden(
|
||||||
|
$data['name_agent_hidden'],
|
||||||
|
$data['id_agent_hidden'],
|
||||||
|
$data['return']
|
||||||
|
);
|
||||||
|
// $output .= html_print_input_hidden('server_name', $server_name);
|
||||||
|
$output .= html_print_input_hidden(
|
||||||
|
$data['name_server_hidden'],
|
||||||
|
$data['server_id_hidden'],
|
||||||
|
$data['return']
|
||||||
|
);
|
||||||
|
// $output .= html_print_input_hidden('id_server', '');
|
||||||
|
$output .= ui_print_agent_autocomplete_input($params);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Ignore.
|
// Ignore.
|
||||||
break;
|
break;
|
||||||
|
@ -2010,54 +2010,55 @@ function load_modal(settings) {
|
|||||||
formdata.append("method", settings.onsubmit.method);
|
formdata.append("method", settings.onsubmit.method);
|
||||||
|
|
||||||
var flagError = false;
|
var flagError = false;
|
||||||
|
if (Array.isArray(settings.form) === false) {
|
||||||
$("#" + settings.form + " :input").each(function() {
|
$("#" + settings.form + " :input").each(function() {
|
||||||
if (this.checkValidity() === false) {
|
if (this.checkValidity() === false) {
|
||||||
$(this).attr("title", this.validationMessage);
|
$(this).attr("title", this.validationMessage);
|
||||||
$(this).tooltip({
|
$(this).tooltip({
|
||||||
tooltipClass: "uitooltip",
|
tooltipClass: "uitooltip",
|
||||||
position: {
|
position: {
|
||||||
my: "right bottom",
|
my: "right bottom",
|
||||||
at: "right top",
|
at: "right top",
|
||||||
using: function(position, feedback) {
|
using: function(position, feedback) {
|
||||||
$(this).css(position);
|
$(this).css(position);
|
||||||
$("<div>")
|
$("<div>")
|
||||||
.addClass("arrow")
|
.addClass("arrow")
|
||||||
.addClass(feedback.vertical)
|
.addClass(feedback.vertical)
|
||||||
.addClass(feedback.horizontal)
|
.addClass(feedback.horizontal)
|
||||||
.appendTo(this);
|
.appendTo(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
$(this).tooltip("open");
|
||||||
$(this).tooltip("open");
|
|
||||||
|
|
||||||
var element = $(this);
|
var element = $(this);
|
||||||
setTimeout(
|
setTimeout(
|
||||||
function(element) {
|
function(element) {
|
||||||
element.tooltip("destroy");
|
element.tooltip("destroy");
|
||||||
element.removeAttr("title");
|
element.removeAttr("title");
|
||||||
},
|
},
|
||||||
3000,
|
3000,
|
||||||
element
|
element
|
||||||
);
|
);
|
||||||
|
|
||||||
flagError = true;
|
flagError = true;
|
||||||
}
|
|
||||||
|
|
||||||
if (this.type == "file") {
|
|
||||||
if ($(this).prop("files")[0]) {
|
|
||||||
formdata.append(this.name, $(this).prop("files")[0]);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if ($(this).attr("type") == "checkbox") {
|
if (this.type == "file") {
|
||||||
if (this.checked) {
|
if ($(this).prop("files")[0]) {
|
||||||
formdata.append(this.name, "on");
|
formdata.append(this.name, $(this).prop("files")[0]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
formdata.append(this.name, $(this).val());
|
if ($(this).attr("type") == "checkbox") {
|
||||||
|
if (this.checked) {
|
||||||
|
formdata.append(this.name, "on");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formdata.append(this.name, $(this).val());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
if (flagError === false) {
|
if (flagError === false) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -2153,16 +2154,29 @@ function load_modal(settings) {
|
|||||||
}
|
}
|
||||||
formdata.append("page", settings.onsubmit.page);
|
formdata.append("page", settings.onsubmit.page);
|
||||||
formdata.append("method", settings.onsubmit.method);
|
formdata.append("method", settings.onsubmit.method);
|
||||||
|
if (Array.isArray(settings.form) === false) {
|
||||||
$("#" + settings.form + " :input").each(function() {
|
$("#" + settings.form + " :input").each(function() {
|
||||||
if (this.type == "file") {
|
if (this.type == "file") {
|
||||||
if ($(this).prop("files")[0]) {
|
if ($(this).prop("files")[0]) {
|
||||||
formdata.append(this.name, $(this).prop("files")[0]);
|
formdata.append(this.name, $(this).prop("files")[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formdata.append(this.name, $(this).val());
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
formdata.append(this.name, $(this).val());
|
} else {
|
||||||
}
|
settings.form.forEach(function(element) {
|
||||||
});
|
$("#" + element + " :input").each(function() {
|
||||||
|
if (this.type == "file") {
|
||||||
|
if ($(this).prop("files")[0]) {
|
||||||
|
formdata.append(this.name, $(this).prop("files")[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formdata.append(this.name, $(this).val());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "post",
|
method: "post",
|
||||||
|
@ -1439,18 +1439,25 @@ function createOrUpdateVisualConsoleItem(
|
|||||||
|
|
||||||
load_modal({
|
load_modal({
|
||||||
target: $("#modalVCItemForm"),
|
target: $("#modalVCItemForm"),
|
||||||
form: "itemForm",
|
form: ["itemForm-label", "itemForm-general", "itemForm-specific"],
|
||||||
url: baseUrl + "ajax.php",
|
url: baseUrl + "ajax.php",
|
||||||
ajax_callback: function(response) {
|
ajax_callback: function(response) {
|
||||||
var item = handleFormResponse(response);
|
var data = JSON.parse(response); //handleFormResponse(response);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
if (item == false) {
|
if (data == false) {
|
||||||
// Error.
|
// Error.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success.
|
$("#modalVCItemForm").dialog("close");
|
||||||
console.log(item);
|
if (item.itemProps.id) {
|
||||||
|
visualConsole.updateElement(data);
|
||||||
|
} else {
|
||||||
|
data["receivedAt"] = new Date();
|
||||||
|
var newItem = visualConsole.addElement(data);
|
||||||
|
newItem.setMeta({ editMode: true });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
cleanup: cleanupDOM,
|
cleanup: cleanupDOM,
|
||||||
modal: {
|
modal: {
|
||||||
@ -1463,14 +1470,14 @@ function createOrUpdateVisualConsoleItem(
|
|||||||
name: "item",
|
name: "item",
|
||||||
value: item
|
value: item
|
||||||
},
|
},
|
||||||
/*{
|
|
||||||
name: "elementsVc",
|
|
||||||
value: elementsVc
|
|
||||||
},*/
|
|
||||||
{
|
{
|
||||||
name: "vCId",
|
name: "vCId",
|
||||||
value: visualConsole.props.id
|
value: visualConsole.props.id
|
||||||
}
|
}
|
||||||
|
/*{
|
||||||
|
name: "elementsVc",
|
||||||
|
value: elementsVc
|
||||||
|
},*/
|
||||||
],
|
],
|
||||||
onshow: {
|
onshow: {
|
||||||
page: "include/rest-api/index",
|
page: "include/rest-api/index",
|
||||||
|
@ -314,48 +314,7 @@ if ($getVisualConsole === true) {
|
|||||||
echo json_encode(io_safe_output($result));
|
echo json_encode(io_safe_output($result));
|
||||||
return;
|
return;
|
||||||
} else if ($getImagesVisualConsole) {
|
} else if ($getImagesVisualConsole) {
|
||||||
$result = [];
|
// TODO: Remove.
|
||||||
|
|
||||||
// Extract images.
|
|
||||||
$all_images = list_files(
|
|
||||||
$config['homedir'].'/images/console/icons/',
|
|
||||||
'png',
|
|
||||||
1,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isset($all_images) === true && is_array($all_images) === true) {
|
|
||||||
$base_url = ui_get_full_url(
|
|
||||||
'/images/console/icons/',
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($all_images as $image_file) {
|
|
||||||
$image_file = substr($image_file, 0, (strlen($image_file) - 4));
|
|
||||||
|
|
||||||
if (strpos($image_file, '_bad') !== false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos($image_file, '_ok') !== false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos($image_file, '_warning') !== false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result[] = [
|
|
||||||
'name' => $image_file,
|
|
||||||
'src' => $base_url.$image_file,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode(io_safe_output($result));
|
|
||||||
return;
|
|
||||||
} else if ($autocompleteAgentsVisualConsole) {
|
} else if ($autocompleteAgentsVisualConsole) {
|
||||||
$params = (array) get_parameter('data', []);
|
$params = (array) get_parameter('data', []);
|
||||||
|
|
||||||
|
@ -1942,28 +1942,6 @@ class Item extends CachedModel
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
// Link enabled.
|
|
||||||
$inputs[] = [
|
|
||||||
'label' => __('Link enabled'),
|
|
||||||
'arguments' => [
|
|
||||||
'name' => 'isLinkEnabled',
|
|
||||||
'id' => 'isLinkEnabled',
|
|
||||||
'type' => 'switch',
|
|
||||||
'value' => $values->isLinkEnabled,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
// Show on top.
|
|
||||||
$inputs[] = [
|
|
||||||
'label' => __('Show on top'),
|
|
||||||
'arguments' => [
|
|
||||||
'name' => 'isOnTop',
|
|
||||||
'id' => 'isOnTop',
|
|
||||||
'type' => 'switch',
|
|
||||||
'value' => $values->isOnTop,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
// Position.
|
// Position.
|
||||||
$inputs[] = [
|
$inputs[] = [
|
||||||
'block_id' => 'position-item',
|
'block_id' => 'position-item',
|
||||||
@ -1994,6 +1972,28 @@ class Item extends CachedModel
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Link enabled.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Link enabled'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'isLinkEnabled',
|
||||||
|
'id' => 'isLinkEnabled',
|
||||||
|
'type' => 'switch',
|
||||||
|
'value' => $values->isLinkEnabled,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Show on top.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Show on top'),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'isOnTop',
|
||||||
|
'id' => 'isOnTop',
|
||||||
|
'type' => 'switch',
|
||||||
|
'value' => $values->isOnTop,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
// Parent.
|
// Parent.
|
||||||
// TODO:XXX
|
// TODO:XXX
|
||||||
$fields = get_parameter('elementsVc', []);
|
$fields = get_parameter('elementsVc', []);
|
||||||
@ -2050,4 +2050,54 @@ class Item extends CachedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List images for Vc Icons.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getListImagesVC():array
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
// Extract images.
|
||||||
|
$all_images = \list_files(
|
||||||
|
$config['homedir'].'/images/console/icons/',
|
||||||
|
'png',
|
||||||
|
1,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isset($all_images) === true && is_array($all_images) === true) {
|
||||||
|
$base_url = \ui_get_full_url(
|
||||||
|
'/images/console/icons/',
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($all_images as $image_file) {
|
||||||
|
$image_file = substr($image_file, 0, (strlen($image_file) - 4));
|
||||||
|
|
||||||
|
if (strpos($image_file, '_bad') !== false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($image_file, '_ok') !== false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($image_file, '_warning') !== false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result[$image_file] = $image_file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,56 @@ final class StaticGraph extends Item
|
|||||||
$inputs = Item::getFormInputs($values);
|
$inputs = Item::getFormInputs($values);
|
||||||
|
|
||||||
if (is_array($inputs) !== true) {
|
if (is_array($inputs) !== true) {
|
||||||
throw new Exception('[StaticGraph]::getFormInputs parent class return is not an array');
|
throw new Exception(
|
||||||
|
'[StaticGraph]::getFormInputs parent class return is not an array'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values->tabSelected === 'specific') {
|
||||||
|
// List images VC.
|
||||||
|
// TODO: Show images.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Image'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => self::getListImagesVC(),
|
||||||
|
'name' => 'imageSrc',
|
||||||
|
'selected' => $values->imageSrc,
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Autocomplete agents.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Agent'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'autocomplete_agent',
|
||||||
|
'name' => 'agentAlias',
|
||||||
|
'id_agent_hidden' => $values->agentId,
|
||||||
|
'name_agent_hidden' => 'agentId',
|
||||||
|
'server_id_hidden' => $values->metaconsoleId,
|
||||||
|
'name_server_hidden' => 'metaconsoleId',
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'default' => __('Hide last value on boolean modules'),
|
||||||
|
'disabled' => __('Disabled'),
|
||||||
|
'enabled' => __('Enabled'),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Show Last Value.
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => __('Show Last Value'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => $fields,
|
||||||
|
'name' => 'showLastValueTooltip',
|
||||||
|
'selected' => $values->showLastValueTooltip,
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $inputs;
|
return $inputs;
|
||||||
|
@ -160,40 +160,136 @@ class View extends \HTML
|
|||||||
*/
|
*/
|
||||||
public function processForm()
|
public function processForm()
|
||||||
{
|
{
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
hd('++++++++++++++++++++++++++++++++++++', true);
|
||||||
hd($_POST, true);
|
hd($_POST, true);
|
||||||
|
hd('++++++++++++++++++++++++++++++++++++', true);
|
||||||
|
|
||||||
|
$item = json_decode(io_safe_output(\get_parameter('item')), true);
|
||||||
|
|
||||||
// Inserted data in new item.
|
// Inserted data in new item.
|
||||||
// $data = json_decode($_REQUEST['item'])->itemProps;
|
|
||||||
$vCId = \get_parameter('vCId', 0);
|
$vCId = \get_parameter('vCId', 0);
|
||||||
|
|
||||||
$data['type'] = 0;
|
$data['type'] = $item['itemProps']['type'];
|
||||||
$data['label'] = \get_parameter('label', 'vacio');
|
|
||||||
|
|
||||||
$class = VisualConsole::getItemClass((int) $data['type']);
|
// Page Label.
|
||||||
try {
|
$data['label'] = \get_parameter('label');
|
||||||
// Save the new item.
|
|
||||||
$data['id_layout'] = $vCId;
|
// Page general.
|
||||||
hd($data, true);
|
$data['width'] = \get_parameter('width');
|
||||||
$result = $class::save($data);
|
$data['height'] = \get_parameter('height');
|
||||||
} catch (\Throwable $th) {
|
$data['x'] = \get_parameter('x');
|
||||||
// There is no item in the database.
|
$data['y'] = \get_parameter('y');
|
||||||
// hd($th, true);
|
$data['isLinkEnabled'] = \get_parameter('isLinkEnabled');
|
||||||
echo false;
|
$data['isOnTop'] = \get_parameter('isOnTop');
|
||||||
return;
|
$data['parentId'] = \get_parameter('parentId');
|
||||||
}
|
$data['aclGroupId'] = \get_parameter('aclGroupId');
|
||||||
|
$data['cacheExpiration_select'] = \get_parameter(
|
||||||
|
'cacheExpiration_select'
|
||||||
|
);
|
||||||
|
$data['cacheExpiration_text'] = \get_parameter('cacheExpiration_text');
|
||||||
|
$data['cacheExpiration'] = \get_parameter('cacheExpiration');
|
||||||
|
$data['cacheExpiration_units'] = \get_parameter(
|
||||||
|
'cacheExpiration_units'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Page specific.
|
||||||
|
$data['imageSrc'] = \get_parameter('imageSrc');
|
||||||
|
$data['agentId'] = \get_parameter('agentId');
|
||||||
|
$data['metaconsoleId'] = \get_parameter('metaconsoleId');
|
||||||
|
$data['agentAlias'] = \get_parameter('agentAlias');
|
||||||
|
$data['showLastValueTooltip'] = \get_parameter('showLastValueTooltip');
|
||||||
|
|
||||||
|
if (isset($item['itemProps']['id']) === false) {
|
||||||
|
// CreateVC.
|
||||||
|
$class = VisualConsole::getItemClass((int) $data['type']);
|
||||||
|
try {
|
||||||
|
// Save the new item.
|
||||||
|
$data['id_layout'] = $vCId;
|
||||||
|
$itemId = $class::save($data);
|
||||||
|
hd('he creado:'.$itemId, true);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
// Bad params.
|
||||||
|
http_response_code(400);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// Extract data new item inserted.
|
// Extract data new item inserted.
|
||||||
try {
|
try {
|
||||||
$item = VisualConsole::getItemFromDB($result);
|
$item = VisualConsole::getItemFromDB($itemId);
|
||||||
|
$result = $item->toArray();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
// Bad params.
|
// Bad params.
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
*/
|
} else {
|
||||||
|
// UpdateVC.
|
||||||
|
$itemId = $item['itemProps']['id'];
|
||||||
|
|
||||||
return json_encode(['error' => obhd($item)]);
|
try {
|
||||||
|
$item = VisualConsole::getItemFromDB($itemId);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
// Bad params.
|
||||||
|
http_response_code(400);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemData = $item->toArray();
|
||||||
|
$itemType = $itemData['type'];
|
||||||
|
$itemAclGroupId = $itemData['aclGroupId'];
|
||||||
|
|
||||||
|
// ACL.
|
||||||
|
$aclRead = check_acl($config['id_user'], $itemAclGroupId, 'VR');
|
||||||
|
$aclWrite = check_acl($config['id_user'], $itemAclGroupId, 'VW');
|
||||||
|
$aclManage = check_acl($config['id_user'], $itemAclGroupId, 'VM');
|
||||||
|
|
||||||
|
if (!$aclRead && !$aclWrite && !$aclManage) {
|
||||||
|
db_pandora_audit(
|
||||||
|
'ACL Violation',
|
||||||
|
'Trying to access visual console without group access'
|
||||||
|
);
|
||||||
|
http_response_code(403);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check also the group Id for the group item.
|
||||||
|
if ($itemType === GROUP_ITEM) {
|
||||||
|
$itemGroupId = $itemData['groupId'];
|
||||||
|
// ACL.
|
||||||
|
$aclRead = check_acl($config['id_user'], $itemGroupId, 'VR');
|
||||||
|
$aclWrite = check_acl($config['id_user'], $itemGroupId, 'VW');
|
||||||
|
$aclManage = check_acl($config['id_user'], $itemGroupId, 'VM');
|
||||||
|
|
||||||
|
if (!$aclRead && !$aclWrite && !$aclManage) {
|
||||||
|
db_pandora_audit(
|
||||||
|
'ACL Violation',
|
||||||
|
'Trying to access visual console without group access'
|
||||||
|
);
|
||||||
|
http_response_code(403);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($data) === true && empty($data) === false) {
|
||||||
|
try {
|
||||||
|
// Save the new item.
|
||||||
|
$data['id_layout'] = $vCId;
|
||||||
|
$data['id'] = $itemId;
|
||||||
|
$item->save($data);
|
||||||
|
hd('he actualizado: '.$itemId, true);
|
||||||
|
$result = $item->toArray();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
// There is no item in the database.
|
||||||
|
echo false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hd($result, true);
|
||||||
|
return json_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user